Cluster Permutation Analysis with mne.stats.spatio_temporal_cluster_test

Hello its me again!

I have a rather general question regarding how to apply the spatio_temporal_cluster_test correctly and how to interprete the results of it. I am just starting in the EEG field so it might be a rather simple question for the experts here.

Here is my code:


# Concatenate the data across conditions
X = [condition_a_2D, condition_b_2D]  # List of arrays, shape: (n_epochs, n_times, n_channels)


n_permutations = 1000  # Number of permutations for the permutation test
tail = 0  # Two-sided test
seed = 42

# Perform spatio-temporal clustering
F_obs, clusters, p_values, _ = spatio_temporal_cluster_test(X, n_permutations=n_permutations, tail=tail, seed=seed, adjacency=adjacency)

I have EEG data inserted for X with the dimensions 41 trials, 4401 timepoints and 64 channels. It used to be a time frequency structure with the dimensions 41, 4401, 5, 64. 5 have been the frequency bins but I averaged over them.

Now I am not sure how to correctly use the mne function. I think I also need to specify a t-test as statistics with a threshold? What condition must be put on position one and two of X? I have a control and intervention condition.

Then how to interprete the outcomes of the function?

And when I have results for one subject with the two conditions how can I analyse the two conditions over all my participants in the experiment?

Best regards,

Till

if you have just two conditions, then you could also subtract them from each other and calculate a one sample ttest against zero, see: mne.stats.spatio_temporal_cluster_1samp_test — MNE 1.7.0.dev5+g44c787fd4 documentation

That’s a bit out of scope for this support forum. I suggest you read up on academic references for this (for example: Nonparametric statistical testing of EEG- and MEG-data - PubMed) or look at the MNE-Python examples, for example: Permutation t-test on source data with spatio-temporal clustering — MNE 1.7.0.dev5+g44c787fd4 documentation

For that you take the analysis to the “second level” → instead of analyzing the epochs in a participant, you average over epochs in each participant, and then analyze over participants. That is the n_epochs becomes n_participants.

1 Like

Hello Stefan,

thank you for your response. I am now trying to use the 1 samp test function you provided. I summarized the participants for the second level and want to calculate the difference between the two conditions resulting in a 20 participants x 64 channels x 5 frequencies x 4401 timepoints.

I get how the theory of the permutations works for 2 conditions as the input. How is it done with this one difference condition?

Best regards,

Till

  • Assuming that this is a within-subjects design, each participant has contributed conditions A and B.
  • You are supplying their difference to a test against zero: diff = A-B
  • The permutation is about changing the labels (A to B and B to A, or leaving them as they are; randomly) within participants
  • This is the same as changing the sign of diff for each participant
1 Like