Self-Supervised Pretraining for Cross-Subject Motor Imagery BCI
Can representation learning reduce calibration?
Built to answer one specific question: can contrastive pretraining across many subjects' EEG reduce the labeled-calibration burden a new user faces before a motor-imagery BCI becomes usable? With an honest account of which interventions actually moved the needle and which didn't.
- Self-Supervised Learning
- EEG
- EEGNet
- NT-Xent
- Riemannian Geometry
- Cross-Subject
- ONNX
Question
Why It Matters
System
Data
Method
Preprocessing
Channel alignment across datasets and per-trial normalization. EEG-specific augmentations: channel dropout, jitter, frequency masking, and noise.
Feature Extraction
Learned representations from a self-supervised NT-Xent contrastive pretext task, plus Riemannian covariance-based tangent-space features. The fusion method combines both feature types.
Model
EEGNet-style encoder with a projection head for contrastive learning. Linear probe head and full fine-tuning head for downstream evaluation. Riemannian tangent-space + Logistic Regression as the classical baseline.
Training
Two-stage: self-supervised pretraining on unlabeled EEG across both datasets (7–15 min on Apple Silicon MPS), followed by supervised few-shot evaluation on held-out subjects. Pretrained checkpoints published on GitHub Releases.
Evaluation
Few-shot evaluation at k=20 (80 labeled trials) on genuinely held-out subjects. Methods compared: random encoder + linear probe, pretrained + linear probe, pretrained + full fine-tune, pretrained + Riemannian fusion, and Riemannian baseline with full data. Cross-dataset transfer tested in both directions.
Experiment
Results
| Method | k=20 Accuracy | % of Full-Cal | Calibration Time |
|---|---|---|---|
| Random encoder + linear probe | 39.1% | 54.1% | 10.7 min |
| Pretrained + linear probe | 46.9% | 64.8% | 10.7 min |
| Pretrained + full fine-tune | 40.4% | 55.9% | 10.7 min |
| Pretrained + Riemannian fusion | 58.2% | 80.4% | 10.7 min |
| Riemannian baseline (full data) | 72.3% | 100% | 76.8 min |
BNCI2014_001, held-out subjects. Fusing SSL with Riemannian features reaches 80.4% of full-calibration accuracy using 86% less calibration time.
Vanilla contrastive pretraining alone plateaued at 45–47% regardless of data scale, schedule, or augmentation tuning. The gain that mattered came from combining the frozen SSL embedding with Riemannian tangent-space features — reaching 58.2% accuracy (80.4% of full-calibration ceiling) with only 80 labeled trials (~10.7 min) instead of 576 trials (~76.8 min). Cross-dataset transfer was also tested: an encoder pretrained on only one dataset, evaluated few-shot on the other dataset's holdout subjects, landed within ~1pt of the within-dataset reference at every k — a genuine transfer result.
What Changed
Three negative results (dataset combination, LR schedule tuning, more pretraining subjects) did not improve accuracy. The one intervention that worked was feature fusion — combining SSL embeddings with Riemannian tangent-space features. This was not the first thing tried; see docs/BENCHMARKS.md for the full negative-result sequence. Additionally, embeddings were found to carry exploitable subject-identity information (69.3% accuracy on subject identity from frozen embeddings, 10% chance floor), which has not yet been decomposed from the motor-imagery-relevant structure.
Limitations
- No real headset tested — only replay outlet streaming recorded research data, never live electrodes.
- Vanilla contrastive pretraining has a real ceiling at 45–47% — three independent interventions all converged to the same band.
- Fusion requires Riemannian feature computation at inference time, not just the frozen encoder.
- Fixed 22-channel montage — a device with a different channel layout is not compatible without retraining.
- Small holdout set (2 subjects/dataset) — reported numbers are means over 2 held-out subjects, not a population-level claim.
Next Experiment
Try a metric-learning objective beyond vanilla NT-Xent (supervised-contrastive or prototypical-network, using pretrain-subject labels which are available but currently unused). Then broaden the holdout evaluation across several different random splits, not just one fixed 2-subject split per dataset.