REVE: A Foundation Model for EEG - Adapting to Any Setup with Large-Scale Pretraining on 25,000 Subjects
Codebase for REVE (EEG foundation model):
- Foundation pretraining (MAE-style) in
src/train.py - Downstream linear probing / fine-tuning in
src/dt.py - Optuna search for downstream hyperparameters in
src/dt_opt.py - Evaluation utility in
src/eval_dt.py
src/: training, downstream, models, and utilitiessrc/configs/: Hydra configuration tree for all runspreprocessing/: dataset conversion/preparation scriptshf/: Hugging Face export artifacts and wrappers.scripts/: helper launch scripts
Detailed docs:
Python requirement comes from pyproject.toml (>=3.11).
Using uv:
uv syncUsing pip (alternative):
python -m venv .venv
source .venv/bin/activate
pip install -e .Then run scripts directly with python, accelerate, or torchrun.
All training/eval scripts use Hydra configs from src/configs.
- Pretraining root config:
src/configs/config_train.yaml - Downstream root config:
src/configs/config_dt.yaml
Read the full config documentation here:
Main entrypoint:
accelerate launch src/train.py --config-name config_train.yamlCommon overrides:
accelerate launch src/train.py --config-name config_train.yaml \
data.path=/path/to/preprocessed_foundation_data \
checkpointing.path=/path/to/checkpoints \
trainer.batch_size=256 \
trainer.lr=3e-4Switch encoder variant:
accelerate launch src/train.py --config-name config_train.yaml encoder=smallHelper wrapper:
bash .scripts/train.shMain entrypoint:
torchrun --nproc_per_node=gpu src/dt.py \
--config-name config_dt.yaml \
task=bciciv2a \
data_root=/path/to/downstream_data \
pretrained_path=hf:brain-bzh/reve-base \
training_mode=lpRun both stages (linear probing then fine-tuning):
torchrun --nproc_per_node=gpu src/dt.py \
--config-name config_dt.yaml \
task=bciciv2a \
data_root=/path/to/downstream_data \
pretrained_path=/path/to/encoder.pth \
training_mode=lp+ftAdjust stage hyperparameters inline:
torchrun --nproc_per_node=gpu src/dt.py \
--config-name config_dt.yaml \
task=bciciv2a \
data_root=/path/to/downstream_data \
training_mode=lp \
task.linear_probing.n_epochs=50 \
task.linear_probing.optimizer.lr=1e-3Helper wrapper for all tasks:
bash .scripts/dt.sh /path/to/downstream_datatorchrun --nproc_per_node=gpu src/dt_opt.py \
--config-name config_dt.yaml \
task=bciciv2a \
data_root=/path/to/downstream_data \
pretrained_path=hf:brain-bzh/reve-base \
n_runs=50dt_opt.py reads optuna:* parameter declarations from config values (for example in task/bciciv2a.yaml).
By default src/eval_dt.py loads model_best.pth from current run directory.
python src/eval_dt.py \
--config-name config_dt.yaml \
task=bciciv2a \
data_root=/path/to/downstream_data \
checkpoint_path=/path/to/model_best.pthPreprocessing scripts live in preprocessing/ and are dataset-specific.
Examples:
python preprocessing/preprocessing_bciciv2a.py --raw /path/raw --processed /path/processed
python preprocessing/preprocessing_physio.py --root /path/raw --processed /path/processed --type reve
python preprocessing/ISRUC/prepare_ISRUC.py --raw /path/raw --processed /path/out/{}See full notes here:
Part of the dataset (for which the license allows redistribution) is available on Hugging Face:
More documentation on how to use the dataset will be provided soon.
- Hydra sets run directories (see
hydra.run.dirin config files), and scripts usehydra.job.chdir: true. - Set environment variables expected by config interpolations (for example
SCRATCH) if you rely on${env:SCRATCH}defaults. - Downstream tasks and dataset metadata are defined in
src/configs/task/*.yaml.
Special thanks to all the people who contributed to the codebase.
- Timotée Ly-Manson
- Alix Lamouroux
If you use this repository or pretrained REVE models, cite:
@article{elouahidi2025reve,
title = {{REVE}: A Foundation Model for {EEG}: Adapting to Any Setup with Large-Scale Pretraining on 25,000 Subjects},
author = {El Ouahidi, Yassine and Lys, Jonathan and Thölke, Philipp and Farrugia, Nicolas and Pasdeloup, Bastien and Gripon, Vincent and Jerbi, Karim and Lioi, Giulia},
journal = {Advances in Neural Information Processing Systems},
year = {2025},
url = {https://brain-bzh.github.io/reve/}
}Machine-readable citation metadata is available in CITATION.cff.