A real-time 8-channel EEG visualization and recording application designed for the OpenBCI Cyton board. Built using PyQt5, pyqtgraph, and BrainFlow, this tool provides low-latency live streaming, robust digital filtering, and high-fidelity data logging to MATLAB-compatible .mat files.
Main interface featuring real-time scrolling multi-channel EEG visualization and configuration panel.
-
Real-Time Data Streaming: Low-latency multi-threaded serial reading directly from the OpenBCI Cyton USB Dongle (250 Hz sampling rate).
-
Interactive Multi-Channel Plotting: Continuous scrolling display with vertical channel separation, individual labeling, and a moving gap visualizer.
-
On-the-Fly Signal Processing:
- Automated detrending to eliminate DC offsets.
- User-configurable Butterworth Bandpass Filter (adjustable high-cut and low-cut thresholds).
- Built-in Notch Filters to effectively suppress 50 Hz and 60 Hz electrical line noise.
-
Dynamic Display Adjustments: Interactive dropdown menus to scale amplitude ranges (10 µV to 1000 µV) and update filter bands in real time.
-
Lossless Recording: Streamlined data logging to standard v7.3 MAT-files via
hdf5storage. Saves an absolute timestamped matrix containing the time axis and microvolt-scaled EEG channels.
The codebase is structured into two decoupled core components:
- Manages a background
threading.Threadto poll the serial port synchronously without blocking the user interface. - Implements the binary OpenBCI Cyton Protocol, validating incoming packets via
0xA0start bytes and0xC0/0xC1stop bytes. - Decodes 24-bit signed integer values using bitwise operations, converting raw telemetry into microvolts (µV) using the hardware-specific scaling factor:
Scale Factor = (4.5 / (Gain × (2^23 − 1))) × 10^6
- Stores rolling window segments inside thread-safe
collections.dequebuffers.
- Built on top of
QtWidgets.QMainWindow, providing a dark-themed instrumentation dashboard. - Uses a
pg.PlotWidgetto render 8 channels simultaneously with memory-efficient ring buffers (np.nanpadding avoids vertical drawing artifacts across wrap-around boundaries). - Drives screen updates at 50 Hz (20 ms interval) using an efficient
QTimer.
Ensure you have Python 3.8+ installed.
Clone the repository and install the dependencies:
pip install numpy pyqt5 pyqtgraph pyserial brainflow hdf5storage