# Issues generating functional labels for RH

**URL:** <https://mne.discourse.group/t/issues-generating-functional-labels-for-rh/970>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [March 4, 2016, 2:37pm UTC](https://mne.discourse.group/t/issues-generating-functional-labels-for-rh/970 "2016-03-04T14:37:08Z")\
**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:** [March 4, 2016, 2:37pm UTC](https://mne.discourse.group/t/issues-generating-functional-labels-for-rh/970/1 "2016-03-04T14:37:08Z")

</div>

Hi all,

I have been attempting to generate functional labels from source estimates for a data set as outlined here: [https://martinos.org/mne/stable/auto\_examples/inverse/plot\_label\_from\_stc.html#sphx-glr-auto-examples-inverse-plot-label-from-stc-py](https://martinos.org/mne/stable/auto_examples/inverse/plot_label_from_stc.html#sphx-glr-auto-examples-inverse-plot-label-from-stc-py)

This works beautifully for all the left hemisphere parcellations I try, but whenever I try a right hemisphere counter-part, the list of func\_labels return empty, causing the below indexing error:

---

<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:** [March 4, 2016, 2:46pm UTC](https://mne.discourse.group/t/issues-generating-functional-labels-for-rh/970/2 "2016-03-04T14:46:26Z")

</div>

I've recently run my own code based on this example and it works for both  
hemispheres. Just guessing here, but what does stc\_mean.vertices look like?  
Does it have vertices in the correct hemisphere?

---

<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:** [March 4, 2016, 2:57pm UTC](https://mne.discourse.group/t/issues-generating-functional-labels-for-rh/970/3 "2016-03-04T14:57:58Z")

</div>

Hm, well the problem must be with me somewhere then. If I run the code for a right hemi parc, I get:

In [50]: stc\_mean.vertices  
Out[50]:  
[array([12, 68, 76, ..., 132204, 132241, 132257]),  
array([7, 38, 43, ..., 134417, 134419, 134449])]

If I run it on the left hemisphere, I get the exact same thing. Do those two arrays represent vertices for each hemisphere? Or is that telling me its looking at the same vertices (only in the lh) when looking for rh activation?

---

<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:** [March 4, 2016, 4:08pm UTC](https://mne.discourse.group/t/issues-generating-functional-labels-for-rh/970/4 "2016-03-04T16:08:37Z")

</div>

My guess is stc\_to\_label doesn't like 'connected=True' when you have  
vertices in both hemispheres but I have not looked at the source code. You  
could try 'connected=False' which should return labels in each hemisphere  
according to the documentation. Either that, or try to figure out why your  
parcellation labels are resulting in vertices in both hemispheres and  
change that. (The ROIs I used to restrict the stc were hand drawn in  
Freesurfer, so when I use 'stc.in\_label(label)', I only get vertices in one  
hemisphere; 'stc.vertices' returns a list in which one of the arrays is  
empty.)

---

<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:** [March 4, 2016, 5:34pm UTC](https://mne.discourse.group/t/issues-generating-functional-labels-for-rh/970/5 "2016-03-04T17:34:32Z")

</div>

Hi Natalie and others,

It was actually just my failure to understand the syntax of the output. I needed to change this line:

func\_labels,\_ = mne.stc\_to\_label(stc\_mean\_label, src=src, smooth=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;subjects\_dir=subjects\_dir, connected=True)  
to:

\_,func\_labels = mne.stc\_to\_label(stc\_mean\_label, src=src, smooth=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;subjects\_dir=subjects\_dir, connected=True)

in order to get my list of rh labels. Thus the emptiness of my list of right hemisphere labels. Thanks to Ivan on the martinos-python list for pointing that out. So (in case it helps anyone else), something like:

func\_labels\_lh, func\_labels\_rh = mne.stc\_to\_label(stc\_mean\_label, src=src, smooth=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;subjects\_dir=subjects\_dir, connected=True)

would get me two lists, each containing the respective lh and rh labels (as I'm imagining is obvious to anyone with more than a week's worth of python experience).

Thanks for trying to help Natalie!
