First of all, I am a former EEGLAB user moving slowly towards MNE-Python (yay!). I have tried searching for this issue into the (very complete) docs, github issues, etc. but haven’t been able to find an answer to my question. @larsoner told me to come here and ask for your help!

I have been struggling with a time-frequency analysis that I would like to perform: cluster-based permutation test with a two-way repeated measures design on spatial andtime-frequency data.
I have found a way to perform spatio-temporo-frequential cluster-based permutation tests on one way dependent samples, on two independent groups and two-way repeated measures on spatio-temporal (thus spatio-frequential) or temporo-frequential data. But not two-way repeated measures on spatio-temporo-frequential data.
As an example, my data shape, that I would like as input of the permutation test is (4 x 29 x 1001 x 94 x 64), i.e. (n_conditions [2-by-2], n_participants, n_times, n_freqs, n_chans).

I have tried adapting code, but my (too) basic knowledge on MNE-Python istaking me nowhere…

Does anyone know whether this type of analysis is feasible on MNE-Python? If so which function would be the best fit?

The within-subjects / repeated-measures code requires that you give it something of shape (n_subjects, ...) where the ... are the spatio(-temporal) dimensions you want to cluster over. Thinking about a 2-way rmANOVA, there are presumably 3 effects of interest (though you could choose a subset if you wanted):

Main effect of A

Main effect of B

Interaction of A and B

To test the first one, given your data of shape (4, 29, 10001, 94, 64), let’s think about reshaping this to a data2 of shape (2, 2, 29, ...) as A, B, subjects, <clustering dims>. For the main effect of A, you can pass the clustering function np.mean(data2[1] - data2[0], axis=0) (and use the default ttest_1samp_no_p on it), which will have shape (29, ...) as required by our clustering functions. For the main effect of B, you can pass np.mean(data2[:, 1] - data2[:, 0], axis=0). For the interaction term, you can pass (data2[0, 0] + data2[1, 1]) / 2 - (data2[1, 0] + data2[0, 1]) / 2). I’m not 100% sure it’s valid to run these three tests separately instead of jointly – and even if it is, you might in principle need another multiple comparisons correction for doing 3 tests like this – but it will at least give you an idea for your data.

Separately there is an issue about how to properly construct your adjacency in this case, but hopefully our API docs and existing tutorials might help you figure that part out?