A free, short course that takes you from your first variable to a real analysis of open fMRI data. Each notebook is one session of roughly ten minutes. Everything runs in your browser on Google Colab with no installation.
Sessions 1 to 4 are Python itself, taught with neuroscience examples from the first line.
Sessions 5 to 9 build on one synthetic signal, created by generate_toy_signal() in session 5 and reused after that. It is a sine wave plus noise, and it is labelled as a toy every time it appears so nobody mistakes it for a recording.
Sessions 10 to 12 move to networks and then to real data. The capstone uses the open development fMRI dataset distributed with nilearn: children and adults watching a short film in the scanner. Session 12 reproduces a well-replicated developmental result, that within-network default mode connectivity is stronger in adults than in children.
On Colab. Click any badge above. Nothing to install.
Locally.
git clone https://github.com/saeedrafsharx/python-for-neuroscience.git
cd python-for-neuroscience
pip install -r requirements.txt
jupyter lab notebooks/| File | What it is |
|---|---|
one_subject_timeseries.csv |
39 region time series from one participant. Used for the demo in session 1 and as a fallback in session 11. |
dev_fmri_timeseries.npz |
50 participants (25 children, 25 adults), 168 timepoints, 39 regions. The session 12 dataset. |
participants.csv |
Participant id, age, group. |
msdl_regions.csv |
The 39 MSDL atlas regions, their network membership and coordinates. |
All of it is derived from the public nilearn dataset by scripts/prepare_capstone_data.py. Extracting the time series for 50 people takes a few minutes, which is why it is cached here rather than run live. Delete the folder and rerun the script to rebuild it from scratch.
Notebooks 1 and 12 load data over the network when they are run on Colab. They build the URL from a constant near the top:
REPO_RAW = "https://raw.githubusercontent.com/saeedrafsharx/python-for-neuroscience/main/data/"Change that line to point at your own repo. When the notebook is run locally it uses ../data/ instead and ignores the URL.
Notebooks and text: CC BY 4.0. Code: MIT. The fMRI dataset keeps its own licence from the original authors.