TL;DR
BioCodec is a novel, self-supervised foundation model that adapts neural audio codec principles to tokenize continuous biosignals (like EEG and EMG) into discrete latent sequences. By utilizing Residual Vector Quantization (RVQ) in a channel-agnostic manner, it filters out non-reproducible noise and achieves state-of-the-art performance across diverse downstream tasks—all while being significantly more lightweight and data-efficient than existing models.
What Problem Does This Paper Address?
Neurophysiological recordings, such as electroencephalography (EEG) and electromyography (EMG), are vital for clinical diagnostics, sleep monitoring, and brain-computer interfaces (BCIs). However, these signals are notoriously high-dimensional, noisy, and highly variable across different subjects and recording devices.
While foundation models have revolutionized language and vision, transferring these paradigms to biosignals has proven difficult. Biosignals lack natural semantic building blocks (like words in text or objects in images), making standard pretext tasks like masked patch modeling a poor fit. Furthermore, existing models often hard-code specific multi-channel electrode layouts, limiting their ability to generalize across different recording setups.
Methods
The authors introduce BioCodec, a framework that treats biosignal representation learning as a signal compression problem. Inspired by neural audio codecs like SoundStream and EnCodec, BioCodec learns to compress and reconstruct continuous 1D waveforms without imposing artificial temporal boundaries.
Key Architectural Components:
- Encoder-Decoder Backbone: Based on the SEANet architecture, it uses 1D convolutions and a two-layer LSTM to map continuous waveforms into a sequence of low-dimensional embeddings.
- Residual Vector Quantization (RVQ): The core innovation. RVQ projects embeddings into a discrete space across 6 hierarchical codebook layers (each with 256 codewords). This hierarchy acts as an information bottleneck: early layers capture broad, discriminative physiological patterns, while deeper layers encode fine-grained details and noise.
- Channel-Agnostic Pre-training: BioCodec processes multi-channel inputs as collections of independent 1D sequences. It completely defers spatial and cross-channel modeling to a lightweight dual-transformer architecture during downstream fine-tuning, making the core foundation model entirely flexible to any electrode layout.
- Pre-training Objective: The model optimizes a combination of smooth L1 temporal loss, multi-scale spectral loss (to preserve frequency and phase characteristics), and a quantizer commitment loss. Notably, it omits adversarial discriminator losses commonly used in audio codecs, as biosignals lack the semantic structure to differentiate "real" vs. "fake" data meaningfully.
Datasets
The model was pre-trained on massive, publicly available datasets and evaluated across a diverse suite of downstream tasks:
- Pre-training: The TUH-EEG corpus (approx. 5 million single-channel segments) for the EEG model, and emg2qwerty (346 hours of surface EMG) for the EMG extension.
- Downstream EEG Evaluation: Included TUAB (clinical abnormality), TUEV (epilepsy event detection), PhysioNet-MI & BCI IV-2a (motor imagery), Sleep-EDF (sleep staging), and N400 (speech decoding).
- Downstream EMG Evaluation: Ninapro (DB2, DB3, DB5) and EMG MCS for hand gesture recognition.
Key Insights and Ideas
- Biosignals as Audio: Low-level oscillatory patterns and spike events share more structural commonalities with raw audio waveforms than text or images. Treating them as continuous acoustic-like streams yields highly robust tokens.
- Hierarchical Decomposition Filters Noise: The authors' ablation studies confirmed that the first two quantizer layers ($Q_1 + Q_2$) contain almost all the discriminative power needed for downstream tasks. Later layers capture non-reproducible noise, validating RVQ's strength as a biosignal denoising mechanism.
- The Power of Channel Agnosticism: Deferring spatial modeling to the fine-tuning phase doesn't hurt performance; instead, it creates a highly versatile tokenizer that can easily adapt to out-of-distribution channel counts and configurations.
Key Results
BioCodec achieves competitive or superior performance against state-of-the-art foundation models (like LaBraM and CBraMod) despite having up to 4x fewer parameters and operating on 8x compressed signal bitrates.
Downstream Performance Highlights:
- Clinical Abnormality (TUAB): Achieved a Balanced Accuracy (BAC) of 0.816, performing on par with LaBraM (0.814) while utilizing a fraction of the parameter space.
- Event Detection (TUEV): Outperformed popular baselines like BIOT and EEGPT with a BAC of 0.648.
- Out-of-Distribution Tasks (Sleep-EDF & Kaggle-ERN): Attained state-of-the-art BAC across both tasks, outperforming heavier models by over 3 and 2 percentage points, respectively.
- Low-Resource Resilience: When downstream training data was restricted to just 10% or 30%, BioCodec retained remarkable accuracy, demonstrating the strength of the representational prior learned during pre-training.
- Cross-Modality Generalization: When applied to EMG gesture recognition, BioCodec significantly improved balanced accuracy by 10 and 8 percentage points on Ninapro DB2 and DB5 compared to the TimesNet baseline.
Limitations and Future Work
- Sensitivity to Absolute Scale: Perturbation analysis revealed that BioCodec is highly sensitive to amplitude/gain shifts. A moderate 20% change in signal amplitude destabilized more than half of the code assignments. This highlights a critical dependency on meticulous preprocessing and normalization.
- Loss of Fine-Grained Detail: Because quantization inherently smooths out minor signal variations, BioCodec occasionally lagged behind in ranking-based metrics like AUROC, even when dominating in Balanced Accuracy (BAC).
- Future Directions: The authors suggest exploring scale-invariant loss terms, adaptive normalization strategies, and gain-focused data augmentations to improve the model's robustness to amplitude variations.
Summary updated