Examples#

Warning

If you want to run the examples, make sure you execute them in a directory where you have write permissions, or you copy the examples into such a directory. If you install nilearn manually, make sure you have followed the instructions.

Basic tutorials#

Introductory examples that teach how to use nilearn.

Basic numerics and plotting with Python

Basic numerics and plotting with Python

Basic numerics and plotting with Python
Basic nilearn example: manipulating and looking at data

Basic nilearn example: manipulating and looking at data

Basic nilearn example: manipulating and looking at data
3D and 4D niimgs: handling and visualizing

3D and 4D niimgs: handling and visualizing

3D and 4D niimgs: handling and visualizing
A introduction tutorial to fMRI decoding

A introduction tutorial to fMRI decoding

A introduction tutorial to fMRI decoding
Intro to GLM Analysis: a single-session, single-subject fMRI dataset

Intro to GLM Analysis: a single-session, single-subject fMRI dataset

Intro to GLM Analysis: a single-session, single-subject fMRI dataset

Visualization of brain images#

See Plotting brain images for more details.

Glass brain plotting in nilearn

Glass brain plotting in nilearn

Glass brain plotting in nilearn
Visualizing Megatrawls Network Matrices from Human Connectome Project

Visualizing Megatrawls Network Matrices from Human Connectome Project

Visualizing Megatrawls Network Matrices from Human Connectome Project
Basic Atlas plotting

Basic Atlas plotting

Basic Atlas plotting
Visualizing multiscale functional brain parcellations

Visualizing multiscale functional brain parcellations

Visualizing multiscale functional brain parcellations
Matplotlib colormaps in Nilearn

Matplotlib colormaps in Nilearn

Matplotlib colormaps in Nilearn
Visualizing a probabilistic atlas: the default mode in the MSDL atlas

Visualizing a probabilistic atlas: the default mode in the MSDL atlas

Visualizing a probabilistic atlas: the default mode in the MSDL atlas
Controlling the contrast of the background when plotting

Controlling the contrast of the background when plotting

Controlling the contrast of the background when plotting
NeuroImaging volumes visualization

NeuroImaging volumes visualization

NeuroImaging volumes visualization
Visualizing global patterns with a carpet plot

Visualizing global patterns with a carpet plot

Visualizing global patterns with a carpet plot
Plot Haxby masks

Plot Haxby masks

Plot Haxby masks
Technical point: Illustration of the volume to surface sampling schemes

Technical point: Illustration of the volume to surface sampling schemes

Technical point: Illustration of the volume to surface sampling schemes
Plotting tools in nilearn

Plotting tools in nilearn

Plotting tools in nilearn
Visualizing 4D probabilistic atlas maps

Visualizing 4D probabilistic atlas maps

Visualizing 4D probabilistic atlas maps
Seed-based connectivity on the surface

Seed-based connectivity on the surface

Seed-based connectivity on the surface
Loading and plotting of a cortical surface atlas

Loading and plotting of a cortical surface atlas

Loading and plotting of a cortical surface atlas
Making a surface plot of a 3D statistical map

Making a surface plot of a 3D statistical map

Making a surface plot of a 3D statistical map
Glass brain plotting in nilearn (all options)

Glass brain plotting in nilearn (all options)

Glass brain plotting in nilearn (all options)
More plotting tools from nilearn

More plotting tools from nilearn

More plotting tools from nilearn

Decoding and predicting from brain images#

See Decoding and MVPA: predicting from brain images for more details.

Show stimuli of Haxby et al. dataset

Show stimuli of Haxby et al. dataset

Show stimuli of Haxby et al. dataset
FREM on Jimura et al "mixed gambles" dataset.

FREM on Jimura et al “mixed gambles” dataset.

FREM on Jimura et al "mixed gambles" dataset.
Decoding with FREM: face vs house object recognition

Decoding with FREM: face vs house object recognition

Decoding with FREM: face vs house object recognition
Voxel-Based Morphometry on Oasis dataset with Space-Net prior

Voxel-Based Morphometry on Oasis dataset with Space-Net prior

Voxel-Based Morphometry on Oasis dataset with Space-Net prior
Decoding with ANOVA + SVM: face vs house in the Haxby dataset

Decoding with ANOVA + SVM: face vs house in the Haxby dataset

Decoding with ANOVA + SVM: face vs house in the Haxby dataset
Cortical surface-based searchlight decoding

Cortical surface-based searchlight decoding

Cortical surface-based searchlight decoding
The haxby dataset: different multi-class strategies

The haxby dataset: different multi-class strategies

The haxby dataset: different multi-class strategies
Searchlight analysis of face vs house recognition

Searchlight analysis of face vs house recognition

Searchlight analysis of face vs house recognition
Decoding of a dataset after GLM fit for signal extraction

Decoding of a dataset after GLM fit for signal extraction

Decoding of a dataset after GLM fit for signal extraction
Setting a parameter by cross-validation

Setting a parameter by cross-validation

Setting a parameter by cross-validation
ROI-based decoding analysis in Haxby et al. dataset

ROI-based decoding analysis in Haxby et al. dataset

ROI-based decoding analysis in Haxby et al. dataset
Different classifiers in decoding the Haxby dataset

Different classifiers in decoding the Haxby dataset

Different classifiers in decoding the Haxby dataset
Voxel-Based Morphometry on Oasis dataset

Voxel-Based Morphometry on Oasis dataset

Voxel-Based Morphometry on Oasis dataset
Example of pattern recognition on simulated data

Example of pattern recognition on simulated data

Example of pattern recognition on simulated data
Encoding models for visual stimuli from Miyawaki et al. 2008

Encoding models for visual stimuli from Miyawaki et al. 2008

Encoding models for visual stimuli from Miyawaki et al. 2008
Reconstruction of visual stimuli from Miyawaki et al. 2008

Reconstruction of visual stimuli from Miyawaki et al. 2008

Reconstruction of visual stimuli from Miyawaki et al. 2008

Functional connectivity#

See Clustering to parcellate the brain in regions, Extracting functional brain networks: ICA and related or Extracting times series to build a functional connectome for more details.

Extracting signals of a probabilistic atlas of functional regions

Extracting signals of a probabilistic atlas of functional regions

Extracting signals of a probabilistic atlas of functional regions
Computing a connectome with sparse inverse covariance

Computing a connectome with sparse inverse covariance

Computing a connectome with sparse inverse covariance
Connectivity structure estimation on simulated data

Connectivity structure estimation on simulated data

Connectivity structure estimation on simulated data
Deriving spatial maps from group fMRI data using ICA and Dictionary Learning

Deriving spatial maps from group fMRI data using ICA and Dictionary Learning

Deriving spatial maps from group fMRI data using ICA and Dictionary Learning
Producing single subject maps of seed-to-voxel correlation

Producing single subject maps of seed-to-voxel correlation

Producing single subject maps of seed-to-voxel correlation
Group Sparse inverse covariance for multi-subject connectome

Group Sparse inverse covariance for multi-subject connectome

Group Sparse inverse covariance for multi-subject connectome
Regions extraction using dictionary learning and functional connectomes

Regions extraction using dictionary learning and functional connectomes

Regions extraction using dictionary learning and functional connectomes
Comparing connectomes on different reference atlases

Comparing connectomes on different reference atlases

Comparing connectomes on different reference atlases
Classification of age groups using functional connectivity

Classification of age groups using functional connectivity

Classification of age groups using functional connectivity
Extracting signals from a brain parcellation

Extracting signals from a brain parcellation

Extracting signals from a brain parcellation
Extract signals on spheres and plot a connectome

Extract signals on spheres and plot a connectome

Extract signals on spheres and plot a connectome
Clustering methods to learn a brain parcellation from fMRI

Clustering methods to learn a brain parcellation from fMRI

Clustering methods to learn a brain parcellation from fMRI

GLM: First level analysis#

These are examples focused on showcasing first level models functionality and single subject analysis.

See Analyzing fMRI using GLMs for more details.

Generate an events.tsv file for the NeuroSpin localizer task

Generate an events.tsv file for the NeuroSpin localizer task

Generate an events.tsv file for the NeuroSpin localizer task
Example of explicit fixed effects fMRI model fitting

Example of explicit fixed effects fMRI model fitting

Example of explicit fixed effects fMRI model fitting
Default Mode Network extraction of AHDH dataset

Default Mode Network extraction of AHDH dataset

Default Mode Network extraction of AHDH dataset
Examples of design matrices

Examples of design matrices

Examples of design matrices
Analysis of an fMRI dataset with a Finite Impule Response (FIR) model

Analysis of an fMRI dataset with a Finite Impule Response (FIR) model

Analysis of an fMRI dataset with a Finite Impule Response (FIR) model
Single-subject data (two sessions) in native space

Single-subject data (two sessions) in native space

Single-subject data (two sessions) in native space
Example of MRI response functions

Example of MRI response functions

Example of MRI response functions
Simple example of two-session fMRI model fitting

Simple example of two-session fMRI model fitting

Simple example of two-session fMRI model fitting
Predicted time series and residuals

Predicted time series and residuals

Predicted time series and residuals
First level analysis of a complete BIDS dataset from openneuro

First level analysis of a complete BIDS dataset from openneuro

First level analysis of a complete BIDS dataset from openneuro
Example of surface-based first-level analysis

Example of surface-based first-level analysis

Example of surface-based first-level analysis
Understanding parameters of the first-level model

Understanding parameters of the first-level model

Understanding parameters of the first-level model

GLM: Second level analysis#

These are examples focused on showcasing second level models functionality and group level analysis.

See Analyzing fMRI using GLMs for more details.

Example of second level design matrix

Example of second level design matrix

Example of second level design matrix
Second-level fMRI model: true positive proportion in clusters

Second-level fMRI model: true positive proportion in clusters

Second-level fMRI model: true positive proportion in clusters
Statistical testing of a second-level analysis

Statistical testing of a second-level analysis

Statistical testing of a second-level analysis
Voxel-Based Morphometry on OASIS dataset

Voxel-Based Morphometry on OASIS dataset

Voxel-Based Morphometry on OASIS dataset
Second-level fMRI model: one sample test

Second-level fMRI model: one sample test

Second-level fMRI model: one sample test
Second-level fMRI model: two-sample test, unpaired and paired

Second-level fMRI model: two-sample test, unpaired and paired

Second-level fMRI model: two-sample test, unpaired and paired
Example of generic design in second-level models

Example of generic design in second-level models

Example of generic design in second-level models

Manipulating brain image volumes#

See Manipulating images: resampling, smoothing, masking, ROIs… for more details.

Negating an image with math_img

Negating an image with math_img

Negating an image with math_img
Comparing the means of 2 images

Comparing the means of 2 images

Comparing the means of 2 images
Smoothing an image

Smoothing an image

Smoothing an image
Regions Extraction of Default Mode Networks using Smith Atlas

Regions Extraction of Default Mode Networks using Smith Atlas

Regions Extraction of Default Mode Networks using Smith Atlas
Breaking an atlas of labels in separated regions

Breaking an atlas of labels in separated regions

Breaking an atlas of labels in separated regions
Resample an image to a template

Resample an image to a template

Resample an image to a template
Simple example of NiftiMasker use

Simple example of NiftiMasker use

Simple example of NiftiMasker use
Extracting signals from brain regions using the NiftiLabelsMasker

Extracting signals from brain regions using the NiftiLabelsMasker

Extracting signals from brain regions using the NiftiLabelsMasker
Region Extraction using a t-statistical map (3D)

Region Extraction using a t-statistical map (3D)

Region Extraction using a t-statistical map (3D)
Understanding NiftiMasker and mask computation

Understanding NiftiMasker and mask computation

Understanding NiftiMasker and mask computation
Visualization of affine resamplings

Visualization of affine resamplings

Visualization of affine resamplings
Computing a Region of Interest (ROI) mask manually

Computing a Region of Interest (ROI) mask manually

Computing a Region of Interest (ROI) mask manually

Advanced statistical analysis of brain images#

Multivariate decompositions: Independent component analysis of fMRI

Multivariate decompositions: Independent component analysis of fMRI

Multivariate decompositions: Independent component analysis of fMRI
Massively univariate analysis of a calculation task from the Localizer dataset

Massively univariate analysis of a calculation task from the Localizer dataset

Massively univariate analysis of a calculation task from the Localizer dataset
BIDS dataset first and second level analysis

BIDS dataset first and second level analysis

BIDS dataset first and second level analysis
Functional connectivity predicts age group

Functional connectivity predicts age group

Functional connectivity predicts age group
NeuroVault meta-analysis of stop-go paradigm studies.

NeuroVault meta-analysis of stop-go paradigm studies.

NeuroVault meta-analysis of stop-go paradigm studies.
Massively univariate analysis of a motor task from the Localizer dataset

Massively univariate analysis of a motor task from the Localizer dataset

Massively univariate analysis of a motor task from the Localizer dataset
Surface-based dataset first and second level analysis of a dataset

Surface-based dataset first and second level analysis of a dataset

Surface-based dataset first and second level analysis of a dataset
NeuroVault cross-study ICA maps.

NeuroVault cross-study ICA maps.

NeuroVault cross-study ICA maps.
Massively univariate analysis of face vs house recognition

Massively univariate analysis of face vs house recognition

Massively univariate analysis of face vs house recognition
Advanced decoding using scikit learn

Advanced decoding using scikit learn

Advanced decoding using scikit learn
Beta-Series Modeling for Task-Based Functional Connectivity and Decoding

Beta-Series Modeling for Task-Based Functional Connectivity and Decoding

Beta-Series Modeling for Task-Based Functional Connectivity and Decoding

Gallery generated by Sphinx-Gallery