python-intan 0.0.2__py3-none-any.whl

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.
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-intan
3
+ Version: 0.0.2
4
+ Summary: Python utilities for working with Intan electrophysiology data
5
+ Author-email: Jonathan Shulgach <jshulgac@andrew.cmu.edu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Neuro-Mechatronics-Interfaces/python-intan
8
+ Keywords: intan,emg,neurotech,signal processing,biomedical
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: numpy>=1.26.0
13
+ Requires-Dist: scipy==1.14.1
14
+ Requires-Dist: matplotlib
15
+ Requires-Dist: pandas
16
+ Requires-Dist: PySerial
17
+ Requires-Dist: scikit-learn
18
+ Dynamic: license-file
19
+
20
+ # Python Intan
21
+
22
+ [![Python](https://img.shields.io/badge/python-3.10-blue)](https://www.python.org/)
23
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
24
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/Neuro-Mechatronics-Interfaces/python-intan/test.yml?branch=main)](https://github.com/Neuro-Mechatronics-Interfaces/python-intan/actions)
25
+ [![PyPI version](https://badge.fury.io/py/python-intan.svg)](https://badge.fury.io/py/python-intan)
26
+
27
+ <p align="center">
28
+ <img src="./docs/figs/logo.png">
29
+ </p>
30
+
31
+
32
+ ## Overview
33
+
34
+ **`python-intan`** is a Python package for working with EMG data acquired from Intan Technologies systems. It provides utilities for:
35
+
36
+ - Reading `.rhd` and `.dat` data files
37
+ - Preprocessing and feature extraction
38
+ - Integration with external hardware for closed-loop applications
39
+
40
+ Whether you're analyzing offline data or streaming real-time EMG from the RHX system, `python-intan` aims to make the workflow seamless and modular.
41
+
42
+ ---
43
+
44
+ ## Contents
45
+
46
+ - [Installation](#installation)
47
+ - [Getting Started](#getting-started)
48
+ - [Project Structure](#project-structure)
49
+ - [Future Improvements](#future-improvements)
50
+ - [License](#license)
51
+
52
+ ---
53
+
54
+ ## Installation
55
+
56
+ Using `pip`:
57
+ ```shell script
58
+ pip install python-intan
59
+ ```
60
+
61
+ or clone the repository from GitHub for the latest features:
62
+
63
+ ```bash
64
+ git clone https://github.com/Neuro-Mechatronics-Interfaces/python-intan.git
65
+ cd python-intan
66
+ pip install -e .
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Getting Started
72
+
73
+ We can quickly load EMG signals from an Intan `.rhd` file.
74
+
75
+ ```python
76
+ import intan
77
+
78
+ result = intan.io.load_rhd_file() # Opens Popup window to select file, or pass filepath
79
+ ```
80
+ `.dat` files are also supported
81
+ ```python
82
+ dat_folderpath = "path/to/your/dat/files"
83
+ result = intan.io.load_dat_file(dat_folderpath)
84
+ ```
85
+ The `result` dictionary contains:
86
+ - `amplifier_data`: Raw EMG data (shape: channels x samples)
87
+ - `amplifier_channels`: Channel metadata (names, gain, etc.)
88
+ - `frequency_parameters`: Sampling rate information for the amplifier, aux, and digital inputs
89
+ - `t_amplifier`: Time vector for the amplifier data
90
+ - `board_adc_data`: ADC data from the board
91
+
92
+ Loading multiple `.rhd` files with the option to concatenate can be done with:
93
+ ```python
94
+ result_list = intan.io.load_rhd_files(concatenate=True)
95
+ ```
96
+ Some quick filtering to remove DC offset and noise:
97
+ ```python
98
+ fs = result['frequency_parameters']['amplifier_sample_rate']
99
+ emg = result['amplifier_data'] # Shape: (channels, samples)
100
+
101
+ notch_emg = intan.processing.notch_filter(emg, fs, f0=60) # 60Hz notch filter
102
+ filt_emg = intan.processing.filter_emg(notch_emg, 'bandpass', fs, lowcut=10, highcut=500) # 10-500Hz bandpass filter
103
+ ```
104
+
105
+
106
+ We can visualize the raw EMG data using the `plotting` module. Let's use a waterfall plot to look at the raw activity across a subset of channels:
107
+
108
+ ```python
109
+ t_s = result['t_amplifier']
110
+ chans = range(0, 64) # Selecting channels to plot
111
+ intan.plotting.waterfall(filt_emg, chans, t_s, plot_title='Intan EMG data')
112
+ ```
113
+
114
+ If there is a single channel of interest, we can plot it directly by name or index:
115
+ ```python
116
+ intan.plotting.plot_channel_by_name('A-005', result) # By name (Be sure the channel name exists)
117
+ intan.plotting.plot_channel_by_index(8, result) # By index
118
+ ```
119
+
120
+ Some other processing features:
121
+ ```python
122
+ # Normalize the EMG data
123
+ norm_emg = intan.processing.normalize(filt_emg, method='zscore') # Z-score normalization
124
+
125
+ # Downsample the EMG data
126
+ downsampled_emg = intan.processing.downsample(filt_emg, factor=2) # Downsample by a factor of 2
127
+
128
+ # Rectify
129
+ rectified_emg = intan.processing.rectify(filt_emg) # Rectify the EMG data
130
+
131
+ # Rolling RMS window
132
+ samples = int(0.1 * fs) # 100ms window
133
+ rms_emg = intan.processing.window_rms(filt_emg, window_size=samples) # 100ms RMS window
134
+ ```
135
+
136
+
137
+ ---
138
+
139
+ ## Project Structure
140
+
141
+ ```text
142
+ intan/
143
+ ├── io/ # Load and parse Intan .rhd or .rhs files
144
+ ├── processing/ # Filtering, normalization, and segmentation
145
+ ├── control/ # Real-time control scripts for robot arm or other peripherals
146
+ ├── plotting/ # Plotting and GUI scripts
147
+
148
+ load_rhd_demo.py # Quick-start script for plotting waveform data
149
+ requirements.txt
150
+ README.md
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Future Improvements
156
+
157
+ - [x] Real-time gesture decoding via TCP from RHX
158
+ - [x] Serial control for wearable robotics (e.g. grippers, arms)
159
+ - [x] CNN feature pipeline support
160
+ - [ ] GUI for real-time signal monitoring
161
+ - [ ] Public datasets with training/testing support
162
+ - [ ] Cross-platform support for macOS/Linux (currently optimized for Windows)
163
+
164
+ ---
165
+
166
+ ## Citation
167
+
168
+ This package can be cited as follows:
169
+
170
+ ```bibtex
171
+ @software{Shulgach_Python_Intan_2025,
172
+ author = {Shulgach, Jonathan, Murphy, Max and Foy, Adrian},
173
+ title = {{Python Intan Package}},
174
+ year = {2025},
175
+ month = {05},
176
+ version = {0.1.0},
177
+ url = {https://github.com/Neuro-Mechatronics-Interfaces/python-intan},
178
+ note = "{\tt jshulgac@andrew.cmu.edu}"
179
+ }
180
+ ```
181
+
182
+
183
+ ## License
184
+
185
+ This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,23 @@
1
+ intan/__init__.py,sha256=MrM6q_IJBACjU0K4xmuczidXcvAgxh4j63kwK_UDN6I,997
2
+ intan/control/__init__.py,sha256=voB6OqFjQR3Cdpzx78aFRbpeWDv5lofZOC2Fz05uoV4,59
3
+ intan/control/_messaging.py,sha256=DDnCZYXs3rQd-8NjSjef55xo019lMjxpLYNwaFbEFSY,6833
4
+ intan/io/__init__.py,sha256=YfbQAV17luEa65dkEgDQz77dF_ea292gMa_Y4nHgE80,1836
5
+ intan/io/_block_parser.py,sha256=eaPzsnSxFM8-8kYV_vadP7XQYQUTqTP_cTjZs9NHBQc,10171
6
+ intan/io/_channel_utils.py,sha256=9SmHs3lSCAEzXgebGMZtmZ1ghFMgx1x4cke3iLlUxAs,3464
7
+ intan/io/_data_processing.py,sha256=2rrymxViPWcxpYwWO2FQv9Pkn3u5tBr9IEJhz9V-K0o,7575
8
+ intan/io/_exceptions.py,sha256=Z0Ns-IYkj4YiGpwKPB_lDUPUY5qn7NrWDctq6zCMWJE,1063
9
+ intan/io/_file_utils.py,sha256=RLRM4hdhDyiNvynj-g0ZeZw9-gHZzWR85bIu9_WeQxc,3715
10
+ intan/io/_header_parsing.py,sha256=fsb14RrCohynbf1QkWboMi3yHo7meRql6ZvSGiLvh0M,15296
11
+ intan/io/_metadata_utils.py,sha256=VsEF6_sLYaedGF_w8MW_QzRXK8sBTaf-C4oycmDyJHo,6137
12
+ intan/io/_rhd_loader.py,sha256=L1yybfV1Vfyz6pYU3Bj8v1zCCss-nUgja5mdvTO6C6s,7601
13
+ intan/plotting/__init__.py,sha256=aa3VYJrEXZ7zU72HIq5qV27ptjwbc5OZWfa551yocpE,179
14
+ intan/plotting/_emg_plots.py,sha256=DvxmboGhsyS2Jlk-IBSmgOSDdoBVgcbuQ3yB8_WOzwU,8606
15
+ intan/plotting/_waterfall.py,sha256=Sp-6nB4H7As3S-1tf8Npj56MN7iA5AVcOwTTK4XMJU8,5583
16
+ intan/processing/__init__.py,sha256=YGgKpX0sXUjmaQwabWfDknXqA_0uk0EUYPQbgfuJdMU,460
17
+ intan/processing/_filters.py,sha256=pbkA_57T4vxB5NJpVYeT87vTbFtXZDjBLPCxnMhczIA,20591
18
+ intan/processing/_metrics_utils.py,sha256=KLSW0rlJTUYXT4HKXlAXRW3DWw1bZiRYytmmmsxsTyg,3195
19
+ python_intan-0.0.2.dist-info/licenses/LICENSE,sha256=acfOQeocdtaKmGd_-tdY3yOUSrxP9_nX4q2xv7G9RR0,1099
20
+ python_intan-0.0.2.dist-info/METADATA,sha256=DkCyNij5uutSZAFHvtRsPbhyGsVHxi10bnHDEYuA7GA,5889
21
+ python_intan-0.0.2.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
22
+ python_intan-0.0.2.dist-info/top_level.txt,sha256=P-ybm93eLvEAjcZnvltPlz6ghXTfMSb0ttfh9G_tBkI,6
23
+ python_intan-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.3.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Neuromechatronics Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ intan