Skip to content

About

OpenBCI Cyton EEG Viewer & Recorder in Python

Topics

Resources

Stars

9 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

OpenBCI Cyton EEG Viewer & Recorder in Python

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.


📸 Application Interface

Application GUI

Main interface featuring real-time scrolling multi-channel EEG visualization and configuration panel.


🚀 Key Features

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


🛠️ Software Architecture

The codebase is structured into two decoupled core components:

1. OpenBCIReader (Data Ingestion Layer)

  • Manages a background threading.Thread to poll the serial port synchronously without blocking the user interface.
  • Implements the binary OpenBCI Cyton Protocol, validating incoming packets via 0xA0 start bytes and 0xC0/0xC1 stop 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.deque buffers.

2. OpenBCIViewer (Presentation Layer)

  • Built on top of QtWidgets.QMainWindow, providing a dark-themed instrumentation dashboard.
  • Uses a pg.PlotWidget to render 8 channels simultaneously with memory-efficient ring buffers (np.nan padding avoids vertical drawing artifacts across wrap-around boundaries).
  • Drives screen updates at 50 Hz (20 ms interval) using an efficient QTimer.

📦 Requirements & Installation

Ensure you have Python 3.8+ installed.

Clone the repository and install the dependencies:

pip install numpy pyqt5 pyqtgraph pyserial brainflow hdf5storage

About

OpenBCI Cyton EEG Viewer & Recorder in Python

Topics

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages