Skip to main content

BrainflowCytonEEGWrapper

Test PyPI version Python versions License: MIT

This is particularly aimed at the OpenBCI Cyton/Cyton + Daisy biosensing board.

It allows for low-level board commands such as configuring channels and setting sample rate, making it easier to configure the way you retrieve data from the board.

Status

Fully functional, working with Cyton and Cyton + Daisy.

Todo:

  • Include script to process SDCard data (exists but in a different repo)
  • Make the interface more consistent
  • Bake in multithreading support for easier parallel data collection + processing
  • ???

Details

Default channels coming in with cyton and daisy with the ultracortex mk4 are:

  • 0: "pkg"
  • 1: "Fp1"
  • 2: "Fp2"
  • 3: "C3"
  • 4: "C4"
  • 5: "P7"
  • 6: "P8"
  • 7: "O1"
  • 8: "O2"
  • 9: "F7"
  • 10: "F8"
  • 11: "F3"
  • 12: "F4"
  • 13: "T7"
  • 14: "T8"
  • 15: "P3"
  • 16: "P4"
  • 17: "AX" (accelerometer x)
  • 18: "AY" (accelerometer y)
  • 19: "AZ" (accelerometer z)
  • 31: "marker" (this can be used to put event markers in the EEG data, which is extremely useful, BUT the accelerometer will be disabled)

Installation

pip install BrainflowCyton

Optional: Audio Utilities

If you want to use the Audio class for EEG sonification, install with the audio extra:

pip install BrainflowCyton[audio]

This requires PortAudio to be installed on your system:

macOS:

brew install portaudio

Ubuntu/Debian:

sudo apt-get install portaudio19-dev

Windows: PortAudio should be installed automatically with the package.

Or for development:

git clone https://github.com/zeyus-research/BrainflowCytonEEGWrapper
cd BrainflowCytonEEGWrapper
pip install -e .

Features

  • Low-level control of OpenBCI Cyton/Cyton + Daisy boards
  • Support for custom sample rates (250Hz - 16kHz)
  • SD card recording and real-time streaming
  • Channel configuration (gain, input type, bias, SRB settings)
  • EMG channel support
  • Event markers/tags for experiment synchronization
  • Built-in filtering (bandpass, lowpass, 50Hz noise removal)
  • Context manager support for automatic resource cleanup
  • Type hints for better IDE support
  • Comprehensive test suite

Usage examples

Using context manager (automatically handles cleanup):

from BrainflowCyton.eeg import EEG
from time import sleep

# Context manager automatically calls prepare() and stop()
with EEG(dummyBoard=True) as eeg:
    eeg.start_stream(sdcard=False)
    while True:
        try:
            sleep(0.5)
            data = eeg.poll()
            print(f"Got {data.shape[1]} samples")
        except KeyboardInterrupt:
            break

Or manually managing the connection:

from BrainflowCyton.eeg import EEG
from time import sleep

eeg = EEG(dummyBoard=True)
eeg.start_stream(sdcard=False)

while True:
    try:
        sleep(0.5)
        data = eeg.poll()
    except KeyboardInterrupt:
        eeg.stop()
        break

Read data from a real board in real time

from BrainflowCyton.eeg import EEG
from time import sleep

eeg_source = EEG()
eeg_source.start_stream(sdcard=False)

while True:
    try:
        sleep(0.5)
        data = eeg_source.poll()
    except KeyboardInterrupt:
        eeg_source.stop()

Set a custom sample rate

Note: to use sample rates above 250, an SDCard is required, streaming is limited to 250 Hz.

from BrainflowCyton.eeg import EEG, CytonSampleRate
from time import sleep

eeg_source = EEG()
eeg_source.start_stream(sdcard=True, sr=CytonSampleRate.SR_1000)

while True:
    try:
        sleep(0.5)
        data = eeg_source.poll()
    except KeyboardInterrupt:
        eeg_source.stop()

Enable logging

from BrainflowCyton.eeg import EEG
import logging

# Configure logging before creating EEG object
EEG.configure_logging(level=logging.DEBUG)

with EEG(dummyBoard=True) as eeg:
    eeg.start_stream(sdcard=False)
    # Will now see detailed logs

Bandpass the data

from BrainflowCyton.eeg import EEG, Filtering
from time import sleep

# Set the indexes of channels you want to filter
ch_idx = [1, 2, 3, 4, 5, 6, 7]
eeg_filter = Filtering(exg_channels=ch_idx, sampling_rate=250)

with EEG(dummyBoard=True) as eeg:
    eeg.start_stream(sdcard=False)
    while True:
        try:
            sleep(0.5)
            data = eeg.poll()
            if data is not None:
                # Apply 8-32 Hz bandpass (alpha + beta band)
                filtered_data = eeg_filter.bandpass(data, lowcut=8, highcut=32)
        except KeyboardInterrupt:
            break

Development

Running tests

# Install dev dependencies
uv sync --all-extras --dev

# Run tests
uv run pytest tests/ -v

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

CI/CD

This project uses GitHub Actions for continuous integration and deployment:

  • Tests: Run on every push/PR across Python 3.9-3.13 and Linux/macOS/Windows
  • Pre-releases: Automatically published to GitHub releases on main branch commits
  • Releases: Triggered by version tags (e.g., v0.3.0), publishes to PyPI

License

MIT License - see LICENSE file for details

Metadata

Release files for BrainflowCyton 0.4.1

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

Source distribution (sdist)

Source distribution for BrainflowCyton 0.4.1
File Size Uploaded Provenance Actions
brainflowcyton-0.4.1.tar.gz 76.1 kB Without provenance Details for brainflowcyton-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for BrainflowCyton 0.4.1
File Interpreter ABI Platform Actions
brainflowcyton-0.4.1-py3-none-any.whl Python 3 none any Details for brainflowcyton-0.4.1-py3-none-any.whl

Total release size: 88.9 kB

Release files / brainflowcyton-0.4.1.tar.gz

Download URL brainflowcyton-0.4.1.tar.gz
Size 76.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ec63fff607488783b328c11fbc0b3093941685f65ef6f595efa4a482ae67b4ba
BLAKE2b-256 checksum
How to use checksums
10dccdb9788c1277bca8574be13e139f74c976f80d162f56d099c90da8fb32df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / brainflowcyton-0.4.1-py3-none-any.whl

Download URL brainflowcyton-0.4.1-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
607204ede3761e49b27cf5cc08073dc09147904f52ecd2b4fa04f14088219e55
BLAKE2b-256 checksum
How to use checksums
41c45b5c77984b9ed9a85e62c4035b6df4485e69df78d1a81ec5f014e79d2ce4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for BrainflowCyton 0.4.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files No provenance

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