Skip to main content

Ability logomark
EMG-GUI
Python versions PyPI version Monthly PyPI downloads Total PyPI downloads GitHub release downloads

Real-time acquisition and visualization of OpenBCI EMG signals with Python.

EMG-GUI is a multithreaded Python package built with BrainFlow, Qt, and ModernGL. It displays raw and filtered EMG traces from OpenBCI boards alongside a live spectrogram, with support for recording and playback.

EMG-GUI displaying raw and filtered EMG traces alongside a live spectrogram

Contents

1. Installation

Requirement: Python 3.9, 3.10, 3.11, 3.12, 3.13, or 3.14.

Choose your operating system and follow the steps in order.

🍎 macOS
  1. Install EMG-GUI:

    pip install emg-gui
    
🪟 Windows
  1. Install EMG-GUI in PowerShell:

    pip install emg-gui
    
🐧 Linux — Ubuntu / Debian
  1. Install the system dependencies. For Debian and Ubuntu:

    sudo apt update
    sudo apt install \
      libgl-dev \
      libegl-dev \
      libxcb-icccm4 \
      libxcb-keysyms1 \
      libxcb-xinerama0 \
      libxcb-xkb1 \
      libxkbcommon-x11-0
    
  2. Install EMG-GUI:

    pip install emg-gui
    

Graphics troubleshooting: If the application reports an OpenGL context error, check that your graphics driver provides OpenGL 3.3 or later.

2. Practical Examples

Each script opens raw and filtered EMG traces alongside a live spectrogram. Run it with Python, then click Stream Data to begin. Close the window to exit.

Synthetic data

Source: examples/synthetic_board.py

from emg_gui import (
    ConsoleLogger, EMGVisualizerWindow, MainsFrequency,
    OpenBCIBoard, OpenBCIBoardType, OpenBCIConfig,
)


def main():
    logger = ConsoleLogger()
    board = None
    try:
        config = OpenBCIConfig(board_type=OpenBCIBoardType.SYNTHETIC)
        board = OpenBCIBoard(logger=logger, config=config)
        EMGVisualizerWindow.run(
            logger=logger, board=board, mains_frequency=MainsFrequency.FIFTY_HZ
        )
    finally:
        if board is not None:
            board.release()
        logger.release()


if __name__ == "__main__":
    main()

OpenBCI Cyton

Source: examples/cyton_board.py

Set serial_port in the example below to your board's port:

  • macOS: use /dev/cu.*, such as /dev/cu.usbserial-….

  • Windows: use the assigned COM port, such as COM3.

  • Ubuntu / Debian: use /dev/ttyUSB0 or /dev/ttyACM0. To grant serial-port access, run the following, then sign out and back in:

    sudo usermod -aG dialout "$USER"
    
from emg_gui import (
    ConsoleLogger, EMGVisualizerWindow, MainsFrequency,
    OpenBCIBoard, OpenBCIBoardType, OpenBCIConfig,
)


def main():
    logger = ConsoleLogger()
    board = None
    try:
        config = OpenBCIConfig(
            board_type=OpenBCIBoardType.CYTON_SERIAL,
            serial_port="/dev/ttyUSB0",
            polling_interval_ms=40,
            turn_off_srb=True,
        )
        board = OpenBCIBoard(logger=logger, config=config)
        EMGVisualizerWindow.run(
            logger=logger, board=board, mains_frequency=MainsFrequency.FIFTY_HZ
        )
    finally:
        if board is not None:
            board.release()
        logger.release()


if __name__ == "__main__":
    main()

Playback

Source: examples/playback_recording.py

No board connection is needed. Set board_type to the board used for the recording; it determines the playback sampling rate. The bundled example uses SYNTHETIC.

from importlib.resources import files

from emg_gui import (
    ConsoleLogger, EMGVisualizerWindow, MainsFrequency,
    OpenBCIBoardType, PlayBackConfig, PlaybackRecording,
)


def main():
    logger = ConsoleLogger()
    board = None
    try:
        recording = files("emg_gui.data") / "train" / "top_fist" / "file_1.csv"
        # For your own recording, use its path instead:
        # recording = "/home/user/recordings/session.csv"
        config = PlayBackConfig(
            board_type=OpenBCIBoardType.SYNTHETIC,
            file_path=str(recording),
            polling_interval_ms=40,
        )
        board = PlaybackRecording(logger=logger, config=config)
        EMGVisualizerWindow.run(
            logger=logger, board=board, mains_frequency=MainsFrequency.FIFTY_HZ
        )
    finally:
        if board is not None:
            board.release()
        logger.release()


if __name__ == "__main__":
    main()

File format: numeric, tab-separated rows without a header. Each row is one sample; columns contain EMG channels followed by one marker column. Use zeros in the marker column when there are no markers. Relative paths resolve from your working directory. Playback outputs zeros after the last sample; stop and restart streaming to replay from the beginning.

Configuration

OpenBCIConfig and PlayBackConfig are immutable. Create a new configuration and data-source instance to change their settings.

OpenBCIConfig

Parameter Default Purpose
board_type: OpenBCIBoardType Required Select the board and its sampling rate/channel layout.
polling_interval_ms: int 40 Interval between data reads; does not change the board's sampling rate.
turn_off_srb: bool False Send SRB-disabling channel commands for a compatible Cyton setup. Leave disabled for other board types.
serial_port: str "" Serial device path or COM port.
ip_address: str "" Board/network address.
ip_port: int 0 Network port.
ip_protocol: int 0 BrainFlow IP protocol value.
mac_address: str "" Device MAC address, when required.
serial_number: str "" Device serial number, when required.
timeout: int 0 BrainFlow discovery/connection timeout.
other_info: str "" Additional board-specific connection information.

Connection fields are passed directly to BrainFlow. Supply the fields required by your board's connection instructions.

OpenBCIBoardType

Connection Enum members
Serial / dongle CYTON_SERIAL, CYTON_DAISY_SERIAL, GANGLION_DONGLE
Native Bluetooth GANGLION_NATIVE
Wi-Fi CYTON_WIFI, CYTON_DAISY_WIFI, GANGLION_WIFI
Generated data SYNTHETIC

PlayBackConfig

Parameter Default Purpose
board_type: OpenBCIBoardType Required Board whose sampling rate matches the recording.
file_path: str "" Path to the recording; supply an existing file.
polling_interval_ms: int 40 Playback read interval; samples per read follow the board's sampling rate.

EMGVisualizerWindow.run(logger, board, mains_frequency)

Pass a ConsoleLogger, an OpenBCIBoard or PlaybackRecording, and either MainsFrequency.FIFTY_HZ or MainsFrequency.SIXTY_HZ for mains-noise removal. Use the enum members, not the numbers 50 or 60. This call creates the Qt application and blocks until the window closes. Run it on the main thread; release the board and logger afterwards, as shown above.

3. Architecture

See the architecture guide for the component overview, directory layout, data flow, and thread interactions.

4. Contributing

Contributions are welcome! See CONTRIBUTING.md for the development and linting workflow, planned features, and tech debt.

Report reproducible problems through GitHub Issues, including your operating system, Python and package versions, and the full error output.


5. Acknowledgements

5.1 BrainFlow

This project uses BrainFlow for biosignal acquisition and hardware integration. BrainFlow provides a uniform API for acquiring, parsing, and analyzing EEG, EMG, ECG, and other biosensor data across a wide range of supported boards, including OpenBCI devices. BrainFlow is distributed under the MIT License.

5.2 ModernGL Spectrogram

This project uses nickcercone/spectrogram as a reference for parts of its ModernGL spectrogram rendering implementation. The referenced project demonstrates real-time audio spectrogram visualization using ModernGL and is distributed under the MIT License.

5.3 Text Rendering

This project adapts the code in How to render text with PyOpenGL? by exiled (question) and Rabbid76 (answer) for its ModernGL text renderer. The referenced contributions demonstrate text rendering with PyOpenGL and are distributed under the CC BY-SA 4.0 License.

Videos

Watch demos and tutorials on EMGAbility on YouTube.

Metadata

Release files for emg-gui 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for emg-gui 0.1.8
File Size Uploaded Provenance Actions
emg_gui-0.1.8.tar.gz 2.4 MB With provenance Details for emg_gui-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for emg-gui 0.1.8
File Interpreter ABI Platform Actions
emg_gui-0.1.8-py3-none-any.whl Python 3 none any Details for emg_gui-0.1.8-py3-none-any.whl

Total release size: 4.8 MB

Release files / emg_gui-0.1.8.tar.gz

Download URL emg_gui-0.1.8.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
3bb0cb14d5c57d3aab9fb6b1da12f77a9385b83461bcb32d3e7e26761cc6a5f1
BLAKE2b-256 checksum
How to use checksums
581a3318d14e09378dabcca7bbf335710d4d38efb99aeb32ab5d193270e4023b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / emg_gui-0.1.8-py3-none-any.whl

Download URL emg_gui-0.1.8-py3-none-any.whl
Size 2.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
63b105cf1e8c2144922fb4e4377416dba323916687b79bfdc9886db235f57e15
BLAKE2b-256 checksum
How to use checksums
8008fbfd8138ab8d1e11af30c2aa9f50241a72790e60b36130f290915a0e4312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for emg-gui 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for emg_gui-0.1.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page