EEGFormer: Towards Transferable and Interpretable Large-Scale EEG Foundation Model

Yuqi Chen, Kan Ren, Kaitao Song, Yansen Wang, Yifan Wang, Dongsheng Li, Lili Qiu

TL;DR

EEGFormer is a foundational self-supervised model for electroencephalography (EEG) data pretrained on a massive 1.7TB corpus of unlabelled brain recordings. By combining patch-based spectral processing with a vector-quantized Transformer, it learns a discrete "vocabulary" of neural activity that not only yields state-of-the-art transfer performance across multiple clinical tasks, but also offers transparent, clinically interpretable biomarker discovery.

What Problem Does This Paper Address?

Interpreting multi-channel scalp EEG signals is critical for diagnosing neurological disorders (such as epilepsy, slowing events, and abnormal brain activity), but manual analysis demands rare clinical expertise. While deep learning has helped automate diagnosis, two major bottlenecks remain:

  1. Fragmented, task-specific pretraining: Most self-supervised EEG models are trained on small, individual datasets tailored to single downstream tasks, failing to capitalize on the massive scale of unlabelled clinical data.
  2. The "black box" dilemma: Standard end-to-end architectures lack explainability. In high-stakes medical settings, uninterpretable models risk misleading clinicians and causing medical errors.

Methods

EEGFormer introduces a vector-quantized representation learning framework designed specifically for multi-channel time-series biosignals:

  • Spectral Patching & Embedding: Multi-channel 12-second EEG segments (resampled to 250 Hz) are converted into the frequency domain via Fast Fourier Transform (FFT). Each channel's frequency profile is segmented into sequential patches and mapped to an embedding space with learnable positional encodings.
  • Channel-Independent Encoder: A Transformer encoder processes each channel independently to capture temporal and spectral dynamics without imposing rigid cross-channel topological assumptions.
  • Vector Quantizer (Codebook): Instead of continuous embeddings, encoder outputs are mapped to the nearest codebook vector from a discrete dictionary ($\{v_1, \dots, v_K\}$). This discretizes continuous brain signals into symbolic tokens.
  • Decoding & Pretraining Objective: A shallow 3-layer Transformer decoder reconstructs the original frequency inputs. The pretraining loss combines mean-squared reconstruction error with standard vector-quantization commitment losses (using stop-gradient operators).
  • Fine-Tuning: For downstream classification, decoded representations across all channels and patches are concatenated and routed through a linear classification head.
Raw EEG (12s, 250Hz) ➔ FFT Amplitude ➔ Patching & Linear Projection 
  ➔ Transformer Encoder ➔ Nearest-Neighbor Vector Quantizer (Codebook) 
  ➔ Transformer Decoder ➔ Reconstruction / Linear Task Head

Datasets

  • Pretraining Dataset:
  • TUH EEG Corpus: Over 1.7 TB of unlabelled clinical EEG data from Temple University, marking the first time an EEG foundation model was pretrained at this scale.
  • Downstream Evaluation Corpora:
  • TUAB: Binary classification for abnormal vs. normal EEG recordings.
  • TUAR: Multi-class classification of EEG artifacts.
  • TUSL: Multi-class classification of pathological slowing events.
  • TUSZ: Seizure event detection.
  • Neonate Dataset (Stevenson et al., 2019): An external neonatal seizure dataset used to test out-of-domain transferability (not part of the TUH corpus).

Key Insights and Ideas

  • Brain Waves as Discrete "Words": Discretizing continuous EEG signals into learned codebook tokens allows continuous neural phenomena to be analyzed symbolically, similar to language tokens.
  • Unsupervised Biomarker Discovery: Without any fine-tuning, training a simple Naive Bayes classifier on $n$-gram sequences of codebook indices achieved an AUROC of 0.741 on seizure detection.
  • Direct Clinical Alignment: Inspecting the top $n$-gram features with high posterior seizure probabilities revealed classic spike-and-slow-wave complexes across frontal ($F_z$), parietal ($P_z$), and temporal ($T_3, T_6$) electrodes. These correspond to epileptiform discharges followed by refractory neuronal periods—the exact pathological waveforms neurologists look for when diagnosing epilepsy.
  • Frozen Features Beat Supervised Models: EEGFormer evaluated under a linear probing setup (frozen encoder/decoder, training only the classification head) outperformed fully supervised baselines such as GraphS4mer on artifact detection (TUAR).

Key Results

EEGFormer was compared against prominent baselines, including supervised architectures (EEGNet, TCN, EEG-GNN, GraphS4mer) and self-supervised models (BrainBERT):

  • Cross-Dataset Transfer (Neonate): Achieved an AUPRC of 0.544 and AUROC of 0.833, representing a +9.02% improvement in AUPRC over the strongest baseline (GraphS4mer at 0.374 / EEGNet at 0.499).
  • Seizure Detection (TUSZ): Reached 0.556 AUPRC and 0.883 AUROC, outperforming GraphS4mer by +13.23% in AUPRC and +7.42% in AUROC.
  • Model Scaling: Larger variants showed monotonic scaling: EEGFormer-Large (12 encoder layers, codebook size 2048) consistently surpassed smaller configurations (6-layer / $K=512$ and 8-layer / $K=1024$).
  • Pretraining Duration: Performance on downstream corpora steadily scaled with the number of pretraining epochs.

Limitations and Future Work

  • Channel-Independent Encoding: The encoder models each electrode channel separately, relying on late-stage concatenation in the decoder to combine spatial signals. Explicit spatial/geometric brain topology modeling could improve localization.
  • Fixed Temporal Windows: Experiments were restricted to fixed 12-second input windows resampled to 250 Hz, which may not capture extremely long-range contextual dynamics across multi-hour monitoring sessions.
  • Scope of Clinical Interpretability: While the $n$-gram Naive Bayes analysis demonstrates that learned discrete tokens isolate epileptiform discharges, end-to-end integration of codebook explanations into clinical workflows remains an area for future exploration.

Summary updated

BibTeX
@inproceedings{chen2024eegformer,
  author = {Yuqi Chen and Kan Ren and Kaitao Song and Yansen Wang and Yifan Wang and Dongsheng Li and Lili Qiu},
  title = {{EEGFormer: Towards Transferable and Interpretable Large-Scale EEG Foundation Model}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=MXRy6bYBfB},
}
Figure