Nilearn and Nistats: Machine learning and statistics for fMRI in Python

Presented During:

Poster No:


Submission Type:

Abstract Submission 


Jérôme Dockès1, Kshitij Chawla2, Alexandre Abraham3, Thomas Bazeille4, Moritz Boos5, Salma Bougacha6, Danilo Bzdok7, Jerome-Alexis Chevalier8, Kamalaker Dadi9, Gilles de Hollander10, Céline Delettre11, Elizabeth DuPre7, Daniel Gale12, Krzysztof Gorgolewski13, Alexandre Gramfort14, Antoine Grigis15, Roberto Guidotti16, Ryan Hammonds17, Andrés Hoyos-Idrobo18, Julia Huntenburg19, Gregory Kiar7, Eric Larson20, Guillaume Lemaitre21, Franziskus Liem22, Christopher Markiewicz23, Tuan-Binh Nguyen8, Ana Luísa Pinho24, Derek Pisner25, Mehdi Rahim26, Paula Sanz-Leon27, Sylvain Takerkart28, Bertrand Thirion29, Jacob Vogel30, Johannes Wiesner31, Gaël Varoquaux32


1INRIA, Palaiseau, Saclay, 2INRIA Saclay, Palaiseau, Ile de France, 3Dataiku, BAZEMONT, France, 4INRIA-Saclay, Palaiseau, Ile de France, 5University of Oldenburg, Oldenburg, Niedersachsen, 6École supérieure d'ingénieurs Léonard-de-Vinci, Courbevoie, Courbevoie, 7McGill University, Montreal, Quebec, 8Inria Saclay Ile-de-France, Palaiseau, Ile-de-France, 9INRIA, Paris, Ile de France, 10University of Zurich, Zurich, Switzerland, Zurich, Switzerland, 11Institut Pasteur, Paris, Ile de France, 12Queen's University, Kingston, Ontario, 13Google, Mountain View, CA, 14INRIA, Paris, n/a, 15Neurospin, CEA, Gif-sur-Yvette, france, 16University "G. D'Annunzio" of Chieti-Pescara, Chieti, CH, 17University of Texas at Dallas, Dallas, TX, 18Rakuten Institute of Technology, Paris, Ile de France, 19Champalimaud Research, Lisbon, Portugal, 20University of Washington, Seattle, WA, 21Inria, Palaiseau, Ile-de-France, 22University of Zurich, Zurich, Zurich, 23Stanford University, Stanford, CA, 24Inria Saclay-Île-de-France, Gif-sur-Yvette, France, 25University of Texas at Austin, Austin, TX, 26Air Liquide, Les Loges en Josas, Yvelines, 27QIMR Berghofer, Brisbane, Australia, 28CNRS - Aix Marseille Université, Marseille, France, 29inria, Gif sur Yvette, -, 30McGill University, Montreal, QC, 31Uniklinik Köln, Köln, Cologne, 32INRIA, Saclay, Ile de France

First Author:

Jérôme Dockès  
Palaiseau, Saclay


Kshitij Chawla  
INRIA Saclay
Palaiseau, Ile de France
Alexandre Abraham  
Thomas Bazeille  
Palaiseau, Ile de France
Moritz Boos  
University of Oldenburg
Oldenburg, Niedersachsen
Salma Bougacha  
École supérieure d'ingénieurs Léonard-de-Vinci
Courbevoie, Courbevoie
Danilo Bzdok  
McGill University
Montreal, Quebec
Jerome-Alexis Chevalier  
Inria Saclay Ile-de-France
Palaiseau, Ile-de-France
Kamalaker Dadi  
Paris, Ile de France
Gilles de Hollander  
University of Zurich, Zurich, Switzerland
Zurich, Switzerland
Céline Delettre  
Institut Pasteur
Paris, Ile de France
Elizabeth DuPre  
McGill University
Montreal, Quebec
Daniel Gale  
Queen's University
Kingston, Ontario
Krzysztof Gorgolewski  
Mountain View, CA
Alexandre Gramfort, Dr  
Paris, n/a
Antoine Grigis  
Neurospin, CEA
Gif-sur-Yvette, france
Roberto Guidotti  
University "G. D'Annunzio" of Chieti-Pescara
Chieti, CH
Ryan Hammonds  
University of Texas at Dallas
Dallas, TX
Andrés Hoyos-Idrobo  
Rakuten Institute of Technology
Paris, Ile de France
Julia Huntenburg  
Champalimaud Research
Lisbon, Portugal
Gregory Kiar  
McGill University
Montreal, Quebec
Eric Larson, PhD  
University of Washington
Seattle, WA
Guillaume Lemaitre  
Palaiseau, Ile-de-France
Franziskus Liem  
University of Zurich
Zurich, Zurich
Christopher Markiewicz  
Stanford University
Stanford, CA
Tuan-Binh Nguyen  
Inria Saclay Ile-de-France
Palaiseau, Ile-de-France
Ana Luísa Pinho, PhD  
Inria Saclay-Île-de-France
Gif-sur-Yvette, France
Derek Pisner  
University of Texas at Austin
Austin, TX
Mehdi Rahim  
Air Liquide
Les Loges en Josas, Yvelines
Paula Sanz-Leon  
QIMR Berghofer
Brisbane, Australia
Sylvain Takerkart  
CNRS - Aix Marseille Université
Marseille, France
Bertrand Thirion  
Gif sur Yvette, -
Jacob Vogel  
McGill University
Montreal, QC
Johannes Wiesner  
Uniklinik Köln
Köln, Cologne
Gaël Varoquaux  
Saclay, Ile de France


Efficient and reproducible science depends on a strong software ecosystem [1]. We present Nilearn and Nistats, two Python packages empowering the neuroimaging community, which will soon be united in the same library. Nilearn ( focuses on fast and easy statistical learning on fMRI data. It provides efficient and reliable implementations of machine learning methods tailored to the needs of the neuroimaging community. It builds upon a Python "data science ecosystem" of packages such as numpy [2], scipy [3], scikit-learn [4], and pandas [5], that are extensively used, tested and optimized by a large scientific and industrial community. This makes Nilearn easy to use for a broad spectrum of researchers who are familiar with the Python ecosystem, and reduces the need of learning the idiosyncrasies of specific command line or GUI-based neuroimaging tools. Specifically, Nilearn provides methods for decoding functional connectivity analysis, and biomarker extraction. It also includes datasets for teaching, as well as interactive visualization of brain images and connectomes.

Nistats provides tools for mass univariate linear models –standard analysis in fMRI– It will eventually become a part of Nilearn. Both libraries have been widely used, taught, and maintained by the neuroimaging community for many years. They build upon and contribute to the growing ecosystem of Python tools for neuroimaging, with tools such as nibabel [6] and dipy [7].


Nilearn and Nistats are community-led open-source projects, developed and used by researchers in neuroimaging and machine-learning. Both of them are hosted on Github, enabling anyone to report issues, request new features, or contribute code/bug fixes, documentation improvements, or new methods. Users and developers also regularly answer questions and give help on the NeuroStars forum: To engage the neuroimaging community, tutorials and coding sprints are organized regularly. Nilearn and Nistats are well represented at events such as BrainHacks or the OHBM Open Science Room.

Both libraries strive to be easy to use with simple code. Only reliable and well-established methods fall within their scope. User guides provide an introduction to machine learning and statistics for fMRI and usage of Nilearn and Nistats. Examples showcase all functionalities. All functions are described in a comprehensive reference documentation. Relevant links are, for user guides,, for realistic examples on MRI data,

Nilearn and Nistats use industry-standard methods for software development. Source code is version controlled. All functions are covered by unit tests that are run, along with all the examples, in a Continuous Integration framework. Several reviewers check every contribution. These best practices allow to incorporate contributions from around the world while preserving the quality and reliability of the code.


Nilearn and Nistats are widely used and cover many of the analysis needs for neuroimaging:

- Manipulation of brain images and basic signal processing;
- Supervised learning and decoding;
- Functional connectivity and decomposition methods;
- Plotting (see Fig. 1);
- Projection of volumetric data to surfaces;
- Standard analysis with Nistats (see Fig. 2);
- Model selection and validation, parallelism, and caching.
Supporting Image: image1_with_legend.png
   ·Illustration of data processing and visualization with nilearn
Supporting Image: image2_legend.png
   ·Results of a mass-univariate statistical analysis of task fMRI with nistats


Neuroimaging suffers from a reproducibility crisis and the analytic variability is partly to blame. Industry-grade easily-usable libraries can help, by making analysis pipelines documented, version controlled, peer-reviewed, and shared. Nilearn and Nistats fill this role because they enable researchers to produce pipelines that are intelligible, re-executable and extendable to novel datasets.

Modeling and Analysis Methods:

Classification and Predictive Modeling 2
fMRI Connectivity and Network Modeling
Univariate Modeling

Neuroinformatics and Data Sharing:

Informatics Other 1


Data analysis
Machine Learning
Statistical Methods

1|2Indicates the priority used for review

My abstract is being submitted as a Software Demonstration.


Please indicate below if your study was a "resting state" or "task-activation” study.


Healthy subjects only or patients (note that patient studies may also involve healthy subjects):

Healthy subjects

Was any human subjects research approved by the relevant Institutional Review Board or ethics panel? NOTE: Any human subjects studies without IRB approval will be automatically rejected.

Not applicable

Was any animal research approved by the relevant IACUC or other animal research panel? NOTE: Any animal studies without IACUC approval will be automatically rejected.

Not applicable

Please indicate which methods were used in your research:

Functional MRI
Structural MRI

Which processing packages did you use for your study?

Other, Please list  -   Nilearn

Provide references using author date format

[1] Poldrack, R., Gorgolewski, K., Varoquaux, G. (2019). Computational and Informatic Advances for Reproducible Data Analysis, Neuroimaging Annual Review of Biomedical Data Science, 2, 119-138.
[2] van der Walt, S., Colbert, C and Varoquaux, G. (2011) The NumPy Array: A Structure for Efficient Numerical Computation, Computing in Science & Engineering, 13, 22-30.
[3] Oliphant, T.E. (2007). Python for Scientific Computing, Computing in Science & Engineering, 9, 10-20.
[4] Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., Duchesnay, E. (2011). Scikit-learn: Machine Learning in Python, Journal of Machine Learning Research, 12, 2825-2830.
[5] McKinney, W. (2010). Data Structures for Statistical Computing in Python, Proceedings of the 9th Python in Science Conference, 51-56.
[6] Nibabel, DOI: 10.5281/zenodo.3583002
[7] Garyfallidis E, Brett M, Amirbekian B, Rokem A, van der Walt S, Descoteaux M, Nimmo-Smith I and Dipy Contributors (2014). DIPY, a library for the analysis of diffusion MRI data. Frontiers in Neuroinformatics, vol.8, no.8.