MEG Connectivty issue in spectral_connectivity_epochs() --> length 2, got 68

mne-connectivity version 1.6.1
mne version 1.6.1

operating system: Debian 12

print(src)
<SourceSpaces: [<volume, shape=(41, 41, 41), n_used=12042>] head coords, subject '20071', ~306.9 MB>
print(inverse_operator)
<InverseOperator | MEG channels: 274 | EEG channels: 0 | Source space: volume with 12042 sources | Source orientation: Free>

Then this is where I see the error

# Compute inverse solution and for each epoch. By using "return_generator=True"
# stcs will be a generator object instead of a list.
snr = 1.0  # use lower SNR for single epochs
lambda2 = 1.0 / snr**2
method = "dSPM"  # use dSPM method (could also be MNE or sLORETA)
stcs = apply_inverse_epochs(
    epochs, inverse_operator, lambda2, method, pick_ori="normal", return_generator=True
)

# Get labels for FreeSurfer 'aparc' cortical parcellation with 34 labels/hemi
labels = mne.read_labels_from_annot("20071", parc="aparc", subjects_dir=subjects_dir)
label_colors = [label.color for label in labels]

# Average the source estimates within each label using sign-flips to reduce
# signal cancellations, also here we return a generator
src = inverse_operator["src"]
label_ts = mne.extract_label_time_course(
    stcs, labels, src, mode="mean_flip", return_generator=True
)

fmin = 8.0
fmax = 13.0
sfreq = raw.info["sfreq"]  # the sampling frequency
con_methods = ["pli", "wpli2_debiased", "ciplv"]
con = spectral_connectivity_epochs(
    label_ts,
    method=con_methods,
    mode="multitaper",
    sfreq=sfreq,
    fmin=fmin,
    fmax=fmax,
    faverage=True,
    mt_adaptive=True,
    n_jobs=1,
)

# con is a 3D array, get the connectivity for the first (and only) freq. band
# for each method
con_res = dict()
for method, c in zip(con_methods, con):
    con_res[method] = c.get_data(output="dense")[:, :, 0]
ValueError                                Traceback (most recent call last)
Cell In[22], line 25
     23 sfreq = raw.info["sfreq"]  # the sampling frequency
     24 con_methods = ["pli", "wpli2_debiased", "ciplv"]
---> 25 con = spectral_connectivity_epochs(
     26     label_ts,
     27     method=con_methods,
     28     mode="multitaper",
     29     sfreq=sfreq,
     30     fmin=fmin,
     31     fmax=fmax,
     32     faverage=True,
     33     mt_adaptive=True,
     34     n_jobs=1,
     35 )
     37 # con is a 3D array, get the connectivity for the first (and only) freq. band
     38 # for each method
     39 con_res = dict()

File <decorator-gen-351>:12, in spectral_connectivity_epochs(data, names, method, indices, sfreq, mode, fmin, fmax, fskip, faverage, tmin, tmax, mt_bandwidth, mt_adaptive, mt_low_bias, cwt_freqs, cwt_n_cycles, gc_n_lags, rank, block_size, n_jobs, verbose)

File ~/anaconda3/lib/python3.11/site-packages/mne_connectivity/spectral/epochs.py:973, in spectral_connectivity_epochs(data, names, method, indices, sfreq, mode, fmin, fmax, fskip, faverage, tmin, tmax, mt_bandwidth, mt_adaptive, mt_low_bias, cwt_freqs, cwt_n_cycles, gc_n_lags, rank, block_size, n_jobs, verbose)
    971 logger.info("Connectivity computation...")
    972 warn_times = True

   3422         )
   3423     mri, labels = labels
   3424     infer_labels = False

ValueError: labels, if list or tuple, must have length 2, got 68
fname_raw = "/mnt/e/PMBR_MNE/subjects/20071/20071_AEF01_20230315_007-raw.fif"
# Load data
raw = mne.io.read_raw_fif(fname_raw)

# Pick MEG channels
picks = mne.pick_types(
    raw.info, meg=True, eeg=False, stim=False, eog=False, exclude="bads"
)
events, event_id = mne.events_from_annotations(raw)
# Define epochs for left-auditory condition
event_id, tmin, tmax = 3, -0.5, 1
epochs = mne.Epochs(
    raw,
    events,
    event_id,
    tmin,
    tmax,
    picks=picks,
    baseline=(None, 0),
)

Also for this earlier step I don’t et any projects

Automatically created module for IPython interactive environment
Opening raw data file /mnt/e/PMBR_MNE/subjects/20071/20071_AEF01_20230315_007-raw.fif...
    Read 5 compensation matrices
    Range : 0 ... 886110 =      0.000 ...   738.425 secs
Ready.
Current compensation grade : 3
Used Annotations descriptions: ['block_start', 'button', 'rhand_response', 'rhand_stimulus']
Not setting metadata
120 matching events found
Setting baseline interval to [-0.5, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated

Not sure why this might occur

Hi,

I’m not super familiar with using source estimates in MNE, so I can only comment from the error message (sorry if this isn’t much help).

When epoched data is being extracted from the labels and you are using a volume source space, it seems the labels should consist of a list/tuple of length 2 where the first entry is a path to an MRI atlas, and the second entry the labels themselves.

In most MNE-Connectivity examples is seems surface sources are used, but in some a mixed source space is used (e.g. Compute mixed source space connectivity and visualize it using a circular graph — MNE-Connectivity 0.6.0 documentation). Perhaps you are able to see how the volume labels are represented here?