Adjacency Matrix construction for time-frequency data

  • 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:

  1. Run it for each frequency band separately where within a frequency band, I average over the frequencies before running the cluster permutation.
  2. 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!

Hi,

I am not sure if this solves it, but I noticed that the adjacency you set up last is 3D (channels, frequencies, time) and you compare it with 2D(channels, frequencies). So I would expect different results, as you average over time in the first instance and potentially have more power to detect a significant difference compared to the higher dimensionality in the 3D cluster test. The cluster threshold determines the cluster specificity and is more relevant for your question regarding clusters that contain single frequencies rather than a frequency band. Maybe the paper by Jas et al. will be helpful in how to set the cluster threshold.

Cheers,

Carina

1 Like

Hi,

Looking at the documentation of spatio_temporal_cluster_1samp_test, combine adjacency and this example I would expect the last dimension to correspond to space. What you are doing is like this other example.

I am not sure what would be the correct approach in your case, but I would at least check if it makes any difference.

Cheers,

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.