Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install hiyenwong-ai-collection-collection-skills-cross-subject-eeg-decodinggit clone https://github.com/hiyenwong/ai_collection.gitcp ai_collection/SKILL.MD ~/.claude/skills/hiyenwong-ai-collection-collection-skills-cross-subject-eeg-decoding/SKILL.md---
name: cross-subject-eeg-decoding
description: "Cross-Subject Generalization for EEG Decoding — comprehensive survey of deep learning methods addressing inter-subject variability in EEG-based BCI. Covers domain adaptation, meta-learning, data augmentation, Riemannian geometry, and subject-independent evaluation protocols. Activation: cross-subject EEG, EEG domain adaptation, BCI generalization, subject-independent EEG, EEG transfer learning."
category: ai_collection
source:
paper: "Cross-Subject Generalization for EEG Decoding: A Survey of Deep Learning Methods"
authors:
- "Taida Li"
- "Yujun Yan"
- "Fei Dou"
- "Wenzhan Song"
- "Xiang Zhang"
arxiv: "2604.27033"
date: "2026-04-29"
fields:
- cs.LG
- eess.SP
- q-bio.NC
activation_keywords:
en:
- cross-subject EEG
- EEG decoding
- BCI generalization
- EEG domain adaptation
- subject-independent EEG
- EEG transfer learning
- inter-subject variability
- Riemannian EEG
- EEG meta-learning
- EEG data augmentation
- brain-computer interface
- EEG foundation model
- zero-shot EEG
zh:
- 跨被试脑电解码
- 脑机接口泛化
- EEG域适应
- 被试无关EEG
- EEG迁移学习
- 被试间差异
- 黎曼几何脑电
- EEG元学习
- 脑电数据增强
version: "1.0.0"
---
# Cross-Subject EEG Decoding: Deep Learning Methods for Generalization
> **Reference:** Li, T. et al. *Cross-Subject Generalization for EEG Decoding: A Survey of Deep Learning Methods.* arXiv:2604.27033 [cs.LG] (2026).
## Overview
This survey comprehensively reviews deep learning approaches for **cross-subject EEG decoding** — the challenge of training models on some subjects and generalizing to unseen test subjects. The core problem is **high inter-subject variability** that introduces severe domain shift between training and test distributions.
## Problem Formalization
Cross-subject EEG decoding is formalized as a **multi-source domain generalization** problem:
- **Source domains**: Labeled EEG data from N seen subjects {S₁, S₂, ..., Sₙ}
- **Target domain**: Unlabeled EEG data from M unseen subjects {T₁, T₂, ..., Tₘ}
- **Goal**: Learn a model f: X → Y that generalizes to target domains without target-domain fine-tuning
### Key Challenge: Domain Shift Sources
| Shift Type | Description |
|---|---|
| **Anatomical** | Head shape, brain size, skull thickness affect signal propagation |
| **Electrode** | Slight electrode placement differences between sessions/subjects |
| **Cognitive** | Individual strategies, attention levels, fatigue states differ |
| **Physiological** | Age, gender, neurological conditions alter signal characteristics |
---
## Methodology Taxonomy
### Category 1: Domain Adaptation Methods
Align source and target domain distributions:
**1a. Feature Alignment (MMD, CORAL, adversarial)**
```python
import torch
import torch.nn as nn
class DomainAdversarialEEG(nn.Module):
"""Domain-adversarial EEG decoder with gradient reversal."""
def __init__(self, n_channels=22, n_classes=4, domain_dim=64):
super().__init__()
# Feature extractor (shared)
self.feature_extractor = nn.Sequential(
nn.Conv2d(1, 32, (1, n_channels), padding=(0, n_channels//2)),
nn.BatchNorm2d(32),
nn.ELU(),
nn.Conv2d(32, 64, (10, 1)),
nn.BatchNorm2d(64),
nn.ELU(),
nn.Flatten(),
nn.Linear(64 * 128, domain_dim),
)
# Task classifier
self.task_head = nn.Linear(domain_dim, n_classes)
# Domain discriminator
self.domain_head = nn.Linear(domain_dim, 2)
def forward(self, x, alpha=1.0):
features = self.feature_extractor(x)
task_logits = self.task_head(features)
# Gradient reversal for domain adversarial training
reversed_features = GradientReversal.apply(features, alpha)
domain_logits = self.domain_head(reversed_features)
return task_logits, domain_logits
class GradientReversal(torch.autograd.Function):
@staticmethod
def forward(ctx, x, alpha):
ctx.alpha = alpha
return x
@staticmethod
def backward(ctx, grad_output):
return grad_output.neg() * ctx.alpha, None
```
**1b. Riemannian Alignment**
- Map covariance matrices to tangent space at the Riemannian mean
- Apply Riemannian Procrustes Analysis (RPA) for domain alignment
- Particularly effective for motor imagery and P300 paradigms
**1c. Conditional Domain Adaptation**
- Align class-conditional distributions, not just marginal
- Use pseudo-labels or entropy minimization on target domain
### Category 2: Meta-Learning Approaches
**2a. MAML-based EEG**
```python
class MetaEEG:
"""MAML-based cross-subject EEG decoder."""
def __init__(self, model, inner_lr=0.01, outer_lr=0.001):
self.model = model
self.inner_lr = inner_lr
self.outer_lr = outer_lr
def meta_train_step(self, support_sets, query_sets):
"""One meta-training iteration across multiple subjects."""
meta_grads = []
for support_X, support_y, query_X, query_y in zip(
support_sets, query_sets
):
# Inner loop: adapt to support subject
adapted = self.clone_model()
for _ in range(5): # inner steps
pred = adapted(support_X)
loss = F.cross_entropy(pred, support_y)
adapted.update_params(loss, lr=self.inner_lr)
# Outer loop: evaluate on query
pred = adapted(query_X)
loss = F.cross_entropy(pred, query_y)
meta_grads.append(torch.autograd.grad(loss, self.model.parameters()))
# Average meta-gradients
self.apply_meta_gradients(meta_grads, self.outer_lr)
```
**2b. Prototypical Networks for EEG**
- Learn class prototypes in feature space
- Classification via distance to prototypes
- Naturally handles novel subjects by comparing to learned prototypes
### Category 3: Data Augmentation
**3a. Signal-Level Augmentation**
- Time warping, frequency shifting, amplitude scaling
- Mixup between subjects
- Gaussian noise injection (simulating recording noise)
**3b. Generative Augmentation**
- VAE/GAN-based EEG synthesis for unseen subjects
- Style transfer: transfer subject-specific characteristics
- Conditional generation: generate task-specific EEG for target subjects
**3c. Spatial Augmentation**
- Channel dropout/masking (simulating electrode variation)
- Spatial transformation (simulating placement differences)
### Category 4: Domain-Invariant Representation Learning
**4a. Invariant Risk Minimization (IRM)**
- Learn representations where optimal classifier is invariant across domains
- Penalize classifier variance across subjects
**4b. Subject-Agnostic Feature Learning**
- Remove subject-identifying information from features
- Adversarial subject classification to enforce subject-invariance
### Category 5: Transfer Learning & Fine-Tuning
**5a. Pretrain-Finetune Paradigm**
- Pretrain on large multi-subject dataset
- Fine-tune on small calibration data from new subject (few-shot)
**5b. Subject-Specific Adapter Layers**
- Shared base network + small subject-specific adapter modules
- Learn adapters from minimal calibration data
---
## Evaluation Protocol
### Subject-Independent Cross-Validation
```python
def leave_one_subject_out_cv(X, y, subjects, model_class):
"""Leave-one-subject-out cross-validation for EEG."""
unique_subjects = np.unique(subjects)
accuracies = []
for test_subj in unique_subjects:
# Train on all other subjects
train_mask = subjects != test_subj
test_mask = subjects == test_subj
model = model_class()
model.fit(X[train_mask], y[train_mask])
acc = model.score(X[test_mask], y[test_mask])
accuracies.append(acc)
return np.mean(accuracies), np.std(accuracies)
```
### Key Metrics
| Metric | Description |
|---|---|
| **Mean Accuracy** | Average accuracy across all left-out subjects |
| **Accuracy Drop** | Difference between within-subject and cross-subject accuracy |
| **AUC-ROC** | Area under ROC curve (for binary tasks) |
| **Kappa Score** | Chance-corrected agreement |
| **Information Transfer Rate** | Bits per minute for BCI applications |
---
## Benchmark Datasets
| Dataset | Paradigm | Subjects | Classes | Notes |
|---|---|---|---|---|
| **BCI IV 2a** | Motor Imagery | 9 | 4 | Standard benchmark |
| **BCI IV 2b** | Motor Imagery | 9 | 2 | Binary MI |
| **OpenBMI** | Motor Imagery | 54 | 2 | Large-scale |
| **TUH EEG** | Various | 1000+ | Multiple | Clinical |
| **PhysioNet MI** | Motor Imagery | 109 | 4 | Large-scale MI |
| **SEED** | Emotion | 15 | 3 | Affective computing |
---
## Best Practices
1. **Always use leave-one-subject-out CV** — k-fold random split inflates cross-subject performance
2. **Report within-subject baseline** — to quantify the domain shift magnitude
3. **Riemannian methods are strong baselines** — often outperform deep learning on small datasets
4. **Domain adaptation works best with some target data** — unsupervised DA with unlabeled target samples
5. **Meta-learning shines in few-shot** — when only minutes of calibration data available
6. **Data augmentation is cheap and effective** — always apply as a preprocessing step
7. **Subject-specific adapters** — best trade-off between generalization and personalization
8. **Beware of data leakage** — ensure no temporal overlap between train and test splits
9. **Channel selection matters** — use consistent channel subsets across subjects
10. **Preprocessing standardization** — consistent filtering, referencing, and epoching across subjects
## References
- Li, T. et al. (2026). *Cross-Subject Generalization for EEG Decoding: A Survey of Deep Learning Methods.* arXiv:2604.27033 [cs.LG].
- Related: eeg-foundation-model-adapters, samga-subject-aware-multi-granularity-eeg-image