post hoc invalid contrasts

152 views
Skip to first unread message

Isadora Olive

unread,
Sep 28, 2016, 11:43:51 PM9/28/16
to Aaron's fMRI matlab tools.
Hi Aaron!

as I am trying to run in glm flex fast4 a mixed model with a between group factor with 3 levels and a within factor with 2 levels, I'm stumping on a recurrent problem of post hoc contrasts that are invalid, in spite of being correctly written. The data structure also seems ok.

after searching a lot here in the group I could not find a solution for it.

my structure is

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Scans = dir_wfp('F:\GLM_DATA\*.nii');

%%% Create a data structure to hold the variables
clear dat
dat.fn = [];
dat.Group = [];
dat.SS = [];
dat.Condition = [];

%%% 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.SS{ii,1} = tmp{2};
    dat.Condition{ii,1} = tmp{3};
end

% First 80 Subjects (80 images) are in Group1, 74 in Group2 and the rest are in Group3
dat.Group = cell(274,1);
dat.Group(1:80) = {'CTRL'};
dat.Group(81:154) = {'DISS'};
dat.Group(155:end) = {'PTSD'};

%%% 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*Condition + random(SS|Condition)';
I.Data = dat;
I.OutputDir = '/GLM_RESULTS/Analysis6';
I.RemoveOutliers = 0;
I.DoOnlyAll = 1;
I.estSmooth = 1;
 
%%% With the latest update to GLM_Flex_Fast2 we can also specify post hoc contrasts
I.PostHocs = {
              'Group$CTRL # Group$DISS' 'Posthoc 1';
              'Group$CTRL|Condition$lSC # Group$DISS|Condition$lSC' 'Posthoc 2';
              };

GLM_Flex_Fast4(I);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


And I keep receiving the following error message:
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.

Error in ANOVA_APS (line 397)
        tx1 = RFMs(ET).tx1;

Error in GLM_Flex_Fast4 (line 52)
    MOD = ANOVA_APS(I.Data,I.Model,I.PostHocs,0,1,1);

Error in model (line 45)
GLM_Flex_Fast4(I);



Alternatively, if I slightly  transform the contrast in

%%% With the latest update to GLM_Flex_Fast2 we can also specify post hoc contrasts
I.PostHocs = {
             'Group$CTRL|Condition$lSC # Group$DISS|Condition$lSC' 'lSC_CTRLvsDISS';
              };

I receive yet another error message:

Error using ANOVA_APS>posthoc (line 580)
Invalid Contrast

Error in ANOVA_APS (line 395)
        [ttx1 ttx2 ET df track] = posthoc(posthocs{ii,1},[C Effects{:}],dat,eTerms);

Error in GLM_Flex_Fast4 (line 52)
    MOD = ANOVA_APS(I.Data,I.Model,I.PostHocs,0,1,1);

Error in model (line 44)
GLM_Flex_Fast4(I);

???

Looking forward your feedback,
Isadora


Aaron Schultz

unread,
Nov 17, 2016, 8:22:33 AM11/17/16
to Aaron's fMRI matlab tools.
I'm not sure what the issues is here.  If you would like to send me your I.mat file I can look at things more closely.

-Aaron

Adam Teed

unread,
Aug 16, 2018, 11:52:18 PM8/16/18
to Aaron's fMRI matlab tools.

Hello Aaron,

 

I am trying to fix an invalid posthoc contrast error and found this post referencing the exact error I am receiving. Did you find a solution to this person’s problem? My I.mat and glmFF2 script (I’ve tried glmFF4 as well) are attached but below is the error and a few notes on the most relevant sections of code. I appreciate any feedback on this issue. Note that our glmFF2 script begins by loading a .mat file specifying the conditions and fieldnames for each contrast image.


The I.Model line is as follows where Drug_con refers to a between-subjects pharmacological treatment with 2 levels and “stimulus” currently has 3 levels: parent, stranger, or math.

I.Model = 'Drug_con*stimulus + random(subID|stimulus)';

 

The posthocs commented out below are examples of the format that result in the aforementioned error. The 1st posthoc listed runs but produces an Fcontrast image that returns the warning “NaN for out of range arguments” resulting in “NaN, Inf” for the threshold value fields when I open it in FIVE as an overlay.

I.PostHocs = {

'stimulus$parent # stimulus$math' 'parent-math';

%'Drug_con$OXT|stimulus$parent # Drug_con$PLA|stimulus$parent' 'OXT-PLA_parent';

%'Drug_con$PLA|stimulus$parent # Drug_con$PLA|stimulus$math' 'PLA_parent-math';

 

Like the previous poster, I get the following error:

Error using ANOVA_APS>posthoc (line 580)

Invalid Contrast

 

Error in ANOVA_APS (line 395)

        [ttx1 ttx2 ET df track] = posthoc(posthocs{ii,1},[C

        Effects{:}],dat,eTerms);

 

Error in GLM_Flex_Fast2 (line 51)

    MOD = ANOVA_APS(I.Data,I.Model,I.PostHocs,0,1,1);

 

Error in NP_ATT_MomDad3_noAVP (line 96)

    GLM_Flex_Fast2(I);

 

For completeness, here are the sections of code that created the 1st contrast images:

    matlabbatch{3}.spm.stats.con.consess{1}.tcon.name = 'parent';

    matlabbatch{3}.spm.stats.con.consess{1}.tcon.convec = [0.5 0.5 0 0 0];

    matlabbatch{3}.spm.stats.con.consess{1}.tcon.sessrep = 'none';

 

    matlabbatch{3}.spm.stats.con.consess{2}.tcon.name = 'stranger';

    matlabbatch{3}.spm.stats.con.consess{2}.tcon.convec = [0 0 0.5 0.5 0];

    matlabbatch{3}.spm.stats.con.consess{2}.tcon.sessrep = 'none';

 

    matlabbatch{3}.spm.stats.con.consess{3}.tcon.name = 'math';

    matlabbatch{3}.spm.stats.con.consess{3}.tcon.convec = [0 0 0 0 1];

    matlabbatch{3}.spm.stats.con.consess{3}.tcon.sessrep = 'none';

 

I also have one more question. We want to retain information from regions in which not all participants have data due to signal dropout, but I get the following error if I don’t select DoOnlyAll (and changing the NoMiss or estSmooth parameters hasn’t helped):


Analysing Sub-Model #2 of 505; 121 Observations, across 3 Voxels.Error using  *

Inner matrix dimensions must agree.

 

Error in GLM_Flex_Fast4 (line 680)

            Y = I.W{ii}*OD(Xind,vec);

 

Error in NP_ATT_MomDad3_PH_noAVP_4test (line 97)

    GLM_Flex_Fast4(I);


Thank you for your help and all your efforts to create and support these tools!


Adam
NP_ATT_MomDad3_PH_noAVP.m
I.mat

Aaron Schultz

unread,
Aug 20, 2018, 10:30:28 AM8/20/18
to Aaron's fMRI matlab tools.
Off the top of my head, I'm not sure what's going on.  I'll try to look through the files you sent in more detail later this week.

-Aaron

On Wednesday, September 28, 2016 at 11:43:51 PM UTC-4, Isadora Olive wrote:

Adam Teed

unread,
Aug 20, 2018, 10:45:56 AM8/20/18
to Aaron's fMRI matlab tools.
That would be greatly appreciated. Thank you, Aaron!

Adam

Aaron Schultz

unread,
Aug 21, 2018, 11:31:10 AM8/21/18
to fmri_mat...@googlegroups.com
One immediate issues that I see is that there are not repeated subjects.  There are 122 observations and 122 subjects, which would imply that there is no need to a subjects term as that will simply be an identity matrix. The stimulus variable is also a constant (math for all rows). This implies that the data table has not been structured properly.

-Aaron


--
You received this message because you are subscribed to the Google Groups "Aaron's fMRI matlab tools." group.
To unsubscribe from this group and stop receiving emails from it, send an email to fmri_matlab_to...@googlegroups.com.
To post to this group, send email to fmri_mat...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fmri_matlab_tools/72ed2aec-b07b-499d-be2e-cd6ded93d4b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Teed

unread,
Aug 23, 2018, 12:05:19 AM8/23/18
to Aaron's fMRI matlab tools.
Thank you for checking this out, Aaron. Your feedback helped me find that the code was only taking one contrast image per person. That addressed both issues you mentioned once corrected.

Adam
Reply all
Reply to author
Forward
0 new messages