Questionable connectivity output when feeding epoch by epoch into the spectral_connectivity module

  • MNE-Python version: 0.21.2
  • WSL Ubuntu:

The objective is to compute the spectral connectivity measures for each of the epoch as discussed here. Along the pipeline, the list of epochs will be croped in between x duration and each epoch will be extracted and feed separately into the spectral_connectivity module. For example, the epochs will trimed between tmin=-60 and tmax=-56. For the sake of the discussion, let us calculate the spectral_connectivity of the epoch with index 0 as shown per the code snippet below.

import mne
from mne.connectivity import spectral_connectivity


# method=['coh', 'plv', 'ciplv', 'ppc', 'pli', 'pli2_unbiased', 'wpli', 'wpli2_debiased']
method=['coh']
epochs = mne.read_epochs ( 'raw_csd-epo.fif', preload=True )
epochs = epochs ['Road edge excursion']
sfreq = epochs.info ['sfreq']
epochs.baseline = None
epoch_win_t = epochs.copy ().crop ( tmin=-60, tmax=-56, include_tmax=True )

epoch_win =epoch_win_t[0]
# epoch_win=epoch_win_t

con, freqs, times, n_epochs, n_tapers=spectral_connectivity ( epoch_win, method=method,mode='fourier', sfreq=sfreq, faverage=True, mt_adaptive=False, n_jobs=-1,fmin=[4], fmax=[8])

The above code snippet will produce an all 1 connectivity between the channel as shown in the figure below.

Similarly, the same output was produced for epoch_win_t[1] and epoch_win_t[2], which correspond to the second and third epoch, respectively. In addition, experimenting with different method also produced the value 1.

However, when feeding all the epoch altogether into the spectral_connectivity module, by setting the epoch_win=epoch_win_t would produced the following output.

.

If I understand correctly, the above output is the average connectivity for all the 3 epochs.

However, as seen at the first figure, the connectivity at the lower triangle is equal to ONE, and this also happen to be true for the second and third epoch. I we average these three epochs manually, the result should be equal to 1 for all the lower triangle.

I really appreciate if someone can shed some light on where did I do wrong?

The raw_csd-epo.fif can be downloaded via the link: https://drive.google.com/file/d/1Z4cWjAMdwGH-p56p6SpkGNKlINVKYjg0/view?usp=sharing

You cannot compute connectivity currently on a single epoch and have it be really meaningful. We recommend typically chopping up raw into multiple equal-length segments (e.g., 1 sec or 10 sec) and computing on multiple epochs, as the spectral connectivity measures collapse across epochs (and if you have one epoch, something like PLV will be all ones)