I have a question on cluster-based permutation testing. I have a dataset with 31 participants, each participant performed two tasks and I want to compare the theta power time course between these two tasks at the source level. I used the function source_band_induced_power() to extract the time courses of theta from the whole brain sources.
However, I wonder whether this is actually comparing the two conditions in the way I am interested in. Namely, given that the input matrix X is n_subj * n_timepoints * n_vert, I think the function permutes across time and space.
What I would want to achieve is for each permutation to randomly swap the condition to which the time*space matrix is assigned, without affecting the dependency between time and space. I think this would be a more fair test for the differences between my two tasks.
I am not being able to implement this approach. I think I should use a stat_fun within the permutation_cluster_test analogous to scipy.stats.ttest_rel, but I am not sure how to do this and if it makes sense.
I’m pretty sure that the function is already doing what you want it to do. It does not permute across time and space; it clusters across time and space, as controlled by the adjacency and max_step parameters (which together determine which times are considered temporally adjacent, and which vertices are considered spatially adjacent).
Analyzing your data with the default stat_fun is already effectively the same as using scipy.stats.ttest_rel (which does the subtraction of condition A from condition B for you; here you’ve done the subtraction already so comparing the result against 0 using ttest_1samp is equivalent).
thanks a lot for your clear reply!
I have a follow up question: what is actually being permuted? Is it the sign of the observations? (by observation I mean for each subject the difference value between the two conditions).
I tried to figure it out in the source code but it is too advanced for me.