spectral connectivity analysis / coherence

Hi,

I would like to calculate average beta coherence on two channels from the eeg epoched data. Specifically, I am interested in the coherence of c3 and c4 channels (using connectivity_methods = [“coh”] and mode="multitaper) in the beta frequency. Please can you lmk if this is the right way to calculate coherence ? Also is it typical to calculate coherence epoch by epoch or can this be done on the raw (preprocessed) signal? I was just wondering if it would be better to filter the raw signal in the beta frequency rather than doing it epoch by epoch. Because if I need to filter epoch by epoch, then there would be some amount edge distortions.

 epochs=mne.io.read_epochs_eeglab(os.path.join(directory, filename))
        picks=['C3','C4']
        data= epochs.get_data(picks=picks)
        Freq_Bands = {"beta": [13.0, 30.0]}
        n_freq_bands = len ( Freq_Bands )
        fmin = tuple ( [list ( Freq_Bands.values () ) [f] [0] for f in range ( len ( Freq_Bands ) )] )
        fmax = tuple ( [list ( Freq_Bands.values () ) [f] [1] for f in range ( len ( Freq_Bands ) )] )
        sfreq=epochs.info['sfreq']
        ch_names=epochs.info['ch_names'] 
        connectivity_methods = ["coh"]
        n_con_methods = len ( connectivity_methods )
        con, freqs, times, n_epochs, n_tapers = spectral_connectivity (
                data, method=connectivity_methods,
                mode="multitaper", sfreq=2000, fmin=fmin, fmax=fmax,
                faverage=True, verbose=0 )
        con.mean()
        

Thanks,
Apoorva.

May I know what is the study protocol?

Hi @balandongiv , I am trying to replicate what’s in this paper for the same groups (image below): Dopaminergic therapy in Parkinson's disease decreases cortical beta band coherence in the resting state and increases cortical beta band power during executive control

The paper looks into beta coherence for all channels, but I am interested not only at the global beta coherence (all channels) but also just the motor cortex area, so I want to focus on c3 and c4 channels.

Im asking about the signal length, since you mentioned, preferred to processed as a continuous signal.

oh , the signal is about a 1-3min long.

yes, it is generally better to filter the raw object rather than filtering the epochs, for exactly the reason you mentioned (edge artifacts). But you can do this and then still do your coherence analysis on epochs: the sequence of events is

  1. bandpass filter the raw object: raw.filter(fmin, fmax, ...)
  2. extract epochs: epochs = mne.Epochs(raw, ...)
  3. extract data: data = epochs.get_data(picks=['C3', 'C4'])
  4. compute coherence: spectral_connectivity(data, method='coh', ...)

@drammock , why do we need to epoch the data? Why can’t I calculate coherence on just the raw object data ?

pragmatic answer: because spectral_connectivity accepts either an Epochs object or a NumPy array of shape n_epochs, n_signals, n_times.

I think you could do it on raw data by simply adding a np.newaxis to the beginning of the array, but I don’t know what implications that would have for the speed of computation and/or the validity of the result. Maybe @adam2392 knows those implications?

1 Like

Unfortunately the assumptions under the hood assume you have multiple epochs of a trial.

Time varying spectral connectivity isn’t supported yet. If you just add np.newaxis the results wil probably be wrong

1 Like

@larsoner might know more of the history.

FYI it’s on our TODO list to implement the timevarying version

Maybe the other expert can correct me. But what I can summaries from previous post that it is possible to do connectivity across time as long as the window is long enough to compensate for the bias in the connectivity.