Back to Journal
Neurotechnology 9 min read

How to Process Raw EEG Data for Real-Time BCI Applications

A deterministic pre-processing pipeline for turning noisy consumer-grade EEG headsets into stable focus, relaxation, and fatigue scores in real time.

Key Takeaways

  • Raw consumer EEG is dirty: variable sample rates, shifting electrode montages, and 50/60 Hz powerline noise make naive classifiers useless.
  • A deterministic, fixed-order pipeline (resample → bandpass → notch → baseline) is the difference between a demo and a shippable product.
  • Map device-specific electrodes to three stable virtual channels (frontal, left-temporal, right-temporal) with a fallback to PCA so one model serves every headset.
  • Extract log-RMS bandpower for delta, alpha, and beta over 2-second sliding windows to produce a fixed [T, 9] feature tensor.
  • Budget end-to-end latency under ~250 ms and run inference on-device to keep wellness feedback loops responsive and private.
  • Reject blink and muscle artifacts by dropping contaminated windows rather than repairing them, and z-score features against a short per-user calibration so one model generalizes across very different heads.

Building brain-computer interfaces (BCIs) that run smoothly on consumer devices means bridging the gap between noisy analog sensors and digital classifiers. Raw electroencephalogram (EEG) signals are notoriously dirty: they arrive at varying sample rates, from inconsistent electrode montages, soaked in environmental electrical noise. Feed that directly into a model and you get a system that scores beautifully in the lab and falls apart the moment a real person puts on a real headset in a real room.

To deliver reliable focus, relaxation, and fatigue scoring in real time for wellness applications like our mobile client BrainCare, you need a deterministic pre-processing pipeline: the same operations, in the same order, every time. Below is the engineering blueprint we use to map raw multi-channel data into stable feature vectors a classifier can trust.

Why is raw EEG so hard to work with?

Consumer EEG has three structural problems that lab equipment does not. First, sample rates vary by vendor and firmware: 128 Hz, 250 Hz, 256 Hz, and 512 Hz are all common, and a model trained on one rate produces garbage on another. Second, electrode placement is inconsistent. A four-channel headband and a sixteen-channel cap do not see the brain the same way, and even the same device shifts position between sessions. Third, the signal is buried in noise: 50/60 Hz powerline hum, muscle artifacts from jaw clenching, eye-blink spikes, and slow DC drift all dwarf the microvolt-scale neural activity you actually care about.

The fix is not a smarter model. It is a disciplined, reproducible pipeline that normalizes all of this variation away before a single feature is computed.

Step 1: How do you standardize and de-noise the raw stream?

The incoming stream must be resampled, bandpass filtered, notch filtered, and baseline stabilized before any feature extraction. The order is not negotiable, because each stage assumes the previous one has already run:

  1. Resample: Polyphase resample the incoming stream to a standardized 200 Hz so every downstream constant (filter coefficients, window length, tensor shape) is identical across devices.
  2. Bandpass filter: Apply a Butterworth bandpass from 1 Hz to 60 Hz to isolate neural frequencies and discard slow drift and high-frequency junk.
  3. Notch filter: Notch at 50 Hz or 60 Hz depending on the user's region to cancel ambient powerline interference.
  4. Median subtraction: Perform per-channel baseline subtraction to remove slow DC offset drift that would otherwise bias every feature.

How do you remove eye-blink and muscle artifacts?

Bandpass and notch filtering clear powerline hum and slow drift, but two stubborn biological artifacts survive because they overlap the very bands you want to keep. Eye blinks produce large, slow deflections concentrated at the frontal electrodes — routinely ten to a hundred times the amplitude of the underlying EEG. Muscle activity (EMG) from jaw clenching, swallowing, or neck tension injects broadband high-frequency energy that masquerades as beta and will fake a spike in "concentration" every time the user shifts in their seat.

A real-time consumer pipeline cannot afford heavyweight offline methods like manual ICA component rejection. Three lightweight, deterministic tactics handle the vast majority of contamination:

  • Amplitude gating: flag any window whose peak-to-peak amplitude exceeds a per-channel threshold (on the order of ±150 µV after scaling) and either drop it or hold the last valid score. A single blink should never be allowed to jerk the focus meter.
  • Frontal regression: because blinks dominate the frontal channel, subtract a scaled copy of that channel from the two temporal channels to suppress blink leakage — no full ICA decomposition required.
  • Variance clamping: reject windows where short-time variance jumps far above the running median, the tell-tale signature of an EMG burst, so a jaw clench does not register as cognitive load.

The guiding principle is to reject rather than repair in real time. It is always safer to withhold a score for a few hundred milliseconds than to emit a confident number computed from a window you know is dirty.

Step 2: How do you handle different electrode layouts?

Because every headset uses a different montage, incoming channels must be mapped onto a small, stable set of virtual channels before features are computed. We collapse any device down to three: frontal, left-temporal, and right-temporal. The mapping uses a deterministic candidate table, with PCA as a last-resort fallback when named electrodes are unavailable:

FRONTAL:  average of [Fp1, Fp2, Fpz, AF3, AF4]
TEMP_L:   first available in [T7, FT7, TP7, F7]
TEMP_R:   first available in [T8, FT8, TP8, F8]
FALLBACK: run PCA, take the top 3 principal components

This single abstraction is what lets one trained classifier serve a $200 headband and a research-grade cap without retraining. The model never sees device-specific electrode names; it only ever sees three clean virtual channels.

Step 3: How do you extract features from the cleaned signal?

With clean virtual channels in hand, extract features using sliding windows — a 2.0-second window with a 0.5-second stride works well, giving four overlapping feature frames per second. For each virtual channel, compute the Root-Mean-Square (RMS) bandpower across three key frequency bands:

  • Delta (0.5-4 Hz): deep rest, drowsiness, and sleep onset.
  • Alpha (8-13 Hz): relaxed wakefulness, meditation, and eyes-closed calm.
  • Beta (14-30 Hz): active concentration and cognitive load.

Log-transform the RMS power to compress the dynamic range: feature = ln(1e-8 + rms). The tiny additive constant keeps the logarithm finite when a channel goes silent. The result is a fixed-width tensor of shape [T, 9] — three channels times three bands — ready to feed into a temporal convolutional network (TCN) classifier like our model BrainVee.

Step 4: How do you keep it real-time and private?

Wellness feedback only feels "live" if the loop from electrode to on-screen score stays under roughly 250 ms. Because the pipeline above is arithmetic on small buffers, it runs comfortably on-device — no round trip to a server. That delivers three wins at once: the interface stays responsive, it works offline, and raw neural data never leaves the user's phone. For a category as sensitive as neurodata, that last point is as much a compliance decision as a technical one. We dig into that trade-off in our guide on choosing between on-device and cloud AI, and into the regulatory side in building a HIPAA-compliant health app.

How do you calibrate the pipeline for each user?

Absolute bandpower varies enormously between people. Skull thickness, hair, skin impedance, and electrode contact all shift the baseline, so a feature vector that means "relaxed" for one person can mean "focused" for another. Ship raw, un-normalized features and your scores will be accurate for the handful of users whose heads happen to resemble your training set and wrong for everyone else. The fix is a short per-user calibration that runs once per session:

  1. Capture 30-60 seconds of eyes-open rest and 30-60 seconds of eyes-closed rest. Eyes-closed reliably drives a large alpha increase, giving you two anchored reference points to scale against.
  2. Compute the mean and standard deviation of each of the nine features across the calibration window, then z-score every live feature against that per-user baseline before it reaches the classifier.
  3. Persist the calibration profile so returning users skip the step on later sessions, refreshing it only when contact quality drifts.

This single normalization step does more for cross-user accuracy than almost any change to the model itself. It converts absolute microvolt readings — meaningless across different people — into relative deviations from each individual's own resting state, which is exactly what a wellness score should track.

Common pitfalls when shipping a BCI pipeline

  • Hard-coding electrode names — guarantees you rewrite everything when you add a second headset. Use virtual channels from day one.
  • Assuming a single mains frequency — a fixed 60 Hz notch leaves a loud 50 Hz artifact for half your users.
  • Skipping baseline subtraction — DC drift slowly poisons every bandpower feature and your scores wander over a session.
  • Non-deterministic windowing — if window boundaries jitter, you cannot reproduce or debug a bad session from its capture.
  • Shipping un-normalized features — without per-user calibration the same score means different things on different heads, and your accuracy quietly collapses outside your training set.

From pipeline to product

The model is rarely the hard part of a consumer BCI. The hard part is the unglamorous, deterministic plumbing that turns chaotic analog reality into a clean, fixed-shape tensor — reproducibly, on a phone, in real time. Get that pipeline right and a modest classifier will feel like magic. Get it wrong and the best model in the world will feel broken.

This is the kind of systems work Game Changer Labs does across neurotechnology, from signal pipelines like the one above to the apps and classifiers that sit on top of them. If you are building in this space, we can help you go from raw capture to a shippable product.

Frequently Asked Questions

What sample rate should I use for consumer EEG processing?

Resample every incoming stream to a single standardized rate before doing anything else. We use 200 Hz. Consumer headsets report 128, 250, 256, or 512 Hz depending on the vendor and firmware, so a polyphase resample to a fixed rate guarantees that downstream filter coefficients, window sizes, and feature shapes stay identical across devices.

Why notch filter at both 50 Hz and 60 Hz?

Powerline interference appears at the mains frequency of the region: 50 Hz across most of Europe, Africa, and Asia, and 60 Hz across North America. Apply the notch that matches the user's region, or detect the dominant line frequency at runtime, otherwise a fixed 60 Hz notch leaves a strong 50 Hz artifact untouched in half the world.

Which EEG frequency bands matter for focus and relaxation?

For wellness scoring the three load-bearing bands are delta (0.5-4 Hz) for deep rest and drowsiness, alpha (8-13 Hz) for relaxed wakefulness and eyes-closed calm, and beta (14-30 Hz) for active concentration and cognitive load. Alpha-to-beta ratios are a robust starting signal for relaxation versus focus.

Can EEG be processed in real time on a phone?

Yes. The full clean-and-featurize pipeline is cheap enough to run on-device with a latency budget under about 250 ms per window. Running on-device keeps the feedback loop responsive, works offline, and avoids streaming raw neural data to a server, which matters for both privacy and regulatory posture.

How do you handle headsets with different electrode layouts?

Never hard-code electrode names. Map each device's montage onto a small set of virtual channels using an ordered candidate table, and fall back to Principal Component Analysis to derive synthetic channels when named electrodes are missing. One classifier then serves every headset without retraining.

How do you remove eye-blink and muscle artifacts from EEG in real time?

Reject contaminated windows rather than trying to repair them. Use amplitude gating to drop any window that exceeds a per-channel microvolt threshold (the signature of a blink), variance clamping to catch the broadband bursts of muscle activity from jaw or neck tension, and optionally regress the frontal channel out of the temporal channels to suppress blink leakage. In real time it is safer to withhold a score for a few hundred milliseconds than to emit a confident number from a dirty window.

Why do EEG features need per-user calibration?

Absolute bandpower varies enormously between people because skull thickness, hair, skin impedance, and electrode contact all shift the baseline. A 'relaxed' reading for one person can look like 'focused' for another. A short eyes-open and eyes-closed calibration at the start of a session lets you z-score every live feature against that individual's own resting state, which improves cross-user accuracy more than almost any model change.

What does the output of an EEG feature pipeline look like?

A fixed-width tensor of shape [T, 9] per window: three virtual channels times three bandpower features (delta, alpha, beta), each log-transformed to compress dynamic range. That stable shape feeds directly into a temporal convolutional network or other lightweight classifier.

Game Changer Labs

Have a project that needs to ship?

Game Changer Labs designs and builds production systems across AI, neurotech, civic, and spatial computing. Tell us what you are building and we will scope it.

Keep Reading

Published: April 12, 2026Game Changer Labs