A Python package for EMG data import/export and manipulation with unified interface for various EMG systems
Project description
EMGIO
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
From PyPI (recommended)
pip install emgio
From source
git clone https://github.com/neuromechanist/emgio.git
cd emgio
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
- Clone the repository:
git clone https://github.com/neuromechanist/emgio.git
cd emgio
- Install for development:
pip install -e .
- Install test dependencies (optional):
pip install -r test-requirements.txt
Running Tests
Make sure you have installed the test dependencies first, then 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emgio-0.2.2.tar.gz.
File metadata
- Download URL: emgio-0.2.2.tar.gz
- Upload date:
- Size: 79.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb4fc2c11e5430941149cb5c9a0af21bd305a677f596791e5b06f43919d73955
|
|
| MD5 |
0be1926234ac19d8c8fd6dd4986d542c
|
|
| BLAKE2b-256 |
c7be1e2d1b4c509efe90c059f269d7347c8a3bebdf3a5201dd792775d4c5ba07
|
Provenance
The following attestation bundles were made for emgio-0.2.2.tar.gz:
Publisher:
publish.yml on neuromechanist/emgio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emgio-0.2.2.tar.gz -
Subject digest:
fb4fc2c11e5430941149cb5c9a0af21bd305a677f596791e5b06f43919d73955 - Sigstore transparency entry: 785727566
- Sigstore integration time:
-
Permalink:
neuromechanist/emgio@901518259b243c07988f9eb78d6c07d2abf0efd3 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/neuromechanist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@901518259b243c07988f9eb78d6c07d2abf0efd3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file emgio-0.2.2-py3-none-any.whl.
File metadata
- Download URL: emgio-0.2.2-py3-none-any.whl
- Upload date:
- Size: 88.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a4d2d0b7e308e6006a43598eccfbe1abddbaffa04c02f2b89f30d3ac1258303
|
|
| MD5 |
8df1aae60fd023b546313d0c169b3c96
|
|
| BLAKE2b-256 |
128ff30ab97a3099b9befcd6387273c6d5093f337424580da0803b9a14911243
|
Provenance
The following attestation bundles were made for emgio-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on neuromechanist/emgio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emgio-0.2.2-py3-none-any.whl -
Subject digest:
3a4d2d0b7e308e6006a43598eccfbe1abddbaffa04c02f2b89f30d3ac1258303 - Sigstore transparency entry: 785727570
- Sigstore integration time:
-
Permalink:
neuromechanist/emgio@901518259b243c07988f9eb78d6c07d2abf0efd3 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/neuromechanist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@901518259b243c07988f9eb78d6c07d2abf0efd3 -
Trigger Event:
release
-
Statement type: