ArchitectureBrain-Computer Interfaces (BCI)
An EEG BCI pipeline, from electrode to real-time command
An EEG BCI pipeline has six working stages: acquire and timestamp the signal, filter and remove artifacts, cut it into windows, extract features, decode intent and drive an interface that feeds back to the user. The paradigm you choose decides most of the rest, and honest evaluation on held-out sessions decides whether the system will work outside the lab.
On this page
- Picking motor imagery, P300 or SSVEP before writing any code
- Stages of the closed loop between headset and interface
- Acquisition and synchronization details that decide data quality
- Pre-processing and decoding terms used in this architecture
- Three decoder families compared for small, noisy EEG datasets
- Calibration, drift and the latency budget
- Evaluation mistakes that inflate offline accuracy
- Consent and governance hooks inside the signal pipeline
- Questions and answers
- Sources
Picking motor imagery, P300 or SSVEP before writing any code
Each paradigm asks something different of the user and produces a different signal for the decoder to find.
- If
Users must issue commands without looking at a screen, for example to steer a wheelchair or a cursor.
ThenUse motor imagery, where the user imagines moving a hand or foot and the decoder reads changes in sensorimotor rhythms.
It needs no external stimulus, but it demands the most training, and some users struggle to reach usable control at all.
- If
The task is choosing among many options, such as spelling or selecting menu items.
ThenUse a P300 event-related potential design that flashes options and detects the brain's response to the attended one.
Calibration is short, but selection is slow because each choice needs repeated flashes.
- If
Speed matters and users can fixate on visual targets.
ThenUse SSVEP, where targets flicker at distinct frequencies and the decoder detects which frequency dominates over visual cortex.
It needs little training, but flicker is tiring, and participants should be screened for photosensitive epilepsy.
Stages of the closed loop between headset and interface
- Acquire
Amplifier or headset streams samples through a device driver or BrainFlow.
- Timestamp and sync
Lab Streaming Layer aligns EEG with stimulus markers and other sensors on one clock.
- Filter and clean
Notch and band-pass filters, re-referencing and artifact handling.
- Window or epoch
Sliding windows for continuous control, stimulus-locked epochs for P300.
- Extract features
Spatial filters, covariance matrices or learned representations.
- Decode intent
A classifier turns features into a command with a confidence value.
- Act and feed back
The interface executes or withholds the command and shows the user the result.
- Log under consent
Raw signal, markers and outputs stored with consent tags for evaluation.
Acquisition and synchronization details that decide data quality
Most failed BCI experiments fail before the decoder. Check electrode contact and impedance at the start of each session and log it, because a single poor channel can dominate a spatial filter. Record at a sampling rate comfortably above the highest frequency you will analyze, and decide early whether you need dry electrodes for convenience or gel electrodes for signal quality.
Timing is the second trap. Lab Streaming Layer timestamps samples from every device against a shared clock and records multiple streams into one XDF file, so EEG, stimulus markers and eye tracking can be aligned afterwards1. BrainFlow offers a uniform API across many consumer and research boards, which keeps the acquisition layer replaceable if you change hardware2. Where stimulus timing matters, as it does for P300, verify the lag between the screen and the marker with a photodiode rather than trusting software events.
Store recordings in the Brain Imaging Data Structure's EEG format so channel locations, events and acquisition settings travel with the data and other tools can read it9.
Pre-processing and decoding terms used in this architecture
- Notch filter
- Removes a narrow band at the local mains frequency and its harmonics; MNE-Python documents both notch and spectrum-fitting approaches3.
- Band-pass filter
- Keeps the frequency range the paradigm depends on, such as sensorimotor rhythms for motor imagery, and removes slow drift.
- Re-referencing
- Expresses every channel relative to a chosen reference, often the common average, so results do not depend on one electrode.
- Independent component analysis
- Separates recorded signals into components so those driven by blinks, eye movement or heartbeat can be removed offline4.
- Artifact subspace reconstruction
- Detects and reconstructs high-variance bursts relative to clean calibration data, and can run online; it is implemented in EEGLAB's clean_rawdata plugin5.
- Common spatial patterns
- Learns spatial filters that maximize variance differences between two classes; the classic front end for motor imagery.
- Riemannian classifier
- Treats each window's channel covariance matrix as a point on a curved manifold and classifies by distance or in tangent space6.
- EEGNet
- A compact convolutional network designed to work across EEG paradigms with relatively few parameters7.
Three decoder families compared for small, noisy EEG datasets
| Criterion | CSP with LDA | Riemannian methods | Compact CNN such as EEGNet |
|---|---|---|---|
| Best fit | Two-class motor imagery | Motor imagery, P300 and SSVEP alike | Larger datasets or several paradigms in one model |
| Calibration data needed | Low | Low | Higher, unless pre-trained on other users |
| Compute at inference | Trivial | Light; covariance per window | Moderate; may need a GPU for training |
| Interpretability | Spatial patterns can be plotted | Distances are inspectable | Needs attribution methods |
| Handling session drift | Retrain or adapt filters | Re-center covariances per session | Fine-tuning or domain adaptation |
| Open tooling | MNE-Python | pyRiemann | Deep-learning libraries; MOABB for benchmarks |
Start with a Riemannian or CSP baseline. Move to a deep model only if it beats that baseline on held-out sessions, not on a single within-session split.
Calibration, drift and the latency budget
EEG changes between sessions as electrodes shift, users tire and impedance moves. Plan for a short calibration block at the start of each session, and test transfer methods such as covariance re-centering so returning users need less of it. Adaptive decoders that update during use can help, but they need guardrails so a run of errors does not teach the model the wrong thing.
For closed-loop control, write down a latency budget: the window length you need for a confident decision, the processing time per window, transport to the interface and screen refresh. Window length usually dominates, which is the real trade-off between speed and accuracy. Measure the whole loop end to end with a hardware marker rather than adding up stage estimates.
Evaluation mistakes that inflate offline accuracy
Leakage between training and test data
Early signalTrials from the same session or overlapping windows appear on both sides of the split.
MitigationSplit by session or by participant, and report which split you used.
Artifacts doing the classification
Early signalAccuracy collapses when frontal or temporal channels are removed.
MitigationCheck spatial patterns and rerun with eye and muscle artifacts removed.
Comparing against weak baselines
Early signalA new model is only compared with chance or an untuned classifier.
MitigationBenchmark against Riemannian and CSP pipelines on public datasets with MOABB8.
Offline results reported as control performance
Early signalNo closed-loop sessions with real feedback have been run.
MitigationReport online accuracy, selection time and calibration effort per user, including users who could not achieve control.
Consent and governance hooks inside the signal pipeline
Governance is easier to build into the pipeline than to bolt on later. Attach a consent identifier and allowed purposes to each recording's metadata at acquisition, pseudonymize participant identifiers before data reaches shared storage, and keep raw signal separate from derived features so retention can differ. The neural data privacy laws page explains which rules drive those choices.
ColdAI's BCI work covers exactly this software layer: acquisition pipelines, validated decoding models and benchmarks, and neural data governance, with medical uses left to a regulated device pathway led by clinical partners10.
Questions and answers
Can a consumer EEG headset be used for a BCI prototype?
Often, for early prototypes. Consumer headsets with few dry electrodes can support SSVEP or simple attention measures, but spatial filters for motor imagery need good coverage over sensorimotor areas. Check whether the device exposes raw signal and timestamps through its SDK or BrainFlow, and expect more artifacts than with a gel research system.
How much calibration data does an EEG decoder need?
It depends on paradigm and decoder rather than a fixed number. P300 and SSVEP decoders typically calibrate in minutes, while motor imagery usually needs longer sessions and repeated practice. Riemannian methods and CSP work with small datasets; deep models usually need more data or pre-training on other users. Measure the learning curve on your own pilot data.
Do EEG decoding models generalize across people?
Only partly. Head shape, electrode placement and individual brain activity differ enough that most systems still calibrate per user. Cross-subject transfer with covariance alignment or pre-trained networks can shorten calibration, and it should be evaluated with participants held out entirely, never mixed into training.
Is Python fast enough for a real-time EEG BCI?
Usually, yes. Filtering, covariance estimation and a linear or Riemannian classifier take far less time than the decision window itself. Real-time problems more often come from buffering, garbage collection pauses or display timing, so profile the full loop and keep acquisition in a separate process from decoding and the interface.
Sources
- Lab Streaming Layer: introduction — Lab Streaming Layer project · checked 10 October 2026
- BrainFlow — BrainFlow project · checked 10 October 2026
- Filtering and resampling data — MNE-Python · checked 10 October 2026
- Repairing artifacts with ICA — MNE-Python · checked 10 October 2026
- clean_rawdata EEGLAB plugin — Swartz Center for Computational Neuroscience · checked 10 October 2026
- pyRiemann documentation — pyRiemann · checked 10 October 2026
- EEGNet: a compact convolutional neural network for EEG-based brain-computer interfaces — Journal of Neural Engineering · checked 10 October 2026
- MOABB: Mother of All BCI Benchmarks — NeuroTechX · checked 10 October 2026
- BIDS specification: electroencephalography — Brain Imaging Data Structure · checked 10 October 2026
- Brain-Computer Interfaces (BCI) — ColdAI