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
wrong).

I have checked the documentation
(https://secure-web.cisco.com/1Gf0PHvuRFQv76oTm1ABAUmOVTk9MHhrw8EqhEsEaoAUypEMpA6HoZzm56S1KPbJP5SlpoAgAq2VR3Rp7Ff96ecibUq67Ro5_CpoEd2PrLVeUR9X8pll0HRaEtCw-w3Wk1yFJueGe9mvLz9JVUmRILxV_g4JI9Azx-FJHJrQMLcu7I0qOlVytQuIoXA_-3GF-oFjDMZ-OvC3PmMSoQv5Bmg/https%3A%2F%2Fmne.tools%2Fstable%2Fgenerated%2Fmne.connectivity.spectral_connectivity.h
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
(https://secure-web.cisco.com/1VmCPK-IGvORXkRuZA4yZNNiiEmR7ZXufQjC_stjurXC4i8Xwh0vJZ1dBcYegzyFDEv7M87f0HRBInfXmTxv8FztUd5KZfX5fMG7g9cwY7knLxXULeaki34Q7TtGXFnsY9xbdh0_x9J4aeAgzqJa60AcYo5uwBnlQU4SiF9k4C1llCva-sbSd3YRweiM_wkb5NUuWka0UJQnJ6DHrcl8BBQ/https%3A%2F%2Fgithub.com%2Fmne-tools%2Fmne-python%2Fblob%2F0e080a5a645b5934445ef4da6da744
d7dfa7f68d/mne/connectivity/spectral.py#L630)
<https://secure-web.cisco.com/1VmCPK-IGvORXkRuZA4yZNNiiEmR7ZXufQjC_stjurXC4i8Xwh0vJZ1dBcYegzyFDEv7M87f0HRBInfXmTxv8FztUd5KZfX5fMG7g9cwY7knLxXULeaki34Q7TtGXFnsY9xbdh0_x9J4aeAgzqJa60AcYo5uwBnlQU4SiF9k4C1llCva-sbSd3YRweiM_wkb5NUuWka0UJQnJ6DHrcl8BBQ/https%3A%2F%2Fgithub.com%2Fmne-tools%2Fmne-python%2Fblob%2F0e080a5a645b5934445ef4da6da744
d7dfa7f68d/mne/connectivity/spectral.py#L630)> 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 = raw.info['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 = raw.info['sfreq'] # the sampling frequency

tmin = 0 # exclude the baseline period

tmax=2

epochs.load_data()

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

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

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

Regards

Rodney

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20201104/1e05474c/attachment-0001.html

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