Discrete by design
Each channel is tokenized by a VQ-based tokenizer, so the model predicts code indices instead of waveform power.
1University of Southern California · 2Microsoft Research
BrainCodes is a lightweight EEG foundation model with 1.9M trainable parameters, pretrained through self-supervised learning on more than 800 hours of EEG recordings from over 1,000 participants.
Most EEG foundation models are pretrained to reconstruct masked signal patches. Under a squared-error loss, high-power broadband activity dominates the objective, and a masked channel can largely be recovered by interpolating its neighbors, so a model can fit the signal well without retaining its rhythms or spatial structure. BrainCodes instead predicts the discrete codes of a frozen vector-quantized tokenizer, encodes relative electrode positions directly in channel attention, and adds an auxiliary objective that localizes synthetic oscillatory bursts. It matches or surpasses the state of the art across 14 benchmarks and transfers to consumer wearable devices.
Each channel is tokenized by a VQ-based tokenizer, so the model predicts code indices instead of waveform power.
Electrodes are modeled through rotary encodings of their 3D relative positions, so they are agnostic to the utilized layout.
A tuned lightweight backbone matches or surpasses the state of the art across 14 different performance benchmarks.
(B, C, T) at 250 Hz, from any number of channels with provided 3D coordinates.
Frozen BioCodec: 6 RVQ codes per channel, resulting in a 128D input embedding.
A 3-layer, factorized time-channel U-Net with 3D rotary channel encoding.
Per-channel bottleneck features for probing downstream evaluation.
| Model | Params | TUAB | TUEV | ISRUC | Siena | Phy-MI | BCI IV-2a | EEGMAT | Mean nBAC |
|---|---|---|---|---|---|---|---|---|---|
| BIOT | 3.2M | 0.796 | 0.528 | 0.753 | 0.735 | 0.615 | 0.475 | 0.688 | 0.478 |
| LaBraM-Base | 5.8M | 0.814 | 0.641 | 0.763 | 0.708 | 0.617 | 0.487 | 0.691 | 0.501 |
| CBraMod | 4.0M | 0.829 | 0.667 | 0.787 | 0.732 | 0.642 | 0.514 | 0.726 | 0.540 |
| REVE-Base | 69M | 0.832 | 0.676 | 0.782 | 0.740 | 0.648 | 0.640 | 0.766 | 0.581 |
| BrainCodes | 1.9M | 0.811 | 0.690 | 0.796 | 0.827 | 0.664 | 0.639 | 0.772 | 0.609 |
The released package ships pretrained weights and a minimal API. Full documentation lives in the associated GitHub repository.
git clone https://github.com/microsoft/BrainCodes.git
cd BrainCodes && pip install -e .
# the frozen BioCodec tokenizer is a separate download
git clone https://github.com/klean2050/BioCodec-release.git
import torch
from braincodes import BrainCodesModel
ch_names = ["TP9", "AF7", "AF8", "TP10"]
model = BrainCodesModel.from_pretrained(ch_names, device="cuda")
eeg = torch.randn(8, 4, 1000) # (B, C, T) @ 250 Hz
emb = model.embed(eeg, pool="channel") # (B, C*D)
clf = model.build_classifier(num_classes=4, mode="linear_probe")
logits = clf(model.tokenize(eeg))
@article{braincodes2026,
title = {BrainCodes: A Lightweight EEG Foundation Model over Discrete Neural Codes},
author = {Avramidis, Kleanthis and Emmanouilidou, Dimitra and Tashev, Ivan},
year = {2026}
}
BrainCodes is hereby released for neuroscientific research. It is not intended to support clinical, diagnostic, or other high-impact decisions about individuals. The present release includes model parameters only, and no guidance or implementation for a specific downstream task.