BrainCodes: A Lightweight EEG Foundation Model over Discrete Neural Codes
Authors: Kleanthis Avramidis, Ivan Tashev, Dimitra Emmanouilidou
Organizations: Signal Analysis and Interpretation Lab, University of Southern California, Los Angeles, CA 90007, USA · Microsoft Research, Redmond, WA, USA
Recent electroencephalography (EEG) foundation models increasingly emphasize model scale, potentially limiting their deployment on resource-constrained devices and in everyday environments. We argue that transferable EEG features can instead be learned with a compact architecture and introduce BrainCodes, a lightweight foundation model pretrained through self-supervised learning on more than 800 hours of recordings from over 1,000 participants. Our architecture combines a quantization-based neural tokenizer with a spatiotemporal encoder that supports arbitrary electrode configurations. The pretraining objective explicitly encourages representations that capture spatial connectivity through channel positional encoding, and sensitivity to narrowband neural oscillations through an auxiliary training objective. Our model matches or surpasses the state of the art across diverse neurophysiological monitoring tasks, including sleep staging, attention assessment, and cognitive load estimation. BrainCodes transfers effectively to low-resource wearable devices while using up to 97% fewer trainable parameters than comparable architectures. Beyond predictive accuracy, our evaluation framework characterizes the geometry and invariances of learned EEG representations across measurable spatial, temporal, and spectral signal properties.
Figures & tables
Figure 1: The pretraining objectives of BrainCodes . A) Contiguous blocks of codes are masked and the model predicts the missing indices, evaluated through mean cross-entropy over the masked positions ( Ltok ). B) Narrowband bursts are injected into regions of electrodes and the bottleneck is read by linear heads for its frequency, duration and location ( Losc ).
Dataset
Category
Channels
Length (s)
Classes
Samples
Participants
Main Bench
TUAB
Clinical
21
10
2
409,455
2,329
TUEV
Events
16
5
6
106,394
370
Siena
Seizures
29
10
2
50,749
14
PhysioNet-MI
Motor
64
4
4
9,838
109
BCI IV-2a
Motor
22
4
4
5,184
9
Table 1: EEG datasets used for downstream inference. ERP stands for event-related potentials.
Methods
Size
TUAB
TUEV
ISRUC
Siena
EEGNet
0.1M
0.764 ± 0.004
0.388 ± 0.014
0.715 ± 0.012
0.749 ± 0.052
EEGConformer
0.8M
0.776 ± 0.005
0.407 ± 0.016
0.740 ± 0.013
0.756 ± 0.021
SPaRCNet
0.8M
0.790 ± 0.002
0.416 ± 0.026
0.749 ± 0.008
0.657 ± 0.038
ContraWR
1.6M
0.775 ± 0.004
0.438 ± 0.035
0.740 ± 0.013
0.655 ± 0.031
CNN-Transformer
3.2M
0.778 ± 0.002
0.409 ± 0.016
0.736 ± 0.009
0.698 ± 0.056
ST-Transformer
2.6M
0.797 ± 0.002
0.398 ± 0.023
0.738 ± 0.021
0.753 ± 0.038
Table 2: Balanced accuracy on the main-bench datasets under full fine-tuning, mean ± s.d. over seeds. Mean nBAC is the chance-normalized mean over all seven datasets, with uncertainty propagated from the per-dataset deviations. Best per column in bold , second best underlined .
CBraMod
REVE-Base
BrainCodes
Dataset
Best config
Best config
bc
bˉc
EEGMAT (2-class)
0.6050 ± 0.0200
0.7400 ± 0.0730
0.7430 ± 0.0175
0.7097 ± 0.0225
PhysioNet-MI (4-class)
0.5310 ± 0.0150
0.5370 ± 0.0050
0.4137 ± 0.0076
0.4953 ± 0.0055
BCIC-IV-2a (4-class)
0.3760 ± 0.0060
0.5170 ± 0.0150
0.5023 ± 0.0096
0.5628 ± 0.0025
TUEV (6-class)
0.4820 ± 0.0370
0.5920 ± 0.0080
0.5406 ± 0.0052
0.5875 ± 0.0155
Siena (2-class) ∗
0.7320 ± 0.0660
0.7400 ± 0.0070
0.8747 ± 0.0005
0.7830 ± 0.0340
Table 3: Linear probe performance on frozen encoders (BAC, mean ± s.d. over 3 seeds). bc is the time-averaged bottleneck feature and bˉc the concatenated one, both as defined in Section 2.3 .
Model
Size
EESM23
Muse-Motor
Muse-Mental
Mean nBAC
LaBraM-Base
5.8M
0.4109 ± 0.0087
0.4720 ± 0.0048
0.8245 ± 0.1446
0.4126 ± 0.0724
CBraMod
4.0M
0.3993 ± 0.0163
0.5083 ± 0.0267
0.8079 ± 0.1812
0.4178 ± 0.0918
CSBrain
8.9M
0.3663 ± 0.0261
0.4452 ± 0.0349
0.7081 ± 0.2143
0.3232 ± 0.1091
REVE-Base
69M
0.4176 ± 0.0224
0.4485 ± 0.0240
0.7165 ± 0.2177
0.3495 ± 0.1099
BrainCodes
1.9M
0.5254 ± 0.0251
0.5889 ± 0.0318
0.8163 ± 0.0957
0.5128 ± 0.0514
Table 4: Balanced accuracy on low-resource, consumer wearables. Muse results are means over 4-fold cross-validation; EESM23 over 3 seeds on the test set used in ( Pradeepkumar et al., 2025 ) .
Figure 2: Grounding analysis of BrainCodes. (a–c) Spatial organization: influence of one electrode on another against inter-electrode distance, the fitted decay length λ relative to head width, and channel mixing against spatial locality. (d–f) Spectral selectivity under four-way injected rhythm identification, white-versus-pink noise control, and their difference as a preference index.
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
Methods
Size
Motor
ERP
Memory
Eyes
Mean nBAC
BIOT
3.2M
0.443 ± 0.079
0.500 ± 0.000
0.510 ± 0.018
0.763 ± 0.049
0.201 ± 0.037
CBraMod
4.0M
0.614 ± 0.104
0.777 ± 0.052
0.574 ± 0.038
0.839 ± 0.041
0.466 ± 0.052
EEGPT
25M
0.313 ± 0.035
0.668 ± 0.146
0.520 ± 0.017
0.797 ± 0.037
0.264 ± 0.077
NeuroGPT
79.5M
0.682 ± 0.083
0.757 ± 0.048
0.597 ± 0.029
0.827 ± 0.036
0.484 ± 0.043
BrainOmni †
33M
0.585 ± 0.058
0.723 ± 0.041
0.518 ± 0.023
0.852 ± 0.022
0.408 ± 0.032
LaBraM †
5.8M
0.630 ± 0.076
0.822 ± 0.040
0.526 ± 0.026
0.799 ± 0.047
0.450 ± 0.042
Appendix
Table 5: Model performance on the NeuroRVQ benchmark (balanced accuracy). External numbers are as published in Barmpas et al. (2025) . Sleep-EDF ( Kemp et al., 2000 ) was not included due to computational constraints in both studies. Best per column in bold , second best underlined .
Figure 3: Balanced accuracy as electrodes are removed by farthest-point sampling, with shading marking the standard deviation over seeds. Left: absolute performance, with dotted lines at chance. Right: fraction of each full-montage score, where each full montage sits at its own electrode count. ∗
Figure 4: Low-resource fine-tuning under independently varied participant and within-participant label budgets. (a,b) Mean balanced accuracy of BrainCodes across three seeds on PhysioNet-MI and OpenBMI-ERP. (c) Estimated gain in balanced-accuracy points per doubling of each budget axis. Error bars denote coefficient standard errors.
Ablated component
BCI IV-2a
EEGMAT
EESM23
Mean nBAC
MLP positional encoding
0.631 ± 0.007
0.698 ± 0.038
0.510 ± 0.010
0.439 ± 0.026
Random token masking
0.640 ± 0.032
0.753 ± 0.066
0.477 ± 0.038
0.466 ± 0.049
Codebook initialization
0.639 ± 0.020
0.677 ± 0.034
0.461 ± 0.026
0.409 ± 0.026
Auxiliary objective Losc
0.607 ± 0.025
0.670 ± 0.032
0.444 ± 0.021
0.383 ± 0.025
Official BrainCodes
0.639 ± 0.002
0.772 ± 0.015
0.525 ± 0.025
0.498 ± 0.014
Appendix
Table 6: Ablation study on the pretraining configuration. We report BAC on three sampled datasets from the main benchmark, with the average computed across all datasets in three seeds.
Tokenizer
Backbone
BCI IV-2a
EEGMAT
EESM23
Mean nBAC
BioCodec
BrainCodes
0.639 ± 0.002
0.772 ± 0.015
0.525 ± 0.025
0.498 ± 0.014
BioCodec
from scratch
0.531 ± 0.015
0.561 ± 0.047
0.429 ± 0.019
0.270 ± 0.033
Random
from scratch
0.319 ± 0.010
0.501 ± 0.002
0.392 ± 0.030
0.121 ± 0.013
Appendix
Table 7: Contributions of tokenizer and backbone pretraining. Values are fully fine-tuned mean balanced accuracy ± standard deviation over 3 seeds. The last column reports mean chance-normalized balanced accuracy. Random indicates an identical to BioCodec but randomly initialized RVQ.
Figure 5: Positional bias of the learned channel rotary encoding for a sample attention head from BrainCodes, seeded at each of eight electrodes, where the white marker gives the seed and the color gives the bias assigned to every other site. Top : frontal. Bottom : fronto-temporal and central.
Figure 6: Linear decoding of aperiodic and oscillatory spectral components from frozen representations on PhysioNet-MI, measured by within-channel R2 . (a) Decoding of the 1/f exponent and mean oscillatory power across the five canonical frequency bands from BioCodec and BrainCodes. (b) Band-specific decoding, with other EEG foundation models shown as reference markers.
Figure 7: Phase assigned by the learned channel rotary encoding to a 10–20 montage, for each of the eight attention heads. Columns: the three rotation pairs of largest frequency magnitude, ordered by decreasing magnitude, and the mean over the remaining five pairs.
Methods
Size
Balanced Accuracy
AUC-PR
AUROC
EEGNet
0.1M
0.7642 ± 0.0036
0.8299 ± 0.0043
0.8412 ± 0.0031
EEGConformer
0.8M
0.7758 ± 0.0049
0.8427 ± 0.0054
0.8445 ± 0.0038
SPaRCNet
0.8M
0.7896 ± 0.0018
0.8414 ± 0.0018
0.8676 ± 0.0012
ContraWR
1.6M
0.7746 ± 0.0041
0.8421 ± 0.0104
0.8456 ± 0.0074
CNN-Transformer
3.2M
0.7777 ± 0.0022
0.8433 ± 0.0039
0.8461 ± 0.0013
ST-Transformer
2.6M
0.7966 ± 0.0023
0.8521 ± 0.0026
0.8707 ± 0.0019
Appendix
Table 8: Model performance on abnormality detection (TUAB, 2-class).
Methods
Size
Balanced Accuracy
Cohen’s κ
Weighted F1
EEGNet
0.1M
0.3876 ± 0.0143
0.3577 ± 0.0155
0.6539 ± 0.0120
EEGConformer
0.8M
0.4074 ± 0.0164
0.3967 ± 0.0195
0.6983 ± 0.0152
SPaRCNet
0.8M
0.4161 ± 0.0262
0.4233 ± 0.0181
0.7024 ± 0.0104
ContraWR
1.6M
0.4384 ± 0.0349
0.3912 ± 0.0237
0.6893 ± 0.0136
CNN-Transformer
3.2M
0.4087 ± 0.0161
0.3815 ± 0.0134
0.6854 ± 0.0293
ST-Transformer
2.6M
0.3984 ± 0.0228
0.3765 ± 0.0306
0.6823 ± 0.0190
Appendix
Table 9: Model performance on event type classification (TUEV, 6-class).
Methods
Size
Balanced Accuracy
Cohen’s Kappa
Weighted F1
EEGNet
0.1M
0.7154 ± 0.0121
0.7040 ± 0.0173
0.7513 ± 0.0124
EEGConformer
0.8M
0.7400 ± 0.0133
0.7143 ± 0.0162
0.7634 ± 0.0151
SPaRCNet
0.8M
0.7487 ± 0.0075
0.7097 ± 0.0132
0.7624 ± 0.0092
ContraWR
1.6M
0.7402 ± 0.0126
0.7178 ± 0.0156
0.7610 ± 0.0137
CNN-Transformer
3.2M
0.7363 ± 0.0087
0.7129 ± 0.0121
0.7719 ± 0.0105
ST-Transformer
2.6M
0.7381 ± 0.0205
0.7013 ± 0.0352
0.7681 ± 0.0175
Appendix
Table 10: Model performance on sleep staging (ISRUC, 5-class).
Methods
Size
Balanced Accuracy
AUC-PR
AUROC
EEGNet
0.1M
0.7487 ± 0.0521
0.3753 ± 0.0867
0.8687 ± 0.0527
EEGConformer
0.8M
0.7556 ± 0.0210
0.2091 ± 0.0786
0.8159 ± 0.0261
SPaRCNet
0.8M
0.6572 ± 0.0381
0.3164 ± 0.0659
0.7334 ± 0.0857
ContraWR
1.6M
0.6546 ± 0.0311
0.3711 ± 0.0405
0.7819 ± 0.0596
CNN-Transformer
3.2M
0.6982 ± 0.0560
0.3835 ± 0.0709
0.8719 ± 0.0403
ST-Transformer
2.6M
0.7527 ± 0.0381
0.3636 ± 0.0252
0.8884 ± 0.0091
Appendix
Table 11: Model performance on seizure detection (Siena, 2-class).
Methods
Size
Balanced Accuracy
Cohen’s κ
Weighted F1
EEGNet
0.1M
0.5814 ± 0.0125
0.4468 ± 0.0199
0.5796 ± 0.0115
EEGConformer
0.8M
0.6049 ± 0.0104
0.4736 ± 0.0171
0.6062 ± 0.0095
SPaRCNet
0.8M
0.5932 ± 0.0152
0.4564 ± 0.0234
0.5937 ± 0.0147
ContraWR
1.6M
0.5892 ± 0.0133
0.4527 ± 0.0248
0.5918 ± 0.0116
CNN-Transformer
3.2M
0.6053 ± 0.0118
0.4725 ± 0.0223
0.6041 ± 0.0105
ST-Transformer
2.6M
0.6035 ± 0.0081
0.4712 ± 0.0199
0.6053 ± 0.0075
Appendix
Table 12: Model performance on motor imagery (PhysioNet-MI, 4-class).
Methods
Size
Balanced Accuracy
Cohen’s κ
Weighted F1
EEGNet
0.1M
0.4482 ± 0.0094
0.2693 ± 0.0121
0.4226 ± 0.0108
EEGConformer
0.8M
0.4696 ± 0.0106
0.2924 ± 0.0141
0.4533 ± 0.0128
SPaRCNet
0.8M
0.4635 ± 0.0117
0.2847 ± 0.0147
0.4432 ± 0.0126
ContraWR
1.6M
0.4678 ± 0.0125
0.2905 ± 0.0160
0.4413 ± 0.0142
CNN-Transformer
3.2M
0.4600 ± 0.0108
0.2800 ± 0.0148
0.4460 ± 0.0114
ST-Transformer
2.6M
0.4575 ± 0.0145
0.2733 ± 0.0198
0.4471 ± 0.0142
Appendix
Table 13: Model performance on motor imagery (BCIC-IV-2a, 4-class).
Methods
Size
Balanced Accuracy
AUC-PR
AUROC
EEGNet
0.1M
0.6770 ± 0.0116
0.5763 ± 0.0102
0.7321 ± 0.0108
EEGConformer
0.8M
0.6805 ± 0.0123
0.5829 ± 0.0134
0.7424 ± 0.0128
SPaRCNet
0.8M
0.6879 ± 0.0107
0.5825 ± 0.0193
0.7418 ± 0.0132
ContraWR
1.6M
0.6631 ± 0.0097
0.5787 ± 0.0164
0.7332 ± 0.0082
CNN-Transformer
3.2M
0.6779 ± 0.0268
0.5777 ± 0.0285
0.7258 ± 0.0336
ST-Transformer
2.6M
0.6631 ± 0.0173
0.5672 ± 0.0259
0.7132 ± 0.0174
Appendix
Table 14: Model performance on mental stress detection (EEGMAT, 2-class).
Models
Size
Balanced Accuracy
Cohen’s κ
Weighted F1
BIOT
3.2M
0.3858 ± 0.0085
0.3406 ± 0.0096
0.4888 ± 0.0124
BIOT-TFM
3.2M
0.3952 ± 0.0170
0.3603 ± 0.0252
0.5033 ± 0.0165
LaBraM-Base
5.8M
0.3890 ± 0.0182
0.3322 ± 0.0232
0.4827 ± 0.0157
LaBraM-TFM
5.8M
0.4004 ± 0.0086
0.3475 ± 0.0128
0.4864 ± 0.0118
TFM-Tokenizer
1.9M
0.4148 ± 0.0209
0.3883 ± 0.0233
0.5174 ± 0.0141
Reproduced:
Appendix
Table 15: Model performance on low-resource sleep staging (EESM23, 6-class).
Dataset
Balanced Accuracy
Cohen’s κ
Weighted F1
Muse-Motor (3-class)
0.5885 ± 0.0318
0.3650 ± 0.0516
0.5800 ± 0.0298
Muse-Mental (3-class)
0.8160 ± 0.0957
0.7097 ± 0.1287
0.8125 ± 0.0793
Appendix
Table 16: Detailed results (over 4 cross-validation folds) of BrainCodes on the Muse tasks.
Dataset
Head
Peak LR
Epochs (warmup)
Batch
TUAB
bˉc
5×10 −4
10 (2)
128
TUEV
bˉc
5×10 −4
10 (2)
32
Siena
bc
5×10 −4
20 (2)
32
ISRUC
bc
5×10 −4
20 (2)
64
PhysioNet-MI
bc
5×10 −4
20 (2)
64
BCI IV-2a
bˉc
2×10 −4
20 (2)
32
Appendix
Table 17: Fine-tuning settings of BrainCodes for the results reported in the main benchmarks.
Electroencephalography (EEG) foundation models learn reusable representations of brain signals for transfer across people, tasks, and recording setups.