Problem with volume source space label identification using in_label

  • MNE-Python version: 0.22.1
  • operating system: macOS Big Sur, version 11.0

Dear mne-pythonistas,

we are testing volume source space reconstruction with @mmagnuski
and stumbled across a problem with volume source space label identification.
In short - none of the large labels that we tested could be found in the volume source space.

For example after doing:

vol_stc_label = stc.in_label('wm-lh-supramarginal', mri, src)

We get the following message:

    Reading a source space...
    [done]
    1 source spaces read
Reading atlas /Users/futuru/Dropbox/DATA/DiamSar/diamsar_theta/test_volume_src_in_label/src/fsaverage/mri/aseg.mgz
0/1 atlas regions had at least one vertex in the source space

The alignment of the mri and the volume source space looks ok:

We tried to narrow down the problem in the debugging mode and found that
in _volume_labels function _get_atlas_values returns following unique
values and counts:

(array([  0.,   2.,   3.,   4.,   5.,   7.,   8.,  10.,  11.,  12.,  13.,

        14.,  15.,  16.,  17.,  18.,  24.,  26.,  28.,  30.,  31.,  41.,

        42.,  43.,  44.,  46.,  47.,  49.,  50.,  51.,  52.,  53.,  54.,

        58.,  60.,  63., 251., 252., 253., 254., 255.]), array([5756, 2055, 2538,  160,    5,  103,  531,   68,   30,   57,   15,

         17,   16,  208,   39,   14,   12,    7,   44,    1,   16, 2102,

       2522,  152,    6,  104,  503,   73,   34,   59,   15,   42,   19,

          5,   41,    3,    9,    5,    3,    5,    8]))

None of the volume source space atlas values matches the label value:

labels.values()

dict_values([3031])

We are not sure who is to blame: us (user error) or mne-python (bug). :slight_smile:

To help reproducing the problem here is the code we use:

the required files can be found in this Dropbox directory:

The label you’re requesting is in fact not in the .mgz file:

mne.get_volume_labels_from_aseg(mri)
['Unknown',
 'Left-Cerebral-White-Matter',
 'Left-Cerebral-Cortex',
 'Left-Lateral-Ventricle',
 'Left-Inf-Lat-Vent',
 'Left-Cerebellum-White-Matter',
 'Left-Cerebellum-Cortex',
 'Left-Thalamus-Proper',
 'Left-Caudate',
 'Left-Putamen',
 'Left-Pallidum',
 '3rd-Ventricle',
 '4th-Ventricle',
 'Brain-Stem',
 'Left-Hippocampus',
 'Left-Amygdala',
 'CSF',
 'Left-Accumbens-area',
 'Left-VentralDC',
 'Left-vessel',
 'Left-choroid-plexus',
 'Right-Cerebral-White-Matter',
 'Right-Cerebral-Cortex',
 'Right-Lateral-Ventricle',
 'Right-Inf-Lat-Vent',
 'Right-Cerebellum-White-Matter',
 'Right-Cerebellum-Cortex',
 'Right-Thalamus-Proper',
 'Right-Caudate',
 'Right-Putamen',
 'Right-Pallidum',
 'Right-Hippocampus',
 'Right-Amygdala',
 'Right-Accumbens-area',
 'Right-VentralDC',
 'Right-vessel',
 'Right-choroid-plexus',
 'WM-hypointensities',
 'Optic-Chiasm',
 'CC_Posterior',
 'CC_Mid_Posterior',
 'CC_Central',
 'CC_Mid_Anterior',
 'CC_Anterior']

Thanks @drammock, I think we got confused by the previous message we got which informed us that given label is not available and listed other labels (which we assumed are present in the file).
We’d be thankful for any advice on how to create/download more detailed mri segmentation then.

Hello, just wanted to say Hi and Welcome to the forum, @nruban! :partying_face:

I expected to find it in aparc+aseg.mgz but it wasn’t there. Tagging @larsoner and @agramfort, who know way more about MRI segmentations than I do.

@mmagnuski you need an MRI parcellation that contains the label you want.

in the files you shared your options are

aparc.a2005s+aseg.mgz
aparc.a2009s+aseg.mgz
aparc+aseg.mgz
aseg.mgz

Alex

@drammock, @agramfort
Thanks, we’ll take a look at the labels present in these files. We actually don’t need the exact label shown in the example pasted by @nruban - it was just one of the labels we tested.

aseg.mgz only has the subcortical parcels (plus entire left and right cortical ones which are not so useful). You probably want aparc+aseg.mgz, which has the aparc cortical labels + aseg labels, or aparc.a2009s+aseg.mgz, which has the aparc.a2009s cortical labels + aseg labels. To see what names each of these should have you can look at something like:

>>> import os.path as op
>>> import mne
>>> fname_aseg = mne.datasets.sample.data_path() + '/subjects/fsaverage/mri/aparc+aseg.mgz'
>>> labels = mne.get_volume_labels_from_aseg(fname_aseg)
>>> [label for label in labels if 'supramarg' in label]
['ctx-lh-supramarginal', 'ctx-rh-supramarginal']