- MNE version: 1.2
- operating system: Ubuntu 20.04.5 LTS
Dear MNE community,
Iâm trying to perform this functional connectivity tutorial using my own data:
âCompute source space connectivity and visualize it using a circular graphâ
https://mne.tools/mne-connectivity/stable/auto_examples/mne_inverse_label_connectivity.html
Iâve previously created the inverse operator using the fsaverage template.
However, when I run the function âspectral_connectivity_epochsâ, I get the following error:
ValueError: source space does not contain any vertices for 1 label:
['unknown-lh']
Here is my code:
path_epochs_Tfr = '/home/(...)/epochs_OGT_Tfr_p004_A-epo.fif'
epochs_Tfr = mne.read_epochs(path_epochs_Tfr, preload=True)
fname_inv = '/home/(...)/p004_A-inv.fif'
inverse_operator = read_inverse_operator(fname_inv)
subjects_dir='/home/(...)/mne_data/MNE-fsaverage-data'
subj = 'p004_A'
#%%
# Compute the inverse solution for this data
# Returns the sources / source activity that Iâll use in computing connectivity.
# I can specify particular frequencies to include in the connectivity with the fmin and fmax flags.
# mne-python does:
# reads an epoch from the raw file
# applies SSP and baseline correction
# computes the inverse to obtain a source estimate
# averages the source estimate to obtain a time series for each label
# includes the label time series in the connectivity computation
# moves to the next epoch.
# 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_Tfr, 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(subj, 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)#, allow_empty=True)
fmin = 8.
fmax = 13.
sfreq = epochs_Tfr.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]
I already read the following topic, where itâs suggested to add `allow_missing=True:
If I do it as suggested, I receive the following error, when trying to make a connectivity plot:
ValueError: node_order has to be the same length as node_names
my node_order variable has length â70â and the node_names variable was not created, but the variable ânameâ has just the string âunknown-lhâ in it.
Do you have any hints, why this happens? How could I proceed with my analysis?
Iâd be pleased to post any additional information and would greatly appreciate any help.
Best,
Bruno