Skip to main content

EEG Preprocessing Requirements

NimbusSDK expects embeddings or preprocessed features, NOT raw EEG.The SDK performs Bayesian inference on feature-space data — either frozen-encoder embeddings (encode(X) → Z) or classical CSP / bandpower / ERP features.
Two valid handoffs into Nimbus
  1. Product path: freeze a neural trunk → wrapPersonalizerBrainState (Nimbus does not own the DL architecture).
  2. Classical path: extract CSP / bandpower / ERP features → NimbusLDA / other heads (this page).

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?

  1. 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
  2. Hardware-dependent: Different amplifiers require different artifact handling
  3. Domain expertise: Use established tools (MNE-Python, EEGLAB, BrainDecode, etc.)
  4. Flexibility: You can use any preprocessing or encoder pipeline
  5. 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.
Output dimension: 2 × n_components (e.g., 16 for 8 components)

Bandpower Features - SSVEP

Compute power in specific frequency bands:
Output dimension: n_channels × n_bands

ERP Amplitude - P300

Extract amplitude at specific time windows:

Paradigm-Specific Guidelines

Motor Imagery

Recommended pipeline:
  1. Bandpass: 8-30 Hz (mu + beta)
  2. Artifact removal: ICA (remove eye blinks)
  3. Epoching: 0-4 seconds post-cue
  4. Feature extraction: CSP (8 components → 16 features)
  5. Temporal aggregation: Log-variance
Data requirements:
  • Minimum: 40 trials per class
  • Recommended: 80+ trials per class
Expected accuracy: 70-90% (subject-dependent)

P300

Recommended pipeline:
  1. Bandpass: 0.5-10 Hz
  2. Artifact removal: ICA or rejection
  3. Epoching: -0.2 to 0.8 seconds post-stimulus
  4. Feature extraction: ERP amplitude (300-500ms window)
  5. Temporal aggregation: Mean
Data requirements:
  • Minimum: 200 target, 1000 non-target trials
  • Recommended: 400 target, 2000 non-target trials
Expected accuracy: 80-95% (with averaging)

SSVEP

Recommended pipeline:
  1. Bandpass: Target frequency ± 2 Hz
  2. Artifact removal: Eye blink rejection
  3. Epoching: 2-4 seconds post-onset
  4. Feature extraction: CCA or bandpower
  5. No baseline correction (steady-state)
Data requirements:
  • Minimum: 30 trials per frequency
  • Recommended: 60+ trials per frequency
Expected accuracy: 85-98%

Data Format Requirements

Expected Format

Where:
  • 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:
Convert 0-indexed to 1-indexed:

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

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

Feature Normalization

Feature normalization is CRITICAL for cross-session BCI!EEG amplitude varies 50-200% across sessions. Proper normalization improves cross-session accuracy by 15-30%.
For optimal performance, especially when using models across different sessions:
Impact:
  • Same session: +1% accuracy
  • Cross-session (next day): +15-25% accuracy
  • Multi-subject transfer: +15-20% accuracy
See Feature Normalization for the recommended train/test scaling workflow.

Preprocessing Diagnostics

NimbusSDK includes built-in diagnostics:
What it checks:
  • 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

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”