0001 function [D, changef] = add_trial_f(D)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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
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);