# Retrieve destrieux parcellation in fsaverage5 space from nilearn
from nilearn import datasets
destrieux_atlas = datasets.fetch_atlas_surf_destrieux()
# The parcellation is already loaded into memory
parcellation = destrieux_atlas['map_left']
# Retrieve fsaverage5 surface dataset for the plotting background. It contains
# the surface template as pial and inflated version and a sulcal depth maps
# which is used for shading
fsaverage = datasets.fetch_surf_fsaverage()
# The fsaverage dataset contains file names pointing to the file locations
print('Fsaverage5 pial surface of left hemisphere is at: %s' %
fsaverage['pial_left'])
print('Fsaverage5 inflated surface of left hemisphere is at: %s' %
fsaverage['infl_left'])
print('Fsaverage5 sulcal depth map of left hemisphere is at: %s' %
fsaverage['sulc_left'])
and
# Display Destrieux parcellation on fsaverage5 pial surface using nilearn
from nilearn import plotting
plotting.plot_surf_roi(fsaverage['pial_left'], roi_map=parcellation,
hemi='left', view='lateral',
bg_map=fsaverage['sulc_left'], bg_on_data=True,
darkness=.5)
It works fine, but I would like to reassign the values of the labels of the atlas.
Is there a way to get access to a look up table, and for instance to assign a specific value to each label ?
Let’s say for instance, that I would like the label “b’G_and_S_paracentral” to be 0.5
Hello @melez, I am not sure I understand the question. The example you point to fetches an atlas where the labels (represented by integer values) are assigned to vertices defining the different regions. I am not sure why you would want to change the label values.
Perhaps you can checkout Freesurfer for more information on how parcellations like this are created and to get information about creating your own atlas if that is what you are after: CorticalParcellation - Free Surfer Wiki
Last thing, there are 76 labels for destrieux atlas, you can access them using destrieux_atlas.labels. I believe their order corresponds to their label number hence you can use something like the following to get a mapping:
labels_map = {}
for i, j in enumerate(destrieux_atlas.labels):
labels_map[i] = j
labels_map
Thank you ymzayek ! Sorry if I was not clear. I have in a csv file a Z score for each label of the destrieux atlas (eg left prefrontal cortex = 0, right insula = 1.2 etc…), . I would like to plot these Z score, which is why I would like to replace the labels of the destrieux atlas by my Z score. But I don’t know what step I am missing.
Ok just to make sure I understand correctly, you want to plot a statistical map of z-scores onto a surface while displaying ROIs? Because we have tooling which I can point you to to do that without having to replace the values of the labels of the destrieux atlas but maybe I am missing something?
Sorry if I was not clear. No actually I just want to plot the ROI of the atlas, but instead of having an arbitrary value for each label, I would like to have an other value (the Z score) for each ROI. My analysis was not at a voxel level, but at a ROI level. My input is a csv file, with a value (a Z score) for each ROI of the atlas. Which is why I am trying to find a way to pass the values stored in the csv in the atlas, and to change the label of the atlas. I hope that I am more clear ? As for instance in the Figure 1 of this paper… https://pubmed.ncbi.nlm.nih.gov/28461699/ Many thanks again for taking the time…
To do that , you simply need to create a new array and use numpy-type indexing to replace label values by ROI-averages. Something like (sorry I did not run the code):
stat_map = np.zeros_like(destrieux_atlas.labels, dtype='float')
for i , label in zip(destrieux_atlas.labels):
stat_map[idestrieux_atlas.labels == label] = my_roi_value[i]
Then you can display stat_map on the mesh.
HTH,
Bertrand