How to plot_sensors_connectivity()?

Hello all,

  • MNE version: 1.6.1
  • operating system: Windows 10

I aiming to compute the coherence connectivity and show them in 3D using the helmet geometry like the example (Compute all-to-all connectivity in sensor space — MNE-Connectivity 0.6.0 documentation).
However, I got an error in plotting the channels which the size does not correspond. My channels are 22 channels and the connectivity data are 484 (22 * 22).

ValueError: The number of channels picked (22) does not correspond to the size of the connectivity data (484)

You can have a look on my code:

import mne
from mne_connectivity import spectral_connectivity_epochs
from mne_connectivity.viz import plot_sensors_connectivity

# Load the raw EEG data
data_path = 'D:/data/1.edf'
raw = mne.io.read_raw_edf(data_path, preload=True)

# Define parameters for creating fixed length events
start = 0  # Time of the first event (in seconds)
stop = None  # Maximum time of the last event (in seconds). Set to None to extend events to the end of the recording.
duration = 1.0  # Duration to separate events by (in seconds)

# Create fixed length events
events = mne.make_fixed_length_events(raw, id=1, start=start, stop=stop, duration=duration)
print(events)

# Select channels of interest
picks = mne.pick_types(raw.info, meg=False, eeg=True,stim=False)

# Create epochs for the EEG data
event_id = 1  # Event ID to use
tmin = -0.2  # Start time of the epoch (in seconds)
tmax = 1.5   # End time of the epoch (in seconds)
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=(None, 0), preload=True)

# Compute connectivity for band containing the evoked response
fmin, fmax = 4.0, 9.0  # Frequency range of interest
sfreq = raw.info['sfreq']

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,
)
print("Number of channels in epochs:", len(epochs.info['ch_names']))
print("Number of channels in connectivity data:", con.n_nodes)

# Visualize the connectivity in 3D
plot_sensors_connectivity(epochs.info, con, picks='all')
#plot_sensors_connectivity(epochs.info, con.get_data(output="dense")[:, :, 0])

Thanks for advance.