Details

ai / research

Brain Signal Processing Game

A research neurofeedback system that turns OpenBCI EEG beta activity into a real-time Pygame aircraft feedback loop through Lab Streaming Layer.

Live 3D architecture

The scene beside this panel is this system's architecture. Drag to rotate, scroll panel to read on.

Problem

The project needed a complete closed loop: acquire EEG safely from OpenBCI, process noisy neural signals in near real time, extract the beta rhythm used by the research protocol, and turn that signal into a readable game interaction for adult ADHD attention-training experiments.

Contribution

Built the Python signal-processing path and game-facing integration pieces: LSL stream handling, buffered EEG windows, band-feature extraction, marker output, Pygame trial flow, stimulus timing, aircraft feedback behavior, and experiment-friendly local execution.

Architecture

The system is split into acquisition, processing, transport, and game layers. OpenBCI GUI captures EEG from 8 electrodes and streams floating-point data through LSL. A Python processing server buffers 3 second windows, applies 60 Hz notch and 4-100 Hz bandpass filtering, transforms the data with Welch power spectral density, extracts frequency-band features with beta emphasized, then publishes a marker stream. The Pygame layer consumes that marker, maps beta activity to aircraft movement, controls baseline and active phases, shows a focus cue, and ends sessions with positive feedback.

Technical decisions

LSL separated OpenBCI acquisition, signal processing, and gameplay so each layer could be developed and inspected independently
Python, pylsl, NumPy, SciPy, and Welch PSD were used for fast iteration on EEG windows and band extraction
The signal path used a 60 Hz notch filter plus 4-100 Hz bandpass filtering before frequency-domain analysis
Beta rhythm was used as the game-facing attention marker, matching the research protocol for adult ADHD neurofeedback
Pygame was chosen for local full-screen experiment control, sprite rendering, audio cues, and real-time marker-driven feedback
The game used a blue calm visual field, yellow direction/focus cue, 2 second baseline, short configurable sessions, and smile feedback as reinforcement

Tradeoffs

Research implementation clarity over a reusable clinical platform
Local lab execution over web deployment
Single beta-marker control over a broader multimodal feature API

Outcome

A concrete brain-computer interaction artifact: EEG acquisition, signal processing, asynchronous data transport, and an interactive neurofeedback game connected into one reproducible research software loop.

Signal-processing layer

The processing server is the bridge between raw EEG and game behavior. It waits for stable stream data, buffers samples into experiment-sized windows, cleans the signal, and emits a simple marker that the game can consume without knowing anything about EEG acquisition.

OpenBCI GUI acquisition
LSL inlet and outlet
3 second sample windows
60 Hz notch plus 4-100 Hz bandpass
Welch PSD band extraction
Beta marker output

Game layer

The Pygame interface was designed as a feedback instrument rather than a normal game. It keeps the screen calm, uses a clear focus target, maps beta activity to aircraft movement, and separates baseline, active trial, and feedback states.

Blue low-distraction background
Yellow focus direction cue
2 second baseline phase
6-10 second training sessions
Audio start cue
Smile feedback reinforcement

Research context

The article frames the work as software for adult ADHD neurofeedback research, where beta-rhythm feedback supports attention-training protocols and the implementation makes future replication easier.

Adult ADHD focus
Selective attention protocol
Computer-brain interface loop
Experiment reproducibility
Local data flow
Public research artifact

Stack and domains

  • Python
  • OpenBCI
  • Lab Streaming Layer
  • pylsl
  • NumPy
  • SciPy
  • Welch PSD
  • Pygame
  • EEG
  • neurofeedback