[Neuroimaging] Plotting a Single ROI from an Atlas
Gael Varoquaux
gael.varoquaux at normalesup.org
Fri Jan 5 09:46:36 EST 2018
Hi Lou,
Here is code that I believe does what you want, with a bit of comments to
explain briefly how it works. I suggest that you study each step to
understand what it does.
"""
from nilearn import datasets, image, plotting
# Retrieve the AAL atlas
aal_atlas = datasets.fetch_atlas_aal('SPM12')
# Now find the position of the Rectus_R in the list of region
# labels, and use the corresponding list of indices of the image to
# convert it to the index value in the map
rectus_r_idx = aal_atlas.indices[aal_atlas.labels.index('Rectus_R')]
# Select only the voxels of the map for which the value is equal to the
# this index.
rectus_r_map = image.math_img('img == %s' % rectus_r_idx,
img=aal_atlas.maps)
# The resulting map is a binay map that contains only the Rectus_R, we
# can plot it.
plotting.plot_roi(rectus_r_map, title='Rectus_R')
"""
Best,
Gaël
On Thu, Jan 04, 2018 at 03:09:12PM -0800, Lodewijk Brand wrote:
> Hi All,
> I am trying to figure out a way to plot specific ROIs from an atlas in Python.
> I am looking specifically at the AAL atlas:
> aal_atlas = datasets.fetch_atlas_aal('SPM12')
> I would like to plot individual regions (eg. 'Rectus_R', 'Insula_L',
> 'Insula_R', etc.) that are specified within the atlas. I've been able to plot
> the entire brain image with all the ROIs at once cannot seem to figure out how
> to do each one individually. Any help/direction would be greatly appreciated!
> Best,
> Lou
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
--
Gael Varoquaux
Senior Researcher, INRIA Parietal
NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
Phone: ++ 33-1-69-08-79-68
http://gael-varoquaux.info http://twitter.com/GaelVaroquaux
More information about the Neuroimaging
mailing list