{{{ function one_sub_sess_model_moves5(MYV, sb, ss) % check for defaults global defaults if isempty(defaults), spm_defaults; end % store path pwd_orig = pwd; % condition stuff condnames = MYV.cond_names; nconds = length(condnames); % Names for movement parameters move_names = {'x trans', 'y trans', 'z trans', ... 'x rot', 'y rot', 'z rot'}; % Specify some design stuff % Note that the TR must be the same for all runs in a model TR = MYV.TRs(sb); % seconds SPM.xY.RT = TR; % Specify design %=========================================================================== % global normalization: OPTOINS:'Scaling'|'None' %--------------------------------------------------------------------------- SPM.xGX.iGXcalc = 'None'; % low frequency confound: high-pass cutoff (secs) [Inf = no filtering] %--------------------------------------------------------------------------- SPM.xX.K(1).HParam = MYV.hf_cut; % intrinsic autocorrelations: OPTIONS: 'none'|'AR(1) + w' %----------------------------------------------------------------------- SPM.xVi.form = 'AR(1) + w'; % basis functions and timing parameters %--------------------------------------------------------------------------- % OPTIONS:'hrf' % 'hrf (with time derivative)' % 'hrf (with time and dispersion derivatives)' % 'Fourier set' % 'Fourier set (Hanning)' % 'Gamma functions' % 'Finite Impulse Response' %--------------------------------------------------------------------------- % Fill in the field below with the corresponding string above SPM.xBF.name = 'hrf (with time derivative)'; %SPM.xBF.length = 20; % length in seconds - not used for hrf %SPM.xBF.order = 1; % order of basis set - not used for hrf % The next two fields usually don't need changing. SPM.xBF.T = 16; % number of time bins per scan SPM.xBF.T0 = 1; % first time bin (see slice % timing) % Selfish explanatory SPM.xBF.UNITS = 'scans'; % OPTIONS: 'scans'|'secs' for % onsets % value of one means no Volterra pain SPM.xBF.Volterra = 1; % OPTIONS: 1|2 = order of convolution % specify filter for filenames Filter = MYV.snstats_filter; % file list PP = ''; % get, make, goto SPM results directory sess_dir = fullfile(MYV.root, MYV.subjects{sb}, MYV.sesses{ss}); ana_dir = fullfile(sess_dir, MYV.ana_dir); if ~(exist(ana_dir)) mkdir(sess_dir,MYV.ana_dir); end cd(ana_dir); % file selection P = spm_get('files',sess_dir,Filter); SPM.nscan(1) = size(P,1); PP = strvcat(PP,P); % Condition stuff - onsets, durations, types. c_ons = spm_load(MYV.cond_files{sb, ss}); [TRIAL_NO ONSET RESPONSE RESP_ONSET] = deal(1,2,3,4); % now set into SPM design for cno = 1:nconds tmp = c_ons(:, ONSET) -1; % because we deleted the first scan % Make sure onsets are within scan range tempi = tmp >=0 & tmp <= size(P, 1); tmp = tmp(tempi); SPM.Sess.U(cno) = struct(... 'ons', tmp,... 'dur', ones(size(tmp)) * MYV.cond_dur * TR, ... 'name',{condnames(cno)},... 'P', struct('name','none')); % Parametric modulation end % design (user specified covariates) %------------------------------------------------------------------ % realignment parameters to add to model movefil = spm_get('Files', sess_dir, ... ['rp_' MYV.sl_prefix '*.txt']); moves = spm_load(movefil); if isempty(moves) error(['Cannot get movement parameters from: ' sess_dir]); end % Fix goofy realignment params moves = moves(1:size(P,1), :); % mean centre moves moves = moves - ones(size(P, 1), 1) * mean(moves); move_diff = [zeros(1, 6); diff(moves)]; move_m1 = [zeros(1, 6); moves(1:end-1,:)]; % Put various params in SPM.Sess.C.C = [moves]; SPM.Sess.C.name = [move_names]; % set files SPM.xY.P = PP; % Configure design matrix SPMdes = spm_fmri_spm_ui(SPM); % Estimate parameters spm_unlink(fullfile('.', 'mask.img')); % avoid overwrite dialog SPMest = spm_spm(SPMdes); % back to initial directory cd(pwd_orig); }}}