Home > marsbar > @mardo_99 > add_trial_f.m

add_trial_f

PURPOSE ^

method to add trial-specific F contrasts

SYNOPSIS ^

function [D, changef] = add_trial_f(D)

DESCRIPTION ^

 method to add trial-specific F contrasts  
 
 D         - design to put contrasts into

 Returns
 D         - design with any added contrasts
 changef   - set to 1 if any contrasts have been added
  
 The routine only adds contrasts that are not already present

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [D, changef] = add_trial_f(D)
0002 % method to add trial-specific F contrasts
0003 %
0004 % D         - design to put contrasts into
0005 %
0006 % Returns
0007 % D         - design with any added contrasts
0008 % changef   - set to 1 if any contrasts have been added
0009 %
0010 % The routine only adds contrasts that are not already present
0011 %
0012 % $Id$
0013   
0014 if ~strcmp(modality(D), 'fmri')
0015   error('Can only set trial-specific F contrasts for FMRI designs');
0016 end
0017 SPM = des_struct(D);
0018 xX = SPM.xX;
0019 
0020 %-Append contrasts for fMRI - specified by SPM.Sess(s).Fc(i)
0021 %-----------------------------------------------------------------------
0022 if ~isfield(SPM,'Sess')
0023   changef = 0;
0024   return;
0025 end
0026 
0027 Sess = SPM.Sess;
0028 xCon = [];
0029 if (Sess{1}.rep)
0030   for t = 1:length(Sess{1}.name)
0031     u     = [];
0032     for s = 1:length(Sess)
0033       u = [u Sess{s}.col(Sess{s}.ind{t})];
0034     end
0035     q             = 1:size(xX.X,2);
0036     q(u)          = [];
0037     Fcname        = Sess{s}.name{t};
0038     xcon          = spm_FcUtil('Set',Fcname,'F','iX0',q,xX.xKXs);
0039     xCon          = [xCon xcon];
0040   end
0041 else % Sessions are not repeated
0042   for s = 1:length(Sess)
0043     str   = sprintf('Session %d: ',s);
0044     for t = 1:length(Sess{s}.name)
0045       q             = 1:size(xX.X,2);
0046       q(Sess{s}.col(Sess{s}.ind{t})) = [];
0047       Fcname        = [str Sess{s}.name{t}];
0048       xcon          = spm_FcUtil('Set',Fcname,'F','iX0',q,xX.xKXs);
0049       xCon          = [xCon xcon];
0050     end
0051   end
0052 end
0053 
0054 [D Ic changef] = add_contrasts(D, xCon);

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019