Compact EEG foundation model pretrained on discrete codec tokens, transferring to sleep staging, motor imagery and four-electrode wearables.
No providers recorded yet. Browse all providers
Most self-supervised EEG models learn by reconstructing masked parts of a recording, as a waveform or a spectrum. That objective fits EEG poorly. Scalp EEG follows a roughly 1/f power spectrum, so a squared-error loss is dominated by high-power broadband activity, and a model can score well while ignoring the low-power narrowband rhythms (alpha, mu, sleep spindles) that often carry the signal of interest. Neighbouring electrodes also record overlapping mixtures of the same sources, so a masked channel can be filled in by spatial interpolation without the model learning anything about brain dynamics.
BrainCodes, from Microsoft Research, changes what the model predicts. Each EEG channel is first converted into discrete code indices by a frozen residual vector-quantized tokenizer, BioCodec. The model is then trained to predict the missing codes in masked spans. Because this is a categorical prediction rather than a regression on signal power, high-amplitude components do not automatically dominate the loss. Two further design choices push the representation toward physiology. An auxiliary objective asks the model to recover the frequency, duration and location of synthetic narrowband bursts injected into the recording. Electrode positions enter attention as relative 3D displacements, so the model learns from the geometry between sensors rather than their absolute placement.
The work was led by Kleanthis Avramidis of the Signal Analysis and Interpretation Lab at the University of Southern California, during an internship at Microsoft Research, with Ivan Tashev and Dimitra Emmanouilidou. It was posted to arXiv in October 2026. The code and the pretrained encoder checkpoint are public in the MIT-licensed GitHub repository.
The backbone is a three-block transformer U-Net. Each block has two temporal-attention layers and one channel-attention layer, and time is pooled by a factor of 4 into a 128-dimensional bottleneck. BioCodec emits about 21 code frames per second per channel at 250 Hz and is excluded from the parameter count. Pretraining used releases R3, R4, R7 and R8 of the Healthy Brain Network EEG dataset: about 820 hours from 1,131 children and adolescents on a 128-channel montage. Training windows ranged from 2 to 30 seconds and used random channel subsets.
The model was evaluated on 14 downstream tasks. On seven standard benchmarks under full fine-tuning (TUAB, TUEV, Siena, PhysioNet-MI, BCI IV-2a, EEGMAT, ISRUC), BrainCodes led on five and reached a mean chance-normalized balanced accuracy of 0.609. The comparison models were BIOT (0.478), LaBraM-Base (0.501), CBraMod (0.540) and REVE-Base (0.581). It trailed REVE-Base and CBraMod on TUAB, the dataset with the most training data. On three consumer-hardware datasets (in-ear sleep staging on EESM23 and two four-electrode Muse headband tasks), it reached a mean normalized score of 0.513, against 0.418 for the best baseline. Grounding probes found that its channel interactions decay with inter-electrode distance more sharply than those of CSBrain or CBraMod, and that it favours narrowband rhythms over broadband noise colour.
BrainCodes is aimed at EEG researchers who need a pretrained encoder on modest hardware: sleep staging, motor-imagery brain–computer interfaces, mental-workload and attention monitoring, and event or seizure classification. Its montage flexibility matters most for wearables with only a few electrodes. The package provides tokenization, embedding extraction and classifier construction but no trained task heads, and the model card excludes clinical and diagnostic use.
Recent EEG foundation models have mostly grown by adding parameters and data. BrainCodes argues the other way: an objective built around known properties of the signal can match larger models with a fraction of the parameters. Its probes of spatial locality and spectral sensitivity also give the field a way to compare encoders beyond benchmark accuracy. The paper is a preprint under review. All pretraining data comes from a single developmental cohort, so performance on adult and clinical populations is less well established. The paper reports the first systematic benchmark of EEG foundation models on consumer-grade wearable hardware.
Much of this page is generated or calculated automatically. Flag anything that looks off and we will re-run it.