EEG Preprocessing Requirements
NimbusSDK expects preprocessed features, NOT raw EEG.The SDK performs Bayesian inference on feature-space data. You must preprocess your raw EEG signals before using NimbusSDK.
What NimbusSDK Does
✅ Bayesian inference with Bayesian LDA (RxLDA) and Bayesian GMM (RxGMM) models✅ Real-time and batch classification
✅ Confidence scoring and quality assessment
✅ Performance metrics (ITR, accuracy)
What NimbusSDK Does NOT Do
❌ Raw EEG filtering (bandpass, notch)❌ Artifact removal (ICA, regression, ASR)
❌ Spatial filtering (CSP, ICA, Laplacian)
❌ Feature extraction (bandpower, CSP, ERP)
Why This Separation?
- Preprocessing is paradigm-specific: Motor Imagery needs CSP at 8-30 Hz, P300 needs ERP at 0.5-10 Hz
- Hardware-dependent: Different amplifiers require different artifact handling
- Domain expertise: Use established tools (MNE-Python, EEGLAB, etc.)
- Flexibility: You can use any preprocessing pipeline (Python, MATLAB, custom)
- Focus: NimbusSDK excels at Bayesian inference, not signal processing
For integration examples with preprocessing tools, see Real-time Setup
Required Preprocessing Pipeline
Step 1: Bandpass Filtering
Remove frequencies outside the band of interest:| BCI Paradigm | Frequency Band | Rationale |
|---|---|---|
| Motor Imagery | 8-30 Hz | Mu rhythm (8-13 Hz) and Beta rhythm (13-30 Hz) |
| P300 | 0.5-10 Hz | Slow event-related potentials |
| SSVEP | Target ± 2 Hz | Narrow band around stimulation frequency |
raw.filter(), EEGLAB pop_eegfiltnew()
Step 2: Artifact Removal
Remove physiological and environmental artifacts:| Artifact Type | Frequency Range | Removal Method |
|---|---|---|
| Eye blinks | 0-4 Hz, high amplitude | ICA (remove components) |
| Muscle | >30 Hz, high amplitude | ICA or thresholding |
| Line noise | 50/60 Hz | Notch filter |
| Movement | 0-10 Hz, transient | Regression or rejection |
Step 3: Epoching
Segment continuous EEG into trials aligned to events:| Paradigm | Time Window | Baseline |
|---|---|---|
| Motor Imagery | 0 to 4 seconds post-cue | -0.5 to 0 seconds |
| P300 | -0.2 to 0.8 seconds post-stimulus | -0.2 to 0 seconds |
| SSVEP | 2 to 4 seconds post-onset | No baseline (steady-state) |
Step 4: Feature Extraction
Convert filtered epochs to discriminative features (see below).Feature Types
CSP (Common Spatial Patterns) - Motor Imagery
Recommended for Motor Imagery CSP maximizes variance ratio between two classes, making it ideal for motor imagery BCI.2 × n_components (e.g., 16 for 8 components)
Bandpower Features - SSVEP
Compute power in specific frequency bands:n_channels × n_bands
ERP Amplitude - P300
Extract amplitude at specific time windows:Paradigm-Specific Guidelines
Motor Imagery
Recommended pipeline:- Bandpass: 8-30 Hz (mu + beta)
- Artifact removal: ICA (remove eye blinks)
- Epoching: 0-4 seconds post-cue
- Feature extraction: CSP (8 components → 16 features)
- Temporal aggregation: Log-variance
- Minimum: 40 trials per class
- Recommended: 80+ trials per class
P300
Recommended pipeline:- Bandpass: 0.5-10 Hz
- Artifact removal: ICA or rejection
- Epoching: -0.2 to 0.8 seconds post-stimulus
- Feature extraction: ERP amplitude (300-500ms window)
- Temporal aggregation: Mean
- Minimum: 200 target, 1000 non-target trials
- Recommended: 400 target, 2000 non-target trials
SSVEP
Recommended pipeline:- Bandpass: Target frequency ± 2 Hz
- Artifact removal: Eye blink rejection
- Epoching: 2-4 seconds post-onset
- Feature extraction: CCA or bandpower
- No baseline correction (steady-state)
- Minimum: 30 trials per frequency
- Recommended: 60+ trials per frequency
Data Format Requirements
Expected Format
n_features: Number of extracted features (e.g., 16 for CSP)n_samples: Samples per trial (e.g., 1000 for 4 seconds at 250 Hz)n_trials: Number of trials
Converting from Python/NumPy
Python typically uses(n_trials, n_features, n_samples):
Labels
Labels must be 1-indexed integers:Common Pitfalls
Pitfall 1: Using Raw EEG Instead of Features
Symptom: Accuracy near chance level (25% for 4-class) Fix: Apply feature extraction (CSP, bandpower, etc.)Pitfall 2: Wrong Frequency Band
Symptom: Low confidence scores, poor separability| Paradigm | Correct Band | Wrong Band | Result |
|---|---|---|---|
| Motor Imagery | 8-30 Hz | 0.5-10 Hz | Accuracy ↓ 20-30% |
| P300 | 0.5-10 Hz | 8-30 Hz | Amplitude ↓, noise ↑ |
Pitfall 3: Incorrect Data Shape
Symptom:DimensionMismatch error
Validation Checklist
Before using NimbusSDK, verify:Data Quality ✅
- No NaN values:
@assert !any(isnan, features) - No Inf values:
@assert !any(isinf, features) - Finite range: Values are reasonable
- No constant features: Each feature varies
Preprocessing Steps ✅
- Bandpass filtered: Paradigm-appropriate frequency band
- Artifacts removed: ICA or equivalent applied
- Epoched correctly: Proper time windows
- Features extracted: CSP/bandpower/ERP, not raw EEG
Format Requirements ✅
- Correct shape:
(n_features × n_samples × n_trials) - Correct type:
Float64(or convertible) - Labels valid: 1-indexed integers
- Metadata accurate: Sampling rate, paradigm, feature type
Preprocessing Diagnostics
NimbusSDK includes built-in diagnostics:- Line noise (50/60 Hz components)
- Amplitude range (detects raw EEG vs features)
- DC offset
- Temporal correlation
- Feature normalization
- NaN/Inf values
Next Steps
Real-time Setup
Integration with EEG acquisition systems
Batch Processing
Process multiple trials efficiently
Julia SDK
Complete SDK reference
Code Examples
Working preprocessing examples
Additional Resources
Tools
- MNE-Python - Python EEG processing
- EEGLAB - MATLAB EEG processing
- BrainFlow - Hardware integration
Papers
- Ramoser et al. (2000). “Optimal spatial filtering of single trial EEG”
- Blankertz et al. (2008). “Optimizing spatial filters for robust EEG single-trial analysis”
- Lotte et al. (2018). “A review of classification algorithms for EEG-based BCI”