Adapting Neural Audio Codecs to EEG

Ard Kastrati, Luca A Lanzendörfer, Riccardo Rigoni, John Staib Matilla, Roger Wattenhofer

TL;DR

Training neural codecs directly on EEG data is notoriously difficult due to severe data scarcity, but this paper reveals an unexpected shortcut: an off-the-shelf neural audio codec (DAC) can be repurposed and fine-tuned for EEG. The resulting models—including DAC-MC, a multi-channel extension with cross-channel attention—achieve high-fidelity discrete EEG compression and preserve critical diagnostic features for clinical tasks like epilepsy and abnormality detection.

What Problem Does This Paper Address?

Foundation models in language, vision, and audio rely heavily on tokenization—compressing continuous signals into discrete tokens so standard autoregressive or masked sequence models can process them. Applying this recipe to electroencephalography (EEG) is a major hurdle:

  • EEG datasets are orders of magnitude smaller than audio or text corpora due to clinical and privacy constraints, leading models trained from scratch to overfit or fail to generalize across subjects and recording setups.
  • EEG signals differ drastically from audio: they are multi-channel (spatial), recorded at much lower sampling rates (e.g., 256–512 Hz vs. 44.1 kHz), and have distinct amplitude and frequency dynamics.

The authors explore whether representations learned by deep neural audio codecs on massive audio datasets can be transferred to EEG signals despite these cross-modal differences.

Methods

The authors adopt the Descript Audio Codec (DAC)—an adversarial autoencoder using Residual Vector Quantization (RVQ)—and adapt it in several ways:

  1. Direct Temporal Mapping: DAC processes audio with a fixed downsampling stride of 512 samples per latent token. In 44.1 kHz audio, 512 samples represent ~13 ms; in 512 Hz EEG, they represent a full second. The authors directly feed raw, normalized EEG into this stride without altering the core architecture.
  2. DAC-SC (Single-Channel): Compresses each EEG electrode independently using the audio-pretrained encoder-decoder.
  3. DAC-MC (Multi-Channel): Extends DAC to exploit spatial correlations across electrodes:
  4. Encodes each channel independently with the DAC encoder.
  5. Applies cross-channel self-attention over concatenated latent vectors, then projects back to the latent dimension.
  6. Decodes channels using learned, channel-specific style vectors that apply affine transformations (scale and bias, inspired by StyleGAN) along with positional encodings.
  7. To keep memory manageable in DAC’s 1024-dimensional latent space, channels are partitioned into small subsets (up to 5 channels) using either Random Groups (sampled via geodesic scalp proximity) or anatomical Manual Groups.
  8. Training Adjustments: The model is initialized from DAC’s 44.1 kHz audio checkpoint and fine-tuned. The authors replace the Mel-spectrogram loss with a standard linear spectrogram loss, initially weight waveform loss higher, and disable GAN adversarial losses once training stabilizes to prevent domain-mismatch divergence.

Datasets

The authors use datasets from the Temple University Hospital (TUH) EEG Corpus:

  • TUH EEG (pretraining/fine-tuning): Serves as the primary source for adapting the codec.
  • TUAB (TUH Abnormal EEG): Benchmark subset used to evaluate anomaly detection.
  • TUEP (TUH Epilepsy): Benchmark subset used to evaluate epilepsy diagnosis.

All data were filtered (0.1 Hz high-pass), resampled to 512 Hz (or 256 Hz), clipped to $\pm 200\,\mu\text{V}$, normalized to $[-1, 1]$, and segmented into non-overlapping 30-second windows.

Key Insights and Ideas

  • Surprising Cross-Modal Transfer: Off-the-shelf audio codecs can reconstruct EEG out-of-the-box without modifying weights. Even though 512 samples mean something temporally distinct between speech/music and brain waves, the multi-scale convolutional filters capture oscillatory EEG features effectively.
  • Pretrained Initialization Beats Training from Scratch: Fine-tuning the audio-pretrained checkpoint achieves a spectrogram loss of 1.05—dramatically better than training the same architecture from scratch on EEG (1.46) and matching DAC’s original reconstruction fidelity on audio (1.09).
  • Graceful Bitrate Scaling: Pruning residual codebooks from 9 down to 6 increases reconstruction loss by less than 10%, offering substantial bitrate reduction with negligible perceptual quality degradation.
  • Task-Dependent Spatial Value: Jointly modeling multiple channels via cross-attention (DAC-MC) improves downstream epilepsy classification beyond the raw signal baseline, demonstrating that cross-electrode context is preserved and useful. However, for general abnormality detection, per-channel decoding preserved diagnostic features better.

Key Results

  • Reconstruction Quality (Spectrogram Loss on Test Set):
  • Audio-Pretrained (Zero-shot, no fine-tuning): 2.50
  • Trained from Scratch on EEG: 1.46
  • Audio-to-EEG Fine-Tuned: 1.05
  • Downstream Clinical Classification:
  • Epilepsy Detection (TUEP): Grouped DAC-MC achieved 85% accuracy, outperforming both single-channel DAC-SC (80%) and the original uncompressed signal baseline (84%).
  • Abnormal EEG Detection (TUAB): Single-channel DAC-SC achieved 83% accuracy and DAC-MC in single-channel mode achieved 81% (comparable to the original uncompressed baseline of 82%), whereas grouped DAC-MC achieved 78%.

Limitations and Future Work

  • Adversarial Instability: GAN discriminators commonly used in audio codecs proved unstable on EEG, requiring authors to turn off adversarial losses mid-training to avoid divergence.
  • Scalability of Cross-Channel Attention: Because the latent dimension is wide (1024-D), full self-attention across standard clinical montages (e.g., 20+ channels) is computationally prohibitive, forcing channel grouping heuristics (max 5 channels per group).
  • Upsampling Efficiency: Upsampling EEG to 512 Hz (compared to native 256 Hz) doubles the bitrate (180 bps vs. 90 bps) but provides only marginal reconstruction improvements.
  • Future Directions: Incorporating these discrete neural tokens into generative sequence models (e.g., autoregressive transformers or masked token prediction) to build general-purpose EEG foundation models.

Summary updated

BibTeX
@inproceedings{kastrati2025adapting,
  author = {Ard Kastrati and Luca A Lanzendörfer and Riccardo Rigoni and John Staib Matilla and Roger Wattenhofer},
  title = {{Adapting Neural Audio Codecs to EEG}},
  booktitle = {BrainBodyFM @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=i4Vf28vvhQ},
}
Figure