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