Skip to main content

PyoMyo

Python module for the Thalmic Labs Myo armband.

Cross platform and multithreaded and works without the Myo SDK.

pip install pyomyo

Playing breakout with sEMG

Python Open-source Myo library

This library was made from a fork of the MIT licensed dhzu/myo-raw. Bug fixes from Alvipe/myo-raw were also added to stop crashes and also add essential features.

This code was then updated to Python3, multithreading support was added then more bug fixes and other features were added, including support for all 3 EMG modes the Myo can use.

Note that sEMG data, the same kind gathered by the Myo is thought to be uniquely identifiable. Do not share this data without careful consideration of the future implications.

Also note, the Myo is outdated hardware, over the last year I have noticed a steady incline in the cost of second hand Myos. Both of my Myo's were bought for under £100, I do not recommend spending more than that to acquire one. Instead of buying one you should join the discord to create an open hardware alternative!

The Basics

pyomyo.py

Prints sEMG readings at 200Hz straight from the Myo's ADC using the raw EMG mode.
Each EMG readings is between -128 and 127, it is the most "raw" the Myo can provide, however it's unlikely to be useful without extra processing. This file is also where the Myo driver is implemented, which uses Serial commands which are then sent over Bluetooth to interact with the Myo.

plot_emgs.py

Starts the Myo in mode 0x01 which provides data that's already preprocessed (bandpass filter + rectified).
This data is then plotted in pygame and is a good first step to see how the Myo works.
Sliding your finger under each sensor on the Myo will help identify which plot is for sensor. With the terminal selected press Ctrl + C to kill the processes.

simple_classifier.py

Uses a simple nearest neighbour classifier and predicts gestures live.
Make a gesture with one hand then press a number key to label the incoming EMG values that class.
Once two classes have been made new data is automatically classified. Labelled data is stored as a numpy array in the data directory.

myo_multithreading_examp.py

Devs start here.
This file shows how to use the library and get Myo data in a seperate thread.

Myo Modes Explained

To communicate with the Myo, I used dzhu's myo-raw. Then added some functions from Alvipe to allow changing of the Myo's LED.

(0x01, raw=False)
By default myo-raw sends 50Hz data that has been rectified and filtered, using a hidden 0x01 mode.
(0x02, raw=True, filtering=True)
Alvipe added the ability to also get filtered non-rectified sEMG (thanks Alvipe).
(0x03, raw=True, filtering=False)
Then I futher added the ability to get true raw non-filtered data at 200Hz. This data is unrectified but scales from -128 and 127.

Sample data and a comparison between data captured in these modes can be found in MyoEMGPreprocessing.ipynb

Metadata

Release files for OpenEMG 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for OpenEMG 0.0.1
File Size Uploaded
OpenEMG-0.0.1.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for OpenEMG 0.0.1
File Interpreter ABI Platform
OpenEMG-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.2 kB

Release files / OpenEMG-0.0.1.tar.gz

Download URL OpenEMG-0.0.1.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6473697507412127ead064175183f40ff38831ab61a60627af0c7b9bb9e05985
BLAKE2b-256 checksum
How to use checksums
034f9c8112ebda1d7c22df56bfc99d8997238f5c1052851d33324f5725d11c5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.2

Release files / OpenEMG-0.0.1-py3-none-any.whl

Download URL OpenEMG-0.0.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da52fd9463b21b900b9c9de053329e0933f58f068c0fa275bdaaaeaa92b5a912
BLAKE2b-256 checksum
How to use checksums
8c4c11767abad2dfc8ff181fac9ac5e0857a6a1421b924ff8e70880e89e96892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page