- MNE version: 1.8.0
- operating system: e.g. macOS 14
Hi all!
I am trying to run a spatio-temporal cluster permutation using MEG data from two different conditions “B” and “C”. The permutation is being done on data from a group of subjects.
t_obs, clusters, cluster_pv, H0 = mne.stats.spatio_temporal_cluster_1samp_test(X_diff, threshold=threshold,
n_permutations=1024,
tail=0, adjacency=adjacency,
n_jobs=4, step_down_p=0,
t_power=1, out_type='indices',
verbose=True)
Where X_diff
is of shape subjects x times x freqs x channels
and is obtained from the TFR for the difference between the two conditions.
I aim to run the cluster permutation in two ways:
- Run it for each frequency band separately where within a frequency band, I average over the frequencies before running the cluster permutation.
- Run it over all frequencies in a range so that the clusters obtained from the cluster permutation also give me information about the frequencies where a significant effect is observed.
The issue I am facing is in the construction of the adjacency matrix in the latter case. Following this discussion x, I specified the adjacency in the following manner:
freq_adjacency = sparse.csr_matrix(np.zeros((89, 89)))
chan_adjacency = sparse.csr_matrix(np.ones((248, 248)))
adjacency = mne.stats.combine_adjacency(freq_adjacency, chan_adjacency)
I ran the cluster permutation and got 4 significant clusters for 4 different frequencies 7,8,9,10 Hz. I should point out that this effect is what I was also expecting to observe. However, I thought that it was strange that I was obtaining clusters per a single frequency value and I thought that this method isn’t lumping neighbouring frequencies together, so I searched around a bit more and followed this tutorial x, and tried to construct the adjacency matrix like so:
tfr_epochs = diff_TFRs[0]
epochs_power = tfr_epochs.data
sensor_adjacency, ch_names = mne.channels.find_ch_adjacency(tfr_epochs.info, "mag")
assert sensor_adjacency.shape == (len(tfr_epochs.ch_names), len(tfr_epochs.ch_names))
adjacency = mne.stats.combine_adjacency(sensor_adjacency, len(tfr_epochs.freqs), len(tfr_epochs.times))
This, I thought, would group together the neighbouring frequencies and so I might get refined results (?) if that makes sense. I may be wrong but I thought I would be losing information if I don’t specify in the adjacency matrix, the fact that neighbouring frequencies might show similar effects.
Anyway, I ran the cluster permutation using this adjacency matrix and I lose all the significant clusters I was observing using the first method. There are no significant clusters anymore.
I would really appreciate some help on this. Maybe my understanding of the adjacency matrix is flawed.
Thank you!