Skip to main content

A Python package for EMG data import/export and manipulation with unified interface for various EMG systems

Project description

EMGIO

PyPI version Tests codecov

A Python package for EMG data import/export and manipulation. This package provides a unified interface for working with EMG data from various systems (Trigno, EEGLAB, OTB, etc) and exporting to standardized formats like EDF and BDF with harmonized metadata.

The determination of the EDF/BDF format is based on the dynamic range of the data. If the data is within the range of 16-bit integers (~90dB), the EDF format is used. Otherwise, the BDF format is used. This is to ensure that the data is stored in the most efficient format possible. This determination is made automatically using SVD decomposition and/or FFT to determine the dynamic range of the data. (Alternatively, the user can override the format selection by explicitly indicating their desired format).

Documentation

The documentation including installation instructions, examples, and API reference is available at https://neuromechanist.github.io/emgio/.

Features

  • Import EMG data from multiple systems:

    • EEGLAB set files (supported)
    • Delsys Trigno (supported)
    • OTB Systems (supported)
    • EDF/BDF(+) (supported, including annotations)
    • WFDB (supported, including annotations)
    • XDF/Lab Streaming Layer (supported, multi-stream)
    • Generic CSV (supported with auto-detection)
    • Noraxon (planned)
  • Smart import:

    • Automatic file format detection based on extension
    • Specialized format detection for CSV files
    • Custom importers for system-specific formats
    • Automatic annotation loading (WFDB, planned for EDF+/BDF+ and EEGLAB's .set files)
    • LSL timestamp preservation for XDF files (for synchronization)
  • Export to standardized formats:

    • EDF/BDF(+) with channels.tsv metadata (automatically selects format based on signal properties, preserves annotations)
  • Data manipulation:

    • Channel selection
    • Metadata handling
    • Event/Annotation handling (access, add)
    • Basic signal visualization
    • Raw data access and modification

Installation

EMGIO uses UV for Python environment and package management.

From PyPI (recommended)

uv pip install emgio

(If your own project is uv-managed, use uv add emgio to track it as a dependency.)

From source

git clone https://github.com/neuromechanist/emgio.git
cd emgio
uv pip install .

Usage

Basic Example

from emgio import EMG

# Load data with automatic format detection
emg = EMG.from_file('data.csv')  # Format detected from file extension

# Load data with explicit importer
emg = EMG.from_file('data.csv', importer='trigno')

# Plot specific channels
emg.plot_signals(['EMG1', 'EMG2'])

# Export to EDF or BDF (format automatically determined)
emg.to_edf('output.edf')

Generic CSV Import

# Import a generic CSV file
emg = EMG.from_file('data.csv', importer='csv',
                   sample_frequency=1000,  # Required if no time column
                   has_header=True,        # Whether file has header row
                   channel_names=['EMG_L', 'EMG_R', 'ACC_X'])

Channel Selection

# Select specific channels
subset_emg = emg.select_channels(['EMG1', 'EMG2', 'ACC1'])

# Select all channels of a specific type
emg_only = emg.select_channels(channel_type='EMG')

# Plot selected channels
subset_emg.plot_signals()

Metadata Handling

# Set metadata
emg.set_metadata('subject', 'S001')
emg.set_metadata('condition', 'resting')

# Get metadata
subject = emg.get_metadata('subject')

Development

Setup

  1. Clone the repository:
git clone https://github.com/neuromechanist/emgio.git
cd emgio
  1. Install for development (editable install with dev dependencies):
uv sync --extra dev

Running Tests

uv run pytest

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

Acknowledgment

This project is partially supported by a Meta Reality Labs gift to @sccn and NIH 5R01NS047293.

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

emgio-0.3.0.tar.gz (105.0 kB view details)

Uploaded Source

Built Distribution

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

emgio-0.3.0-py3-none-any.whl (118.4 kB view details)

Uploaded Python 3

File details

Details for the file emgio-0.3.0.tar.gz.

File metadata

  • Download URL: emgio-0.3.0.tar.gz
  • Upload date:
  • Size: 105.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for emgio-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7cee77029c2b13209beee7a0f29d2c7cc8c14f81ffcf0bf74298d1cac4f6e0d0
MD5 da2f22dc8613d365bda5fc5396eab506
BLAKE2b-256 89f4c76fabdf959df8d81a0f4cf0d2a3f744cbca48a49bed4aa4516f450d2aa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for emgio-0.3.0.tar.gz:

Publisher: publish.yml on neuromechanist/emgio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file emgio-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: emgio-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 118.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for emgio-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea372716b8113e6a3931945a04648e99b6ba414457101c96a2643359c25728e5
MD5 7cf843cc92f66262d3ce327bdd877cc0
BLAKE2b-256 22b93eddc0ea3c1b59ca51e456d09f4d453e0652581c729ec0d7efd530edaba4

See more details on using hashes here.

Provenance

The following attestation bundles were made for emgio-0.3.0-py3-none-any.whl:

Publisher: publish.yml on neuromechanist/emgio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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