Repeated-measured oneway ANOVA / paired ttest in spatio temporal clustering

Dear mailing list,

I'm doing spatio-temporal clustering on 12 subjects in source space. Very
basically, I would like to compare two conditions by taking into account
subjects variability, so I need to do a paired ttest/oneway
repeated-measure ANOVA. Yet, the spatio_temporal_cluster_test function is
only implementing oneway anova, while the spatio_temporal_cluster_1samp_test
is implementing simple ttest on the difference
*.*
*I looked at related issues on github and found that there is a twoway
anova with repeated measures function implemented under the name of
f_twoway_rm but it doesn't work for oneway anova (factor_levels = [2],
n_conditions = 2). Then I tried to build a stat_fun function from *

*scipy.stats.ttest_rel:*

*def stat_fun(*args):*

* a = X[0]*
* b = X[1]** return *
*scipy.stats.ttest_rel(a,b)*

*But I get an error at lign 708 in _permutation_cluster_test (cannot copy
sequence with size 2 to array axis with dimension 0), I guessed there is a
format problem in my stat_fun function...*

*Did someone find a way to do such an analysis?*

*Thanks in advance,Laetitia Grabot.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20141027/d1a670d8/attachment.html

Maybe I don't fully understand the question, but I believe you want to use
spatial_temporal_cluster_1samp_test. The paired t-test between two
conditions should be the same as a one-sample t-test on the difference
between those conditions. You can see it by looking at the one-sample
t-test and paired t-test equations:

You can also check out the docs of `ttest_1samp` and `ttest_rel` in
`scipy.stats`, and see them in action:

from scipy.stats import ttest_1samp, ttest_rel
x = np.random.rand(10)
y = np.random.rand(10) + 1
ttest_1samp(x - y, 0)

(-8.4152236461504959, 1.4741495462601121e-05)

ttest_rel(x, y)

(-8.4152236461504959, 1.4741495462601121e-05)

We thus operate on the difference signal for efficiency in mne-python,
which should work for your use case.

Eric

Hi Laetitia,

how may 'factors' / conditions do you have?
A t-test for related samples is equivalent to a 1 smaple t-test of the
paired contrast which is the same as a repeated measures ANOVA for 2
factors after squaring the output:

def stat_fun(x):
    return mne.stats.ttest_1samp_no_p(x, sigma=1e-3, method='relative') ** 2

Also see this modified example that showd how to compute an interaction
contrast using this stat_fun.

HTH,
Denis

2014-10-27 15:03 GMT+01:00 Laetitia Grabot <laetitia.grabot at gmail.com>:

Dear mailing list,

I'm doing spatio-temporal clustering on 12 subjects in source space. Very
basically, I would like to compare two conditions by taking into account
subjects variability, so I need to do a paired ttest/oneway
repeated-measure ANOVA. Yet, the spatio_temporal_cluster_test function is
only implementing oneway anova, while the spatio_temporal_cluster_1samp_test
is implementing simple ttest on the difference
*.*
*I looked at related issues on github and found that there is a twoway
anova with repeated measures function implemented under the name of
f_twoway_rm but it doesn't work for oneway anova (factor_levels = [2],
n_conditions = 2). Then I tried to build a stat_fun function from *

*scipy.stats.ttest_rel:*

*def stat_fun(*args):*

* a = X[0]*
* b = X[1]** return *
*scipy.stats.ttest_rel(a,b)*

*But I get an error at lign 708 in _permutation_cluster_test (cannot copy
sequence with size 2 to array axis with dimension 0), I guessed there is a
format problem in my stat_fun function...*

*Did someone find a way to do such an analysis?*

*Thanks in advance,Laetitia Grabot.*

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20141027/216aff0c/attachment.html

Ok so I understood that paired ttest = ttest of the paired contrast. Yet I
didn't see why a paired ttest is the same thing as a 2 factors repeated
measures anova. I would understand the equivalence between a paired ttest
and a one way repeated measures anova, but why 2 factors? I also don't
understand the squared output...
And I have only one factor "Condition" with two levels "condition 1" and
"condition 2".

2014-10-27 15:20 GMT+01:00 Denis-Alexander Engemann <
denis.engemann at gmail.com>:

Hi Laetitia,

how may 'factors' / conditions do you have?
A t-test for related samples is equivalent to a 1 smaple t-test of the
paired contrast which is the same as a repeated measures ANOVA for 2
factors after squaring the output:

def stat_fun(x):
    return mne.stats.ttest_1samp_no_p(x, sigma=1e-3, method='relative') **
2

Also see this modified example that showd how to compute an interaction
contrast using this stat_fun.

https://gist.github.com/dengemann/ff96e48dd1dd3eeaca3e

HTH,
Denis

2014-10-27 15:03 GMT+01:00 Laetitia Grabot <laetitia.grabot at gmail.com>:

Dear mailing list,

I'm doing spatio-temporal clustering on 12 subjects in source space. Very
basically, I would like to compare two conditions by taking into account
subjects variability, so I need to do a paired ttest/oneway
repeated-measure ANOVA. Yet, the spatio_temporal_cluster_test function
is only implementing oneway anova, while the spatio_temporal_cluster_1samp_test
is implementing simple ttest on the difference
*.*
*I looked at related issues on github and found that there is a twoway
anova with repeated measures function implemented under the name of
f_twoway_rm but it doesn't work for oneway anova (factor_levels = [2],
n_conditions = 2). Then I tried to build a stat_fun function from *

*scipy.stats.ttest_rel:*

*def stat_fun(*args):*

* a = X[0]*
* b = X[1]** return *
*scipy.stats.ttest_rel(a,b)*

*But I get an error at lign 708 in _permutation_cluster_test (cannot copy
sequence with size 2 to array axis with dimension 0), I guessed there is a
format problem in my stat_fun function...*

*Did someone find a way to do such an analysis?*

*Thanks in advance,Laetitia Grabot.*

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you
in error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20141027/c9710587/attachment.html

Hi,

Ok so I understood that paired ttest = ttest of the paired contrast. Yet I didn't see why a paired ttest is the same thing as a 2 factors repeated measures anova.

it's more precisely a 1 factot repeated measures analysis with 2 factor levels. the example shows how to use. this for a 2 x 2 analysis

I would understand the equivalence between a paired ttest and a one way repeated measures anova, but why 2 factors? I also don't understand the squared output...

the f-dist can be obtained from squaring the t-dist. you can try it and / or google it. a 1-sided t-dist is obtained from computing the square root of the f-dist. this is only valid for 1 factor with 2 levels

And I have only one factor "Condition" with two levels "condition 1" and "condition 2".

2014-10-27 15:20 GMT+01:00 Denis-Alexander Engemann <denis.engemann at gmail.com>:

Hi Laetitia,

how may 'factors' / conditions do you have?
A t-test for related samples is equivalent to a 1 smaple t-test of the paired contrast which is the same as a repeated measures ANOVA for 2 factors after squaring the output:

def stat_fun(x):
    return mne.stats.ttest_1samp_no_p(x, sigma=1e-3, method='relative') ** 2

Also see this modified example that showd how to compute an interaction contrast using this stat_fun.

plot_cluster_stats_spatio_temporal_repeated_measures_interaction_ttest.py · GitHub

HTH,
Denis

2014-10-27 15:03 GMT+01:00 Laetitia Grabot <laetitia.grabot at gmail.com>:

Dear mailing list,

I'm doing spatio-temporal clustering on 12 subjects in source space. Very basically, I would like to compare two conditions by taking into account subjects variability, so I need to do a paired ttest/oneway repeated-measure ANOVA. Yet, the spatio_temporal_cluster_test function is only implementing oneway anova, while the spatio_temporal_cluster_1samp_test is implementing simple ttest on the difference.
I looked at related issues on github and found that there is a twoway anova with repeated measures function implemented under the name of f_twoway_rm but it doesn't work for oneway anova (factor_levels = [2], n_conditions = 2). Then I tried to build a stat_fun function from
scipy.stats.ttest_rel:
def stat_fun(*args):
      a = X[0]
      b = X[1]
      return scipy.stats.ttest_rel(a,b)
But I get an error at lign 708 in _permutation_cluster_test (cannot copy sequence with size 2 to array axis with dimension 0), I guessed there is a format problem in my stat_fun function...
Did someone find a way to do such an analysis?

Thanks in advance,
Laetitia Grabot.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20141027/28914fc1/attachment.html

Ok thanks a lot!

2014-10-27 16:03 GMT+01:00 Denis A. Engemann <denis.engemann at gmail.com>:

Hi,

Ok so I understood that paired ttest = ttest of the paired contrast. Yet I
didn't see why a paired ttest is the same thing as a 2 factors repeated
measures anova.

it's more precisely a 1 factot repeated measures analysis with 2 factor
levels. the example shows how to use. this for a 2 x 2 analysis

I would understand the equivalence between a paired ttest and a one way
repeated measures anova, but why 2 factors? I also don't understand the
squared output...

the f-dist can be obtained from squaring the t-dist. you can try it and /
or google it. a 1-sided t-dist is obtained from computing the square root
of the f-dist. this is only valid for 1 factor with 2 levels

And I have only one factor "Condition" with two levels "condition 1" and
"condition 2".

2014-10-27 15:20 GMT+01:00 Denis-Alexander Engemann <
denis.engemann at gmail.com>:

Hi Laetitia,

how may 'factors' / conditions do you have?
A t-test for related samples is equivalent to a 1 smaple t-test of the
paired contrast which is the same as a repeated measures ANOVA for 2
factors after squaring the output:

def stat_fun(x):
    return mne.stats.ttest_1samp_no_p(x, sigma=1e-3, method='relative')
** 2

Also see this modified example that showd how to compute an interaction
contrast using this stat_fun.

plot_cluster_stats_spatio_temporal_repeated_measures_interaction_ttest.py · GitHub

HTH,
Denis

2014-10-27 15:03 GMT+01:00 Laetitia Grabot <laetitia.grabot at gmail.com>:

Dear mailing list,

I'm doing spatio-temporal clustering on 12 subjects in source space.
Very basically, I would like to compare two conditions by taking into
account subjects variability, so I need to do a paired ttest/oneway
repeated-measure ANOVA. Yet, the spatio_temporal_cluster_test function
is only implementing oneway anova, while the spatio_temporal_cluster_1samp_test
is implementing simple ttest on the difference
*.*
*I looked at related issues on github and found that there is a twoway
anova with repeated measures function implemented under the name of
f_twoway_rm but it doesn't work for oneway anova (factor_levels = [2],
n_conditions = 2). Then I tried to build a stat_fun function from *

*scipy.stats.ttest_rel:*

*def stat_fun(*args):*

* a = X[0]*
* b = X[1]** return *
*scipy.stats.ttest_rel(a,b)*

*But I get an error at lign 708 in _permutation_cluster_test (cannot
copy sequence with size 2 to array axis with dimension 0), I guessed there
is a format problem in my stat_fun function...*

*Did someone find a way to do such an analysis?*

*Thanks in advance,Laetitia Grabot.*

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom
it is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you
in error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you
in error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20141027/a400ecaa/attachment.html