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.
![](../_images/sphx_glr_plot_nilearn_101_thumb.png)
Basic nilearn example: manipulating and looking at data
![](../_images/sphx_glr_plot_single_subject_single_run_thumb.png)
Intro to GLM Analysis: a single-run, single-subject fMRI dataset
Visualization of brain images¶
See Plotting brain images for more details.
![](../_images/sphx_glr_plot_visualize_megatrawls_netmats_thumb.png)
Visualizing Megatrawls Network Matrices from Human Connectome Project
![](../_images/sphx_glr_plot_overlay_thumb.png)
Visualizing a probabilistic atlas: the default mode in the MSDL atlas
![](../_images/sphx_glr_plot_dim_plotting_thumb.png)
Controlling the contrast of the background when plotting
![](../_images/sphx_glr_plot_multiscale_parcellations_thumb.png)
Visualizing multiscale functional brain parcellations
![](../_images/sphx_glr_plot_surface_projection_strategies_thumb.png)
Technical point: Illustration of the volume to surface sampling schemes
Decoding and predicting from brain images¶
See Decoding and MVPA: predicting from brain images for more details.
![](../_images/sphx_glr_plot_oasis_vbm_space_net_thumb.png)
Voxel-Based Morphometry on Oasis dataset with Space-Net prior
![](../_images/sphx_glr_plot_haxby_frem_thumb.png)
Decoding with FREM: face vs house vs chair object recognition
![](../_images/sphx_glr_plot_haxby_anova_svm_thumb.png)
Decoding with ANOVA + SVM: face vs house in the Haxby dataset
![](../_images/sphx_glr_plot_haxby_multiclass_thumb.png)
The haxby dataset: different multi-class strategies
![](../_images/sphx_glr_plot_haxby_glm_decoding_thumb.png)
Decoding of a dataset after GLM fit for signal extraction
![](../_images/sphx_glr_plot_haxby_full_analysis_thumb.png)
ROI-based decoding analysis in Haxby et al. dataset
![](../_images/sphx_glr_plot_haxby_different_estimators_thumb.png)
Different classifiers in decoding the Haxby dataset
![](../_images/sphx_glr_plot_miyawaki_encoding_thumb.png)
Encoding models for visual stimuli from Miyawaki et al. 2008
![](../_images/sphx_glr_plot_miyawaki_reconstruction_thumb.png)
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.
![](../_images/sphx_glr_plot_inverse_covariance_connectome_thumb.png)
Computing a connectome with sparse inverse covariance
![](../_images/sphx_glr_plot_probabilistic_atlas_extraction_thumb.png)
Extracting signals of a probabilistic atlas of functional regions
![](../_images/sphx_glr_plot_simulated_connectome_thumb.png)
Connectivity structure estimation on simulated data
![](../_images/sphx_glr_plot_multi_subject_connectome_thumb.png)
Group Sparse inverse covariance for multi-subject connectome
![](../_images/sphx_glr_plot_seed_to_voxel_correlation_thumb.png)
Producing single subject maps of seed-to-voxel correlation
![](../_images/sphx_glr_plot_compare_decomposition_thumb.png)
Deriving spatial maps from group fMRI data using ICA and Dictionary Learning
![](../_images/sphx_glr_plot_extract_regions_dictlearning_maps_thumb.png)
Regions extraction using dictionary learning and functional connectomes
![](../_images/sphx_glr_plot_atlas_comparison_thumb.png)
Comparing connectomes on different reference atlases
![](../_images/sphx_glr_plot_group_level_connectivity_thumb.png)
Classification of age groups using functional connectivity
![](../_images/sphx_glr_plot_data_driven_parcellations_thumb.png)
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.
![](../_images/sphx_glr_plot_fir_model_thumb.png)
Analysis of an fMRI dataset with a Finite Impule Response (FIR) model
![](../_images/sphx_glr_plot_write_events_file_thumb.png)
Generate an events.tsv file for the NeuroSpin localizer task
![](../_images/sphx_glr_plot_bids_features_thumb.png)
First level analysis of a complete BIDS dataset from openneuro
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.
![](../_images/sphx_glr_plot_proportion_activated_voxels_thumb.png)
Second-level fMRI model: true positive proportion in clusters
![](../_images/sphx_glr_plot_second_level_two_sample_test_thumb.png)
Second-level fMRI model: two-sample test, unpaired and paired
Manipulating brain image volumes¶
See Manipulating images: resampling, smoothing, masking, ROIs… for more details.
![](../_images/sphx_glr_plot_extract_rois_smith_atlas_thumb.png)
Regions Extraction of Default Mode Networks using Smith Atlas
![](../_images/sphx_glr_plot_nifti_labels_simple_thumb.png)
Extracting signals from brain regions using the NiftiLabelsMasker
![](../_images/sphx_glr_plot_roi_extraction_thumb.png)
Computing a Region of Interest (ROI) mask manually
Advanced statistical analysis of brain images¶
![](../_images/sphx_glr_plot_ica_resting_state_thumb.png)
Multivariate decompositions: Independent component analysis of fMRI
![](../_images/sphx_glr_plot_localizer_simple_analysis_thumb.png)
Massively univariate analysis of a calculation task from the Localizer dataset
![](../_images/sphx_glr_plot_neurovault_meta_analysis_thumb.png)
NeuroVault meta-analysis of stop-go paradigm studies
![](../_images/sphx_glr_plot_surface_bids_analysis_thumb.png)
Surface-based dataset first and second level analysis of a dataset
![](../_images/sphx_glr_plot_localizer_mass_univariate_methods_thumb.png)
Massively univariate analysis of a motor task from the Localizer dataset
![](../_images/sphx_glr_plot_haxby_mass_univariate_thumb.png)
Massively univariate analysis of face vs house recognition
![](../_images/sphx_glr_plot_beta_series_thumb.png)
Beta-Series Modeling for Task-Based Functional Connectivity and Decoding
Examples for experimental modules¶
These are examples focused on showcasing experimental features and are subject to change without any notice.
![](../_images/sphx_glr_plot_new_surface_bids_analysis_experimental_thumb.png)
Surface-based dataset first and second level analysis of a dataset