python-intan 0.0.2__tar.gz → 0.0.3__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 (39) hide show
  1. python_intan-0.0.3/PKG-INFO +439 -0
  2. python_intan-0.0.3/README.md +409 -0
  3. python_intan-0.0.3/intan/__init__.py +42 -0
  4. python_intan-0.0.3/pyproject.toml +45 -0
  5. python_intan-0.0.3/python_intan.egg-info/PKG-INFO +439 -0
  6. python_intan-0.0.3/python_intan.egg-info/SOURCES.txt +13 -0
  7. python_intan-0.0.3/python_intan.egg-info/requires.txt +18 -0
  8. python_intan-0.0.2/PKG-INFO +0 -185
  9. python_intan-0.0.2/README.md +0 -166
  10. python_intan-0.0.2/intan/__init__.py +0 -42
  11. python_intan-0.0.2/intan/control/__init__.py +0 -1
  12. python_intan-0.0.2/intan/control/_messaging.py +0 -171
  13. python_intan-0.0.2/intan/io/__init__.py +0 -64
  14. python_intan-0.0.2/intan/io/_block_parser.py +0 -253
  15. python_intan-0.0.2/intan/io/_channel_utils.py +0 -86
  16. python_intan-0.0.2/intan/io/_data_processing.py +0 -193
  17. python_intan-0.0.2/intan/io/_exceptions.py +0 -37
  18. python_intan-0.0.2/intan/io/_file_utils.py +0 -110
  19. python_intan-0.0.2/intan/io/_header_parsing.py +0 -383
  20. python_intan-0.0.2/intan/io/_metadata_utils.py +0 -150
  21. python_intan-0.0.2/intan/io/_rhd_loader.py +0 -199
  22. python_intan-0.0.2/intan/plotting/__init__.py +0 -2
  23. python_intan-0.0.2/intan/plotting/_emg_plots.py +0 -245
  24. python_intan-0.0.2/intan/plotting/_waterfall.py +0 -132
  25. python_intan-0.0.2/intan/processing/__init__.py +0 -20
  26. python_intan-0.0.2/intan/processing/_filters.py +0 -569
  27. python_intan-0.0.2/intan/processing/_metrics_utils.py +0 -84
  28. python_intan-0.0.2/pyproject.toml +0 -24
  29. python_intan-0.0.2/python_intan.egg-info/PKG-INFO +0 -185
  30. python_intan-0.0.2/python_intan.egg-info/SOURCES.txt +0 -30
  31. python_intan-0.0.2/python_intan.egg-info/requires.txt +0 -6
  32. {python_intan-0.0.2 → python_intan-0.0.3}/LICENSE +0 -0
  33. {python_intan-0.0.2 → python_intan-0.0.3}/python_intan.egg-info/dependency_links.txt +0 -0
  34. {python_intan-0.0.2 → python_intan-0.0.3}/python_intan.egg-info/top_level.txt +0 -0
  35. {python_intan-0.0.2 → python_intan-0.0.3}/setup.cfg +0 -0
  36. {python_intan-0.0.2 → python_intan-0.0.3}/tests/test_RHD2164_SPI.py +0 -0
  37. {python_intan-0.0.2 → python_intan-0.0.3}/tests/test_denoise.py +0 -0
  38. {python_intan-0.0.2 → python_intan-0.0.3}/tests/test_pc_server.py +0 -0
  39. {python_intan-0.0.2 → python_intan-0.0.3}/tests/test_pico_server.py +0 -0
@@ -0,0 +1,439 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-intan
3
+ Version: 0.0.3
4
+ Summary: Python interface and utilities for working with Intan RHX devices and electrophysiology data
5
+ Author-email: Jonathan Shulgach <jshulgac@andrew.cmu.edu>
6
+ License: 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
+ Requires-Dist: tqdm
19
+ Requires-Dist: tensorflow==2.19.0
20
+ Requires-Dist: seaborn
21
+ Requires-Dist: pyyaml
22
+ Requires-Dist: PyQt5
23
+ Requires-Dist: pyqtgraph
24
+ Requires-Dist: pylsl
25
+ Provides-Extra: docs
26
+ Requires-Dist: sphinx; extra == "docs"
27
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
28
+ Requires-Dist: myst-parser; extra == "docs"
29
+ Dynamic: license-file
30
+
31
+ ![Logo](https://raw.githubusercontent.com/neuro-mechatronics-interfaces/python-intan/main/docs/figs/logo.png)
32
+
33
+ # Python Intan
34
+
35
+ [![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://neuro-mechatronics-interfaces.github.io/python-intan/)
36
+ [![Python](https://img.shields.io/badge/python-3.10+-blue)](https://www.python.org/)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
38
+ [![PyPI version](https://badge.fury.io/py/python-intan.svg)](https://badge.fury.io/py/python-intan)
39
+ [![Downloads](https://pepy.tech/badge/python-intan)](https://pepy.tech/project/python-intan)
40
+
41
+ **python-intan** is a comprehensive Python package for working with Intan Technologies RHX systems and electrophysiology data. From file loading to real-time streaming, signal processing to machine learning, hardware integration to GUI applications—everything you need for EMG/neural data analysis in one package.
42
+
43
+ ---
44
+
45
+ ## ✨ Key Features
46
+
47
+ - 📁 **File I/O**: Load `.rhd`, `.rhs`, `.dat`, `.csv`, and `.npz` files with ease
48
+ - 🔴 **Real-time Streaming**: TCP interface for live data acquisition from RHX devices
49
+ - 🎛️ **Signal Processing**: Filtering, normalization, RMS, feature extraction
50
+ - 🤖 **Machine Learning**: Complete gesture classification pipeline with TensorFlow
51
+ - 📊 **Visualization**: Waterfall plots, real-time plotting, GUI applications
52
+ - 🔌 **Hardware Integration**: LSL support, Raspberry Pi Pico, robotic control
53
+ - 🖥️ **GUI Applications**: EMG viewer, trial selector, gesture pipeline interface
54
+ - 🚀 **Performance**: GPU acceleration, optimized for real-time applications
55
+
56
+ ---
57
+
58
+ ## 📚 Quick Links
59
+
60
+ - [**Documentation**](https://neuro-mechatronics-interfaces.github.io/python-intan/) - Full guides and API reference
61
+ - [**Examples**](https://github.com/Neuro-Mechatronics-Interfaces/python-intan/tree/main/examples) - 60+ code examples
62
+ - [**FAQ**](https://neuro-mechatronics-interfaces.github.io/python-intan/info/faqs.html) - Frequently asked questions
63
+ - [**Contributing**](CONTRIBUTING.md) - How to contribute
64
+ - [**Changelog**](CHANGELOG.md) - Version history
65
+
66
+ ---
67
+
68
+ ## 📦 Installation
69
+
70
+ ### From PyPI (Recommended)
71
+
72
+ ```bash
73
+ pip install python-intan
74
+ ```
75
+
76
+ ### From Source (Latest Features)
77
+
78
+ ```bash
79
+ git clone https://github.com/Neuro-Mechatronics-Interfaces/python-intan.git
80
+ cd python-intan
81
+ pip install -e .
82
+ ```
83
+
84
+ ### With Virtual Environment
85
+
86
+ ```bash
87
+ # Using conda
88
+ conda create -n intan python=3.10
89
+ conda activate intan
90
+ pip install python-intan
91
+
92
+ # Or using venv
93
+ python -m venv intan
94
+ source intan/bin/activate # Windows: intan\Scripts\activate
95
+ pip install python-intan
96
+ ```
97
+
98
+ ### GPU Support (Optional)
99
+
100
+ For faster machine learning training:
101
+
102
+ ```bash
103
+ pip install tensorflow[and-cuda] nvidia-cudnn-cu12
104
+ ```
105
+
106
+ ---
107
+
108
+ ## 🚀 Getting Started
109
+
110
+ ### Load and Visualize EMG Data
111
+
112
+ ```python
113
+ import intan
114
+
115
+ # Load .rhd file (opens file picker)
116
+ result = intan.io.load_rhd_file()
117
+
118
+ # Or specify path directly
119
+ result = intan.io.load_rhd_file('path/to/file.rhd')
120
+
121
+ # Access data
122
+ emg_data = result['amplifier_data'] # Shape: (channels, samples)
123
+ fs = result['frequency_parameters']['amplifier_sample_rate']
124
+ t = result['t_amplifier']
125
+
126
+ # Quick filtering
127
+ emg_filtered = intan.processing.notch_filter(emg_data, fs, f0=60)
128
+ emg_filtered = intan.processing.filter_emg(emg_filtered, 'bandpass', fs,
129
+ lowcut=10, highcut=500)
130
+
131
+ # Visualize
132
+ intan.plotting.waterfall(emg_filtered, range(64), t,
133
+ plot_title='Filtered EMG Data')
134
+ ```
135
+
136
+ ### Real-time Streaming from RHX Device
137
+
138
+ ```python
139
+ from intan.interface import IntanRHXDevice
140
+
141
+ # Connect to device
142
+ device = IntanRHXDevice()
143
+ device.enable_wide_channel(range(64))
144
+ device.start_streaming()
145
+
146
+ # Stream data
147
+ timestamps, data = device.stream(duration_sec=1.0)
148
+ print(f"Acquired data shape: {data.shape}")
149
+
150
+ device.close()
151
+ ```
152
+
153
+ ### Train a Gesture Classifier
154
+
155
+ ```python
156
+ from intan.ml import ModelManager
157
+ import numpy as np
158
+
159
+ # Load training data
160
+ data = np.load('training_data.npz')
161
+ X_train, y_train = data['features'], data['labels']
162
+
163
+ # Train model
164
+ manager = ModelManager()
165
+ model, pca, scaler = manager.train_model(X_train, y_train,
166
+ model_type='CNN', epochs=50)
167
+
168
+ # Save for later use
169
+ manager.save_model('gesture_model.keras')
170
+ ```
171
+
172
+ ### Real-time Gesture Recognition
173
+
174
+ ```python
175
+ from intan.interface import IntanRHXDevice
176
+ from intan.ml import EMGRealTimePredictor
177
+ import tensorflow as tf
178
+
179
+ # Load trained model
180
+ model = tf.keras.models.load_model('gesture_model.keras')
181
+
182
+ # Initialize device
183
+ device = IntanRHXDevice(num_channels=128)
184
+ device.start_streaming()
185
+
186
+ # Create predictor
187
+ predictor = EMGRealTimePredictor(device, model, pca, mean, std, label_names)
188
+ predictor.run_prediction_loop()
189
+
190
+ # Get predictions
191
+ while True:
192
+ prediction = predictor.get_prediction()
193
+ if prediction:
194
+ print(f"Gesture: {prediction['label']} ({prediction['confidence']:.1%})")
195
+ ```
196
+
197
+ ### Lab Streaming Layer (LSL) Integration
198
+
199
+ ```python
200
+ from intan.interface import IntanRHXDevice, LSLPublisher
201
+
202
+ # Start device
203
+ device = IntanRHXDevice(num_channels=64)
204
+ device.start_streaming()
205
+
206
+ # Publish to LSL
207
+ publisher = LSLPublisher(name='IntanEMG', stream_type='EMG',
208
+ channel_count=64, sample_rate=4000)
209
+
210
+ while True:
211
+ _, data = device.stream(n_frames=40)
212
+ publisher.push_chunk(data.T)
213
+ ```
214
+
215
+ ---
216
+
217
+ ## 🗂️ Package Structure
218
+
219
+ ```text
220
+ intan/
221
+ ├── io/ # File loading (.rhd, .dat, .csv, .npz)
222
+ ├── interface/ # RHX device, LSL, hardware interfaces
223
+ ├── processing/ # Signal processing and filtering
224
+ ├── ml/ # Machine learning pipeline
225
+ ├── plotting/ # Visualization utilities
226
+ ├── applications/ # GUI applications
227
+ ├── decomposition/ # PCA, ICA decomposition
228
+ └── samples/ # Sample data utilities
229
+
230
+ examples/
231
+ ├── Read_Files/ # File loading examples
232
+ ├── RHXDevice/ # Device streaming examples
233
+ ├── LSL/ # Lab Streaming Layer examples
234
+ ├── gesture_classifier/ # ML training and prediction
235
+ ├── applications/ # GUI application demos
236
+ ├── 3D_printed_arm_control/ # Robotic control integration
237
+ └── interface/ # Hardware interfacing examples
238
+ ```
239
+
240
+ ---
241
+
242
+ ## 🎯 Use Cases
243
+
244
+ ### 📊 Data Analysis
245
+ - Load and analyze `.rhd` recordings
246
+ - Batch process multiple files
247
+ - Extract specific time segments
248
+ - Generate publication-quality figures
249
+
250
+ ### 🔴 Real-time Applications
251
+ - Live EMG visualization
252
+ - Online gesture recognition
253
+ - Closed-loop control systems
254
+ - Synchronized multi-modal recording
255
+
256
+ ### 🤖 Machine Learning
257
+ - Train gesture classifiers
258
+ - Real-time prediction
259
+ - Cross-session validation
260
+ - Transfer learning
261
+
262
+ ### 🔬 Research
263
+ - Impedance testing
264
+ - Signal quality monitoring
265
+ - Protocol automation
266
+ - Custom experimental setups
267
+
268
+ ---
269
+
270
+ ## 📖 Documentation
271
+
272
+ Comprehensive documentation is available at [neuro-mechatronics-interfaces.github.io/python-intan](https://neuro-mechatronics-interfaces.github.io/python-intan/)
273
+
274
+ **Key Sections:**
275
+ - [Installation Guide](https://neuro-mechatronics-interfaces.github.io/python-intan/info/installation.html)
276
+ - [Loading Files](https://neuro-mechatronics-interfaces.github.io/python-intan/examples/loading_data.html)
277
+ - [Real-time Streaming](https://neuro-mechatronics-interfaces.github.io/python-intan/examples/live_plotting.html)
278
+ - [Signal Processing](https://neuro-mechatronics-interfaces.github.io/python-intan/info/signal_processing.html)
279
+ - [Gesture Classification](https://neuro-mechatronics-interfaces.github.io/python-intan/examples/gesture_classification.html)
280
+ - [LSL Integration](https://neuro-mechatronics-interfaces.github.io/python-intan/examples/lsl_streaming.html)
281
+ - [GUI Applications](https://neuro-mechatronics-interfaces.github.io/python-intan/examples/gui_applications.html)
282
+ - [Hardware Control](https://neuro-mechatronics-interfaces.github.io/python-intan/examples/hardware_control.html)
283
+ - [FAQ](https://neuro-mechatronics-interfaces.github.io/python-intan/info/faqs.html)
284
+ - [API Reference](https://neuro-mechatronics-interfaces.github.io/python-intan/intan_api/modules.html)
285
+
286
+ ---
287
+
288
+ ## 🎓 Examples
289
+
290
+ The `examples/` directory contains 60+ working examples organized by category:
291
+
292
+ ```bash
293
+ # File loading
294
+ python examples/Read_Files/load_rhd_demo.py
295
+
296
+ # Real-time streaming
297
+ python examples/RHXDevice/scrolling_live.py
298
+
299
+ # Gesture classification pipeline
300
+ python examples/gesture_classifier/1a_build_training_dataset_rhd.py
301
+ python examples/gesture_classifier/2_train_model.py
302
+ python examples/gesture_classifier/3d_predict_from_device_realtime.py
303
+
304
+ # GUI applications
305
+ python examples/applications/run_emg_viewer.py
306
+ python examples/applications/gesture_pipeline_gui.py
307
+
308
+ # LSL streaming
309
+ python examples/LSL/lsl_waveform_viewer.py
310
+ python examples/LSL/lsl_rms_barplot.py
311
+ ```
312
+
313
+ See the [Examples Documentation](https://neuro-mechatronics-interfaces.github.io/python-intan/examples/introduction.html) for complete guides.
314
+
315
+ ---
316
+
317
+ ## 🛠️ Supported Hardware
318
+
319
+ - **Intan RHX Controllers**: RHD USB Interface Board, RHD Recording Controller
320
+ - **Amplifiers**: RHD2000 series (RHD2132, RHD2164, RHD2216, etc.)
321
+ - **Stimulation**: RHS2000 series amplifiers
322
+ - **Peripherals**: Raspberry Pi Pico, servo controllers, IMU sensors
323
+ - **Integration**: Lab Streaming Layer (LSL) compatible devices
324
+
325
+ ---
326
+
327
+ ## 🤝 Contributing
328
+
329
+ We welcome contributions! Whether it's:
330
+
331
+ - 🐛 Bug reports
332
+ - ✨ Feature requests
333
+ - 📝 Documentation improvements
334
+ - 🧪 New examples
335
+ - 🔧 Code contributions
336
+
337
+ Please see our [Contributing Guide](CONTRIBUTING.md) for details.
338
+
339
+ **Ways to contribute:**
340
+ - Report bugs or request features via [GitHub Issues](https://github.com/Neuro-Mechatronics-Interfaces/python-intan/issues)
341
+ - Submit pull requests with improvements
342
+ - Share your use cases and examples
343
+ - Help answer questions in discussions
344
+ - Improve documentation
345
+
346
+ ---
347
+
348
+ ## 📝 Citation
349
+
350
+ If you use this package in your research, please cite:
351
+
352
+ ```bibtex
353
+ @software{Shulgach_Python_Intan_2025,
354
+ author = {Shulgach, Jonathan and Murphy, Max and Foy, Adrian},
355
+ title = {{Python Intan Package}},
356
+ year = {2025},
357
+ month = {01},
358
+ version = {0.0.3},
359
+ url = {https://github.com/Neuro-Mechatronics-Interfaces/python-intan},
360
+ note = {Neuromechatronics Lab, Carnegie Mellon University}
361
+ }
362
+ ```
363
+
364
+ ---
365
+
366
+ ## 📄 License
367
+
368
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
369
+
370
+ **MIT License means:**
371
+ - ✅ Commercial use
372
+ - ✅ Modification
373
+ - ✅ Distribution
374
+ - ✅ Private use
375
+
376
+ ---
377
+
378
+ ## 🙏 Acknowledgments
379
+
380
+ Developed by the [Neuromechatronics Lab](https://www.meche.engineering.cmu.edu/faculty/neuromechatronics-lab.html) at Carnegie Mellon University.
381
+
382
+ **Core Contributors:**
383
+ - Jonathan Shulgach
384
+ - Max Murphy
385
+ - Adrian Foy
386
+
387
+ **Special Thanks:**
388
+ - Intan Technologies for hardware and support
389
+ - The open-source neuroscience community
390
+
391
+ ---
392
+
393
+ ## 📧 Contact & Support
394
+
395
+ - **Documentation**: [neuro-mechatronics-interfaces.github.io/python-intan](https://neuro-mechatronics-interfaces.github.io/python-intan/)
396
+ - **Issues**: [GitHub Issues](https://github.com/Neuro-Mechatronics-Interfaces/python-intan/issues)
397
+ - **Email**: jshulgac@andrew.cmu.edu
398
+ - **Lab Website**: [Neuromechatronics Lab](https://www.meche.engineering.cmu.edu/faculty/neuromechatronics-lab.html)
399
+
400
+ ---
401
+
402
+ ## 🚦 Status & Roadmap
403
+
404
+ **Current Version: 0.0.3** (January 2025)
405
+
406
+ ### Completed ✅
407
+ - [x] File loading (.rhd, .dat, .csv, .npz)
408
+ - [x] Real-time TCP streaming from RHX
409
+ - [x] Signal processing pipeline
410
+ - [x] Machine learning (CNN, LSTM, Dense models)
411
+ - [x] Real-time gesture recognition
412
+ - [x] Lab Streaming Layer integration
413
+ - [x] GUI applications (EMG viewer, trial selector, gesture pipeline)
414
+ - [x] Hardware integration (Pico, robotic arms, IMU)
415
+ - [x] Comprehensive documentation and examples
416
+
417
+ ### In Progress 🚧
418
+ - [ ] Performance benchmarking suite
419
+ - [ ] Extended LSL marker synchronization
420
+ - [ ] Additional ML model architectures
421
+ - [ ] Mobile device integration
422
+
423
+ ### Planned 📋
424
+ - [ ] Public training datasets
425
+ - [ ] Cloud integration for distributed processing
426
+ - [ ] Advanced impedance testing tools
427
+ - [ ] Multi-language support (MATLAB, Julia wrappers)
428
+
429
+ See [CHANGELOG.md](CHANGELOG.md) for detailed version history.
430
+
431
+ ---
432
+
433
+ <p align="center">
434
+ <b>⭐ If you find this package useful, please consider giving it a star on GitHub! ⭐</b>
435
+ </p>
436
+
437
+ <p align="center">
438
+ Made with ❤️ by the Neuromechatronics Lab
439
+ </p>