National University of Singapore / Nanyang Technological University / Chinese Academy of Sciences
EEG foundation model pairing a decoupled time-frequency tokenizer with a multi-scale state-space encoder for generalization under distribution shift.
EEG foundation models promise to replace the sprawl of task-specific classifiers — one for sleep staging, another for seizure detection, another for motor imagery — with a single pretrained encoder. In practice most have inherited two weaknesses. They compress temporal waveform and spectral rhythm into a single entangled token stream, which makes the learned codes hard to relate back to recognizable neural events, and they lean on either global attention or purely local convolution, capturing one scale of dependency at the cost of the other.
CodeBrain, from the Saw Swee Hock School of Public Health and Institute of Data Science at the National University of Singapore with collaborators at Nanyang Technological University and the Institute of Automation of the Chinese Academy of Sciences, attacks both. Its two-stage design first learns separate discrete codebooks for the temporal and frequency views of each EEG patch, then trains a multi-scale encoder to predict those codes from masked input. The architecture is motivated explicitly by the brain's small-world topology: sparse long-range connections handled by structured global convolution, dense local structure by sliding window attention.
It sits directly in the lineage of tokenizer-based EEG models such as LaBraM and CBraMod, and the paper benchmarks against both. CodeBrain was published at ICLR 2026.
Pretraining uses the Temple University Hospital EEG Corpus (TUEG), the largest public EEG dataset. Recordings are standardized to 19 channels at 200 Hz, split into 30-second segments, amplitude-filtered, and divided into 1-second patches — 570 patches per sample, yielding 1,109,545 samples or roughly 9,246 hours after preprocessing. The tokenizer uses temporal and frequency codebooks of 4,096 codes at 32 dimensions each, trained for 20 epochs across six A100 GPUs. The released backbone is an 8-layer EEGSSM with hidden size 200 and 15.17M parameters, trained for 10 epochs at a 0.5 masking ratio.
Across eight tasks and ten datasets, CodeBrain leads the strongest prior foundation model, CBraMod, on the representative benchmarks: Cohen's Kappa of 0.5406 versus 0.5041 on 9-class FACED emotion recognition, 0.2735 versus 0.2569 on 5-class SEED-V, 0.7671 versus 0.7407 on ISRUC-S3 sleep staging, and 0.5127 versus 0.4216 on BCIC 2020-T3 imagined speech. The comparison set also includes task-specific models (EEGNet, EEGConformer, ST-Transformer) and foundation models BENDR, BIOT, LaBraM, and EEGPT. Scaling experiments run from a 3-layer/3.86M model to a 24-layer/146.75M model; Kappa improves monotonically with both data and parameters but with diminishing returns, which is why the 8-layer configuration is the released default.
The pretrained encoder is a general-purpose starting point for clinical and research EEG pipelines — sleep staging, seizure and abnormality detection from hospital recordings, emotion recognition, motor imagery and imagined-speech brain-computer interfaces, and mental stress monitoring. Because it is small enough to fine-tune on a single GPU, it is practical for labs without large compute budgets. The interpretable codebook gives neuroscientists an additional handle: token identity can be inspected against spectral bands rather than treated as an opaque embedding.
CodeBrain's main contribution is showing that architectural choices, not just corpus size, determine whether an EEG foundation model generalizes across cohorts and montages. Pretrained weights for both the tokenizer and the EEGSSM encoder are on Hugging Face under Apache 2.0, and training, fine-tuning, and preprocessing code is on GitHub, though the code repository itself carries no license file. One honest caveat the authors raise: TUAB and TUEV both derive from the same TUH corpus used for pretraining, so those two benchmarks partially overlap the pretraining distribution and pretraining is deliberately stopped early to limit overfitting to it.
Papers that recently cited this model.
The most-cited papers that cite this model.
Providers that host CodeBrain for inference, fine-tuning, or weight download.
No providers recorded yet. Browse all providers
Not enough data