Authors:
- Fatemeh Jafari – Sessions 1–6
- Mohammad Saeed Soleimani – Sessions 7–11
Program: Neuroscience Research Training Program – fMRI Department, Interdisciplinary School
This repository contains the complete instructional materials for a hands-on training course in Neuroimaging Data Analysis using Python, delivered as part of the neuroscience research training curriculum.
Sessions 1–9 closely follow and implement concepts from the reference textbook:
Ariel Rokem & Tal Yarkoni (2024), Data Science for Neuroimaging: An Introduction, Princeton University Press
Sessions 10–11 expand into applied fMRI modeling and connectivity analysis using modern neuroimaging tools.
session1-review/
session2-numpy/
session3-pandas/
session4-neuroimaging-python/
session5-practical-neuroimaging/
session6-practical-neuroimaging-part 2/
session7-image-processing/
session8-segmentation/
session9-registration/
session10-masking/
session11-firstlevel-GLM/
session11-functional-connectivity/
mini project of 6 first sessions /
project for fMRI analysis
The course is divided into two major modules:
Introduces core Python programming concepts necessary for reproducible neuroimaging analysis.
Topics
- Variables, data types, lists, dictionaries
- Loops, conditionals, functions
- Modularity and clean code
- Basic scripting for scientific work
Outcome: Students gain functional fluency in Python fundamentals.
Students learn high-performance numerical programming using arrays.
Topics
ndarraystructure- Array creation & manipulation
- Broadcasting and vectorized operations
- Statistical operations & mathematical functions
Outcome: Builds the mathematical foundation for MRI/fMRI data (3D/4D arrays).
Essential training for working with experiment metadata, event files, and confounds.
Topics
- DataFrame & Series
- Filtering, indexing, grouping
- Joining and merging data tables
- Exploratory data analysis
Students connect Python tools to neuroimaging datasets.
Topics
- MRI & fMRI modalities
- NIfTI format and metadata
- Spatial orientation, affine transforms
- Loading images with NiBabel
- Basic visualization (axial/coronal/sagittal)
Hands-on exploration of real neuroimaging data.
Topics
- Navigating 3D/4D NIfTI volumes
- Slice visualization
- Voxel time-series extraction
- Intensity distributions
Students combine Python tools to create mini neuroimaging workflows.
Topics
- Basic preprocessing
- Exploratory fMRI analysis
- Simple pipeline building
- Data visualization
(Expanded detailed explanations included.)
This session builds the conceptual framework to understand MRI/fMRI data as multidimensional arrays, an essential perspective for all subsequent analysis.
Students explore:
- Grayscale → 2D arrays
- RGB → 3D arrays
- MRI → 3D volumes
- fMRI → 4D data (3D + time)
A key demonstration shows how spatial information is crucial—shuffling pixel values destroys meaning despite unchanged intensity values.
- Voxel coordinate systems
- Affine matrices linking voxel → world space
- TR and time dimension in fMRI
- Inspection of image header metadata
- Load Haxby dataset
- Extract slices across different planes
- View single volumes
- Plot voxel-level time-series to understand BOLD fluctuations
Students fully understand how neuroimaging data are stored, represented, and manipulated computationally.
Students learn how to isolate brain tissue using intensity-based segmentation, as introduced in Ch. 15 of the reference book.
Using histograms, students learn to identify:
- Background air
- CSF
- Gray matter
- White matter
- Fast but imprecise
- Good for rough background removal
- Maximizes inter-class variance
- Automatically finds optimal threshold
- Produces multiple classes (background, GM, WM, high-CSF)
- Suitable for rough volumetric tissue separation
Students compare the masks visually and evaluate segmentation quality.
- Mask overlays
- Binary vs multi-class segmentation
- Tissue boundaries
Students gain intuition for tissue intensity behavior and practical segmentation workflows.
Based on Ch. 16 of Data Science for Neuroimaging.
Registration aligns images into a shared spatial frame—an essential step for fMRI preprocessing, subject alignment, and multimodal integration.
- Align anatomical and functional images
- Correct for movement
- Standardize subjects into template/MNI space
- Compare across sessions and individuals
Students develop deep understanding of:
- Translation
- Rotation
- Scaling
- Shearing
- Affine matrices
RGB overlay visualizations show misalignment clearly.
- MSE for same-modality alignment
- Mutual Information (MI) for multi-modality alignment
- Gradient-based optimization considerations
Students implement a pyramid approach:
- Coarse alignment (downsampled)
- Medium refinement
- Fine full-resolution adjustment
This prevents optimization from falling into poor local minima.
- Set up
AffineRegistration - Define metric (MI), interpolator, optimizer
- Estimate transform
- Apply transform to moving image
- Visual inspection before/after
Students become capable of performing and evaluating affine registration on neuroimaging datasets.
A full introduction to ROI-based neuroimaging workflows.
Students learn to create and use masks to:
- Remove non-brain regions
- Define anatomical structures
- Constrain GLM/modeling to desired voxels
Using the Harvard–Oxford atlas, students:
- Load atlas images
- Inspect region labels
- Extract ROI masks
- Visualize ROI boundaries
Maskers convert neuroimaging data → 2D matrices usable in machine learning and statistics.
Students learn four major maskers:
Voxel-level extraction with:
- Standardization
- Confound removal
- Filtering & smoothing
ROI-summary signals based on atlas labels.
Probabilistic atlas support (e.g., ICA maps).
Seed-based extraction for connectivity.
Students master ROI creation, atlas navigation, and time-series extraction pipelines.
Students learn how to build and fit statistical models to fMRI time-series.
At each voxel:
[ Y = X\beta + \epsilon ]
Where:
- Y: BOLD time series
- X: Design matrix (HRF-convolved regressors + confounds)
- β: Parameter estimates
- ε: Noise (autocorrelated)
Students build:
- Task regressors (onset/duration/type)
- Convolution with HRF models
- High-pass filters
- Motion regressors
- Physiological confound regressors
- Scrubbing regressors
Design matrix quality checks include collinearity and shape diagnosis.
Using FirstLevelModel, students:
- Fit voxelwise regression
- Estimate β maps
- Create contrasts
- Generate t- and z-statistics
- Voxelwise thresholds
- FDR & FWE corrections
- Cluster-level inference
- Interpretation cautions
Students gain full proficiency in first-level fMRI statistical modeling and interpretation.
Students move into network-based neuroimaging analysis.
Functional connectivity reflects temporal co-fluctuation between brain regions. Students learn distinctions between:
- Functional connectivity
- Effective connectivity
- Structural connectivity
Used to normalize correlation values:
[ Z = \tanh^{-1}(r) ]
Enables proper group averaging and statistical tests.
Motion correction, confound regression, filtering, normalization.
Atlases (Harvard–Oxford, AAL, Schaefer) or seed coordinates.
Using maskers to produce:
- ROI × time matrices
- Seed time-series
- Correlation matrices
- Seed-to-voxel maps
- Z-transform operations
Heatmaps, connectome plots, thresholded maps.
Trial-wise GLM regressors → beta estimates → ROI correlations.
Tests task-modulated connectivity by adding an interaction term to the GLM.
Students learn modern methods to analyze and interpret functional brain networks.
After completing this course, students will be able to:
- Use Python, NumPy, Pandas for scientific computing
- Manipulate multidimensional MRI/fMRI datasets
- Write reproducible, modular analysis code
- Load, visualize, and inspect NIfTI files
- Perform segmentation and registration
- Build atlas-based ROI pipelines
- Extract voxel- and ROI-level time series
- Build and evaluate first-level GLM models
- Compute and interpret functional connectivity
- Implement advanced methods (BSC, PPI)
- Interpret results responsibly
All concepts in Sessions 1–9 are based on:
Ariel Rokem & Tal Yarkoni (2024) Data Science for Neuroimaging: An Introduction Princeton University Press
This course is part of the Neuroscience Research Training Program, fMRI Department – Interdisciplinary School.
- Fatemeh Jafari — Sessions 1–6 ( foundational sessions on data science & neuroimaging)
- Mohammad Saeed Soleimani — Sessions 7–11 (advanced neuroimaging analysis modules)