Micromed IO library
A library to read, emulate, and forward Micromed data in standard formats. See online doc.
Main features:
simulate online data from a trc file
push online tcp data to LSL server
convert trc to mne format
rename trc files to include the recording datetime
Install
$ pip install micromed-io
Convert a Micromed (.trc) file to MNE (.fif) format
from micromed_io.to_mne import create_mne_from_micromed_recording
mne_raw = create_mne_from_micromed_recording("path/to/file.TRC")
Emulate TRC to TCP & read/forward to LSL server
See details in next sections
Emulate Online Micromed TCP from .trc file
$ mmio_emulate_trc --file=../data/sample.TRC --address=localhost --port=5123
Emulate the online data stream of Micromed to test your real-time platform. See all the arguments and adapt them:
$ mmio_emulate_trc --help # to see all arguments
Read TCP and push to LSL Stream
$ mmio_tcp_to_lsl --address=localhost --port=5123
While receiving online data throug tcp, this command forward the data to 3 LSL stream outlets:
Micromed_EEG: the eeg data in float32 format [n_channels, n_samples]
Micromed_Markers: markers if any in int32 format [sample, marker] (2 channels)
Micromed_Notes: notes if any in string format [sample, note] (2 channels)
You can easily change the LSL parameters:
$ mmio_tcp_to_lsl --help # to see all arguments
Read TRC file
from micromed_io.trc import MicromedTRC
mmtrc = MicromedTRC("sample.TRC")
Then you have access to the trc data:
mmtrc.get_header()
mmtrc.get_markers()
mmtrc.get_data()
mmtrc.get_notes()
Read and parse Micromed TCP live data
Download tcp_to_lsl.py from the github repo in scripts/
$ python tcp_to_lsl.py --address=localhost --port=5123
Note: Micromed TCP behaves as a client. If you want to try the emulate/read TCP script, launch the reader first that acts as server, then the emulator.
Read online Micromed TCP in a sliding window buffer
If you plan to use the Micromed data as input of a decoder, you probably want epochs of format (n_channels, n_samples). Then the MicromedBuffer class is for you. The script tcp_to_epoch.py shows you how to use it (see the PROCESS HERE comment). It uses a buffer that mimics the sliding window and triggers each time it is filled.
from micromed_io.buffer import MicromedBuffer
micromed_buffer = MicromedBuffer(epoch_duration=5, epoch_overlap=2.5)
To run the example, you can download and run the tcp_to_epoch.py script in extern/ folder:
$ python tcp_to_epoch.py --epoch-size=5 --overlap=2.5
Rename TRC files with recording datetime
$ mmio_rename_trc --dirpath=./ --format=%Y%m%d-%H%M%S
Rename the TRC files of the given folder to include the recording date in the filename. Output is : <filename>__<recording_date>.TRC. The format must be compliant with python strftime format codes
mmio_rename_trc --help # to see help
Local install
Download the repo and:
$ conda env create -f environment.yml
$ conda activate mmio
$ poetry install
Please feel free to reach me if you want to contribute.
Metadata
Release files for micromed-io 0.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| micromed_io-0.3.9.tar.gz | 20.2 kB | Without provenance | Details for micromed_io-0.3.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| micromed_io-0.3.9-py3-none-any.whl | Python 3 | none | any | Details for micromed_io-0.3.9-py3-none-any.whl |
Total release size: 46.2 kB
Release files / micromed_io-0.3.9.tar.gz
| Download URL | micromed_io-0.3.9.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d0c32e593ea8383b58bbc6853452b3b4f774f57fdaf10548bf60324022b7409
|
|
BLAKE2b-256 checksum How to use checksums |
31b784c809ecbbcfd26cbf0b5eb504952fc0606aa0ac1cbbaa94f803633442ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.9.12 Windows/10
|
Release files / micromed_io-0.3.9-py3-none-any.whl
| Download URL | micromed_io-0.3.9-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8abe4a7d15b93251dc02fc1eb62e748f98254a023d6a4096a40d0928f37fc0ba
|
|
BLAKE2b-256 checksum How to use checksums |
75ee0e30e73f3d34c6e5e79d94f87f7a72c85bd6df7f5c681125c8f741b39054
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.9.12 Windows/10
|
Security for micromed-io 0.3.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.