# How to get volumetric source estimates for all vertices across multiple labels

**URL:** https://mne.discourse.group/t/how-to-get-volumetric-source-estimates-for-all-vertices-across-multiple-labels/5682
**Category:** Support & Discussions
**Tags:** ﻿source-localization
**Created:** [October 5, 2022, 4:58pm UTC](https://mne.discourse.group/t/how-to-get-volumetric-source-estimates-for-all-vertices-across-multiple-labels/5682 "2022-10-05T16:58:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nder](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nder/32/1949_2.png) [@nder](https://mne.discourse.group/u/nder)
#### Post date: [October 5, 2022, 4:58pm UTC](https://mne.discourse.group/t/how-to-get-volumetric-source-estimates-for-all-vertices-across-multiple-labels/5682/1 "2022-10-05T16:58:14Z")

</div>

Dear MNE community,

I’ll begin with saying that I am very much a python and mne-python beginner, so my apologies if I haven’t provided enough information for you to make sense of my question!

• MNE version: 1.1.0  
• OS: Linux-3.10.0-1160.el7.x86\_64-x86\_64-with-glibc2.17

**Summary of question** : I would like to do decoding in volumetric, vectorised source space for a number of ROIs/volumetric labels. While I have seen that the _in\_label_ method allows you to restrict your source estimate to all sources within a label (which is what I want), I cannot see how to scale this method up to take into account multiple labels. Thus, my main question is, how can I get source time courses for all sources across multiple labels in volumetric vectorised source space?

I have described my question and what I’ve done so far in more detail below in case this helps 🙂

I have a volumetric source space (for the whole brain)…

```python
surface = op.join(anat_path, subject, 'bem', 'inner_skull.surf')
src = mne.setup_volume_source_space(subject, subjects_dir=anat_path,
surface=surface, 
verbose=True)

```

…and then have gotten source time courses for each of my epochs:

```python
stcs = apply_inverse_epochs(epochs_dec, inverse_operator, lambda2, method, 
                            pick_ori="vector", nave=evoked_dec.nave)

```

What I want to do from this point is get time courses for each of my vertices within my ROIs/labels of interest in order to input these into my classifier. I have used the _in\_label_ method attached to volumetric vectorised source spaces to get stcs for a given label, but I cannot see how this can easily scale up to incorporate multiple labels.

To illustrate, first, these are the labels I am interested in from my volumetric parcellation (e.g., all occipital labels):

```python
atlas_path = op.join(anat_path, subject, 'mri/aparc.a2009s+aseg.mgz') # Destrieux atlas
label_names_d = mne.get_volume_labels_from_aseg(atlas_path) 
occ_d = [label for label in label_names_d \
                    if 'occ' in label or 'oc-' in label \
                        or 'oc_' in label or '_cuneus' in label]

```

I have seen that I can then apply the _in\_label_ method to restrict my source estimate one of these labels, but only one at a time as the label input here needs to either be a string or an integer. For instance, this works:

```python
stcs = stcs[0].in_label(label = occ_d [0], 
                              mri = atlas_path,
                              src = src)

```

But is there a way to upscale this to incorporate multiple labels? Ideally, I would like to get source estimates for all vertices within the labels in occ\_d. I currently have a workaround that loops through the labels and epochs using _in\_label_, but it feels a bit clunky. In contrast to this VolVectorSourceEstimate version of _in\_label_, the SourceEstimate _in\_label_ method takes mne.label objects, thus allowing one to add labels of interest together – is there a way to do something similar with volumetric source spaces or volumetric vectorised source spaces?

Alternatively, I wondered whether there might be a way to restrict my source estimate to my labels of interest at an earlier stage, for instance at the _apply\_inverse\_epochs_ stage. I saw that this method allows one to input labels to restrict source estimates, however, it requires a mne.label input. As far as I can see, the volume labels are only strings. I tried to use _read\_labels\_from\_annot_ with the aparc.a2009s parcellation to get mne.label objects to then input into _apply\_inverse\_epochs_, but I get type errors.

For example, this here yields a type error:

```python
regexp = 'occipital_inf'
label = mne.read_labels_from_annot(subject = subject, parc = 'aparc.a2009s',
                                          hemi='both', regexp=regexp)[0]
stcs = apply_inverse_epochs(epochs_dec, inverse_operator, lambda2, method, 
                            label = label,
                            pick_ori="vector", nave=evoked_dec.nave)

```

Does anyone have any suggestions or thoughts on how to get source estimates for all vertices across multiple labels with a volumetric vectorised source space?

Thanks very much!
