emgio 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. emgio-0.2.0/LICENSE +29 -0
  2. emgio-0.2.0/PKG-INFO +228 -0
  3. emgio-0.2.0/README.md +149 -0
  4. emgio-0.2.0/emgio/__init__.py +8 -0
  5. emgio-0.2.0/emgio/analysis/__init__.py +16 -0
  6. emgio-0.2.0/emgio/analysis/signal.py +345 -0
  7. emgio-0.2.0/emgio/analysis/verification.py +205 -0
  8. emgio-0.2.0/emgio/core/__init__.py +0 -0
  9. emgio-0.2.0/emgio/core/emg.py +485 -0
  10. emgio-0.2.0/emgio/exporters/__init__.py +0 -0
  11. emgio-0.2.0/emgio/exporters/edf.py +650 -0
  12. emgio-0.2.0/emgio/importers/__init__.py +0 -0
  13. emgio-0.2.0/emgio/importers/base.py +20 -0
  14. emgio-0.2.0/emgio/importers/csv.py +440 -0
  15. emgio-0.2.0/emgio/importers/edf.py +171 -0
  16. emgio-0.2.0/emgio/importers/eeglab.py +298 -0
  17. emgio-0.2.0/emgio/importers/otb.py +309 -0
  18. emgio-0.2.0/emgio/importers/trigno.py +134 -0
  19. emgio-0.2.0/emgio/importers/wfdb.py +152 -0
  20. emgio-0.2.0/emgio/tests/__init__.py +0 -0
  21. emgio-0.2.0/emgio/tests/test_core.py +711 -0
  22. emgio-0.2.0/emgio/tests/test_eeglab_importer.py +244 -0
  23. emgio-0.2.0/emgio/tests/test_exporters.py +905 -0
  24. emgio-0.2.0/emgio/tests/test_importer_wfdb.py +149 -0
  25. emgio-0.2.0/emgio/tests/test_importers.py +474 -0
  26. emgio-0.2.0/emgio/tests/test_verification.py +356 -0
  27. emgio-0.2.0/emgio/tests/test_visualization.py +306 -0
  28. emgio-0.2.0/emgio/utils/__init__.py +0 -0
  29. emgio-0.2.0/emgio/version.py +14 -0
  30. emgio-0.2.0/emgio/visualization/__init__.py +6 -0
  31. emgio-0.2.0/emgio/visualization/static.py +321 -0
  32. emgio-0.2.0/emgio.egg-info/PKG-INFO +228 -0
  33. emgio-0.2.0/emgio.egg-info/SOURCES.txt +36 -0
  34. emgio-0.2.0/emgio.egg-info/dependency_links.txt +1 -0
  35. emgio-0.2.0/emgio.egg-info/requires.txt +22 -0
  36. emgio-0.2.0/emgio.egg-info/top_level.txt +1 -0
  37. emgio-0.2.0/pyproject.toml +127 -0
  38. emgio-0.2.0/setup.cfg +4 -0
emgio-0.2.0/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Swartz Center for Computational Neuroscience
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
emgio-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: emgio
3
+ Version: 0.2.0
4
+ Summary: A Python package for EMG data import/export and manipulation with unified interface for various EMG systems
5
+ Author-email: Seyed Yahya Shirazi <shirazi@ieee.org>
6
+ Maintainer-email: Seyed Yahya Shirazi <shirazi@ieee.org>
7
+ License: BSD 3-Clause License
8
+
9
+ Copyright (c) 2024, Swartz Center for Computational Neuroscience
10
+ All rights reserved.
11
+
12
+ Redistribution and use in source and binary forms, with or without
13
+ modification, are permitted provided that the following conditions are met:
14
+
15
+ 1. Redistributions of source code must retain the above copyright notice, this
16
+ list of conditions and the following disclaimer.
17
+
18
+ 2. Redistributions in binary form must reproduce the above copyright notice,
19
+ this list of conditions and the following disclaimer in the documentation
20
+ and/or other materials provided with the distribution.
21
+
22
+ 3. Neither the name of the copyright holder nor the names of its
23
+ contributors may be used to endorse or promote products derived from
24
+ this software without specific prior written permission.
25
+
26
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+
37
+ Project-URL: Homepage, https://github.com/neuromechanist/emgio
38
+ Project-URL: Documentation, https://neuromechanist.github.io/emgio/
39
+ Project-URL: Repository, https://github.com/neuromechanist/emgio
40
+ Project-URL: Issues, https://github.com/neuromechanist/emgio/issues
41
+ Project-URL: Changelog, https://github.com/neuromechanist/emgio/releases
42
+ Keywords: emg,electromyography,biosignal,edf,bdf,wfdb,trigno,delsys,neuroscience,signal-processing
43
+ Classifier: Development Status :: 4 - Beta
44
+ Classifier: Intended Audience :: Science/Research
45
+ Classifier: Intended Audience :: Healthcare Industry
46
+ Classifier: License :: OSI Approved :: BSD License
47
+ Classifier: Operating System :: OS Independent
48
+ Classifier: Programming Language :: Python :: 3
49
+ Classifier: Programming Language :: Python :: 3.11
50
+ Classifier: Programming Language :: Python :: 3.12
51
+ Classifier: Programming Language :: Python :: 3.13
52
+ Classifier: Programming Language :: Python :: 3.14
53
+ Classifier: Topic :: Scientific/Engineering
54
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
55
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
56
+ Requires-Python: >=3.11
57
+ Description-Content-Type: text/markdown
58
+ License-File: LICENSE
59
+ Requires-Dist: numpy>=1.20.0
60
+ Requires-Dist: pandas>=1.3.0
61
+ Requires-Dist: scipy>=1.7.0
62
+ Requires-Dist: matplotlib>=3.4.0
63
+ Requires-Dist: pyedflib>=0.1.30
64
+ Requires-Dist: wfdb>=4.0.0
65
+ Provides-Extra: dev
66
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
67
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
68
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
69
+ Provides-Extra: docs
70
+ Requires-Dist: mkdocs>=1.6.0; extra == "docs"
71
+ Requires-Dist: mkdocs-material>=9.5.0; extra == "docs"
72
+ Requires-Dist: mkdocstrings[python]>=1.0.0; extra == "docs"
73
+ Requires-Dist: pymdown-extensions>=10.10.0; extra == "docs"
74
+ Requires-Dist: mkdocs-jupyter>=0.25.0; extra == "docs"
75
+ Requires-Dist: mike>=2.1.0; extra == "docs"
76
+ Provides-Extra: all
77
+ Requires-Dist: emgio[dev,docs]; extra == "all"
78
+ Dynamic: license-file
79
+
80
+ # EMGIO
81
+
82
+ [![PyPI version](https://badge.fury.io/py/emgio.svg)](https://badge.fury.io/py/emgio)
83
+ [![Tests](https://github.com/neuromechanist/emgio/actions/workflows/tests.yml/badge.svg)](https://github.com/neuromechanist/emgio/actions/workflows/tests.yml)
84
+ [![codecov](https://codecov.io/gh/neuromechanist/emgio/branch/main/graph/badge.svg?token=63EDIA9TWD)](https://codecov.io/gh/neuromechanist/emgio)
85
+
86
+ 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.
87
+
88
+ 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).
89
+
90
+ ## Documentation
91
+
92
+ The documentation including installation instructions, examples, and API reference is available at [https://neuromechanist.github.io/emgio/](https://neuromechanist.github.io/emgio/).
93
+
94
+ ## Features
95
+
96
+ - Import EMG data from multiple systems:
97
+ - EEGLAB set files (supported)
98
+ - Delsys Trigno (supported)
99
+ - OTB Systems (supported)
100
+ - EDF/BDF(+) (supported, including annotations)
101
+ - WFDB (supported, including annotations)
102
+ - Generic CSV (supported with auto-detection)
103
+ - Noraxon (planned)
104
+
105
+ - Smart import:
106
+ - Automatic file format detection based on extension
107
+ - Specialized format detection for CSV files
108
+ - Custom importers for system-specific formats
109
+ - Automatic annotation loading (WFDB, planned for EDF+/BDF+ and EEGLAB's .set files)
110
+
111
+ - Export to standardized formats:
112
+ - EDF/BDF(+) with channels.tsv metadata (automatically selects format based on signal properties, preserves annotations)
113
+
114
+ - Data manipulation:
115
+ - Channel selection
116
+ - Metadata handling
117
+ - Event/Annotation handling (access, add)
118
+ - Basic signal visualization
119
+ - Raw data access and modification
120
+
121
+ ## Installation
122
+
123
+ ### From PyPI (recommended)
124
+
125
+ ```bash
126
+ pip install emgio
127
+ ```
128
+
129
+ ### From source
130
+
131
+ ```bash
132
+ git clone https://github.com/neuromechanist/emgio.git
133
+ cd emgio
134
+ pip install .
135
+ ```
136
+
137
+ ## Usage
138
+
139
+ ### Basic Example
140
+
141
+ ```python
142
+ from emgio import EMG
143
+
144
+ # Load data with automatic format detection
145
+ emg = EMG.from_file('data.csv') # Format detected from file extension
146
+
147
+ # Load data with explicit importer
148
+ emg = EMG.from_file('data.csv', importer='trigno')
149
+
150
+ # Plot specific channels
151
+ emg.plot_signals(['EMG1', 'EMG2'])
152
+
153
+ # Export to EDF or BDF (format automatically determined)
154
+ emg.to_edf('output.edf')
155
+ ```
156
+
157
+ ### Generic CSV Import
158
+
159
+ ```python
160
+ # Import a generic CSV file
161
+ emg = EMG.from_file('data.csv', importer='csv',
162
+ sample_frequency=1000, # Required if no time column
163
+ has_header=True, # Whether file has header row
164
+ channel_names=['EMG_L', 'EMG_R', 'ACC_X'])
165
+ ```
166
+
167
+ ### Channel Selection
168
+
169
+ ```python
170
+ # Select specific channels
171
+ subset_emg = emg.select_channels(['EMG1', 'EMG2', 'ACC1'])
172
+
173
+ # Select all channels of a specific type
174
+ emg_only = emg.select_channels(channel_type='EMG')
175
+
176
+ # Plot selected channels
177
+ subset_emg.plot_signals()
178
+ ```
179
+
180
+ ### Metadata Handling
181
+
182
+ ```python
183
+ # Set metadata
184
+ emg.set_metadata('subject', 'S001')
185
+ emg.set_metadata('condition', 'resting')
186
+
187
+ # Get metadata
188
+ subject = emg.get_metadata('subject')
189
+ ```
190
+
191
+ ## Development
192
+
193
+ ### Setup
194
+
195
+ 1. Clone the repository:
196
+ ```bash
197
+ git clone https://github.com/neuromechanist/emgio.git
198
+ cd emgio
199
+ ```
200
+
201
+ 2. Install for development:
202
+ ```bash
203
+ pip install -e .
204
+ ```
205
+
206
+ 3. Install test dependencies (optional):
207
+ ```bash
208
+ pip install -r test-requirements.txt
209
+ ```
210
+
211
+ ### Running Tests
212
+
213
+ Make sure you have installed the test dependencies first, then run:
214
+
215
+ ```bash
216
+ pytest
217
+ ```
218
+
219
+ ## Contributing
220
+
221
+ Contributions are welcome! Please feel free to submit a Pull Request.
222
+
223
+ ## License
224
+
225
+ This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
226
+
227
+ ## Acknowledgment
228
+ This project is partially supported by a Meta Reality Labs gift to @sccn and NIH 5R01NS047293.
emgio-0.2.0/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # EMGIO
2
+
3
+ [![PyPI version](https://badge.fury.io/py/emgio.svg)](https://badge.fury.io/py/emgio)
4
+ [![Tests](https://github.com/neuromechanist/emgio/actions/workflows/tests.yml/badge.svg)](https://github.com/neuromechanist/emgio/actions/workflows/tests.yml)
5
+ [![codecov](https://codecov.io/gh/neuromechanist/emgio/branch/main/graph/badge.svg?token=63EDIA9TWD)](https://codecov.io/gh/neuromechanist/emgio)
6
+
7
+ 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.
8
+
9
+ 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).
10
+
11
+ ## Documentation
12
+
13
+ The documentation including installation instructions, examples, and API reference is available at [https://neuromechanist.github.io/emgio/](https://neuromechanist.github.io/emgio/).
14
+
15
+ ## Features
16
+
17
+ - Import EMG data from multiple systems:
18
+ - EEGLAB set files (supported)
19
+ - Delsys Trigno (supported)
20
+ - OTB Systems (supported)
21
+ - EDF/BDF(+) (supported, including annotations)
22
+ - WFDB (supported, including annotations)
23
+ - Generic CSV (supported with auto-detection)
24
+ - Noraxon (planned)
25
+
26
+ - Smart import:
27
+ - Automatic file format detection based on extension
28
+ - Specialized format detection for CSV files
29
+ - Custom importers for system-specific formats
30
+ - Automatic annotation loading (WFDB, planned for EDF+/BDF+ and EEGLAB's .set files)
31
+
32
+ - Export to standardized formats:
33
+ - EDF/BDF(+) with channels.tsv metadata (automatically selects format based on signal properties, preserves annotations)
34
+
35
+ - Data manipulation:
36
+ - Channel selection
37
+ - Metadata handling
38
+ - Event/Annotation handling (access, add)
39
+ - Basic signal visualization
40
+ - Raw data access and modification
41
+
42
+ ## Installation
43
+
44
+ ### From PyPI (recommended)
45
+
46
+ ```bash
47
+ pip install emgio
48
+ ```
49
+
50
+ ### From source
51
+
52
+ ```bash
53
+ git clone https://github.com/neuromechanist/emgio.git
54
+ cd emgio
55
+ pip install .
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ ### Basic Example
61
+
62
+ ```python
63
+ from emgio import EMG
64
+
65
+ # Load data with automatic format detection
66
+ emg = EMG.from_file('data.csv') # Format detected from file extension
67
+
68
+ # Load data with explicit importer
69
+ emg = EMG.from_file('data.csv', importer='trigno')
70
+
71
+ # Plot specific channels
72
+ emg.plot_signals(['EMG1', 'EMG2'])
73
+
74
+ # Export to EDF or BDF (format automatically determined)
75
+ emg.to_edf('output.edf')
76
+ ```
77
+
78
+ ### Generic CSV Import
79
+
80
+ ```python
81
+ # Import a generic CSV file
82
+ emg = EMG.from_file('data.csv', importer='csv',
83
+ sample_frequency=1000, # Required if no time column
84
+ has_header=True, # Whether file has header row
85
+ channel_names=['EMG_L', 'EMG_R', 'ACC_X'])
86
+ ```
87
+
88
+ ### Channel Selection
89
+
90
+ ```python
91
+ # Select specific channels
92
+ subset_emg = emg.select_channels(['EMG1', 'EMG2', 'ACC1'])
93
+
94
+ # Select all channels of a specific type
95
+ emg_only = emg.select_channels(channel_type='EMG')
96
+
97
+ # Plot selected channels
98
+ subset_emg.plot_signals()
99
+ ```
100
+
101
+ ### Metadata Handling
102
+
103
+ ```python
104
+ # Set metadata
105
+ emg.set_metadata('subject', 'S001')
106
+ emg.set_metadata('condition', 'resting')
107
+
108
+ # Get metadata
109
+ subject = emg.get_metadata('subject')
110
+ ```
111
+
112
+ ## Development
113
+
114
+ ### Setup
115
+
116
+ 1. Clone the repository:
117
+ ```bash
118
+ git clone https://github.com/neuromechanist/emgio.git
119
+ cd emgio
120
+ ```
121
+
122
+ 2. Install for development:
123
+ ```bash
124
+ pip install -e .
125
+ ```
126
+
127
+ 3. Install test dependencies (optional):
128
+ ```bash
129
+ pip install -r test-requirements.txt
130
+ ```
131
+
132
+ ### Running Tests
133
+
134
+ Make sure you have installed the test dependencies first, then run:
135
+
136
+ ```bash
137
+ pytest
138
+ ```
139
+
140
+ ## Contributing
141
+
142
+ Contributions are welcome! Please feel free to submit a Pull Request.
143
+
144
+ ## License
145
+
146
+ This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
147
+
148
+ ## Acknowledgment
149
+ This project is partially supported by a Meta Reality Labs gift to @sccn and NIH 5R01NS047293.
@@ -0,0 +1,8 @@
1
+ """EMGIO: A Python package for EMG data import/export and manipulation."""
2
+
3
+ from .core.emg import EMG
4
+ from .exporters.edf import EDFExporter
5
+ from .importers.trigno import TrignoImporter
6
+ from .version import __version__, __version_info__
7
+
8
+ __all__ = ["EMG", "TrignoImporter", "EDFExporter", "__version__", "__version_info__"]
@@ -0,0 +1,16 @@
1
+ # Signal analysis module
2
+
3
+ from .signal import (
4
+ analyze_signal,
5
+ determine_format_suitability,
6
+ quantization_analysis,
7
+ # Add other signal analysis functions if needed
8
+ )
9
+ from .verification import compare_signals
10
+
11
+ __all__ = [
12
+ "analyze_signal",
13
+ "determine_format_suitability",
14
+ "quantization_analysis",
15
+ "compare_signals", # Add to __all__
16
+ ]