This tutorial provides a hands-on introduction to neuroimaging data analysis for first-year neuroscience graduate students at Stanford University. Using fMRI data from the Haxby et al. (2001), students will learn the fundamentals of:
- BIDS (Brain Imaging Data Structure) data organization
- fMRI preprocessing with fMRIPrep
- General Linear Model (GLM) analysis for task fMRI
- Statistical mapping and data visualization
Haxby et al. (2001) investigates face and object representation in human ventral temporal cortex. The dataset includes:
- 3 subjects, each with multiple runs
- Block-design fMRI with 8 object categories (faces, houses, cats, bottles, scissors, shoes, chairs, scrambled images)
- 2.5s TR, 24s stimulus blocks
- Available from OpenNeuro ds000105
By the end of this tutorial, students will understand:
- BIDS Data Structure: How neuroimaging data is organized using the BIDS standard and queried with PyBIDS
- NIfTI Format: The standard neuroimaging data format and how to work with 4D (space + time) data
- fMRI Preprocessing: Why preprocessing is necessary and what fMRIPrep does (motion correction, spatial normalization, confound estimation)
- Hemodynamic Response: How neural activity relates to the BOLD signal and why we need to convolve task designs with the hemodynamic response function
- GLM Analysis: How to create design matrices, fit statistical models, and interpret results
- Statistical Mapping: How to threshold and visualize brain activation maps
- BIDS layout and file organization
- NIfTI image headers and data structure
- fMRIPrep preprocessing pipeline
- Brain masks and template alignment
- Design matrix creation (boxcar and convolved)
- Hemodynamic response function (HRF) convolution
- Confound regression (motion, physiological noise)
- General Linear Model fitting
- Statistical thresholding with FDR correction
- Anatomical and functional image plotting
- Statistical map overlays
- Time series extraction from regions of interest
- Design matrix visualization
- Clone this repository
- Install dependencies:
pip install -r requirements.txt - Run the data download script:
bash download.sh - Open
tutorial.ipynbin Jupyter
Click the Binder badge to run this tutorial in your browser with no installation required. Binder will automatically install all dependencies from requirements.txt.
To run in Google Colab:
- Click the Colab badge above or manually upload
tutorial.ipynb - Run the following setup cell first:
# Install dependencies
!pip3 install -r https://raw.githubusercontent.com/lobennett/bids_neuroimaging_workshop/main/requirements.txt
# Download dataset
!wget https://raw.githubusercontent.com/lobennett/bids_neuroimaging_workshop/main/download.sh
!bash download.shbids_neuroimaging_workshop/
├── tutorial.ipynb # Main tutorial notebook
├── download.sh # Script to download Haxby dataset
├── requirements.txt # Python dependencies
├── images/
├── hrf.png # Hemodynamic response example
├── fmriprep.jpg # fMRIPrep workflow diagram
├── ds000105/ # Downloaded dataset (after running download.sh)
- Basic Python programming knowledge
- Familiarity with NumPy and Pandas
- Basic understanding of neuroimaging concepts (helpful but not required)
- nilearn: Neuroimaging analysis and visualization
- nibabel: NIfTI file I/O
- pybids: BIDS dataset queries
- scikit-learn: Statistical modeling
- matplotlib: Plotting and visualization
- pandas/numpy: Data manipulation
- Haxby, J. V., et al. (2001). Distributed and overlapping representations of faces and objects in ventral temporal cortex. Science, 293(5539), 2425-2430.
- Gorgolewski, K. J., et al. (2016). The brain imaging data structure, a format for organizing and describing outputs of neuroimaging experiments. Scientific Data, 3, 160044.
- Esteban, O., et al. (2019). fMRIPrep: a robust preprocessing pipeline for functional MRI. Nature Methods, 16(1), 111-116.