A hands-on learning lab for exploring EEG, MEG, and fMRI data using Python, MNE, Nilearn, and Machine Learning.
This repository is designed for learners with a Computer Science / AI background who want to understand neuroimaging data analysis — from basic visualization to deep learning and multimodal integration.
- How to load and visualize brain data (EEG, MEG, fMRI)
- How to preprocess and clean neuroimaging signals
- How to analyze brain activity (ERPs, GLMs, connectivity)
- How to apply machine learning & deep learning to brain data
- How to build reproducible and open-source pipelines
Each tutorial is standalone and focused on a single concept.
| Modality | What It Measures (Directly) | Primary Use Case | Resolution Strengths |
|---|---|---|---|
| EEG (Electroencephalography) | Electrical Potential (Voltage) on the scalp from neural currents. | Capturing the exact timing of brain events (e.g., event-related potentials). | Excellent Temporal (milliseconds) / Poor Spatial |
| MEG (Magnetoencephalography) | Magnetic Fields outside the head generated by neural currents. | Localizing brain activity with high precision and timing (e.g., surgical planning). | Excellent Temporal / Good Spatial |
| fMRI (functional Magnetic Resonance Imaging) | Blood Oxygen Level Dependent (BOLD) signal, a measure of blood flow/metabolism. | Mapping brain functions to specific anatomical structures (e.g., localizing language centers). | Excellent Spatial (millimeters) / Poor Temporal |
The core difference lies in the trade-off between when activity occurs (temporal resolution) and where it occurs (spatial resolution).
- EEG & MEG are direct measures of neuronal electrical activity. They provide millisecond-level temporal resolution, allowing us to track the rapid sequence of cognitive processing.
- MEG is superior to EEG in spatial resolution because magnetic fields pass through the skull undistorted, whereas the electrical signals of EEG are smeared and blurred by the skull.
- fMRI is an indirect measure. It detects the resulting change in blood flow (the hemodynamic response), which is linked to neural activity but is slow (on the order of seconds). This slowness makes its temporal resolution poor.
- However, fMRI excels at spatial resolution, providing detailed, millimeter-scale maps of activation across the entire brain structure.
neuro-ai-playground/
│
├── README.md
├── requirements.txt
├── LICENSE
│
├── tutorials/ # Learning notebooks organized by skill
│ ├── 01_foundations/
│ ├── 02_preprocessing/
│ ├── 03_time_domain/
│ ├── 04_frequency_domain/
│ ├── 05_spatial_analysis/
│ ├── 06_connectivity/
│ ├── 07_machine_learning/
│ ├── 08_deep_learning/
│ └── 09_multimodal/
│
└── datasets/ # Data download scripts
Learn to load and visualize neuroimaging data
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 01.1 EEG Basics | Load and plot EEG signals, compute PSD | EEG | File I/O, time series plotting, PSD analysis |
| 01.2 MEG Basics | Visualize raw MEG and evoked responses, topographies | MEG | Sensor layouts, evoked vs raw, topographic maps |
| 01.3 fMRI Basics | Display mean images, glass brain, deviation maps | fMRI | NIfTI handling, anatomical overlay, temporal deviations |
Status: ദ്ദി(ᵔᗜᵔ) Complete
Clean and prepare data for analysis
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 02.1 EEG/MEG Cleaning | Filtering, ICA, artifact removal | EEG/MEG | Signal processing, ICA decomposition |
| 02.2 fMRI Pipeline | Motion correction, slice timing | fMRI | BIDS, preprocessing workflows |
Status: ദ്ദി(ᵔᗜᵔ) Complete
Analyze brain activity over time
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 03.1 ERP Analysis | Event-related potentials | EEG/MEG | Epoching, averaging, statistics |
| 03.2 GLM Activation | Task-based fMRI analysis | fMRI | General linear model, design matrices |
Status: ദ്ദി(ᵔᗜᵔ) Complete
Understand brain oscillations
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 04.1 Time-Frequency | Spectrograms, wavelets | EEG/MEG | Wavelet transforms, multitaper methods |
| 04.2 Oscillatory Power | Band-specific analysis | EEG/MEG | Alpha, beta, gamma rhythms |
Status: ദ്ദി(ᵔᗜᵔ) Complete
Localize brain activity
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 05.1 Source Localization | Inverse solutions | MEG/EEG | Forward/inverse modeling, dipoles |
| 05.2 ROI Analysis | Region-of-interest extraction | fMRI | Atlases, parcellation, timecourses |
Status: ദ്ദി(ᵔᗜᵔ) Complete
Map brain networks
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 06.1 EEG/MEG Connectivity | Phase locking, coherence | EEG/MEG | Functional connectivity metrics |
| 06.2 fMRI Networks | Resting-state networks | fMRI | Correlation matrices, graph theory |
Status: ദ്ദി(ᵔᗜᵔ) Complete
Decode brain states
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 07.1 EEG Decoding | Classification basics | EEG | Scikit-learn, cross-validation |
| 07.2 fMRI MVPA | Multi-voxel pattern analysis | fMRI | Searchlight, classification |
| 07.3 Cross-Validation | Proper validation strategies | All | Nested CV, permutation testing |
Status: ദ്ദി(ᵔᗜᵔ) Complete
End-to-end neural networks
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 08.1 EEG CNN | Convolutional neural nets | EEG | PyTorch, CNN architectures |
| 08.2 EEG RNN | Recurrent neural nets | EEG | LSTM, temporal modeling |
| 08.3 fMRI 3D CNN | Volumetric deep learning | fMRI | 3D convolutions, attention |
Status: ദ്ദി(ᵔᗜᵔ) Complete
Combine different brain imaging modalities
| Tutorial | Focus | Modality | Key Skills |
|---|---|---|---|
| 09.1 EEG-fMRI Fusion | Joint analysis | EEG + fMRI | Feature fusion, co-registration |
| 09.2 MEG-fMRI Fusion | Temporal + spatial integration | MEG + fMRI | Source space fusion |
Status: ദ്ദി(ᵔᗜᵔ) Complete
git clone https://github.com/YOUR_USERNAME/neuro-ai-playground.git
cd neuro-ai-playgroundpython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtjupyter notebookThen navigate to tutorials/ and open any notebook to get started!
| Purpose | Libraries |
|---|---|
| EEG/MEG Analysis | MNE-Python |
| fMRI Analysis | Nilearn |
| Machine Learning | scikit-learn |
| Deep Learning | PyTorch |
| Multimodal Fusion | EEG+fMRI feature fusion, co-registration workflows |
| Visualization | matplotlib, seaborn |
| Data & Numerics | nibabel, pandas, numpy, scipy |
All datasets can be downloaded through the notebooks in each corresponding tutorial.
| Dataset | Modality | Description | Size |
|---|---|---|---|
| MNE Sample | MEG/EEG | Auditory/Visual task (used in 7.1, 8.1, 8.2, 9.2) | ~1.5 GB |
| Nilearn Development | fMRI | Resting-state fMRI (used in 6.2) | ~10 MB |
| Haxby 2001 | fMRI | Visual object categories + VT mask (used in 7.2, 8.3, 9.1, 9.2) | ~150 MB |
| OpenNeuro ds000117 | fMRI | Famous faces task | ~50 GB |
| OpenNeuro ds003775 | EEG | Motor imagery | ~5 GB |
Contributions are welcome! You can:
- Add new tutorials
- Improve existing notebooks
- Add documentation or examples
- Report bugs or suggest features
Please open a Pull Request or Issue on GitHub.
If you use this repository in your research or education, please cite:
@software{neuro_ai_playground,
author = {Wang Chen, Yibei},
title = {Neuro-AI Playground: A Learning Lab for Neuroimaging Analysis},
year = {2025},
url = {https://github.com/YOUR_USERNAME/neuro-ai-playground}
}This repository is licensed under the MIT License.
You are free to use, modify, and distribute for educational and research purposes.
Created with ♡ by Yibei Wang Chen