Mixed Design ANOVA

Download Example Data: ExampleVolumes.tar.gz

Home        GLM Flex        FIVE        Downloads    Batch Scripts        News Feed

 

This is a nice example of a rather complicated but common design and we can put the whole thing in a single model.


So here’s the setup.  We ran 15 Subjects, 8 in Group #1 and 7 in Group #2.  Each subject did a two different tasks within each of four runs.  After running our first level model we get 8 Contrasts for each subject:


Run1 Cond1

Run1 Cond2

Run2 Cond1

Run2 Cond2

Run3 Cond1

Run3 Cond2

Run4 Cond1

Run4 Cond2


In this case we didn’t collapse across runs because we are interested in looking for a run effect.


So what we end up with is two between factors, one for “Everything”, and one for Group1 vs. Group2 difference, and we have two within factors, Run and Task.  Additionally since we have within factors we need to count Subjects as an additional Factor.  This gives us a total of 5 factors in a rather hairy mixed design ANOVA.  So let’s make a model!


Scans = dir_wfp(‘path/to/images/*.nii’);



clear IN; clear F; clear I;

IN.N_subs = [8 7];

IN.Between = [1 2];  % The 1 here is so we can run a one sample t-test across all the data

IN.BetweenLabs = {{'All'} {'Group1', 'Group2'}};

IN.Within = [4 2];

IN.WithinLabs = {{'R1' 'R2' 'R3' 'R4'} {'Condition1' 'Condition2'}};

IN.FactorLabs = {'F1' 'F2' 'F3' 'F4'};

IN.Interactions = {[2 3] [2 4] [3 4] [2 3 4]};

IN.EqualVar = [1 0 0 0];

IN.Independent = [1 1 0 0];


F = CreateDesign(IN);


figure(20); imagesc(F.XX); shg


I.OutputDir = pwd;

I.F = F;

I.Scans = Scans;

I.RemoveOutliers = 0;

I.minN = 2;

I.DoOnlyAll = 1;

I.CompOpt=0;



I = GLM_Flex(I);


%%

I.Cons(1).name = 'All';

I.Cons(1).Groups = {1};

I.Cons(1).Levs = [1];

I.Cons(1).ET = [];

I.Cons(1).mean = 0;


I.Cons(2).name = 'Group Effect';

I.Cons(2).Groups = {2 3};

I.Cons(2).Levs = [2];

I.Cons(2).ET = [];

I.Cons(2).mean = 0;


I.Cons(3).name = 'Run Effect';

I.Cons(3).Groups = {4 5 6 7};

I.Cons(3).Levs = [4];

I.Cons(3).ET = [];

I.Cons(3).mean = 0;


I.Cons(4).name = 'Condition Effect';

I.Cons(4). Groups = {8 9};

I.Cons(4).Levs = [2];

I.Cons(4).ET = [];

I.Cons(4).mean = 0;


I.Cons(5).name = 'Group by Run';

I.Cons(5). Groups = {10 11 12 13 14 15 16 17};

I.Cons(5).Levs = [2 4];

I.Cons(5).ET = [];

I.Cons(5).mean = 0;


I.Cons(6).name = 'Group by Cond';

I.Cons(6). Groups = {18 19 20 21};

I.Cons(6).Levs = [2 2];

I.Cons(6).ET = [];

I.Cons(6).mean = 0;


I.Cons(7).name = 'Run by Cond';

I.Cons(7). Groups = {22 23 24 25 26 27 28 29};

I.Cons(7).Levs = [2 4];

I.Cons(7).ET = [];

I.Cons(7).mean = 0;


I.Cons(8).name = 'Group by Run by Cond';

I.Cons(8). Groups = {30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45};

I.Cons(8).Levs = [2 4 2];

I.Cons(8).ET = [];

I.Cons(8).mean = 0;



I = GLM_Flex_Contrasts(I);



The cool thing about this is the number of comparisons we can make from a single second level model.

Rather than running multiple different models based on various combinations of our original 120 input

volumes we are able to look at every single test of interest in one holistic model

INPUT FILE LIST

Scans = {

ss_Sub01_G1_run1_Cond1.nii

ss_Sub01_G1_run1_Cond2.nii

ss_Sub01_G1_run2_Cond1.nii

ss_Sub01_G1_run2_Cond2.nii

ss_Sub01_G1_run3_Cond1.nii

ss_Sub01_G1_run3_Cond2.nii

ss_Sub01_G1_run4_Cond1.nii

ss_Sub01_G1_run4_Cond2.nii

ss_Sub02_G1_run1_Cond1.nii

ss_Sub02_G1_run1_Cond2.nii

ss_Sub02_G1_run2_Cond1.nii

ss_Sub02_G1_run2_Cond2.nii

ss_Sub02_G1_run3_Cond1.nii

ss_Sub02_G1_run3_Cond2.nii

ss_Sub02_G1_run4_Cond1.nii

ss_Sub02_G1_run4_Cond2.nii

ss_Sub03_G1_run1_Cond1.nii

ss_Sub03_G1_run1_Cond2.nii

ss_Sub03_G1_run2_Cond1.nii

ss_Sub03_G1_run2_Cond2.nii

ss_Sub03_G1_run3_Cond1.nii

ss_Sub03_G1_run3_Cond2.nii

ss_Sub03_G1_run4_Cond1.nii

ss_Sub03_G1_run4_Cond2.nii

ss_Sub04_G1_run1_Cond1.nii

ss_Sub04_G1_run1_Cond2.nii

ss_Sub04_G1_run2_Cond1.nii

ss_Sub04_G1_run2_Cond2.nii

ss_Sub04_G1_run3_Cond1.nii

ss_Sub04_G1_run3_Cond2.nii

ss_Sub04_G1_run4_Cond1.nii

ss_Sub04_G1_run4_Cond2.nii

ss_Sub05_G1_run1_Cond1.nii

ss_Sub05_G1_run1_Cond2.nii

ss_Sub05_G1_run2_Cond1.nii

ss_Sub05_G1_run2_Cond2.nii

ss_Sub05_G1_run3_Cond1.nii

ss_Sub05_G1_run3_Cond2.nii

ss_Sub05_G1_run4_Cond1.nii

ss_Sub05_G1_run4_Cond2.nii

ss_Sub06_G1_run1_Cond1.nii

ss_Sub06_G1_run1_Cond2.nii

ss_Sub06_G1_run2_Cond1.nii

ss_Sub06_G1_run2_Cond2.nii

ss_Sub06_G1_run3_Cond1.nii

ss_Sub06_G1_run3_Cond2.nii

ss_Sub06_G1_run4_Cond1.nii

ss_Sub06_G1_run4_Cond2.nii

ss_Sub07_G1_run1_Cond1.nii

ss_Sub07_G1_run1_Cond2.nii

ss_Sub07_G1_run2_Cond1.nii

ss_Sub07_G1_run2_Cond2.nii

ss_Sub07_G1_run3_Cond1.nii

ss_Sub07_G1_run3_Cond2.nii

ss_Sub07_G1_run4_Cond1.nii

ss_Sub07_G1_run4_Cond2.nii

ss_Sub08_G1_run1_Cond1.nii

ss_Sub08_G1_run1_Cond2.nii

ss_Sub08_G1_run2_Cond1.nii

ss_Sub08_G1_run2_Cond2.nii

ss_Sub08_G1_run3_Cond1.nii

ss_Sub08_G1_run3_Cond2.nii

ss_Sub08_G1_run4_Cond1.nii

ss_Sub08_G1_run4_Cond2.nii

ss_Sub09_G2_run1_Cond1.nii

ss_Sub09_G2_run1_Cond2.nii

ss_Sub09_G2_run2_Cond1.nii

ss_Sub09_G2_run2_Cond2.nii

ss_Sub09_G2_run3_Cond1.nii

ss_Sub09_G2_run3_Cond2.nii

ss_Sub09_G2_run4_Cond1.nii

ss_Sub09_G2_run4_Cond2.nii

ss_Sub10_G2_run1_Cond1.nii

ss_Sub10_G2_run1_Cond2.nii

ss_Sub10_G2_run2_Cond1.nii

ss_Sub10_G2_run2_Cond2.nii

ss_Sub10_G2_run3_Cond1.nii

ss_Sub10_G2_run3_Cond2.nii

ss_Sub10_G2_run4_Cond1.nii

ss_Sub10_G2_run4_Cond2.nii

ss_Sub11_G2_run1_Cond1.nii

ss_Sub11_G2_run1_Cond2.nii

ss_Sub11_G2_run2_Cond1.nii

ss_Sub11_G2_run2_Cond2.nii

ss_Sub11_G2_run3_Cond1.nii

ss_Sub11_G2_run3_Cond2.nii

ss_Sub11_G2_run4_Cond1.nii

ss_Sub11_G2_run4_Cond2.nii

ss_Sub12_G2_run1_Cond1.nii

ss_Sub12_G2_run1_Cond2.nii

ss_Sub12_G2_run2_Cond1.nii

ss_Sub12_G2_run2_Cond2.nii

ss_Sub12_G2_run3_Cond1.nii

ss_Sub12_G2_run3_Cond2.nii

ss_Sub12_G2_run4_Cond1.nii

ss_Sub12_G2_run4_Cond2.nii

ss_Sub13_G2_run1_Cond1.nii

ss_Sub13_G2_run1_Cond2.nii

ss_Sub13_G2_run2_Cond1.nii

ss_Sub13_G2_run2_Cond2.nii

ss_Sub13_G2_run3_Cond1.nii

ss_Sub13_G2_run3_Cond2.nii

ss_Sub13_G2_run4_Cond1.nii

ss_Sub13_G2_run4_Cond2.nii

ss_Sub14_G2_run1_Cond1.nii

ss_Sub14_G2_run1_Cond2.nii

ss_Sub14_G2_run2_Cond1.nii

ss_Sub14_G2_run2_Cond2.nii

ss_Sub14_G2_run3_Cond1.nii

ss_Sub14_G2_run3_Cond2.nii

ss_Sub14_G2_run4_Cond1.nii

ss_Sub14_G2_run4_Cond2.nii

ss_Sub15_G2_run1_Cond1.nii

ss_Sub15_G2_run1_Cond2.nii

ss_Sub15_G2_run2_Cond1.nii

ss_Sub15_G2_run2_Cond2.nii

ss_Sub15_G2_run3_Cond1.nii

ss_Sub15_G2_run3_Cond2.nii

ss_Sub15_G2_run4_Cond1.nii

ss_Sub15_G2_run4_Cond2.nii}