Let’s say we want to know if the fit between education and functional connectivity is greater in Group1 than it is in Group2.

First Let’s start off by setting up the design for two Groups.

IN.N_subs = [20 20];

IN.Between = [2];

IN.BetweenLabs = {{‘Group1’ ‘Group2’}};

Then we put in the covariate.

IN.Covar = {X(:,1)};

IN.CovarLabs = {‘Age’};

Now we specify an interaction between the groups (Factor 1) and the covariate:

IN.CovarInt = {[1]};

IN.FactorLabs = {‘Const’ ‘Age’};

IN.EqualVar = [1];

IN.Independent = [1];

F = CreateDesign(IN);

figure(20); clf

imagesc(F.XX); colormap(gray); shg

The interaction between the covariate and the Factor creates two columns for the covariate. In this model we are allowing each group to have it’s own intercept and it’s own slope.

I.OutputDir = pwd;

I.F = F;

I.minN = 5;

I.DoOnlyAll = 1;

I.RemoveOutliers=0;

I.Scans = {...

‘s01.nii’;

‘s02.nii’;

‘s03.nii’;

‘s04.nii’;

... };

This test the difference in slopes we specify the columns that correspond to the covariate for each group

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

I.Cons(1).Levs = [2]; %% Levs = 2 since we are interested in the difference between the fit for each group.

I.Cons(1).ET = 1;

I.Cons(1).mean = 0;

I = GLM_Flex(I);

This framework can scale to many factors and many covariates.