Note
Go to the end to download the full example code. or to run this example in your browser via Binder
Regions Extraction of Default Mode Networks¶
This simple example shows how to extract regions with a probabilistic atlas.
In particular, we show how default mode network regions are extracted
using RegionExtractor
from the regions module.
dataset
This example uses the Smith 2009 atlas.
Fetching the Smith atlas 10 resting state networks.
from nilearn import datasets
atlas_networks = datasets.fetch_atlas_smith_2009(resting=True, dimension=10)
[fetch_atlas_smith_2009] Dataset directory found: /home/runner/work/nilearn/nilearn/nilearn_data/smith_2009_atlas
{'type': <class 'str'>, 'desc': 'Full path to 4D nifti file containing the requested resting fMRI or BrainMap components (depending on the value passed to ``resting``) image with the number of requested dimensions. The shape of the image is ``(91, 109, 91, dimension)`` where dimension is the value passed to ``dimension``.'}
Import region extractor to extract atlas networks
from nilearn.regions import RegionExtractor
# min_region_size in voxel volume mm^3
extraction = RegionExtractor(
atlas_networks.maps,
min_region_size=800,
threshold=98,
thresholding_strategy="percentile",
verbose=1,
)
# Just call fit() to execute region extraction procedure
extraction.fit()
regions_img = extraction.regions_img_
[RegionExtractor.fit] Loading regions from <nibabel.nifti1.Nifti1Image object at 0x720371679850>
[RegionExtractor.fit] Finished fit
Visualization Show region extraction results by importing image & plotting utilities
from nilearn import plotting
from nilearn.image import index_img
from nilearn.plotting import find_xyz_cut_coords
# Showing region extraction results using 4D maps visualization tool
plotting.plot_prob_atlas(
regions_img,
display_mode="z",
cut_coords=1,
view_type="contours",
title="Regions extracted.",
)
# To reduce the complexity, we choose to display all the regions
# extracted from network 3
import numpy as np
DMN_network = index_img(atlas_networks.maps, 3)
plotting.plot_stat_map(
DMN_network,
display_mode="z",
cut_coords=1,
title="Network 3",
colorbar=False,
)
regions_indices_network3 = np.where(np.array(extraction.index_) == 3)
for index in regions_indices_network3[0]:
cur_img = index_img(extraction.regions_img_, index)
coords = find_xyz_cut_coords(cur_img)
plotting.plot_stat_map(
cur_img,
display_mode="z",
cut_coords=coords[2:3],
title="Blob of network3",
colorbar=False,
cmap="inferno",
vmax=15,
)
plotting.show()
Total running time of the script: (0 minutes 13.354 seconds)
Estimated memory usage: 606 MB







