global  Base MaskStr
%---------------------------------------------------------------
% model(1) Low-Off vs High Off
%----------------------------------------------------------
clear F1 F2 F3 F4
Mask=[MaskStr,'*.img'];
FolderName=['E:\fMRIData\Sound\01\Sound1'];
F1=spm_get('Files',FolderName,Mask);
size(F1)
RealignFile1=spm_get('Files',FolderName,['realignment*.*'])
RealignMat1=ReadTxtMat(RealignFile1,[6 366]);
RealignMat1=RealignMat1';
if size(RealignMat1)~=[366,6]
   error('size(RealignMat1)~=[366,6]')
end
FolderName=['E:\fMRIData\Sound\01\Sound2'];
F2=spm_get('Files',FolderName,Mask);
size(F2)
RealignFile2=spm_get('Files',FolderName,['realignment*.*'])
RealignMat2=ReadTxtMat(RealignFile2,[6 366]);
RealignMat2=RealignMat2';
if size(RealignMat2)~=[366,6]
   error('size(RealignMat2)~=[366,6]')
end
FolderName=['E:\fMRIData\Sound\02\Sound1'];
F3=spm_get('Files',FolderName,Mask);
size(F3)
RealignFile3=spm_get('Files',FolderName,['realignment*.*'])
RealignMat3=ReadTxtMat(RealignFile3,[6 366]);
RealignMat3=RealignMat3';
if size(RealignMat3)~=[366,6]
   error('size(RealignMat3)~=[366,6]')
end
FolderName=['E:\fMRIData\Sound\02\Sound2'];
F4=spm_get('Files',FolderName,Mask);
size(F4)
RealignFile4=spm_get('Files',FolderName,['realignment*.*'])
RealignMat4=ReadTxtMat(RealignFile4,[6 366]);
RealignMat4=RealignMat4';
if size(RealignMat4)~=[366,6]
   error('size(RealignMat4)~=[366,6]')
end
F1
F2
F3
F4
%----------------------------------------------------------
% batch variables defined here for analysis 'model
%-----------------------------------------------------
model(1) = struct( ...
   'types',          4, ...
   'global_effects', {'Scaling'}, ...
   'burst_mode',     0, ...
   'HF_fil',         'specify',  ...
   'HF_cut',         [48], ...
   'LF_fil',         'Gaussian', ...
   'LF_cut',         [4], ...
   'int_corr',       'none', ...
   'now_later',      1, ...
   'stop_writing',   0, ...
   'trial_fcon',     0, ...
   'RT',             3, ...
   'replicated',     0, ...
   'same_time_param',0, ...
   'nsess',          1, ...
   'nscans',         [366], ...
   'files',          {{F1}}, ...
   'conditions_nb',  [1], ...
   'conditions',     [1], ...
   'regressors_nb',  [0], ...
   'regressors',     [1], ...
   'parametrics_type', {{'none'}}, ...
   'parametrics',    [], ...
   'stochastics_flag',[0], ...
   'stochastics',    []);

NScanPerBlock=4;

PosTone1=([3    14    25    32    40    52    60    66    79    84]-1)*NScanPerBlock+Base;
%============================================
conditions(1) = struct( ...
'names',   {{'PosTone1'}}, ...
'onsets',{{PosTone1}}, ...
'bf_ep',   [1], ...
'volterra',  0, ...
'variable_dur',0);
%-------------------------------------------
bf_ep(1) = struct( ...
   'ep_type',4, ...
   'length',NScanPerBlock, ...
   'conv',  1, ...
   'deriv', 0);