Home > marsbar > @mardo_2 > 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 [nScan nBeta] = size(xX.X);
0020 
0021 %-Append contrasts for fMRI - specified by SPM.Sess(s).Fc(i)
0022 %-----------------------------------------------------------------------
0023 xCon = [];
0024 if isfield(SPM,'Sess')
0025   for s = 1:length(SPM.Sess)
0026     for i = 1:length(SPM.Sess(s).Fc)
0027       iX0           = 1:nBeta;
0028       iX            = SPM.Sess(s).col(SPM.Sess(s).Fc(i).i);
0029       iX0(iX)       = [];
0030       Fcname        = sprintf('Sess(%d):%s',s,SPM.Sess(s).Fc(i).name);
0031       xcon          = spm_FcUtil('Set',Fcname,'F','iX0',iX0,xX.xKXs);
0032       xCon          = [xCon xcon];
0033     end
0034   end
0035 end
0036 [D Ic changef] = add_contrasts(D, xCon);

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