I am comparing the time-frequency matrices (n_freqs, n_times) between two conditions using mne.stats.spatio_temporal_cluster_1samp_test.
If I understand correctly setting the adjacency parameter to None (default) will connect adjacent neighbors in the time dimension (horizontal). I would like to consider adjacent neighbors in both the frequency (vertical) and time (horizontal) dimensions.
Is there an example I could follow to set up such an adjacency matrix?
Hello @anapesq, if the input data has the shape (observations, times, frequencies), passing
adjacency=None should do exactly what you want and form clusters across immediately neighboring time and frequency bins. Clusters are always implicitly formed over neighboring time points.
Thank you for the quick reply and clarification.
Do you know how I would have to set-up the adjacency if I wished to check not only the immediately neighboring time and frequency bins (next cells) but also the bins at a distance of two cells?
Meaning, how could I expand what is considered a neighboring cell.
I’m sure @sappelhoff is now in a good position to help here — he just reworked a big chunk of the clustering documentation
Do you mean you don’t have “channels” as a dimension? If your data is really just
observations * n_freqs * n_times, then mne.stats.spatio_temporal_cluster_1samp_test is the wrong test to choose, see the docstring:
This function provides a convenient wrapper for
mne.stats.permutation_cluster_1samp_test() , for use with data organized in the form (observations × time × space).
I think I would rather advise you to use: mne.stats.permutation_cluster_1samp_test
You could have a look at the
max_step parameter in the cluster permutation functions. However I haven’t looked into the source code for that, and the parameter description makes me think that:
- this param only works when you specify adjacency for channels as obtained by mne.channels.find_ch_adjacency
- this param only works for the 2nd dimension of the input data … and not as you’d like to have it, for several input dimensions
So overall I don’t think this is possible right now, but it sounds like a very reasonable feature request to me to expand what
max_step can do.
Thank you for your quick and informative reply.
I re-run the analysis using the suggested
mne.stats.permutation_cluster_1samp_test() and the results are the same as when using ‘mne.stats.spatio_temporal_cluster_1samp_test()’. Possibly the later function (which is not the preferred as you suggest) adapts to an input without the channel dimension.
I will look into how to request mne features.