<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>In fact <b>rms_gard</b> is the same as <b>_merge_grad_data</b> function imported from <b>mne.channels.layout</b> (<b>from mne.channels.layout import _merge_grad_data as rms_grad</b>). 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).</div></div></blockquote><div><br></div><div>Ok, that makes sense. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Regarding your suggesting of subtracting the conditions first and then using mne.stats.spatio_temporal_clus<wbr>ter_1samp_test instead, could you please try to explain a bit more the logic behind using this method instead of the way I&#39;m currently using now?</div></div></blockquote><div><br></div><div>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.<br></div><div><br></div><div>Hope that helps,</div><div><br></div><div>Jean-Rémi<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>with best regards</div><div>Rasha<br></div><div><br></div><br></div><div id="m_8627169073257330069DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tbody><tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" style="width:46px;height:29px" width="46" height="29"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:#4453ea" target="_blank">www.avast.com</a>
                </td>
        </tr>
</tbody></table><a href="#m_8627169073257330069_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 17 January 2018 at 21:07, JR KING <span dir="ltr">&lt;<a href="mailto:jeanremi.king@gmail.com" target="_blank">jeanremi.king@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Rasha,<br><br></div>1. I&#39;m not sure I follow your script. We don&#39;t have an rms_grad function, but I guess you&#39;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&#39;t it?<br><br></div>2. I think the correct way to do the within subject analysis you mention is to use mne.stats.spatio_temporal_clus<wbr>ter_1samp_test: i.e. first you subtract the two condition within subject, second you run the permutations <br>spatio_temporal_cluster_1samp_<wbr>test(X[:17]-X[17:])<br><br></div>Hope that helps,<br><br>Jean-Rémi<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_8627169073257330069h5">On 17 January 2018 at 11:34, Rasha Hyder <span dir="ltr">&lt;<a href="mailto:rasha.hyder12@gmail.com" target="_blank">rasha.hyder12@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_8627169073257330069h5"><div dir="ltr"><div>Hi all,</div><div><br></div><div>I&#39;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:<br><br></div>to do so I&#39;m using the following:<br><div><br><div># for 17 subjects and 100 ms time window</div><div><br>conditions= [cond1, cond2]<br></div><div>for j, cond in enumerate(conditions):<br>    X_tmp = np.zeros((17, 101, 102))<br>    <br>    for i, subject in enumerate(subjects):<br>        evoked = mne.read_evokeds(fname)</div><div>        grads= evoked.pick_types(meg=&quot;grad&quot;)<br>        rms = rms_grad(grads.data) <br>        X_tmp[i, :] = np.transpose(rms)<br><br>    if j == 0:<br>        X = X_tmp<br>    else:<br>        X = np.vstack((X, X_tmp))</div><div><br></div><div>connectivity, ch_names = find_ch_connectivity(<a href="http://evoked.info" target="_blank">evoked.in<wbr>fo</a>, ch_type=&#39;mag&#39;) <br></div><div><br></div><div>T_obs, clusters, p_values, _ = spatio_temporal_cluster_test([<wbr>X[:17], X[17:]],<br>                              <wbr>                      n_permutations=5000,<br>                              <wbr>                      tail=0,<br>                              <wbr>                      n_jobs=2,<br>                              <wbr>                      connectivity=connectivity)</div><div><br></div><div>After around 20 mints of running the script, the returned p_values look like this:<br></div><div><br></div><div>p_values<br>Out[68]: <br>array([ 0.9476,  1.    ,  1.    ,  0.8854,  1.    ,  1.    ,  0.9966,<br>        1.    ,  1.    ,  1.    ,  1.    ,  1.    ,  0.9974,  1.    ,<br>        1.    ,  1.    ,  1.    ,  1.    ])</div><div><br></div><div>My question is, given the input data: [X[:17], X[17:]] where:<br></div><div>X[17:] contains the data observed in cond1 from all 17 subjects and similarly X[17:] is the data observed in cond2.<br></div><div><br></div><div>are the permutations in this case done between cond1 and cond2 within the same subject (as should be) or randomly between subjects? <br></div><div><br></div><div>Many thanks in advance <br></div><div><br></div><div>Rasha<br></div><br><div><br></div></div></div><div id="m_8627169073257330069m_-3461909942541472768m_-8311896079980075393DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tbody><tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" style="width:46px;height:29px" width="46" height="29"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:#4453ea" target="_blank">www.avast.com</a>
                </td>
        </tr>
</tbody></table><a href="#m_8627169073257330069_m_-3461909942541472768_m_-8311896079980075393_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>
<br></div></div>______________________________<wbr>_________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.e<wbr>du</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.e<wbr>du/mailman/listinfo/mne_analys<wbr>is</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/compli<wbr>anceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.e<wbr>du</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.e<wbr>du/mailman/listinfo/mne_analys<wbr>is</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/compli<wbr>anceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu">Mne_analysis@nmr.mgh.harvard.<wbr>edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.<wbr>edu/mailman/listinfo/mne_<wbr>analysis</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/<wbr>complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br></div></div>