How to plot topomap of average spectral connectivity of epoched data

I have epoched dataset with 61 channels. I calculated spectral connectivity using following code:

fmin, fmax = 4., 9.

tmin = 0.0  # exclude the baseline period
  con = spectral_connectivity_epochs(
    epochs, method='coh', mode='multitaper', sfreq=sfreq, fmin=fmin, fmax=fmax,
    faverage=True, tmin=tmin, mt_adaptive=False, n_jobs=1, verbose=False).get_data('dense')

and average it using the following code:
mean_con = np.mean(con)

Now I have to plot the topomap of mean_con which is a 61x61 matrix (lower triangular). I need a topomap like below:
topo

I am using mne.viz.plot_topomap(mean_con, pos=raw.info…) but getting error that mean_con is not of same dimension as n_channels. Please help.

  • MNE version: e.g. 0.24.0
  • operating system: Windows 11

A topo map represents one value at each sensor location, in your case, a vector of shape (61, ). Instead, you are providing 61 different values for each sensor location, which can not be plotted as a topographic map by mne.viz.plot_topomap.

You have to figure out which information you want to keep and to plot exactly. Maybe average across your frequency band?

2 Likes

This example might help Compute all-to-all connectivity in sensor space β€” MNE-Connectivity 0.4dev0 documentation. MNE-connectivity has split from the main MNE recently so you’ll need pip install mne-connectivity (not because of a difference in opinions, just for convenience and making sure mne-python stays as lean as practical)

2 Likes