Correspondence of sources with parcellation

External Email - Use Caution

Dear MNE community,
I would like to determine the correspondence between the sources of a
forward model (say fsaverage, ico 4 5124 sources) and the labels of a
parcellation (say aparc). I found some nice examples on MNE website in
which the activity of the sources are averaged over a given label ( *Generate
a functional label from source estimates
<https://martinos.org/mne/stable/auto_examples/inverse/plot_label_from_stc.html#sphx-glr-auto-examples-inverse-plot-label-from-stc-py>
*)
but I am actually looking for something simpler (for a given parcellation
find the corresponding indexes of the sources).
I believe it should be feasible.
Any ideas?
Thanks in advance
Thierry

External Email - Use Caution

Hi Thierry,

I use this function:

def label2idx(src, label):
    """
    finding the vertex numbers corresponding to vertices in parcel specified in label
    :param src: source spaces
    :param label: label object of the desired parcel
    :return: parc_idx: indexes of the vertices in label,
             parc_hemi_idx: indexes of the vertices in label, but in the corresponding hemisphere
    """
    offset = src[0]['vertno'].shape[0]
    this_hemi = 0 if (label.hemi == 'lh') else 1
    idx = np.intersect1d(label.vertices, src[this_hemi]['vertno'])
    parc_hemi_idx = np.searchsorted(src[this_hemi]['vertno'], idx)
    parc_idx = parc_hemi_idx + offset * this_hemi
    return parc_idx, parc_hemi_idx

Best,
Mina

External Email - Use Caution

Hi Mina,
thank you very much for the code.
I was getting closer to the solution but your help was quite appreciated!
Best
Thierry

External Email - Use Caution

Dear all,

I am still stuck with the correspondence of the source space with
parcellation.
I have a much better understanding on how functions&data are organized
after Mina Jamshidi's feedback on that but I am still missing something.
I thought that sources were organized the same way as the parcellation
(source 1 corresponds to vertices 1 in the parcellation etc...). So, for a
given source space (e.g. ico 4, 2562 sources per hemisphere) I would expect
to find the vertices 0...2561 in the parcellation. Although there is a good
correspondence between source, parcellation and lobes I cannot locate all
my sources in the parcellation.

For instance, if I run the following:

import numpy as np
import mne
label=mne.read_labels_from_annot('fsaverage',parc='aparc',hemi='lh')
vertices=np.zeros(0,int)
for lab in label: vertices=np.hstack((vertices,lab.vertices))
vertices=np.sort(vertices)
print(vertices[2561])

I expected to get 2561 instead of 2792 so there is something about my
belief that is wrong.

Does someone can help me to sort this out?

Thanks in advance

Thierry

External Email - Use Caution

I am still stuck with the correspondence of the source space with
parcellation.

In general, a source space takes the high resolution mesh (~100k verts) and
subselects a small subset of them (~10k or less). The subset is stored in
`src[0]['vertno']` for the left hemi and `src[1]['vertno']` for the right.

Parcellations are generally defined (by FreeSurfer) on the entire high
resolution cortical surface, and thus should contain many more points than
our decimated source space.

So, for a given source space (e.g. ico 4, 2562 sources per hemisphere) I

would expect to find the vertices 0...2561 in the parcellation.

The parcellation can have holes. In the case of "aparc" the medial wall
vertices are missing:

import surfer
brain = surfer.Brain('fsaverage', 'lh', 'white', views='med')
brain.add_annotation('aparc', borders=False)

[image: Screenshot from 2019-09-06 09-58-16.png]

Also keep in mind that the decimated source space vertices being numbered 0
to 2561 is a property unique to `fsaverage` (and how its spherical mesh is
arranged), in general for other subjects these can and will be integers
spanning the whole ~100k brain space.

Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190906/51273d8d/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.jpg
Type: image/jpeg
Size: 15760 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190906/51273d8d/attachment-0001.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot from 2019-09-06 09-58-16.png
Type: image/png
Size: 333943 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190906/51273d8d/attachment-0001.png

External Email - Use Caution

Hi Eric,
thanks a lot for the clarification. The last days I went also though the
mailing list and found a "patch" to the problem of matching the sources
with the lobes.
For the convenience of other users with similar issues I post the direct
link to it:

Fill missing vertices in parcellation and save the labels

https://mail.nmr.mgh.harvard.edu/pipermail//mne_analysis/attachments/20140818/2347751d/attachment.py

Best