[Mne_analysis] ValueError: source space does not contain any vertices for label unknown-lh

Eric Larson larson.eric.d at gmail.com
Fri May 1 11:52:47 EDT 2020
Search archives:

        External Email - Use Caution        

It's tough to know where the error is occurring without the traceback, but
I suspect it comes from:

 label_ts = mne.extract_label_time_course(
        stcs, labels, inv['src'], return_generator=True)

You can add `allow_missing=True`, see documentation here
<https://mne.tools/stable/generated/mne.extract_label_time_course.html>.

Eric


On Fri, May 1, 2020 at 11:42 AM Andrade Rey René <rene.andrade at edu.uah.es>
wrote:

>         External Email - Use Caution
>
> Dear experts:
> I have the issue that I put in the subject of this email. The error occurs
> when trying to execute this line.
>
>
>
>     corr = mne.connectivity.envelope_correlation(label_ts, verbose=True)
>
>
>
> Below is the whole script.
>
> Sincerely,
> Andrade.
>
>
> import mne
> import os
> import numpy as np
> import matplotlib.pyplot as plt
> from mne.minimum_norm import make_inverse_operator, apply_inverse
> mne.viz.set_3d_backend('pyvista')
> trans='fsaverage'
> subject='fsaverage'
> src='/usr/local/freesurfer/subjects/fsaverage/fsaverage-oct6-src.fif'
> raw =
> mne.io.read_raw_bdf('/home/andraderenew/Downloads/meditation_arnaud_delorme/sub-001_ses-01_eeg_sub-001_ses-01_task-meditation_eeg.bdf',
> preload=True)
> events = mne.find_events(raw, stim_channel=None)
> epochs = mne.Epochs(raw, events, preload=True)
> evoked = epochs.average()
> mne.set_eeg_reference(evoked, ref_channels='average', copy=True,
> projection=True, ch_type='auto', verbose=None)
>
> cov =
> mne.read_cov('/usr/local/freesurfer/subjects/fsaverage/data_eeg_meditation_subj1_sess1/fsaverage-5120-5120-5120-cov.fif')
>
> fwd_sol =
> mne.read_forward_solution('/usr/local/freesurfer/subjects/fsaverage/data_eeg_meditation_subj1_sess1/fsaverage-5120-5120-5120-fwd.fif')
>
> inv =
> mne.minimum_norm.read_inverse_operator('/usr/local/freesurfer/subjects/fsaverage/data_eeg_meditation_subj1_sess1/fsaverage-5120-5120-5120-inv.fif')
>
> subjects_dir = '/usr/local/freesurfer/subjects/'
>
>
>
> snr = 3.
> lambda2 = 1. / snr ** 2
>
> surfer_kwargs = dict(
>     hemi='lh', subjects_dir=subjects_dir,
>     clim=dict(kind='value', lims=[8, 12, 15]), views='lateral',
>     initial_time=0.09, time_unit='s', size=(800, 800),
>     smoothing_steps=5)
>
>
> surfer_kwargs['clim'].update(kind='percent', lims=[99, 99.9, 99.99])
> for mi, method in enumerate(['MNE', 'dSPM', 'sLORETA', 'eLORETA']):
>     stc = apply_inverse(evoked, inv, lambda2,
>                         method=method, pick_ori=None,
>                         verbose=True)
>     peak_vertex, peak_time = stc.get_peak(hemi='lh', vert_as_index=True,
>                                       time_as_index=True)
>
>     peak_vertex_surf = stc.lh_vertno[peak_vertex]
>
>     peak_value = stc.lh_data[peak_vertex, peak_time]
>     brain = stc.plot(figure=mi, **surfer_kwargs)
>     brain.add_foci(peak_vertex_surf, coords_as_verts=True, hemi='lh',
> color='blue')
>     brain.add_text(0.1, 0.9, method, 'title', font_size=20)
>     print(stc)
>  #  lh_coordinates = src[0]['rr'][stc.lh_vertno]
>  #  lh_data = stc.lh_data
>  #   input()
>
>
>
>     labels = mne.read_labels_from_annot(subject, 'aparc',
>                                     subjects_dir=subjects_dir)
>     epochs.apply_hilbert()  # faster to apply in sensor space
>     stcs = mne.minimum_norm.apply_inverse_epochs(epochs, inv, lambda2=1. /
> 9., pick_ori='normal',
>                                 return_generator=True)
>     label_ts = mne.extract_label_time_course(
>         stcs, labels, inv['src'], return_generator=True)
>     corr = mne.connectivity.envelope_correlation(label_ts, verbose=True)
>
>     # let's plot this matrix
>     fig, ax = plt.subplots(figsize=(4, 4))
>     ax.imshow(corr, cmap='viridis', clim=np.percentile(corr, [5, 95]))
>     fig.tight_layout()
>     input()
>
>     threshold_prop = 0.15  # percentage of strongest edges to keep in the
> graph
>     degree = mne.connectivity.degree(corr, threshold_prop=threshold_prop)
>     stc = mne.labels_to_stc(labels, degree)
>     stc = stc.in_label(mne.Label(inv['src'][0]['vertno'], hemi='lh') +
>                        mne.Label(inv['src'][1]['vertno'], hemi='rh'))
>     brain = stc.plot(
>         clim=dict(kind='percent', lims=[75, 85, 95]), colormap='gnuplot',
>         subjects_dir=subjects_dir, views='dorsal', hemi='both',
>         smoothing_steps=25, time_label='Beta band')
>
>     del stc
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200501/0459e3b3/attachment.html 


More information about the Mne_analysis mailing list