Source-linked AI summary

BrainCodes: A Lightweight EEG Foundation Model over Discrete Neural Codes

Kleanthis Avramidis, Ivan Tashev, Dimitra Emmanouilidou

arXiv:2610.29320v1cs.LGcs.NE

TL;DR

EEG reconstruction objectives may not preserve task-relevant signal properties because broadband power and spatial redundancy can dominate. BrainCodes predicts discrete neural codes with spatial and oscillatory objectives. It matched or outperformed larger models across benchmarks, transferred to sparse montages, and retained measurable spatial and spectral structure.

  • Problem

    EEG patch reconstruction can be dominated by broadband power or neighboring-electrode redundancy, and downstream benchmarks alone do not show which signal properties representations retain.

    Source: §1 · p. 1
  • Method

    BrainCodes combines vector-quantized discrete-code prediction with relative electrode-distance encoding and an auxiliary objective based on localized narrowband perturbations.

    Source: §1 · p. 2
  • Results

    Across 14 benchmarks, BrainCodes achieved the highest mean performance among compared models, retained 91% of full-montage performance with 4 electrodes, and showed measurable spatial and spectral structure.

    Source: §1 · p. 2
  • Takeaways & Limitations

    Grounded objectives can support EEG representation learning at substantially smaller scale while retaining measurable spatial and spectral structure.

    Source: §6 · p. 10

    Clinical-task accuracies are curated retrospective benchmark results, not evidence of clinical deployment fitness; patient-care use would require prospective validation and regulatory review.

    Source: ETHICS STATEMENT · p. 10

Abstract

from arXiv · show

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

The introduction argues that EEG patch reconstruction can favor broadband power and spatial redundancy without preserving task-relevant rhythms or dynamics. BrainCodes uses discrete-code prediction with oscillatory and spatial objectives, and reports strong benchmark, sparse-montage, and representation-probe results.

  • Patch reconstruction may favor broadband power or spatial interpolation, so low reconstruction error need not preserve task-relevant properties or physiologically informative dynamics.Source: §1 · pp. 1–2
  • BrainCodes predicts discrete codes from a vector-quantized tokenizer, with narrowband perturbation supervision and relative electrode-distance encoding to promote oscillatory and spatial structure.Source: §1 · p. 2
  • With 1.9M trainable backbone parameters, BrainCodes achieved the highest mean performance among compared models across 14 benchmarks in linear probing and full fine-tuning.Source: §1 · p. 2
  • BrainCodes retained an average of 91% of its full-montage performance using only 4 electrodes in controlled sparse-montage simulations.Source: §1 · p. 2
  • Probes found stronger geometry-consistent spatial locality and greater sensitivity to oscillations than to EEG aperiodic slope in BrainCodes representations.Source: §1 · p. 2

2 METHODS

BrainCodes uses a frozen tokenizer and a factorized spatiotemporal transformer to learn bottleneck representations from EEG. Its masked-code prediction and auxiliary narrowband-perturbation tasks target discrete codes and measurable spectral and spatial properties.

2.1 DISCRETE CHANNEL TOKENIZATION

  • A frozen RVQ tokenizer converts each EEG channel into discrete codes and aggregate 128D embeddings, while independent channel tokenization supports variable electrode sets with spatial coordinates.The downstream model operates on continuous embeddings over code frames, with the discrete RVQ codes defining the bottleneck.Source: §2.1 · pp. 2–3

2.2 SPATIOTEMPORAL POSITIONAL ENCODING

  • Channel attention uses relative electrode displacement, while temporal attention uses ordered time positions; mixed-axis rotary encoding lets subspaces learn their own spatial orientations.The model centers and scales electrode coordinates, removing absolute placement while preserving relative distances.Source: §2.2 · pp. 3–4

2.3 FACTORIZED U-NET BACKBONE

  • The factorized U-Net applies temporal attention within channels and channel attention at each time step, avoiding joint attention over all channel-time tokens.Temporal pooling creates a bottleneck; time-averaged features remove explicit event timing, whereas flattened features retain time-step order at Tb-fold greater feature dimension.Source: §2.3 · p. 4

2.4 PRETRAINING OBJECTIVES

  • Masked contiguous code intervals are predicted from backbone states using cross-entropy, while injected narrowband bursts provide bottleneck supervision for frequency, duration, and spatial extent.Auxiliary heads regress burst frequency and duration and classify which channels were perturbed; the objectives are combined in the final loss.Source: Figure 1 · p. 3, §2.4 · pp. 4–5

3 EXPERIMENTAL SETUP

BrainCodes is pretrained on a multi-site developmental EEG corpus and evaluated across standard, NEURORVQ, and consumer-device task regimes. The setup compares fine-tuning protocols and uses participant-disjoint splits and repeated-seed reporting.

3.1 PRETRAINING CORPUS

  • About 820 hours from 1,131 participants in HBN-EEG releases R3, R4, R7, and R8 form the pretraining subset, chosen for age, task, and site variability and its dense 128-channel montage.A 20% participant-disjoint validation set is used.Source: §3.1 · p. 5

3.2 DOWNSTREAM DATASETS

  • The 14 downstream tasks span standard EEG benchmarks, the NEURORVQ suite, and consumer-grade in-ear and four-electrode Muse recordings.The task set includes sleep staging, seizure detection, motor imagery, cognitive load, and other tasks across montages much sparser than pretraining.Source: §3.2 · p. 6

3.3 IMPLEMENTATION DETAILS

  • Evaluation uses full fine-tuning or frozen-backbone linear probing, reports chance-normalized balanced accuracy, and averages reported results over three seeds.Cross-validation results are additionally averaged over four folds in Section 4.3 and five folds in Appendix B.Source: §3.3 · p. 6

4 RESULTS

BrainCodes performs strongly across full fine-tuning, frozen-encoder probing, and consumer-wearable evaluations. Its results span seven standard benchmarks, low-resource wearable tasks, and settings with limited labels or sparse montages.

4.1 FULL FINE-TUNING PERFORMANCE

  • 60.9% versus REVE’s 58.1% of the chance-to-perfect range; BrainCodes led five of seven datasets and had the highest mean nBAC among foundation models.It trailed REVE-Base and CBraMod on TUAB, while its largest margins included +0.087 BAC over REVE on Siena.Source: §4.1 · pp. 6–7, Table 2 · p. 7

4.2 LINEAR PROBING PERFORMANCE

  • 96.2% on mental arithmetic, 85.1% on TUEV, and 91.2% on ear-EEG sleep staging were retained by frozen BrainCodes versus full fine-tuning.The pooled feature was ahead on sustained-state tasks, while the flattened feature performed better on transient-event tasks.Source: §4.2 · p. 7, Table 3 · p. 8

4.3 APPLICATION ON WEARABLE DEVICES

  • 0.5889 BAC versus 0.5083 for the best baseline on motor imagery, and 0.5254 versus 0.4176 for REVE on EESM23; Muse-mental was a tie.Ear-EEG was furthest from the pretraining montage, yet a frozen linear probe reached 91% of full fine-tuning performance.Source: Table 4 · p. 8, §4.3 · p. 8

5 GROUNDING ANALYSIS

The grounding analyses probe whether EEG representations retain spatial dependencies and spectral properties that downstream performance alone cannot establish. BrainCodes shows geometry-consistent spatial locality and preferential sensitivity to narrowband oscillations in these probes.

5.1 RETAINED SPATIAL DYNAMICS

  • λ = 0.73 for BrainCodes, versus 0.90 for LaBraM, 0.96 for REVE, 4.05 for CBraMod, and 4.53 for CSBrain; BrainCodes was most spatially grounded across both axes.Locality was largely independent of mixing; BrainCodes and LaBraM respected scalp geometry most, attributed to explicit channel positional encoding.Source: §5.1 · pp. 8–9, Figure 2 · p. 9

5.2 RETAINED SPECTRAL DYNAMICS

  • 0.95 versus 0.88 for REVE in rhythm identification at the strongest injection; BrainCodes was least accurate on noise color and had a positive preference index throughout the SNR sweep.The noise-color accuracy rose from 0.53 to 0.76 for BrainCodes, while CBraMod reached 0.99; Appendix G reports that narrowband sensitivity extends to naturally occurring rhythms.Source: §5.2 · pp. 9–10, Figure 2 · p. 9

6 CONCLUSION

BrainCodes combines discrete neural token prediction, montage-aware spatial encoding, and oscillatory supervision in a lightweight EEG foundation model. The paper reports transfer and retained spatial and spectral structure, while limiting its claims about clinical validity and noting the need for broader validation.

6 CONCLUSION

  • Across 14 benchmarks, BrainCodes matched or outperformed larger models, transferred to sparse consumer montages, and preserved measurable spatial and spectral structure.The conclusion says validation across more diverse populations and grounded probes would further strengthen the scope.Source: §6 · p. 10
  • The pretraining corpus consists of children and adolescents, and the authors make no claims of clinical or diagnostic validity based on model inference.The paper also warns that benchmark accuracy on curated retrospective clinical datasets is not evidence of fitness for clinical deployment.Source: ETHICS STATEMENT · p. 10

A RELATED WORK

  • Reconstruction-based EEG objectives inherit spectral-power weighting, motivating alternatives less directly tied to signal amplitude.Prior work also describes reconstruction models as tending to emphasize aperiodic and low-frequency content.Source: A RELATED WORK · p. 14
  • Earlier biosignal tokenizers were evaluated primarily through downstream accuracy, while electrode-position methods differ in how they encode montage geometry.The related work describes vector quantization as a potential denoising approach and contrasts electrode-name, input-generated, coordinate-based, and relative-position encodings.Source: A RELATED WORK · p. 14
  • Direct transfer of pretrained EEG representations to consumer hardware remains largely unexplored, despite four-electrode headbands and in-ear systems used in prior studies.The cited prior work largely evaluates foundation models on clinical and laboratory montages.Source: A RELATED WORK · p. 14

B MODEL PERFORMANCE: NEURORVQ BENCHMARK

On the NEURORVQ benchmark, BrainCodes had the highest mean chance-normalized accuracy and led on three of four tasks, ranking second on ERP. Published values are not directly rank-comparable because the participant splits differ.

B MODEL PERFORMANCE: NEURORVQ BENCHMARK

  • The benchmark adds four tasks absent from the standard suite: executed movement, ERP target detection, working-memory load, and eyes-open versus eyes-closed rest.It uses five-fold subject-disjoint cross-validation with distinct validation and test folds.Source: B MODEL PERFORMANCE: NEURORVQ BENCHMARK · p. 14
  • Published baseline scores are not directly rank-comparable because those models trained on 90% of participants, versus about 60% in this study.The authors retained a separate validation fold to match the standard split protocol and isolate the test fold from model selection.Source: B MODEL PERFORMANCE: NEURORVQ BENCHMARK · p. 15
  • 0.579 mean chance-normalized accuracy was highest for BrainCodes, ahead of NeuroRVQ at 0.559 and NeuroGPT at 0.484.BrainCodes led on executed movement (0.735 against 0.700 for NeuroRVQ), working memory (0.606 against 0.597 for NeuroGPT), and resting state, while ranking second on ERP.Source: B MODEL PERFORMANCE: NEURORVQ BENCHMARK · p. 15, Table 5 · p. 15

C MODEL PERFORMANCE: SPARSE MONTAGE ABLATION

BrainCodes retained much of its full-montage performance with four electrodes, while performance generally declined more sharply at one electrode. On two datasets, performance improved with both participant coverage and within-participant label budgets, with participant coverage providing the larger marginal return.

C MODEL PERFORMANCE: SPARSE MONTAGE ABLATION

  • Nested montages of 32, 16, 8, 4, and 1 electrodes were selected by farthest-point sampling over 3D coordinates, then fine-tuned separately over three seeds.The sampling preserved broad, approximately uniform scalp coverage while separating electrode-count effects from placement effects.Source: C MODEL PERFORMANCE: SPARSE MONTAGE… · pp. 15–16
  • 91% of full-montage performance was retained on average with four electrodes; PhysioNet-MI retained 83% and OpenBMI-ERP 87.0%.Siena scored better than full fine-tuning at four electrodes, and none of its reduced-montage results differed significantly from the full montage (p > 0.2).Source: Figure 3 · p. 15, C MODEL PERFORMANCE: SPARSE MONTAGE… · p. 16
  • With one electrode, PhysioNet-MI balanced accuracy fell to 0.261 from 0.550 with four electrodes, while performance generally declined gradually as montages shrank.The authors link the pronounced single-electrode drop to loss of the lateralized spatial contrast needed to distinguish left- and right-hand imagery.Source: C MODEL PERFORMANCE: SPARSE MONTAGE… · p. 16

D MODEL PERFORMANCE: LOW-RESOURCE FINE-TUNING

  • On PhysioNet-MI, each doubling added 7.9 balanced-accuracy points for participants and 6.3 for windows per participant; on OpenBMI-ERP, the gains were 3.0 and 2.0 points, respectively.Broader participant coverage had the larger marginal return on both datasets, though denser within-participant annotation also improved performance.Source: D MODEL PERFORMANCE: LOW-RESOURCE… · p. 16, Figure 4 · p. 16
  • Performance rose across both budget axes, from 0.386 to 0.652 on PhysioNet-MI and from 0.511 to 0.690 on OpenBMI-ERP at the reported low and high budget conditions.The high PhysioNet-MI score approached the full-partition score of 0.664; the reported endpoints were 16 participants with 24 windows each versus 48 with 90, and 8 with 24 versus 40 with 720 on OpenBMI-ERP.Source: D MODEL PERFORMANCE: LOW-RESOURCE… · p. 16

E ABLATION ON THE PRETRAINING COMPONENTS

Ablations identify oscillation supervision and tokenizer initialization as consequential components, with backbone pretraining accounting for the largest share of the reported gain. The study evaluates matched variants on three datasets and reports balanced accuracy.

E ABLATION ON THE PRETRAINING COMPONENTS

  • Removing the oscillation objective reduced mean balanced accuracy from 0.645 to 0.574, the largest drop among the four tested design changes.Random code-embedding initialization yielded 0.592, while replacing positional encoding or masking yielded 0.613 and 0.623, respectively.Source: E ABLATION ON THE PRETRAINING COMPONENTS · p. 17, Table 6 · p. 17
  • Four matched variants replaced rotary channel encoding, block masking, BioCodec code-embedding initialization, or the oscillation-injection objective before full fine-tuning on three datasets.Random-token masking was less stable on BCI IV-2a and EEGMAT, while EESM23 was least affected by the positional-encoding change.Source: E ABLATION ON THE PRETRAINING COMPONENTS · p. 17, Table 6 · p. 17
  • Mean chance-normalized balanced accuracy fell from 0.498 to 0.270 when the pretrained backbone was replaced with a scratch-initialized backbone, and to 0.121 when the tokenizer was also randomized.With a randomly initialized backbone, BioCodec improved balanced accuracy by 0.212 on BCI IV-2a, 0.060 on EEGMAT, and 0.037 on EESM23; the tokenizer advantage was strongest for motor imagery.Source: E ABLATION ON THE PRETRAINING COMPONENTS · p. 17, Table 7 · p. 17

F THE LEARNED CHANNEL POSITIONAL ENCODING

BrainCodes learns relative electrode-position biases through rotary phases that encode spatial displacement in channel attention. Pretraining concentrates this encoding into a compact, approximately isotropic three-dimensional distance code shared across attention heads.

F THE LEARNED CHANNEL POSITIONAL ENCODING

  • Each learned vector maps the displacement between electrodes into a relative phase, with its direction setting the spatial axis and its magnitude setting distance sensitivity.Near-zero vectors are position-insensitive, whereas larger vectors produce stronger spatial differentiation; the same learned rotations are shared across channel-attention layers.Source: F THE LEARNED CHANNEL POSITIONAL… · pp. 17–18
  • 26 of 64 head–pair vectors grew beyond initialization, and the retained directions formed an approximately orthogonal frame spanning the three spatial axes.Their mean smallest-to-largest singular-value ratio was 0.770, versus 0.257 for size-matched random sets (p < 0.001).Source: F THE LEARNED CHANNEL POSITIONAL… · p. 18
  • Pretraining produced a compact, approximately isotropic three-dimensional distance code whose bias depends mainly on relative electrode separation.Seeding the code at different electrodes yielded similar smoothly decaying spatial fields, consistent with isotropic spatial mixing from volume conduction.Source: F THE LEARNED CHANNEL POSITIONAL… · p. 18
  • Figure 5 shows smoothly varying positional biases from eight electrode seeds, with frontal and fronto-temporal/central views.The white marker indicates each seed; color indicates the bias assigned to other sites.Source: Figure 5 · p. 18, F THE LEARNED CHANNEL POSITIONAL… · p. 18

G SPECTRAL SENSITIVITY ANALYSIS

BrainCodes increased linear accessibility of low-frequency oscillatory structure relative to its tokenizer while leaving aperiodic-exponent decoding essentially unchanged. The paper also reports that its discrete bottleneck reduces input capacity without constraining pretrained performance, while noting that parameter scaling was not directly tested.

G SPECTRAL SENSITIVITY ANALYSIS

  • R2 rose from 0.270 to 0.340 for mean oscillatory decoding, while decoding of the 1/f exponent remained effectively unchanged.The increase was concentrated in delta, theta, and alpha; beta, gamma, and the aperiodic exponent differences were not significant.Source: G SPECTRAL SENSITIVITY ANALYSIS · pp. 18–19, Figure 6 · p. 19
  • BrainCodes achieved the strongest alpha decoding across six models (R2 = 0.720), but REVE and LaBraM decoded oscillatory power more strongly on average.REVE best captured the 1/f exponent; the findings came from real EEG rather than synthetically perturbed proxies.Source: G SPECTRAL SENSITIVITY ANALYSIS · p. 19, Figure 6 · p. 19

H SIGNAL CAPACITY & MODEL SCALING

  • The BioCodec tokenizer encodes approximately 1,000 bits/s per channel versus 4,000 bits/s for the original 16-bit signal, yet the pretrained model surpassed a random projection on all considered datasets.The tokenizer also outperformed a random quantizer at the same bitrate.Source: H SIGNAL CAPACITY & MODEL SCALING · p. 19
  • BrainCodes was pretrained at a single capacity of 1.9M parameters, so the paper did not directly study parameter scaling.The discussion contrasts prior scaling results: LaBraM's TUEV balanced accuracy rose from 0.6409 to 0.6616 when scaled from 5.8M to 369M parameters, a gain smaller than participant-level bootstrap variability.Source: H SIGNAL CAPACITY & MODEL SCALING · p. 19

I MODEL PERFORMANCE: DETAILED RESULTS

This section details benchmark datasets and their preprocessing, splits, and evaluation setup, spanning clinical monitoring, sleep, motor imagery, and cognitive-state tasks. It also describes the referenced models and reports table-level performance summaries, but the supplied passages do not provide benchmark outcome values.

I MODEL PERFORMANCE: DETAILED RESULTS

  • The benchmark tables report balanced accuracy with Cohen’s κ and weighted F1 for multiclass tasks, or AUROC and AUPRC for binary tasks, averaged over three seeds.Published baselines were used where directly comparable protocols existed, and all datasets were resampled to 250 Hz.Source: I MODEL PERFORMANCE: DETAILED RESULTS · p. 20
  • Clinical and sleep benchmarks include TUAB abnormality detection, TUEV event classification, ISRUC sleep staging, and Siena seizure detection, with subject-based train, validation, and test partitions described for several datasets.The supplied passages specify dataset populations, epoch or window construction, and partitioning procedures.Source: I MODEL PERFORMANCE: DETAILED RESULTS · p. 20, Table 8 · p. 20, Table 9 · p. 21
  • Motor-imagery and cognitive-state evaluations use PhysioNet-MI, BCI IV-2a, EEGMAT, and Muse-Mental, with task labels and recording or split details reported for each.Muse-Mental evaluates relaxed, neutral, and concentrating states using four-fold cross-validation over 296 windows.Source: I MODEL PERFORMANCE: DETAILED RESULTS · pp. 20–22, Table 14 · p. 23

J DESCRIPTION OF REFERENCED MODELS

  • The referenced-model descriptions span EEG foundation models, compact task-specific architectures, and sleep-staging systems with varied tokenization, attention, and convolutional designs.Examples include REVE, LaBraM, CBraMod, BIOT, EEGConformer, and U-Sleep.Source: J DESCRIPTION OF REFERENCED MODELS · pp. 23–24

K IMPLEMENTATION DETAILS & RESOURCES

BrainCodes is pretrained on frozen residual-quantization codes using masked code prediction and oscillation injection, with variable crop lengths and channel subsets. The appendix also specifies downstream adaptation, grounding probes, parameter counts, and computing resources.

K IMPLEMENTATION DETAILS & RESOURCES

  • Pretraining uses six residual-quantization stages at 20.8 frames/s, variable 2–30 s crops, and random subsets of 16–64 channels.Batches use masked code prediction 60% of the time and oscillation injection 40%; the final checkpoint follows 20,000 training steps.Source: K IMPLEMENTATION DETAILS & RESOURCES · p. 25
  • Downstream models are generally fine-tuned with AdamW, square-root inverse-frequency class weights, and validation-selected checkpoints.The grounding probes perturb electrode signals or inject band-limited noise, then measure feature influence, locality, decay length, or spectral sensitivity.Source: K IMPLEMENTATION DETAILS & RESOURCES · pp. 25–26
  • The backbone has 1,877,312 trainable parameters, and its encoder checkpoint occupies 7.19 MiB.Pretraining ran for about 190 GPU-hours on four RTX 6000 GPUs; the tokenizer remained frozen and corpus code indices were cached.Source: K IMPLEMENTATION DETAILS & RESOURCES · pp. 25–26
Loading 2610.29320v1…