# Within-subject Cluster-based Permutation

**URL:** <https://mne.discourse.group/t/within-subject-cluster-based-permutation/4794>\
**Category:** Support & Discussions\
**Tags:** statistics\
**Created:** [April 27, 2022, 8:40am UTC](https://mne.discourse.group/t/within-subject-cluster-based-permutation/4794 "2022-04-27T08:40:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giuseppe-1993](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/giuseppe-1993/32/1140_2.png) [@Giuseppe-1993](https://mne.discourse.group/u/Giuseppe-1993)\
**Post date:** [April 27, 2022, 8:40am UTC](https://mne.discourse.group/t/within-subject-cluster-based-permutation/4794/1 "2022-04-27T08:40:49Z")

</div>

Hi MNE community,

I have a quick question concerning the **non-parametric cluster-based permutation** tests for data in the **time-frequency** domain.

I have looked at the many tutorials but I struggle to find any information on what should differ when having a within-subject vs a between-subject design. Mainly, I am not sure which tutorial refers to a within-subject experimental design (my main interest) when comparing N subjects across two conditions in time-frequency-sensor space. In my case, I have two datasets (the conditions), of size nSubjects_nFreqs_nTimes\*nSensors, and would like to find significant clusters when comparing the two.

Could anyone explain whether this **Permutation statistic for time-frequencies** tutorial is appropriate and why (or why not)?

[https://mne.tools/stable/auto\_tutorials/stats-sensor-space/75\_cluster\_ftest\_spatiotemporal.html](https://mne.tools/stable/auto_tutorials/stats-sensor-space/75_cluster_ftest_spatiotemporal.html)

Thank you in advance and apologies if this is a basic question.

---

<div class="post-metadata">

**Author:** ![CarinaFo](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/carinafo/32/746_2.png) [@CarinaFo](https://mne.discourse.group/u/CarinaFo)\
**Post date:** [April 28, 2022, 4:01pm UTC](https://mne.discourse.group/t/within-subject-cluster-based-permutation/4794/2 "2022-04-28T16:01:23Z")

</div>

Hello Giuseppe,

I had basically the same question some time ago, as I am also interested in a within subjects design with 2 conditions and I have nSubsxFreqsxTimesxSensor arrays.  
I think the topic on my question answers a lot of your questions:

> [@mne.stats.permutation\_cluster\_1samp\_test](https://mne.discourse.group/t/mne-stats-permutation-cluster-1samp-test/3530):
>
> Hello MNE community, I am a bit confused about the input to mne.stats.permutation\_cluster\_1samp\_test(X) (see related topic [Data for permutation cluster 1samp test](https://mne.discourse.group/t/data-for-permutation-cluster-1samp-test/2751)) I have 40 participants that were tested in 2 conditions so a within subject design. I am interested in pre stimulus alpha power differences between my 2 conditions. I calculated power using tfr\_morlet(epochs\_cond1) per participant and per condition and I stored it in a list. So I have two lists with length of number of participants…

The tricky part I encountered after running the permutation test was how to plot the 3D output (freqs, time, channels). I am happy to help with that (I got the code idea from Sebastian Speer, so credits to him).

Best of luck with your analysis,

Carina

---

<div class="post-metadata">

**Author:** ![Giuseppe-1993](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/giuseppe-1993/32/1140_2.png) [@Giuseppe-1993](https://mne.discourse.group/u/Giuseppe-1993)\
**Post date:** [April 29, 2022, 8:12am UTC](https://mne.discourse.group/t/within-subject-cluster-based-permutation/4794/3 "2022-04-29T08:12:46Z")

</div>

Hi @CarinaFo

thank you for your reply and the link to your issue. I have looked online and within the forum but have not come across yours.

May I ask, does this mean that is the stat\_fun that defines the design? What is your suggestion for a within-subject design?

Regarding plotting the 3D output, I have for now followed the tutorial, masking the non-significant areas in the average time-freq images of significant clusters. Is there a better idea?

Best,

Giuseppe

---

<div class="post-metadata">

**Author:** ![CarinaFo](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/carinafo/32/746_2.png) [@CarinaFo](https://mne.discourse.group/u/CarinaFo)\
**Post date:** [April 29, 2022, 11:17am UTC](https://mne.discourse.group/t/within-subject-cluster-based-permutation/4794/4 "2022-04-29T11:17:08Z")

</div>

Happy that I could help.

To my understanding the stat\_fun defines the statistical test that you use for the permuation test, you can define your own. I just had 2 conditions, so for me a paired\_ttest is sufficient for a within design (as you can see in the discussion to my question).  
Yes, I plot the significant electrodes and then a time-frequency plot where I play around with the alpha parameter to highlight significant cluster. Did you define the adjacency between all 3 dimensions?

Best,

Carina

---

<div class="post-metadata">

**Author:** ![Giuseppe-1993](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/giuseppe-1993/32/1140_2.png) [@Giuseppe-1993](https://mne.discourse.group/u/Giuseppe-1993)\
**Post date:** [April 29, 2022, 4:37pm UTC](https://mne.discourse.group/t/within-subject-cluster-based-permutation/4794/5 "2022-04-29T16:37:35Z")

</div>

Hi,

I have only one condition, I believe. I will look into which of the statistics function I will need to match my design.

Yes, I did define the adjacency matrix across the ion time-frequency-sensor space. I used and loaded the FieldTrip Biosemi64 standard, which happens to be exactly the same type of EEG system I used to collect data.

Thank you so much for your help and link to your previous questions. Extremely helpful.

Best,

Giuseppe
