.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code or to run this example in your browser via Binder
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_examples_01_plotting_plot_atlas.py:
Basic Atlas plotting
=======================
Plot the regions of a reference atlas (Harvard-Oxford and Juelich atlases).
Retrieving the atlas data
-------------------------
.. code-block:: default
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('Atlas ROIs are located at: %s' % atlas_ho_filename)
print('Atlas ROIs are located at: %s' % atlas_ju_filename)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
Atlas ROIs are located at:
data shape (91, 109, 91)
affine:
[[ 2. 0. 0. -90.]
[ 0. 2. 0. -126.]
[ 0. 0. 2. -72.]
[ 0. 0. 0. 1.]]
metadata:
object, endian='<'
sizeof_hdr : 348
data_type : b''
db_name : b''
extents : 0
session_error : 0
regular : b''
dim_info : 0
dim : [ 3 91 109 91 1 1 1 1]
intent_p1 : 0.0
intent_p2 : 0.0
intent_p3 : 0.0
intent_code : none
datatype : uint8
bitpix : 8
slice_start : 0
pixdim : [1. 2. 2. 2. 1. 1. 1. 1.]
vox_offset : 0.0
scl_slope : nan
scl_inter : nan
slice_end : 0
slice_code : unknown
xyzt_units : 0
cal_max : 0.0
cal_min : 0.0
slice_duration : 0.0
toffset : 0.0
glmax : 0
glmin : 0
descrip : b''
aux_file : b''
qform_code : unknown
sform_code : aligned
quatern_b : 0.0
quatern_c : 0.0
quatern_d : 0.0
qoffset_x : -90.0
qoffset_y : -126.0
qoffset_z : -72.0
srow_x : [ 2. 0. 0. -90.]
srow_y : [ 0. 2. 0. -126.]
srow_z : [ 0. 0. 2. -72.]
intent_name : b''
magic : b'n+1'
Atlas ROIs are located at:
data shape (182, 218, 182)
affine:
[[ 1. 0. 0. -91.]
[ 0. 1. 0. -126.]
[ 0. 0. 1. -72.]
[ 0. 0. 0. 1.]]
metadata:
object, endian='<'
sizeof_hdr : 348
data_type : b''
db_name : b''
extents : 0
session_error : 0
regular : b''
dim_info : 0
dim : [ 3 182 218 182 1 1 1 1]
intent_p1 : 0.0
intent_p2 : 0.0
intent_p3 : 0.0
intent_code : none
datatype : uint8
bitpix : 8
slice_start : 0
pixdim : [1. 1. 1. 1. 1. 1. 1. 1.]
vox_offset : 0.0
scl_slope : nan
scl_inter : nan
slice_end : 0
slice_code : unknown
xyzt_units : 0
cal_max : 0.0
cal_min : 0.0
slice_duration : 0.0
toffset : 0.0
glmax : 0
glmin : 0
descrip : b''
aux_file : b''
qform_code : unknown
sform_code : aligned
quatern_b : 0.0
quatern_c : 0.0
quatern_d : 0.0
qoffset_x : -91.0
qoffset_y : -126.0
qoffset_z : -72.0
srow_x : [ 1. 0. 0. -91.]
srow_y : [ 0. 1. 0. -126.]
srow_z : [ 0. 0. 1. -72.]
intent_name : b''
magic : b'n+1'
Visualizing the Harvard-Oxford atlas
------------------------------------
.. code-block:: default
from nilearn import plotting
plotting.plot_roi(atlas_ho_filename, title="Harvard Oxford atlas")
.. image:: /auto_examples/01_plotting/images/sphx_glr_plot_atlas_001.png
:alt: plot atlas
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
Visualizing the Juelich atlas
------------------------------------
.. code-block:: default
plotting.plot_roi(atlas_ju_filename, title="Juelich atlas")
.. image:: /auto_examples/01_plotting/images/sphx_glr_plot_atlas_002.png
:alt: plot atlas
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
Visualizing the Harvard-Oxford atlas with contours
--------------------------------------------------
.. code-block:: default
plotting.plot_roi(atlas_ho_filename, view_type='contours',
title="Harvard Oxford atlas in contours")
plotting.show()
.. image:: /auto_examples/01_plotting/images/sphx_glr_plot_atlas_003.png
:alt: plot atlas
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
/home/nicolas/GitRepos/nilearn-fork/nilearn/plotting/displays.py:101: UserWarning: No contour levels were found within the data range.
im = getattr(ax, type)(data_2d.copy(),
Visualizing the Juelich atlas with contours
--------------------------------------------------
.. code-block:: default
plotting.plot_roi(atlas_ju_filename, view_type='contours',
title="Juelich atlas in contours")
plotting.show()
.. image:: /auto_examples/01_plotting/images/sphx_glr_plot_atlas_004.png
:alt: plot atlas
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
/home/nicolas/GitRepos/nilearn-fork/nilearn/plotting/displays.py:101: UserWarning: No contour levels were found within the data range.
im = getattr(ax, type)(data_2d.copy(),
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 55.377 seconds)
.. _sphx_glr_download_auto_examples_01_plotting_plot_atlas.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: binder-badge
.. image:: images/binder_badge_logo.svg
:target: https://mybinder.org/v2/gh/nilearn/nilearn.github.io/main?filepath=examples/auto_examples/01_plotting/plot_atlas.ipynb
:alt: Launch binder
:width: 150 px
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_atlas.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_atlas.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_