# one-way ANOVA within a single subject

Hi Afni team,

My experiment has 9 different conditions, let’s say it’s a1, a2, … a9. I want to find the voxels that shows any significant difference between any conditions. Basically, it’s a one-way anova.

The problem is that I want to do this within each subject, not across subjects. I think I should do this with 3dDeconvolve, but how should I define the contrast?

Thank you very much for your help!

–Lingyan

My experiment has 9 different conditions, let’s say it’s a1, a2, … a9

Suppose that the labels for those 9 conditions are a1, a2, …, a9. In your 3dDeconvolve script, add something like

-gltsym ‘SYM: +a1 -a2 \ +a2 -a3 \ +a3 -a4 \ +a4 -a5 \ +a5 -a6 \ +a6 -a7 \ +a7 -a8 \ +a8 -a9’
-fout -tout

Hi Gang,

This contrast seems to test any ‘neighboring’ contrast has a significant difference. If I want to test between any conditions, should I define Combination(9,2)=36 pairs that include all possible ‘two-condition’ pairs?

Or are you saying these 8 neighboring pair is equivalent to the 36 pairs?

Plus, I’m actually not totally sure if the 36 pairs contrast, which calculates ‘significance between any two conditions’ is equivalent to ANOVA, which tests the significance across conditions by using each condition’s difference to the group mean to divide some variance parameter.

Hope you could elaborate on this. Thanks!

With 9 conditions, there are 36 possible pairwise contrasts; however, among them there are only 8 independent ones. So, any set of 8 independent pairwise contrasts would be fine to obtain the conventional “omnibus” inference in this case. For example, you can also go with

-gltsym ‘SYM: +a1 -a2 \ +a1 -a3 \ +a1 -a4 \ +a1 -a5 \ +a1 -a6 \ +a1 -a7 \ +a1 -a8 \ +a1 -a9’

Hi Gang,

This is very interesting and not quite intuitive to me.

Following your explanation, let’s say if I have increasing values from a1 to a9. Each neighboring step is quite small but the difference between a1 and a9 is big. And in a ‘neighboring’ contrast like ‘a1-a2 \ a2-a3 \ a3-a4 .…’, I would expect that none of these pairs would be significant, but you think the F-stats is still gonna catch the difference between a1 and a9?

Hope to get more elaboration. Thank you very much!

–Lingyan

Lingyan,

To convince yourself, add two or more separate lines like the following in 3dDeconvolve:

-gltsym ‘SYM: +a1 -a2 \ +a2 -a3 \ +a3 -a4 \ +a4 -a5 \ +a5 -a6 \ +a6 -a7 \ +a7 -a8 \ +a8 -a9’
-gltsym ‘SYM: +a1 -a2 \ +a1 -a3 \ +a1 -a4 \ +a1 -a5 \ +a1 -a6 \ +a1 -a7 \ +a1 -a8 \ +a1 -a9’

and check if you get the same F-stat value.

Hi Gang,

I did what you said and I’m fully convinced now.

I just have one question left: when we report this method in our paper, can we say it’s single-subject repeated measure ANOVA? Is there any paper you know that used this method before and I could read it as an example?

I would also be happy to read through the math behind this contrast to understand how it calculates the F-stats here!

Thank you so much!

–Lingyan

when we report this method in our paper, can we say it’s single-subject repeated measure ANOVA? Is there any
paper you know that used this method before and I could read it as an example?

I don’t think you need a specific reference to justify your modeling approach. ANOVA simply means that the data have a structure of two or higher dimensions. Such dimensions can be subjects, groups, conditions, etc. Even though ANOVA is often adopted for population-level modeling in neuroimaging with subjects as one dimension, it does not mean the methodology can only be used with subjects as one dimension. In this case, you have conditions and trials as two dimensions in your regression model.

I would also be happy to read through the math behind this contrast to understand how it calculates the F-stats here!

Essentially the model remains the same, but the difference regards various ways to parameterize those conditions. See if the following is helpful:

https://stats.oarc.ucla.edu/r/library/r-library-contrast-coding-systems-for-categorical-variables/

Thanks Gang!