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.

Reviewed 7 min read

On this page
  1. Picking motor imagery, P300 or SSVEP before writing any code
  2. Stages of the closed loop between headset and interface
  3. Acquisition and synchronization details that decide data quality
  4. Pre-processing and decoding terms used in this architecture
  5. Three decoder families compared for small, noisy EEG datasets
  6. Calibration, drift and the latency budget
  7. Evaluation mistakes that inflate offline accuracy
  8. Consent and governance hooks inside the signal pipeline
  9. Questions and answers
  10. 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.

    Then

    Use 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.

    Then

    Use 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.

    Then

    Use 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

samplestimestampedcommanduser adaptsrecording01Acquire02Timestamp and sync03Filter and clean04Window or epoch05Extract features06Decode intent07Act and feed back08Log under consent
  1. Acquire

    Amplifier or headset streams samples through a device driver or BrainFlow.

  2. Timestamp and sync

    Lab Streaming Layer aligns EEG with stimulus markers and other sensors on one clock.

  3. Filter and clean

    Notch and band-pass filters, re-referencing and artifact handling.

  4. Window or epoch

    Sliding windows for continuous control, stimulus-locked epochs for P300.

  5. Extract features

    Spatial filters, covariance matrices or learned representations.

  6. Decode intent

    A classifier turns features into a command with a confidence value.

  7. Act and feed back

    The interface executes or withholds the command and shows the user the result.

  8. Log under consent

    Raw signal, markers and outputs stored with consent tags for evaluation.

Conceptual architecture of a non-invasive EEG BCI loop. It shows how data moves between stages, not a specific product or measured performance.

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

CriterionCSP with LDARiemannian methodsCompact CNN such as EEGNet
Best fitTwo-class motor imageryMotor imagery, P300 and SSVEP alikeLarger datasets or several paradigms in one model
Calibration data neededLowLowHigher, unless pre-trained on other users
Compute at inferenceTrivialLight; covariance per windowModerate; may need a GPU for training
InterpretabilitySpatial patterns can be plottedDistances are inspectableNeeds attribution methods
Handling session driftRetrain or adapt filtersRe-center covariances per sessionFine-tuning or domain adaptation
Open toolingMNE-PythonpyRiemannDeep-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.

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

  1. Lab Streaming Layer: introduction — Lab Streaming Layer project · checked 10 October 2026
  2. BrainFlow — BrainFlow project · checked 10 October 2026
  3. Filtering and resampling data — MNE-Python · checked 10 October 2026
  4. Repairing artifacts with ICA — MNE-Python · checked 10 October 2026
  5. clean_rawdata EEGLAB plugin — Swartz Center for Computational Neuroscience · checked 10 October 2026
  6. pyRiemann documentation — pyRiemann · checked 10 October 2026
  7. EEGNet: a compact convolutional neural network for EEG-based brain-computer interfaces — Journal of Neural Engineering · checked 10 October 2026
  8. MOABB: Mother of All BCI Benchmarks — NeuroTechX · checked 10 October 2026
  9. BIDS specification: electroencephalography — Brain Imaging Data Structure · checked 10 October 2026
  10. Brain-Computer Interfaces (BCI) — ColdAI

More in Brain-Computer Interfaces (BCI)

Back to Brain-Computer Interfaces (BCI)

Next step

Get a second opinion on your EEG pipeline before the next study

Send a sample recording with markers, your protocol and your current evaluation results. We will review acquisition, pre-processing and evaluation design and return a written list of changes, ranked by expected impact on held-out performance.

Send a sample recording