2. What is
nilearn is a package that makes it easy to use advanced machine learning techniques to analyze data acquired with MRI machines.
In particular, underlying machine learning problems include
decoding brain data,
computing brain parcellations,
analyzing functional connectivity and connectomes,
doing multi-voxel pattern analysis (MVPA) or predictive modelling.
For machine learning experts, the value of
nilearn can be seen as
domain-specific feature engineering construction, that is, shaping
neuroimaging data into a feature matrix well suited for statistical learning.
It is ok if these terms don’t make sense to you yet: this guide will walk you through them in a comprehensive manner.
nilearn for the first time#
nilearn is a Python library. If you have never used Python before,
you should probably have a look at a general introduction about Python
as well as to an introduction to using Python for science before diving into
3.1. First steps with nilearn#
At this stage, you should have installed
nilearn and opened a Jupyter notebook
or an IPython / Python session. First, load
nilearn comes in with some data that are commonly used in neuroimaging.
For instance, it comes with volumic template images of brains such as MNI:
Let’s have a look at this image:
3.2. Learning with the API references#
Oftentimes, if you are already familiar with the problems and vocabulary of MRI analysis,
the module and function names are explicit enough that you should understand what
Exercise: Varying the amount of smoothing in an image
Compute the mean EPI for one individual of the brain development
dataset downloaded with
smooth it with an FWHM varying from 0mm to 20mm in increments of 5mm
nilearn.datasets.fetch_development_fmriand inspect the
.keys()of the returned object
nilearn.imagemodule in the documentation to find a function to compute the mean of a 4D image
nilearn.imagemodule again to find a function which smoothes images
Plot the computed image for each smoothing value
A solution can be found here.
3.3. Learning with examples#
nilearn comes with a lot of examples/tutorials.
Going through them should give you a precise overview of what you can achieve with this package.
For new-comers, we recommend going through the following examples in the suggested order:
3.4. Finding help#
On top of this guide, there is a lot of content available outside of
that could be of interest to new-comers:
An introduction to fMRI by Russel Poldrack, Jeanette Mumford and Thomas Nichols.
(For French readers) An introduction to cognitive neuroscience given at the University of Montréal.
The documentation of
scikit-learnexplains each method with tips on practical use and examples: https://scikit-learn.org/stable/. While not specific to neuroimaging, it is often a recommended read.
4. (For Python beginners) A quick and gentle introduction to scientific computing with Python with the scipy lecture notes.
Moreover, you can use
nilearn with Jupyter notebooks or
IPython sessions. They provide an interactive
environment that greatly facilitates debugging and visualisation.
Besides, you can find help on neurostars for questions
nilearn and to computational neuroscience in general.
nilearn team organizes weekly drop-in hours.
We can also be reached on github
in case you find a bug.
4. Machine learning applications to Neuroimaging#
nilearn brings easy-to-use machine learning tools that can be leveraged to solve more complex applications.
The interested reader can dive into the following articles for more content.
We give a non-exhaustive list of such important applications.
Diagnosis and prognosis
Measuring how much an estimator trained on one specific psychological process/task can predict the neural activity underlying another specific psychological process/task (e.g. discriminating left from right eye movements also discriminates additions from subtractions [Knops 2009])
High-dimensional multivariate statistics
From a statistical point of view, machine learning implements statistical estimation of models with a large number of parameters. Tricks pulled in machine learning (e.g. regularization) can make this estimation possible despite the usually small number of observations in the neuroimaging domain [Varoquaux 2012]. This usage of machine learning requires some understanding of the models.
Data mining / exploration
Data-driven exploration of brain images. This includes the extraction of the major brain networks from resting-state data (“resting-state networks”) or movie-watching data as well as the discovery of connectionally coherent functional modules (“connectivity-based parcellation”). For example, Extracting functional brain networks: ICA and related or Clustering to parcellate the brain in regions with clustering.