# ValueError: source space does not contain any vertices for label unknown-lh

**URL:** <https://mne.discourse.group/t/valueerror-source-space-does-not-contain-any-vertices-for-label-unknown-lh/2178>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [May 1, 2020, 3:41pm UTC](https://mne.discourse.group/t/valueerror-source-space-does-not-contain-any-vertices-for-label-unknown-lh/2178 "2020-05-01T15:41:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [May 1, 2020, 3:41pm UTC](https://mne.discourse.group/t/valueerror-source-space-does-not-contain-any-vertices-for-label-unknown-lh/2178/1 "2020-05-01T15:41:36Z")

</div>

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.

&nbsp;&nbsp;&nbsp;&nbsp;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(  
&nbsp;&nbsp;&nbsp;&nbsp;hemi='lh', subjects\_dir=subjects\_dir,  
&nbsp;&nbsp;&nbsp;&nbsp;clim=dict(kind='value', lims=[8, 12, 15]), views='lateral',  
&nbsp;&nbsp;&nbsp;&nbsp;initial\_time=0.09, time\_unit='s', size=(800, 800),  
&nbsp;&nbsp;&nbsp;&nbsp;smoothing\_steps=5)

surfer\_kwargs['clim'].update(kind='percent', lims=[99, 99.9, 99.99])  
for mi, method in enumerate(['MNE', 'dSPM', 'sLORETA', 'eLORETA']):  
&nbsp;&nbsp;&nbsp;&nbsp;stc = apply\_inverse(evoked, inv, lambda2,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method=method, pick\_ori=None,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;verbose=True)  
&nbsp;&nbsp;&nbsp;&nbsp;peak\_vertex, peak\_time = stc.get\_peak(hemi='lh', vert\_as\_index=True,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time\_as\_index=True)

&nbsp;&nbsp;&nbsp;&nbsp;peak\_vertex\_surf = stc.lh\_vertno[peak\_vertex]

&nbsp;&nbsp;&nbsp;&nbsp;peak\_value = stc.lh\_data[peak\_vertex, peak\_time]  
&nbsp;&nbsp;&nbsp;&nbsp;brain = stc.plot(figure=mi, \*\*surfer\_kwargs)  
&nbsp;&nbsp;&nbsp;&nbsp;brain.add\_foci(peak\_vertex\_surf, coords\_as\_verts=True, hemi='lh', color='blue')  
&nbsp;&nbsp;&nbsp;&nbsp;brain.add\_text(0.1, 0.9, method, 'title', font\_size=20)  
&nbsp;&nbsp;&nbsp;&nbsp;print(stc)  
# lh\_coordinates = src[0]['rr'][stc.lh\_vertno]  
# lh\_data = stc.lh\_data  
# input()

&nbsp;&nbsp;&nbsp;&nbsp;labels = mne.read\_labels\_from\_annot(subject, 'aparc',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subjects\_dir=subjects\_dir)  
&nbsp;&nbsp;&nbsp;&nbsp;epochs.apply\_hilbert() # faster to apply in sensor space  
&nbsp;&nbsp;&nbsp;&nbsp;stcs = mne.minimum\_norm.apply\_inverse\_epochs(epochs, inv, lambda2=1. / 9., pick\_ori='normal',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return\_generator=True)  
&nbsp;&nbsp;&nbsp;&nbsp;label\_ts = mne.extract\_label\_time\_course(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stcs, labels, inv['src'], return\_generator=True)  
&nbsp;&nbsp;&nbsp;&nbsp;corr = mne.connectivity.envelope\_correlation(label\_ts, verbose=True)

&nbsp;&nbsp;&nbsp;&nbsp;# let's plot this matrix  
&nbsp;&nbsp;&nbsp;&nbsp;fig, ax = plt.subplots(figsize=(4, 4))  
&nbsp;&nbsp;&nbsp;&nbsp;ax.imshow(corr, cmap='viridis', clim=np.percentile(corr, [5, 95]))  
&nbsp;&nbsp;&nbsp;&nbsp;fig.tight\_layout()  
&nbsp;&nbsp;&nbsp;&nbsp;input()

&nbsp;&nbsp;&nbsp;&nbsp;threshold\_prop = 0.15 # percentage of strongest edges to keep in the graph  
&nbsp;&nbsp;&nbsp;&nbsp;degree = mne.connectivity.degree(corr, threshold\_prop=threshold\_prop)  
&nbsp;&nbsp;&nbsp;&nbsp;stc = mne.labels\_to\_stc(labels, degree)  
&nbsp;&nbsp;&nbsp;&nbsp;stc = stc.in\_label(mne.Label(inv['src'][0]['vertno'], hemi='lh') +  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mne.Label(inv['src'][1]['vertno'], hemi='rh'))  
&nbsp;&nbsp;&nbsp;&nbsp;brain = stc.plot(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clim=dict(kind='percent', lims=[75, 85, 95]), colormap='gnuplot',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subjects\_dir=subjects\_dir, views='dorsal', hemi='both',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;smoothing\_steps=25, time\_label='Beta band')

&nbsp;&nbsp;&nbsp;&nbsp;del stc

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [May 1, 2020, 3:52pm UTC](https://mne.discourse.group/t/valueerror-source-space-does-not-contain-any-vertices-for-label-unknown-lh/2178/2 "2020-05-01T15:52:47Z")

</div>

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(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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](https://mne.tools/stable/generated/mne.extract_label_time_course.html)\>.

Eric

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [May 1, 2020, 4:39pm UTC](https://mne.discourse.group/t/valueerror-source-space-does-not-contain-any-vertices-for-label-unknown-lh/2178/3 "2020-05-01T16:39:42Z")

</div>

External Email - Use Caution

Thank you!!
