Skip to main content

Read, write and convert OpenBCI signal recordings (.raw/.xml/.tag)

Project description

readmanager

Read, write and convert OpenBCI signal recordings stored in the OBCI file format (.raw / .xml / .tag).

Installation

pip install readmanager            # core (numpy only)
pip install readmanager[mne]       # + MNE-Python conversion
pip install readmanager[balance]   # + Wii Balance Board analysis (scipy)
pip install readmanager[all]       # everything

Requires Python 3.10+.

Quick start

from obci_readmanager.signal_processing.read_manager import ReadManager

# Open a recording (three files: .raw, .xml, .tag)
mgr = ReadManager(
    "recording.obci.xml",
    "recording.obci.raw",
    "recording.obci.tag",
)

# Access signal parameters
print(mgr.get_param("sampling_frequency"))
print(mgr.get_param("channels_names"))

# Get all samples as a numpy array (channels x samples)
samples = mgr.get_samples()

# Get samples for a single channel
fp1 = mgr.get_channel_samples("Fp1")

# Get samples in microvolts (applies gain and offset calibration)
uv = mgr.get_microvolt_samples()

# Iterate over tags (event markers)
for tag in mgr.iter_tags():
    print(tag["name"], tag["start_timestamp"])

Smart tags

Smart tags extract signal segments aligned to event markers:

from obci_readmanager.signal_processing.smart_tags_manager import SmartTagsManager
from obci_readmanager.signal_processing.tags.smart_tag_definition import SmartTagDurationDefinition

# Define: 1 second of signal after each "stimulus" tag
tag_def = SmartTagDurationDefinition(
    start_tag_name="stimulus",
    start_offset=0.0,
    end_offset=0.0,
    duration=1.0,
)

smart_mgr = SmartTagsManager(
    tag_def,
    "recording.obci.xml",
    "recording.obci.raw",
    "recording.obci.tag",
)

for smart_tag in smart_mgr.iter_smart_tags():
    data = smart_tag.get_samples()  # channels x samples for this epoch
    print(data.shape)

MNE-Python conversion

# ReadManager -> MNE Raw
raw_mne = mgr.get_mne_raw()

# MNE Raw -> ReadManager
mgr2 = ReadManager.from_mne(raw_mne)

# Smart tags -> MNE Epochs
epochs = smart_mgr.get_mne_epochs()

OBCI file format

An OpenBCI recording consists of three files:

File Content
.obci.raw Binary signal data (channels interleaved, float64 by default)
.obci.xml Recording metadata: channel names, sampling frequency, gains, offsets
.obci.tag Event markers in XML format (name, timestamp, duration, description)

License

GNU General Public License v3 or later (GPLv3+).

Originally developed by BrainTech and the Faculty of Physics, University of Warsaw.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

readmanager-1.2.0.tar.gz (37.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

readmanager-1.2.0-py3-none-any.whl (57.8 kB view details)

Uploaded Python 3

File details

Details for the file readmanager-1.2.0.tar.gz.

File metadata

  • Download URL: readmanager-1.2.0.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for readmanager-1.2.0.tar.gz
Algorithm Hash digest
SHA256 944d946c5bad71e348db1f168768541897f3978abf10096e8d1c42df0a7aca43
MD5 5addc889c7ae674eeca46cfdaf96277a
BLAKE2b-256 937a6d2429277ba50eba18b7f649ec94874ece29976e6ee7cd5a027cc23978e8

See more details on using hashes here.

File details

Details for the file readmanager-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: readmanager-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 57.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for readmanager-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a720d200004bc7e1ce5f67d684b85a76b55e2f8c5ab952a88f252b69b055991
MD5 f3842ecf3b51e2a912d2ade89e3577cf
BLAKE2b-256 ca4da55e274153c83dcf6ab2494bb47696392bfec22997d06a5bd64a81c86c14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page