Note
Go to the end to download the full example code or to run this example in your browser via Binder
Basic Atlas plotting#
Plot the regions of a reference atlas (Harvard-Oxford and Juelich atlases).
Retrieving the atlas data#
from nilearn import datasets
dataset_ho = datasets.fetch_atlas_harvard_oxford("cort-maxprob-thr25-2mm")
dataset_ju = datasets.fetch_atlas_juelich("maxprob-thr0-1mm")
atlas_ho_filename = dataset_ho.filename
atlas_ju_filename = dataset_ju.filename
print(f"Atlas ROIs are located at: {atlas_ho_filename}")
print(f"Atlas ROIs are located at: {atlas_ju_filename}")
Dataset created in /home/remi/nilearn_data/fsl
Downloading data from https://www.nitrc.org/frs/download.php/9902/HarvardOxford.tgz ...
Downloaded 917504 of 25716861 bytes (3.6%, 27.7s remaining)
Downloaded 2498560 of 25716861 bytes (9.7%, 18.8s remaining)
Downloaded 4268032 of 25716861 bytes (16.6%, 15.3s remaining)
Downloaded 5890048 of 25716861 bytes (22.9%, 13.7s remaining)
Downloaded 7118848 of 25716861 bytes (27.7%, 13.2s remaining)
Downloaded 8495104 of 25716861 bytes (33.0%, 12.3s remaining)
Downloaded 9838592 of 25716861 bytes (38.3%, 11.4s remaining)
Downloaded 11223040 of 25716861 bytes (43.6%, 10.4s remaining)
Downloaded 12599296 of 25716861 bytes (49.0%, 9.5s remaining)
Downloaded 14024704 of 25716861 bytes (54.5%, 8.4s remaining)
Downloaded 15294464 of 25716861 bytes (59.5%, 7.6s remaining)
Downloaded 16138240 of 25716861 bytes (62.8%, 7.2s remaining)
Downloaded 17072128 of 25716861 bytes (66.4%, 6.7s remaining)
Downloaded 18055168 of 25716861 bytes (70.2%, 6.0s remaining)
Downloaded 19062784 of 25716861 bytes (74.1%, 5.3s remaining)
Downloaded 20111360 of 25716861 bytes (78.2%, 4.5s remaining)
Downloaded 21225472 of 25716861 bytes (82.5%, 3.6s remaining)
Downloaded 22405120 of 25716861 bytes (87.1%, 2.7s remaining)
Downloaded 23797760 of 25716861 bytes (92.5%, 1.6s remaining)
Downloaded 25518080 of 25716861 bytes (99.2%, 0.2s remaining) ...done. (21 seconds, 0 min)
Extracting data from /home/remi/nilearn_data/fsl/c4d84bbdf5c3325f23e304cdea1e9706/HarvardOxford.tgz..... done.
Downloading data from https://www.nitrc.org/frs/download.php/12096/Juelich.tgz ...
Downloaded 901120 of 3740787 bytes (24.1%, 3.4s remaining)
Downloaded 1679360 of 3740787 bytes (44.9%, 2.5s remaining)
Downloaded 2523136 of 3740787 bytes (67.4%, 1.5s remaining)
Downloaded 3407872 of 3740787 bytes (91.1%, 0.4s remaining) ...done. (5 seconds, 0 min)
Extracting data from /home/remi/nilearn_data/fsl/ab1b53038e13028e55f691a69003c208/Juelich.tgz..... done.
Atlas ROIs are located at: /home/remi/nilearn_data/fsl/data/atlases/HarvardOxford/HarvardOxford-cort-maxprob-thr25-2mm.nii.gz
Atlas ROIs are located at: /home/remi/nilearn_data/fsl/data/atlases/Juelich/Juelich-maxprob-thr0-1mm.nii.gz
Visualizing the Harvard-Oxford atlas#
from nilearn import plotting
plotting.plot_roi(atlas_ho_filename, title="Harvard Oxford atlas")
<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7fd1f296e910>
Visualizing the Juelich atlas#
plotting.plot_roi(atlas_ju_filename, title="Juelich atlas")
<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7fd1e32e8f90>
Visualizing the Harvard-Oxford atlas with contours#
plotting.plot_roi(
atlas_ho_filename,
view_type="contours",
title="Harvard Oxford atlas in contours",
)
plotting.show()
/home/remi/github/nilearn/env/lib/python3.11/site-packages/nilearn/plotting/img_plotting.py:608: UserWarning: Data array used to create a new image contains 64-bit ints. This is likely due to creating the array with numpy and passing `int` as the `dtype`. Many tools such as FSL and SPM cannot deal with int64 in Nifti images, so for compatibility the data has been converted to int32.
img = new_img_like(roi_img, data, affine=roi_img.affine)
Visualizing the Juelich atlas with contours#
plotting.plot_roi(
atlas_ju_filename, view_type="contours", title="Juelich atlas in contours"
)
plotting.show()
Total running time of the script: (1 minutes 25.432 seconds)
Estimated memory usage: 435 MB