Return Spectral Connectivity of Each Epoch {Disarmed}

External Email - Use Caution

Dear Group,

The objective is to compute frequency connectivity measures. Say we have 70
epochs of an event with the id 1, and I would like the connectivity measures
each of the epoch.

However, I noticed the spectral_connectivity() return an average
connectivity measures value of all the 70 epochs (please correct this if I'm

I have checked the documentation
tml#mne.connectivity.spectral_connectivity), but I did not found any related
setting to return connectivity measures value of each of the epoch.

But, the accompanying documentation
d7dfa7f68d/mne/connectivity/> not explicitly mention `
con` will be the average value of all epoch. This leads me to believe that
the function can return the connectivity measures value of each of the
epoch. Appreciate for confirmation about this issue.

Code example lead to the above observation is as below:

import mne

from mne import io

from mne.connectivity import spectral_connectivity

from mne.datasets import sample

data_path = sample.data_path()

raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'

event_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'

raw = io.read_raw_fif(raw_fname)

events = mne.read_events(event_fname)

ch_names =['ch_names']

picks = mne.pick_channels(ch_names=ch_names,include=['EEG 001','EEG
002','EEG 003'])

event_id, tmin, tmax = 1, -10, 0

epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks)

fmin, fmax = (1.,5.),(4.,9.)

sfreq =['sfreq'] # the sampling frequency

tmin = 0 # exclude the baseline period



con, freqs, times, n_epochs, n_tapers = spectral_connectivity(

    epochs, method='pli', mode='multitaper', sfreq=sfreq, fmin=fmin,

    faverage=True, tmin=tmin, tmax=tmax,mt_adaptive=False, n_jobs=1)



-------------- next part --------------
An HTML attachment was scrubbed...

External Email - Use Caution

I can?t recall offhand if there is an explicit way to do this. One work around would be to loop through your epochs and send them one-by-one. In prior versions, you could need to put the epoch back into a list (of length 1) in order for the function to function. So, for example: for epoch in epochs: spectral_connectivity([epoch], ?)

1 Like