
Machine learning for neuroimaging

Information
The estimated time to complete this training module is 4h.
The prerequisites to take this module are:
- installation module
- introduction to python for data analysis module
- introduction to machine learning module
Recommended but not mandatory:
- fmri connectivity module
- fmri parcellation module
If you have any questions regarding the module content please ask them in the relevant module channel on the school Discord server. If you do not have access to the server and would like to join, please send us an email at school [dot] brainhack [at] gmail [dot] com.
Follow up with your local TA(s) to validate you completed the exercises correctly.
Resources
This module is built around two Jupyter notebooks and one set of exercises, all available in the module repository and rendered as a web book:
Tutorial 1: Functional connectivity with nilearn
An introduction to extracting functional connectivity features from resting-state fMRI data using nilearn. Topics covered:
- A brief introduction to fMRI and the challenge of feature extraction
- Computing time series from brain atlases with
NiftiLabelsMasker - Constructing and visualizing connectomes with
ConnectivityMeasure
Tutorial 2: Machine learning with nilearn
A complete ML pipeline applied to a developmental fMRI dataset (children vs. adults classification). Topics covered:
- Loading and exploring phenotypic data
- Extracting connectivity features across subjects
- Training a linear SVM classifier with scikit-learn
- Evaluating model performance with cross-validation
- Visualizing and interpreting results
The dataset used is the NeuroDev developmental fMRI dataset, preprocessed and packaged by Elizabeth Dupre and now integrated as one of nilearn’s main tutorial datasets.
Original lecture
This module builds on a lecture originally delivered by Jacob Vogel during the QLSC 612 course in 2020. The original video (2h13) is available below:
Exercise
The exercise notebook (exercises_adhd.ipynb) has you build a complete ML pipeline to predict ADHD diagnosis from functional connectivity data, using the ADHD200 dataset available through nilearn.
The exercise is structured as follows:
- Part 1 — Exploring phenotypic data: examine clinical and demographic variables (number of subjects, ADHD diagnosis distribution, age, gender).
- Part 2 — Extracting functional connectivity features: use an atlas-based masker to extract time series and compute a connectivity matrix per subject.
- Part 3 — Training and evaluating an SVM classifier: split data, fit a linear SVM, and assess performance with accuracy, a classification report, and a confusion matrix.
- Challenge — Cross-validation: re-evaluate using stratified k-fold cross-validation for a more robust performance estimate.
Important: follow the parameter specifications given in each question exactly — the exercise uses automated grading that compares results to reference values.
Follow up with your local TA(s) to validate you completed the exercises correctly.