8. Reference documentation: all nilearn functions¶
This is the class and function reference of nilearn. Please refer to the user guide for more information and usage examples.
List of modules
nilearn.connectome
: Functional Connectivitynilearn.datasets
: Automatic Dataset Fetchingnilearn.decoding
: Decodingnilearn.decomposition
: Multivariate Decompositionsnilearn.image
: Image Processing and Resampling Utilitiesnilearn.input_data
: Loading and Processing Files Easilynilearn.masking
: Data Masking Utilitiesnilearn.regions
: Operating on Regionsnilearn.mass_univariate
: Mass-Univariate Analysisnilearn.plotting
: Plotting Brain Datanilearn.signal
: Preprocessing Time Seriesnilearn.glm
: Generalized Linear Modelsnilearn.reporting
: Reporting Functionsnilearn.surface
: Manipulating Surface Data
8.1. nilearn.connectome
: Functional Connectivity¶
Tools for computing functional connectivity matrices and also implementation of algorithm for sparse multi subjects learning of Gaussian graphical models.
Classes:
|
A class that computes different kinds of functional connectivity matrices. |
|
Covariance and precision matrix estimator. |
|
Sparse inverse covariance w/ cross-validated choice of the parameter. |
Functions:
|
Return the flattened lower triangular part of an array. |
|
Return the symmetric matrix given its flattened lower triangular part. |
|
Compute sparse precision matrices and covariance matrices. |
|
Return correlation matrix for a given covariance matrix. |
|
Return partial correlation matrix for a given precision matrix. |
8.2. nilearn.datasets
: Automatic Dataset Fetching¶
Helper functions to download NeuroImaging datasets
User guide: See the Fetching open datasets from Internet section for further details.
Functions:
|
Download and return file names for the Craddock 2012 parcellation |
|
Download and load the Destrieux cortical atlas (dated 2009) |
|
Load Harvard-Oxford parcellations from FSL. |
|
Download and load the MSDL brain atlas. |
|
Fetch DiFuMo brain atlas |
Download and load the Power et al. brain atlas composed of 264 ROIs. |
|
|
Load the Seitzman et al. 300 ROIs. |
|
Download and load the Smith ICA and BrainMap atlas (dated 2009). |
|
Download and return file names for the Yeo 2011 parcellation. |
|
Downloads and returns the AAL template for SPM 12. |
|
Downloads and loads multiscale functional brain parcellations |
|
Download and return file names for the Allen and MIALAB ICA atlas (dated 2011). |
|
Download the Pauli et al. (2017) atlas with in total 12 subcortical nodes. |
|
Load the Dosenbach et al. 160 ROIs. |
|
Fetch ABIDE dataset. |
|
Download and load the ADHD resting-state dataset. |
|
Fetch movie watching based brain development dataset (fMRI) |
|
Download and loads complete haxby dataset. |
|
Download and load the ICBM152 template (dated 2009). |
|
Downloads ICBM152 template first, then loads ‘gm’ mask image. |
|
Fetch left vs right button press contrast maps from the localizer. |
|
Download and load Brainomics/Localizer dataset (94 subjects). |
Fetch calculation task contrast maps from the localizer. |
|
|
Download and loads Miyawaki et al. 2008 dataset (153MB). |
|
Download and load the NKI enhanced resting-state dataset, preprocessed and projected to the fsaverage5 space surface. |
|
Download a Freesurfer fsaverage surface. |
|
Download and load Destrieux et al, 2010 cortical atlas |
|
Download the Talairach atlas. |
|
Download and return file names for the Schaefer 2018 parcellation |
|
Download and load Oasis “cross-sectional MRI” dataset (416 subjects). |
|
Downloads and returns Network Matrices data from MegaTrawls release in HCP. |
|
DEPRECATED: ‘fetch_cobre’ has been deprecated and will be removed in release 0.9 . |
|
Download data from neurovault.org that match certain criteria. |
|
Download specific images and collections from neurovault.org. |
Fetch a contrast map from NeuroVault showing the effect of mental subtraction upon auditory instructions |
|
|
Fetch left vs right button press group contrast map from NeuroVault. |
|
Returns the directories in which nilearn looks for data. |
Load skullstripped 2mm version of the MNI152 originally distributed with FSL. |
|
Load brain mask from MNI152 T1 template |
|
Download language localizer demo dataset. |
|
|
Download language localizer example bids dataset. |
|
Download a file with OpenNeuro BIDS dataset index. |
|
Select subset of urls with given filters. |
|
Add symlinks for files not named according to latest BIDS conventions. |
|
Download OpenNeuro BIDS dataset. |
|
Download a first-level localizer fMRI dataset |
|
Function to fetch SPM auditory single-subject data. |
|
Fetcher for Multi-modal Face Dataset. |
|
Download a first-level fiac fMRI dataset (2 sessions) |
8.3. nilearn.decoding
: Decoding¶
Decoding tools and algorithms.
Classes:
|
A wrapper for popular classification strategies in neuroimaging. |
|
A wrapper for popular regression strategies in neuroimaging. |
|
State of the art decoding scheme applied to usual classifiers. |
|
State of the art decoding scheme applied to usual regression estimators. |
|
Classification learners with sparsity and spatial priors. |
|
Regression learners with sparsity and spatial priors. |
|
Implement search_light analysis using an arbitrary type of classifier. |
8.4. nilearn.decomposition
: Multivariate Decompositions¶
The nilearn.decomposition
module includes a subject level
variant of the ICA called Canonical ICA.
Classes:
|
Perform Canonical Independent Component Analysis [R637c2563345c-1] [R637c2563345c-2]. |
|
Perform a map learning algorithm based on spatial component sparsity, over a CanICA initialization [Rd0eec3116114-1]. |
8.5. nilearn.image
: Image Processing and Resampling Utilities¶
Mathematical operations working on Niimg-like objects like a (3+)D block of data, and an affine.
Functions:
|
Improve SNR on masked fMRI signals. |
|
Concatenate a list of 3D/4D niimgs of varying lengths. |
|
Convert the x, y, z coordinates from one image space to another |
|
Copy an image to a nibabel.Nifti1Image. |
|
Crops an image as much as possible. |
|
Get the image data as a |
|
Return confounds signals extracted from input signals with highest variance. |
|
Indexes into a 4D Niimg-like object in the fourth dimension. |
|
Iterates over a 4D Niimg-like object in the fourth dimension. |
Return the largest connected component of an image or list of images. |
|
|
Load a Niimg-like object from filenames or list of filenames. |
|
Interpret a numpy based string formula using niimg in named parameters. |
|
Compute the mean of the images over time or the 4th dimension. |
|
Create a new image of the same class as the reference image |
|
Resample a Niimg-like object |
|
Resample a Niimg-like source image on a target Niimg-like image (no registration is performed: the image should already be aligned). |
|
Returns an image with the affine diagonal (by permuting axes). |
|
Smooth images by applying a Gaussian filter. |
|
Performs swapping of hemispheres in the indicated NIfTI image. |
|
Threshold the given input image, mostly statistical or atlas images. |
8.6. nilearn.input_data
: Loading and Processing Files Easily¶
The nilearn.input_data
module includes scikit-learn tranformers and
tools to preprocess neuro-imaging data.
User guide: See the NiftiMasker: applying a mask to load time-series section for further details.
Classes:
|
Applying a mask to extract time-series from Niimg-like objects. |
|
Class for masking of Niimg-like objects. |
|
Class for masking of Niimg-like objects. |
|
Class for masking of Niimg-like objects. |
|
Class for masking of Niimg-like objects using seeds. |
8.7. nilearn.masking
: Data Masking Utilities¶
Utilities to compute and operate on brain masks
User guide: See the Masking the data: from 4D image to 2D array section for further details.
Functions:
|
Compute a brain mask from fMRI data in 3D or 4D ndarrays. |
|
Compute a common mask for several sessions or subjects of fMRI data. |
|
Compute the whole-brain mask. |
|
Compute a mask corresponding to the gray matter part of the brain for a list of images. |
|
Compute a brain mask for the images by guessing the value of the background from the border of the image. |
|
Compute a common mask for several sessions or subjects of data. |
|
Compute intersection of several masks |
|
Extract signals from images using specified mask. |
|
Take masked data and bring them back into 3D/4D |
8.8. nilearn.regions
: Operating on Regions¶
The nilearn.regions
class module includes region extraction
procedure on a 4D statistical/atlas maps and its function.
Functions:
|
Extraction of brain connected regions into separate regions. |
|
Extract connected regions from a brain atlas image defined by labels (integers). |
|
Extract region signals from image. |
|
Create image from region signals defined as labels. |
|
Extract region signals from image. |
|
Create image from region signals defined as maps. |
Classes:
|
Class for brain region extraction. |
|
Learn parcellations on fMRI images. |
|
Recursive Neighbor Agglomeration (ReNA): Recursively merges the pair of clusters according to 1-nearest neighbors criterion. |
8.9. nilearn.mass_univariate
: Mass-Univariate Analysis¶
Defines a Massively Univariate Linear Model estimated with OLS and permutation test
Functions:
|
Massively univariate group analysis with permuted OLS. |
8.10. nilearn.plotting
: Plotting Brain Data¶
Plotting code for nilearn
Functions:
|
Find ‘good’ cross-section slicing positions along a given axis. |
|
Find the center of the largest activation connected component. |
|
Return coordinates of center of mass of 3D parcellation atlas. |
|
Return coordinates of center probabilistic atlas 4D image. |
|
Plot cuts of an anatomical image (by default 3 cuts: Frontal, Axial, and Lateral) |
|
Plot cuts of a given image (by default Frontal, Axial, and Lateral) |
|
Plot cuts of an EPI image (by default 3 cuts: Frontal, Axial, and Lateral) |
|
Plot the given matrix. |
|
Plot cuts of an ROI/mask image (by default 3 cuts: Frontal, Axial, and Lateral) |
|
Plot cuts of an ROI/mask image (by default 3 cuts: Frontal, Axial, and Lateral) |
|
Plot 2d projections of an ROI/mask image (by default 3 projections: Frontal, Axial, and Lateral). |
|
Plot connectome on top of the brain glass schematics. |
|
Plot connectome strength on top of the brain glass schematics. |
|
Plot network nodes (markers) on top of the brain glass schematics. |
|
Plot the probabilistic atlases onto the anatomical image by default MNI template |
|
Plot an image representation of voxel intensities across time. |
|
Plotting of surfaces with optional background and data |
|
Plotting ROI on a surface mesh with optional background |
|
Plotting contours of ROIs on a surface, optionally over a statistical map. |
|
Plotting a stats map on a surface mesh with optional background |
|
Convenience function to plot multiple views of plot_surf_stat_map in a single figure. |
|
Creates plots to compare two lists of images and measure correlation. |
|
Plot a design matrix provided as a DataFrame |
|
Creates plot for event visualization. |
|
Creates plot for contrast definition. |
|
Insert a surface plot of a surface map into an HTML page. |
|
Insert a surface plot of a statistical map into an HTML page. |
|
Insert a 3d plot of a connectome into an HTML page. |
|
Insert a 3d plot of markers in a brain into an HTML page. |
|
Interactive html viewer of a statistical map, with optional background. |
|
Show all the figures generated by nilearn and/or matplotlib. |
Classes:
|
A class to create 3 linked axes for plotting orthogonal cuts of 3D maps. |
8.11. nilearn.signal
: Preprocessing Time Series¶
Preprocessing functions for time series.
All functions in this module should take X matrices with samples x features
Functions:
|
Improve SNR on masked fMRI signals. |
|
Return confounds time series extracted from series with highest variance. |
8.12. nilearn.glm
: Generalized Linear Models¶
Analysing fMRI data using GLMs.
- Note that the nilearn.glm module is experimental.
It may change in any future (>0.7.0) release of Nilearn.
Classes:
|
The contrast class handles the estimation of statistical contrasts on a given model: student (t) or Fisher (F). |
|
Results from an F contrast of coefficients in a parametric model. |
|
Results from a t contrast of coefficients in a parametric model. |
|
A regression model with an AR(p) covariance structure. |
|
A simple ordinary least squares model. |
|
Class to contain results from likelihood models. |
|
This class summarizes the fit of a linear regression model. |
|
This class contains only information of the model fit necessary for contast computation. |
Functions:
|
Compute the specified contrast given an estimated glm |
|
Compute the fixed effects, given images of effects and variance |
|
Converts a string describing a contrast to a contrast vector |
|
Return the Benjamini-Hochberg FDR threshold for the input z_vals |
|
Report the proportion of active voxels for all clusters defined by the input threshold. |
|
Compute the required threshold level and return the thresholded map |
8.12.15. nilearn.glm.first_level
¶
Classes:
|
Implementation of the General Linear Model for single session fMRI data. |
Functions:
|
Check that the provided DataFrame is indeed a valid design matrix descriptor, and returns a triplet of fields |
|
This is the main function to convolve regressors with hrf model |
|
Create FirstLevelModel objects and fit arguments from a BIDS dataset. |
|
Implementation of the Glover dispersion derivative hrf model |
|
Implementation of the Glover hrf model |
|
Implementation of the Glover time derivative hrf (dhrf) model |
|
Generate a design matrix from the input parameters |
|
Scaling of the data to have percent of baseline change along the specified axis |
|
GLM fit for an fMRI data matrix |
|
Implementation of the SPM dispersion derivative hrf model |
|
Implementation of the SPM hrf model |
|
Implementation of the SPM time derivative hrf (dhrf) model |
8.12.16. nilearn.glm.second_level
¶
Classes:
|
Implementation of the General Linear Model for multiple subject fMRI data |
Functions:
|
Sets up a second level design. |
|
Generate p-values corresponding to the contrasts provided based on permutation testing. |
8.13. nilearn.reporting
: Reporting Functions¶
Reporting code for nilearn
Functions:
|
Creates pandas dataframe with img cluster statistics. |
|
Returns HTMLReport object for a report which shows all important aspects of a fitted GLM. |
8.14. nilearn.surface
: Manipulating Surface Data¶
Functions for surface manipulation.
Functions:
|
Loading data to be represented on a surface mesh. |
|
Loading a surface mesh geometry |
|
Extract surface data from a Nifti image. |