# plot\_label\_from\_stc

**URL:** <https://mne.discourse.group/t/plot-label-from-stc/1164>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [February 8, 2017, 7:34pm UTC](https://mne.discourse.group/t/plot-label-from-stc/1164 "2017-02-08T19:34:45Z")\
**Posts on this page:** 5\
**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 8, 2017, 7:34pm UTC](https://mne.discourse.group/t/plot-label-from-stc/1164/1 "2017-02-08T19:34:45Z")

</div>

Hello MNE experts,

I have a question for creating a Label from a functional STC file

I found the script plot\_label\_from\_stc.py which is great!

However when I use the function mne.stc\_to\_label I am running into a problem

My STC file is an average and morph file and I read it via the command  
mne\_read\_source\_estimate.

I don't have the source space and I am forced to save the label as  
unconnected vertices.

I try to reconnect the vertices in FreeSurfer but with no success so far..

Is there a way to overpass this problem in a way I can save my label as a  
connected surface?

Thanks in advance

Elisabeth

---

<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 8, 2017, 8:38pm UTC](https://mne.discourse.group/t/plot-label-from-stc/1164/2 "2017-02-08T20:38:49Z")

</div>

if its fsaverage, you are morphed to for averaging

# select morph grade  
src\_fsaverage\_fname = subjects\_dir + '/fsaverage/bem/fsaverage-ico-5-src.fif'

src\_fsaverage = mne.read\_source\_spaces(src\_fsaverage\_fname)

func\_labels= mne.stc\_to\_label(stc\_mean\_label, src\_fsaverage, smooth=True,  
connected=True)[0]

---

<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 8, 2017, 9:02pm UTC](https://mne.discourse.group/t/plot-label-from-stc/1164/3 "2017-02-08T21:02:29Z")

</div>

Hi Sheraz,  
Thanks for your quick answer  
I already checked for this directory and file (+  
'/fsaverage/bem/fsaverage-ico-5-src.fif')  
unfortunately I do not have the directory "bem" in my Average directory  
(only label/mri/surf/)  
I am reanalysing some old data and I used older version of mne & FreeSurfer  
(mne\_ version 2.7.3 and freesurfer 4.3.0)  
With the command make\_average\_subject --subjects \<list of subjects\>  
Is there a way or command to create this bem directory and files?  
Elisabeth

---

<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 8, 2017, 11:18pm UTC](https://mne.discourse.group/t/plot-label-from-stc/1164/4 "2017-02-08T23:18:56Z")

</div>

please use following commands, they are data independent, requires only  
anatomical information. mne.setup\_source\_space is the one you need for the  
src file.

conductivity = (0.3,) #MEG only  
model = mne.make\_bem\_model(subject=subject, ico=4,  
&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;conductivity=conductivity,  
&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)  
bem = mne.make\_bem\_solution(model)  
src = mne.setup\_source\_space(subject, spacing='ico5',  
&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;&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;add\_dist=False, overwrite=True)

Sheraz

---

<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 10, 2017, 6:34pm UTC](https://mne.discourse.group/t/plot-label-from-stc/1164/5 "2017-02-10T18:34:40Z")

</div>

Thanks you so much Sheraz!  
It worked perfectly!  
Best,  
Elisabeth
