arXiv:2610.29320cs.LGOct 2026

Manuscript Offprint

arXiv:2610.29320

BrainCodes: A Lightweight EEG Foundation Model over Discrete Neural Codes

Kleanthis Avramidis, Ivan Tashev, Dimitra Emmanouilidou

ABSTRACT

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.

1 INTRODUCTION

Recent self-supervised models for electroencephalography (EEG) are typically trained on patch reconstruction, either in the signal waveform or in a spectral representation (Jiang et al., 2024; Wang et al., 2025; Yang et al., 2023a; El Ouahidi et al., 2025). This objective is inherited from language and computer vision, where a masked token can be reliably estimated from its local context. EEG however presents a different setting, in which a masked interval is only weakly constrained by its neighborhood, while neighboring electrodes often contain redundant mixtures of the same underlying sources due to volume conduction. Consequently, components that carry task-relevant properties may occupy small fraction of the total variance, so that a model need not preserve them to reduce reconstruction error. Whether common EEG pretext tasks produce representations grounded in those properties is an empirical question that downstream benchmarks alone can only partially answer.

Consider reconstruction under a squared-error objective in the frequency domain. EEG typically exhibits an aperiodic power spectrum S(f)∝f−αS(f) \propto f^{-\alpha} (He, 2014; Donoghue et al., 2020a), and the contribution of a frequency band to the reconstruction loss depends on its residual power. High-power broadband components can therefore dominate the objective, whereas narrowband, oscillatory components may contribute relatively little to the optimization process. A pretrained model may consequently achieve low reconstruction error by accurately fitting only the aperiodic background, without faithfully preserving rhythmic structure. Spatial reconstruction presents an analogous ambiguity. Scalp potentials are linear lead-field mixtures of underlying source currents, and their spatial autocorrelation is shaped not only by source dynamics but also by head geometry and electrode density (Nunez & Srinivasan, 2006). Because neighboring electrodes often contain redundant mixtures, a masked channel can be approximated accurately from its neighbors; even spherical spline

∗^{*}Work done during an internship at Microsoft Research.

interpolation can recover missing signals with high fidelity (Perrin et al., 1989). Masked-channel reconstruction may therefore be solved partly through spatial interpolation without requiring the representation to encode physiologically informative spatial dynamics.

Although these ambiguities are well established in neurophysiology, standard downstream benchmarks do not directly determine which properties of EEG signals are retained by a foundation model. We therefore introduce a compact model, trained to predict a finite set of discrete latent codes produced by a vector-quantized tokenizer. The quantizer allocates capacity according to a rate-distortion trade-off, concentrating representational capacity on distinctions between samples. Because this prediction objective is categorical rather than a squared error on the waveform level, its weighting is not directly governed by absolute signal power. To promote sensitivity to physiologically meaningful oscillatory and spatial structure, we supplement masked-token prediction with an auxiliary objective based on localized narrowband perturbations, and we explicitly encode relative electrode distances as positional encoding. The central novelty is therefore an objective designed to preserve oscillatory and spatial structure without relying on scale. Our contributions are as follows:

• A compact foundation model on top of discrete codes. BrainCodes combines a vector-quantized tokenizer and a series of factorized transformer layers trained on masked code prediction under an oscillation-injection auxiliary. With 1.9M trainable parameters in its backbone, our model achieves the highest mean performance among the compared models across 14 downstream benchmarks in both linear probing and full fine-tuning.

• Transfer to sparse, consumer-grade montages. To our knowledge, we provide the first systematic evaluation of EEG foundation models on consumer-grade hardware, using three datasets spanning in-ear EEG and the Muse headband. BrainCodes substantially outperforms the published baselines in these settings. Through controlled sparse-montage simulations, we further demonstrate that BrainCodes retains, on average, 91% of its full-montage performance when using only a sparse set of 4 electrodes.

• Evidence of retained spatial and spectral structure. We introduce controlled probes that measure representational sensitivity to electrode geometry and spectral perturbations. Relative to the compared models, BrainCodes exhibits stronger geometry-consistent spatial locality and greater sensitivity to oscillatory components than to the aperiodic slope of the EEG spectrum. These results demonstrate that its representations retain measurable spatial and spectral properties of EEG beyond those captured by downstream performance alone.

References (73)