[Mne_analysis] Spatiotemporal cluster permutation on evoked data in a within subjects design

Rasha Hyder rasha.hyder12 at gmail.com
Wed Jan 17 16:42:43 EST 2018
Search archives:

Thanks a lot Jean for your clarification. I will try doing it this way.

All the best
Rasha

On 17 January 2018 at 23:29, JR KING <jeanremi.king at gmail.com> wrote:

> In fact *rms_gard* is the same as *_merge_grad_data* function imported
>> from *mne.channels.layout* (*from mne.channels.layout import
>> _merge_grad_data as rms_grad*). It merges the data of each pair of grads
>> using the RMS and returns an array of shape (n_grads/2, n_times) so for the
>> 204 grads I have 102 arrays and the X_temp has this shape (n_subjects,
>> n_times, n_grads/2).
>>
>
> Ok, that makes sense.
>
>>
>> Regarding your suggesting of subtracting the conditions first and then
>> using mne.stats.spatio_temporal_cluster_1samp_test instead, could you
>> please try to explain a bit more the logic behind using this method instead
>> of the way I'm currently using now?
>>
>
> IIRC the 1 sample cluster test permutes the sign (of the subtraction
> between the two conditions) across subjects. The test thus assesses the
> probability that your distribution is distinct from the distribution based
> on permuted signs.
>
> Hope that helps,
>
> Jean-Rémi
>
>>
>> with best regards
>> Rasha
>>
>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>> <#m_4226237532686425253_m_8627169073257330069_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On 17 January 2018 at 21:07, JR KING <jeanremi.king at gmail.com> wrote:
>>
>>> Hi Rasha,
>>>
>>> 1. I'm not sure I follow your script. We don't have an rms_grad
>>> function, but I guess you're taking the root mean square across
>>> gradiometers. If so, the shape of X_tmp should be 2D (17 x n_times) not 3D
>>> (17 * 101 * 102 in your script), shouldn't it?
>>>
>>> 2. I think the correct way to do the within subject analysis you mention
>>> is to use mne.stats.spatio_temporal_cluster_1samp_test: i.e. first you
>>> subtract the two condition within subject, second you run the permutations
>>> spatio_temporal_cluster_1samp_test(X[:17]-X[17:])
>>>
>>> Hope that helps,
>>>
>>> Jean-Rémi
>>>
>>> On 17 January 2018 at 11:34, Rasha Hyder <rasha.hyder12 at gmail.com>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I'm trying to run spatiotemporal cluster permutation on evoked
>>>> responses in a within subjects design where each subject is observed in two
>>>> conditions: cond1 and cond2:
>>>>
>>>> to do so I'm using the following:
>>>>
>>>> # for 17 subjects and 100 ms time window
>>>>
>>>> conditions= [cond1, cond2]
>>>> for j, cond in enumerate(conditions):
>>>>     X_tmp = np.zeros((17, 101, 102))
>>>>
>>>>     for i, subject in enumerate(subjects):
>>>>         evoked = mne.read_evokeds(fname)
>>>>         grads= evoked.pick_types(meg="grad")
>>>>         rms = rms_grad(grads.data)
>>>>         X_tmp[i, :] = np.transpose(rms)
>>>>
>>>>     if j == 0:
>>>>         X = X_tmp
>>>>     else:
>>>>         X = np.vstack((X, X_tmp))
>>>>
>>>> connectivity, ch_names = find_ch_connectivity(evoked.info,
>>>> ch_type='mag')
>>>>
>>>> T_obs, clusters, p_values, _ = spatio_temporal_cluster_test([X[:17],
>>>> X[17:]],
>>>>
>>>> n_permutations=5000,
>>>>                                                     tail=0,
>>>>                                                     n_jobs=2,
>>>>
>>>> connectivity=connectivity)
>>>>
>>>> After around 20 mints of running the script, the returned p_values look
>>>> like this:
>>>>
>>>> p_values
>>>> Out[68]:
>>>> array([ 0.9476,  1.    ,  1.    ,  0.8854,  1.    ,  1.    ,  0.9966,
>>>>         1.    ,  1.    ,  1.    ,  1.    ,  1.    ,  0.9974,  1.    ,
>>>>         1.    ,  1.    ,  1.    ,  1.    ])
>>>>
>>>> My question is, given the input data: [X[:17], X[17:]] where:
>>>> X[17:] contains the data observed in cond1 from all 17 subjects and
>>>> similarly X[17:] is the data observed in cond2.
>>>>
>>>> are the permutations in this case done between cond1 and cond2 within
>>>> the same subject (as should be) or randomly between subjects?
>>>>
>>>> Many thanks in advance
>>>>
>>>> Rasha
>>>>
>>>>
>>>>
>>>>
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
>>>> www.avast.com
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>>>> <#m_4226237532686425253_m_8627169073257330069_m_-3461909942541472768_m_-8311896079980075393_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>
>>>> _______________________________________________
>>>> 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.
>>>
>>>
>>
>> _______________________________________________
>> 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/20180117/acbf5943/attachment.html 


More information about the Mne_analysis mailing list