File size: 9,668 Bytes
fad3523 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | ---
license: bsd-3-clause
language:
- en
tags:
- eeg
- biosignal
- tutorials
- notebooks
- braindecode
- neuroscience
- brain-computer-interface
pretty_name: Braindecode Tutorials
size_categories:
- n<1K
---
# Braindecode Tutorials
Curated collection of **31 executable Jupyter notebooks** showing how to use
[braindecode](https://braindecode.org) for end-to-end EEG / biosignal deep
learning: data loading, preprocessing, model training, fine-tuning of
foundation models, and Hugging Face Hub integration.
> Each notebook is mirrored from the
> [`examples/`](https://github.com/braindecode/braindecode/tree/master/examples)
> directory of the upstream repo. They are auto-converted from the
> sphinx-gallery `.py` source on every release; the canonical rendered
> versions live at <https://braindecode.org/stable/auto_examples>.
## How to use this dataset repo
Three options, in increasing order of convenience:
| Option | What you do |
|---|---|
| **Open in Colab** | Click any `▶ Colab` link below. Free GPU runtime; no install. |
| **Download** | `huggingface-cli download braindecode/tutorials --repo-type dataset --local-dir tutorials/` |
| **Browse rendered HTML** | <https://braindecode.org/stable/auto_examples> (sphinx-gallery output). |
Each notebook installs braindecode in the first cell, so it's runnable
on a fresh kernel.
## Catalogue
### Getting started — datasets & I/O
| Notebook | Topic | Run |
|---|---|---|
| `plot_moabb_dataset_example.ipynb` | Load a MOABB dataset (BNCI 2014-001) | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_moabb_dataset_example.ipynb) |
| `plot_mne_dataset_example.ipynb` | Wrap an `mne.io.Raw` as a braindecode dataset | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_mne_dataset_example.ipynb) |
| `plot_bids_dataset_example.ipynb` | Load a BIDS-formatted EEG dataset | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_bids_dataset_example.ipynb) |
| `plot_custom_dataset_example.ipynb` | Roll your own dataset class | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_custom_dataset_example.ipynb) |
| `plot_load_save_datasets.ipynb` | Cache datasets to disk and reload them | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_load_save_datasets.ipynb) |
| `plot_split_dataset.ipynb` | Train/valid/test splits at session and subject level | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_split_dataset.ipynb) |
| `plot_benchmark_preprocessing.ipynb` | Compare preprocessing strategies head-to-head | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_benchmark_preprocessing.ipynb) |
| `plot_tuh_discrete_multitarget.ipynb` | TUH multi-target discrete labels | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_tuh_discrete_multitarget.ipynb) |
| `plot_hub_integration.ipynb` | Push / pull braindecode datasets to the Hub | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/datasets_io/plot_hub_integration.ipynb) |
### Model building & training
| Notebook | Topic | Run |
|---|---|---|
| `plot_basic_training_epochs.ipynb` | Train any braindecode model in a few cells | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_basic_training_epochs.ipynb) |
| `plot_train_in_pure_pytorch_and_pytorch_lightning.ipynb` | Pure-PyTorch and Lightning training loops | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_train_in_pure_pytorch_and_pytorch_lightning.ipynb) |
| `plot_bcic_iv_2a_moabb_trial.ipynb` | BCI Competition IV 2a — trial-wise decoding | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_bcic_iv_2a_moabb_trial.ipynb) |
| `plot_bcic_iv_2a_moabb_cropped.ipynb` | BCI Competition IV 2a — cropped decoding | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_bcic_iv_2a_moabb_cropped.ipynb) |
| `plot_bcic_iv_2a_eegprep_cleaning.ipynb` | EEG-Prep cleaning before training | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_bcic_iv_2a_eegprep_cleaning.ipynb) |
| `plot_load_pretrained_models.ipynb` | **Load BENDR / BIOT / EEGPT from the Hub and fine-tune** | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_load_pretrained_models.ipynb) |
| `plot_how_train_test_and_tune.ipynb` | Cross-validation and hyper-parameter tuning | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_how_train_test_and_tune.ipynb) |
| `plot_hyperparameter_tuning_with_scikit-learn.ipynb` | scikit-learn `GridSearchCV` over braindecode | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_hyperparameter_tuning_with_scikit-learn.ipynb) |
| `plot_preprocessing_classes.ipynb` | The `Preprocessor` API | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_preprocessing_classes.ipynb) |
| `plot_channel_interpolation.ipynb` | Bad-channel interpolation | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_channel_interpolation.ipynb) |
| `plot_regression.ipynb` | EEG regression instead of classification | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/model_building/plot_regression.ipynb) |
### Advanced training
| Notebook | Topic | Run |
|---|---|---|
| `plot_data_augmentation.ipynb` | EEG-specific augmentations | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/advanced_training/plot_data_augmentation.ipynb) |
| `plot_data_augmentation_search.ipynb` | Search over augmentation policies | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/advanced_training/plot_data_augmentation_search.ipynb) |
| `plot_relative_positioning.ipynb` | Self-supervised pretext tasks | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/advanced_training/plot_relative_positioning.ipynb) |
| `plot_temporal_generalization.ipynb` | Temporal-generalisation matrices | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/advanced_training/plot_temporal_generalization.ipynb) |
| `plot_finetune_foundation_model.ipynb` | Fine-tune a Hub foundation model end-to-end | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/advanced_training/plot_finetune_foundation_model.ipynb) |
| `plot_moabb_benchmark.ipynb` | Run a full MOABB benchmark | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/advanced_training/plot_moabb_benchmark.ipynb) |
| `plot_exca_config.ipynb` | Reproducible experiments with `exca` | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/advanced_training/plot_exca_config.ipynb) |
### Applied examples
| Notebook | Topic | Run |
|---|---|---|
| `plot_sleep_staging_chambon2018.ipynb` | Sleep staging with Chambon2018 | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/applied_examples/plot_sleep_staging_chambon2018.ipynb) |
| `plot_sleep_staging_usleep.ipynb` | Sleep staging with U-Sleep | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/applied_examples/plot_sleep_staging_usleep.ipynb) |
| `plot_sleep_staging_eldele2021.ipynb` | Sleep staging with Eldele2021 | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/applied_examples/plot_sleep_staging_eldele2021.ipynb) |
| `plot_tuh_eeg_corpus.ipynb` | Working with the TUH EEG corpus | [▶ Colab](https://colab.research.google.com/github/braindecode/braindecode/blob/master/examples/applied_examples/plot_tuh_eeg_corpus.ipynb) |
## How the notebooks are produced
Sphinx-gallery automatically generates a `.ipynb` next to each rendered
HTML page during the docs build. The conversion script for this
dataset repo simply collects those generated notebooks:
```bash
# in the braindecode repo
cd docs && make html # builds HTML + .ipynb files
python ../hf_assets/tutorials_index/build_notebooks.py # gathers .ipynb
```
See `build_notebooks.py` for the gather + push logic.
## Cost note
Hosting `.ipynb` files in a public dataset repo is **free** on Hugging
Face. Compute (Colab) is also free for the small datasets used in these
tutorials. No paid tier is required.
## Citation
```bibtex
@article{aristimunha2025braindecode,
title = {Braindecode: a deep learning library for raw electrophysiological data},
author = {Aristimunha, Bruno and others},
journal = {Zenodo},
year = {2025},
doi = {10.5281/zenodo.17699192},
}
```
|