# Reduction of vertices to labels

**URL:** <https://mne.discourse.group/t/reduction-of-vertices-to-labels/1737>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [February 12, 2019, 9:05am UTC](https://mne.discourse.group/t/reduction-of-vertices-to-labels/1737 "2019-02-12T09:05:52Z")\
**Posts on this page:** 2\
**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:** [February 12, 2019, 9:05am UTC](https://mne.discourse.group/t/reduction-of-vertices-to-labels/1737/1 "2019-02-12T09:05:52Z")

</div>

External Email - Use Caution

I have a source estimate file. (stc)  
\<SourceEstimate | 8175 vertices, subject : sub-CC721377\_T1w, tmin : 60.0  
(ms), tmax : 239.0 (ms), tstep : 1.0 (ms), data shape : (8175, 180)\>  
and label, according to desikan atlas,  
label = mne.read\_labels\_from\_annot('sub-CC721377\_T1w', hemi='both',  
parc='aparc', subjects\_dir=subjects\_dir, regexp=None)

I need source points corresponding to labels in variable label. To obtain  
this I use the following line of code:  
abc = mne.extract\_label\_time\_course(stc, label, src, mode='mean\_flip',  
allow\_empty=False, return\_generator=False, verbose=None)  
The output is abc = (68, 180) (matrix)

To generate source file again with this data, I use, mne.labels\_to\_stc(  
\*labels\*, \*values\*, \*tmin=0\*, \*tstep=1\*, \*subject=None\*, \*verbose=None\*)  
stcc = mne.labels\_to\_stc(label0, abc, tmin=0, tstep=1,  
subject='sub-CC721377\_T1w', verbose=None)  
The output in stcc contains the following data:  
\<SourceEstimate | 296592 vertices, subject : sub-CC721377\_T1w, tmin : 0.0  
(ms), tmax : 179000.0 (ms), tstep : 1000.0 (ms), data shape : (296592, 180)\>  
stcc.shape  
(296592, 180)  
but the values provided is (68,180) and the labels are also 68, then why  
the number of vertices is 296592.  
How I can I obtain final source estimate file of shape (68,180) i.e., 68  
vertices only

---

<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:** [February 13, 2019, 5:05pm UTC](https://mne.discourse.group/t/reduction-of-vertices-to-labels/1737/2 "2019-02-13T17:05:45Z")

</div>

External Email - Use Caution

Why would you want this? For display it's useful to have all vertices  
filled out. Did you try `stc.plot` with what you already have? 68 vertices  
in a stc will look weird with stc.plot(). If you want to limit the STC to  
the original ~8000 source vertices (useful for smoothing, used here  
\<[http://mne-tools.github.io/dev/auto\_examples/connectivity/plot\_mne\_inverse\_envelope\_correlation.html](http://mne-tools.github.io/dev/auto_examples/connectivity/plot_mne_inverse_envelope_correlation.html)\>),  
you can do something like:

stc = stc.in\_label(mne.Label(src[0]['vertno'], hemi='lh') +  
mne.Label(src[1]['vertno'], hemi='rh'))

If you really want to reduce it to a STC with only 68 vertices, you can use  
a similar method, but concatenating 68 Label objects (each of which only  
have 1 vertex) or 1 left hemi label with 34 vertices (center of mass  
vertices of each left hemi label?) and 1 right hemi label with 34 vertices.

Eric
