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| 8 |
+
- data-synthesis
|
| 9 |
+
- pytorch
|
| 10 |
+
language: en
|
| 11 |
+
library_name: pytorch
|
| 12 |
+
datasets:
|
| 13 |
+
- physionet/eegmmidb
|
| 14 |
+
model-index:
|
| 15 |
+
- name: EEG Data Synthesis with WGAN-GP
|
| 16 |
+
results: []
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# EEG Data Synthesis with WGAN-GP
|
| 20 |
+
|
| 21 |
+
**Model Type:** Conditional WGAN-GP
|
| 22 |
+
**Dataset:** [EEG Motor Movement/Imagery Dataset (PhysioNet)](https://physionet.org/content/eegmmidb/1.0.0/)
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Model Summary
|
| 27 |
+
|
| 28 |
+
This model implements a **Wasserstein GAN with Gradient Penalty (WGAN-GP)** for generating **subject-conditioned synthetic EEG signals** based on the PhysioNet EEG Motor Movement/Imagery dataset.
|
| 29 |
+
|
| 30 |
+
It generates realistic EEG segments that mimic real recordings in both **time** and **frequency** domains.
|
| 31 |
+
|
| 32 |
+
**Applications:**
|
| 33 |
+
- EEG data augmentation
|
| 34 |
+
- Privacy-preserving EEG synthesis
|
| 35 |
+
- Adversarial and spoofing research in BCI security
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## Model Architecture
|
| 40 |
+
|
| 41 |
+
### Generator (G)
|
| 42 |
+
- **Input:** Latent vector *z ∈ ℝ¹²⁸* + subject embedding (128-dim)
|
| 43 |
+
- **Layers:**
|
| 44 |
+
- Fully connected → reshape to (64, 120)
|
| 45 |
+
- Dilated ConvTranspose1D stack → (64, 480)
|
| 46 |
+
- Gaussian noise injection
|
| 47 |
+
- **Activation:** `tanh`
|
| 48 |
+
- **Output:** EEG segment (64 channels × 480 samples)
|
| 49 |
+
|
| 50 |
+
### Discriminator / Critic (D)
|
| 51 |
+
- **Input:** EEG + embedded label
|
| 52 |
+
- Conv2D + LeakyReLU + global pooling + linear critic output
|
| 53 |
+
- **Regularization:** Dropout + drift penalty + gradient penalty
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
## Training Configuration
|
| 58 |
+
|
| 59 |
+
| Parameter | Value |
|
| 60 |
+
|------------|--------|
|
| 61 |
+
| Optimizer | Adam (β₁=0.0, β₂=0.9) |
|
| 62 |
+
| Learning Rate (G/D) | 1e-4 / 5e-5 |
|
| 63 |
+
| Gradient Penalty λ | 10 |
|
| 64 |
+
| Drift Regularization | 1e-3 × D(real)² |
|
| 65 |
+
| n_critic | 3 |
|
| 66 |
+
| Epochs | 300 |
|
| 67 |
+
| Mixed Precision | Enabled (GradScaler) |
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
## Dataset
|
| 72 |
+
|
| 73 |
+
**Source:** PhysioNet EEG Motor Movement/Imagery Dataset
|
| 74 |
+
**Subjects:** 109
|
| 75 |
+
**Channels:** 64
|
| 76 |
+
**Sampling Rate:** 160 Hz
|
| 77 |
+
**Segment Length:** 480 samples (~3 seconds)
|
| 78 |
+
**Tasks:** Motor imagery (fists, feet) + baseline (eyes open/closed)
|
| 79 |
+
|
| 80 |
+
**Preprocessing:**
|
| 81 |
+
- Downsampled to smallest subject class
|
| 82 |
+
- Per-channel normalization to [-1, 1]
|
| 83 |
+
- Integer-encoded subject IDs (0–108)
|
| 84 |
+
|
| 85 |
+
---
|
| 86 |
+
|
| 87 |
+
## Training Behavior
|
| 88 |
+
|
| 89 |
+
Training remained stable across all epochs — no mode collapse or exploding gradients.
|
| 90 |
+
|
| 91 |
+
| Metric | Mean | Std |
|
| 92 |
+
|---------|------|-----|
|
| 93 |
+
| D(real) | −0.43 | ±0.06 |
|
| 94 |
+
| D(fake) | 0.38 | ±0.04 |
|
| 95 |
+
| GP term | 0.96 | ±0.08 |
|
| 96 |
+
| G loss | −0.41 | ±0.05 |
|
| 97 |
+
|
| 98 |
+
---
|
| 99 |
+
|
| 100 |
+
## Evaluation & Results
|
| 101 |
+
|
| 102 |
+
### Visual & Spectral Fidelity
|
| 103 |
+
- Synthetic EEG signals preserve **oscillatory structure** and amplitude range (±100 µV normalized).
|
| 104 |
+
- **Channel correlations** match real EEG patterns.
|
| 105 |
+
- Spectral energy distribution consistent with 1–40 Hz range.
|
| 106 |
+
|
| 107 |
+
### Quantitative Similarity
|
| 108 |
+
|
| 109 |
+
| Metric | Mean | Std | Interpretation |
|
| 110 |
+
|---------|------|-----|----------------|
|
| 111 |
+
| MSE | 2.279 | 2.806 | Low reconstruction error |
|
| 112 |
+
| MAE | 0.870 | 0.487 | Normalized amplitude deviation |
|
| 113 |
+
| Correlation | −0.0014 | 0.075 | Low linear correlation due to stochastic nature |
|
| 114 |
+
| MMD | 0.0129 | — | Good distribution alignment |
|
| 115 |
+
| Fréchet PCA (32-D) | 40092.3 | — | Baseline EEG-FID |
|
| 116 |
+
| Covariance Similarity | 0.673 | ±0.182 | Preserves inter-channel dependencies |
|
| 117 |
+
|
| 118 |
+
### Bandpower Fidelity
|
| 119 |
+
|
| 120 |
+
| Band | Δ Mean | Δ Std | Interpretation |
|
| 121 |
+
|------|---------|--------|----------------|
|
| 122 |
+
| Delta (1–4 Hz) | 0.391 | 0.675 | Slight underfit |
|
| 123 |
+
| Theta (4–8 Hz) | 0.082 | 0.131 | Close match |
|
| 124 |
+
| Alpha (8–13 Hz) | 0.032 | 0.038 | Excellent fidelity |
|
| 125 |
+
| Beta (13–30 Hz) | 0.012 | 0.016 | Excellent fidelity |
|
| 126 |
+
| Gamma (30–40 Hz) | 0.0007 | 0.0014 | Negligible difference |
|
| 127 |
+
|
| 128 |
+
---
|
| 129 |
+
|
| 130 |
+
## Discussion
|
| 131 |
+
|
| 132 |
+
This WGAN-GP model effectively learns to reproduce **subject-specific EEG morphology** and maintains **stable training** across complex, high-dimensional signals.
|
| 133 |
+
|
| 134 |
+
It provides a promising basis for **privacy-preserving EEG synthesis** and **data augmentation** in BCI research.
|
| 135 |
+
|
| 136 |
+
---
|
| 137 |
+
|
| 138 |
+
## References
|
| 139 |
+
|
| 140 |
+
- Arjovsky, M., Chintala, S., & Bottou, L. (2017). *Wasserstein GAN.* arXiv:1701.07875
|
| 141 |
+
- Gulrajani, I. et al. (2017). *Improved Training of Wasserstein GANs.* NIPS
|
| 142 |
+
- Lawhern, V. J. et al. (2018). *EEGNet: A Compact CNN for EEG-based BCI.* *J. Neural Eng.*, 15(5), 056013
|
| 143 |
+
- Goldberger, A. L. et al. (2000). *PhysioBank, PhysioToolkit, and PhysioNet.* *Circulation*, 101(23), e215–e220
|
| 144 |
+
|
| 145 |
+
---
|