Official implementation of Uni-DMFM: A Universal Dynamic Multi-Scale Foundation Model for EEG Representation Learning, published in Pattern Recognition, 2026.
conda create -n unidmfm python=3.10
conda activate unidmfm
pip install -r requirements.txtUni-DMFM is pretrained on the TUEG corpus. Before running the script, set the raw TUEG dataset path and the output path in the file. Then run:
python preprocessing/TUEG_dataset/preprocessing_tueg_for_pretraining.pyThe pretrained checkpoint can be downloaded from here. After downloading, place it under:
checkpoint/pretrained_weights.pthPlace downstream EEG classification datasets under the project-level DATA directory. Then run the preprocessing script:
bash preprocessing/data_preprocess.shThen generate JSON split files for downstream fine-tuning:
bash preprocessing/json_process.shRun pretraining with:
python pretrain.py \
--epochs 50 \
--batch_size 32 \
--cuda 0 \
--pretrain_data DATA/TUEG_dataset \
--model_dirRun downstream classification fine-tuning with:
python finetune.py \
--dataset SEED \
--subject_mod cross \
--finetune_mod full \
--epochs 50 \
--batch_size 64 \
--device cudaIf you find this repository useful for your research, please cite:
@article{CHEN2026114221,
title = {Uni-DMFM: A universal dynamic multi-scale foundation model for EEG representation learning},
journal = {Pattern Recognition},
volume = {180},
pages = {114221},
year = {2026},
issn = {0031-3203},
doi = {https://doi.org/10.1016/j.patcog.2026.114221},
url = {https://www.sciencedirect.com/science/article/pii/S0031320326011866},
author = {Wensheng Chen and Yurong Li and Jiyu Tan and Xiaojing Xue and Zhenhua Zhao},
}