EEG Preprocessing Requirements
What NimbusSDK Does
✅ Bayesian personalization (Personalizer) and standalone heads (LDA / QDA / Softmax / STS / Probit)✅ Real-time and batch inference with uncertainty
✅ Confidence scoring, gating (
BrainState), and quality assessment✅ Performance metrics (ITR, accuracy)
What NimbusSDK Does NOT Do
❌ Host or train deep EEG architectures (trunks stay external)❌ Raw EEG filtering (bandpass, notch)
❌ Artifact removal (ICA, regression, ASR)
❌ Spatial filtering (CSP, ICA, Laplacian)
❌ Feature extraction (bandpower, CSP, ERP)
Why This Separation?
- Preprocessing / encoding is paradigm-specific: Motor Imagery needs CSP at 8-30 Hz, P300 needs ERP at 0.5-10 Hz; foundation trunks define their own encode contract
- Hardware-dependent: Different amplifiers require different artifact handling
- Domain expertise: Use established tools (MNE-Python, EEGLAB, BrainDecode, etc.)
- Flexibility: You can use any preprocessing or encoder pipeline
- Focus: NimbusSDK excels at Bayesian personalization and inference, not signal processing
Encoder contract: Encoder contract. Classical tool integration: Real-time Setup.
Required Preprocessing Pipeline
Step 1: Bandpass Filtering
Remove frequencies outside the band of interest:
Tools: MNE-Python
raw.filter(), EEGLAB pop_eegfiltnew()
Step 2: Artifact Removal
Remove physiological and environmental artifacts:
Recommended: ICA (Independent Component Analysis) - Most versatile method
Step 3: Epoching
Segment continuous EEG into trials aligned to events: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 separabilityPitfall 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
Feature Normalization
For optimal performance, especially when using models across different sessions:- Same session: +1% accuracy
- Cross-session (next day): +15-25% accuracy
- Multi-subject transfer: +15-20% accuracy
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 Read
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”