Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python for Neuroscience — a 12-session mini-course

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.

The sessions

# Session Open in Colab Video
1 Why Python for Neuroscience? Colab YouTube
2 Variables, Types and Arithmetic Colab YouTube
3 Control Flow and Functions Colab YouTube
4 Lists, Dictionaries and Tuples Colab YouTube
5 NumPy Fundamentals Colab YouTube
6 pandas and Tabular Data Colab YouTube
7 Plotting with Matplotlib and Seaborn Colab YouTube
8 Signal Processing: Sampling and Filtering Colab YouTube
9 Statistics for Neuroscience Colab YouTube
10 Brain Networks and Graph Theory Colab YouTube
11 Capstone Part 1: Real Data In Colab YouTube
12 Capstone Part 2: Analyse and Conclude Colab YouTube

How it fits together

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.

Running the notebooks

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/

What is in data/

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.

If you fork or rename this repo

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.

Licence

Notebooks and text: CC BY 4.0. Code: MIT. The fMRI dataset keeps its own licence from the original authors.