Matrix dimensions must agree.
Error in FactorCross (line 42)
st = st.*input{ii}(:,counts(ii));
Error in ANOVA_APS (line 140)
Effects{end+1} = FactorCross(Effects(i2));
Error in GLM_Flex_Fast4 (line 54)
MOD = ANOVA_APS(I.Data,I.Model,[],0,1,1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Scans = dir_wfp('D:\CogCtrl\GLM_flex_2020\Nback\3x3mixed_2-1back\*.nii');
%%% Create a data structure to hold the variables
clear dat
dat.fn = [];
dat.Group = [];
dat.Time = [];
dat.SS = [];
%%% In this case all the information we need is contained in the file names,
%%% so all we have to do is parse the file names, and store the information in the dat structure.
for ii = 1:numel(Scans)
[a b c] = fileparts(lower(Scans{ii}));
tmp = regexp(b,'_','split');
dat.fn{ii,1} = Scans{ii};
dat.Group{ii,1} = tmp{1};
dat.SS{ii,1} = tmp{2};
dat.Time{ii,1} = tmp{3};
end
% First 24 Subjects (72 images) are in Group1.
% Next 20 subjects (60 images) are in Group2.
% Last 23 sujects (69 images) are in Group3.
dat.Group = cell(402,1);
dat.Group(1:72) = {'G1'};
dat.Group(73:132) = {'G2'};
dat.Group(133:end) = {'G3'};
%%% Now we set up I (same as before) only with new entries for data and for model.
%%% These two new entries obviate the need for the IN + CreateDesign2 step.
clear I;
I.Scans = dat.fn;
I.Model = 'Group*Time + random(SS|Time)';
I.Data = dat;
I.OutputDir = 'D:/CogCtrl/GLM_flex_2020/Nback/3x3mixed_2-1back_results';
I.RemoveOutliers = 0;
I.DoOnlyAll = 1;
I.estSmooth = 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%