PyoMyo - Python Opensource Myo library

Overview

PyoMyo

Python module for the Thalmic Labs Myo armband.

Cross platform and multithreaded and works without the Myo SDK.

pip install pyomyo

Documentation is in the Wiki, see Getting Started.

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!

Included Example Code

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.

emg_mode.PREPROCESSED (0x01)
By default myo-raw sends 50Hz data that has been rectified and filtered, using a hidden 0x01 mode.

emg_mode.FILTERED (0x02)
Alvipe added the ability to also get filtered non-rectified sEMG (thanks Alvipe).

emg_mode.RAW (0x03)
Then I further 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

Comments
  • Serial Read leaves program hanging on Raspberry Pi

    Serial Read leaves program hanging on Raspberry Pi

    Hi, I am running a project that uses the Myo armband to control several servos. I have noticed that sometimes the Serial read on line 124 of the pyomyo.py file does not complete or timeout and therefore the program hangs.

    Perhaps setting a timeout on the Serial may help avoid this?

    opened by Marcus1818787 3
  • Adding more live classifiers

    Adding more live classifiers

    • Added simple classes for live labelling and classification for:
      KNN, SVM, Decision Trees, XGBoost and Logistic Regression Classifiers
    • Added a deletion function to erase data labelled using a classifier.

    Note these only work with the preprocessed emg mode, however its unlikely a classifier would work well on unpreprocessed data anyway.

    PR is a work in progress, as I hope to clean up the pygame plotting and move a classifier into pyomyo and update the version on PyPI.

    hacktoberfest-accepted 
    opened by PerlinWarp 1
  • Cleaning of the interface and updating the README

    Cleaning of the interface and updating the README

    Using an enum for the EMG mode so people don't need to remember the difference between 0x01, 0x02 and 0x03. Changing the class name from MyoRaw to Myo.

    opened by PerlinWarp 0
  • Position Calibration tools to minimise cross session variance.

    Position Calibration tools to minimise cross session variance.

    Sensor positioning is hard and solving it is part of solving cross session generalisation, although there are fancy techniques that can be performed after the data is gathered, it would be worth having a discussion on the simple things. Here are some of my rough thoughts:

    Calibration Methods

    Once a placement is chosen, originally I would sharpie an outline of the whole Myo on my hand. It's important to mark the position of each sensor pod, not just one. The Myo can both rotate around the arm, move up and down, or tilt up and down.

    One simple way I calibrate is by placing the Myo on my proximal forearm of my right hand, waving my wrist right and then making sure this movement only peaks one channel, e.g. channel 3. If the movement peaks two channels, I know the relevant muscle is in-between 2 EMG sensors and then rotate the Myo slightly to minimise cross talk and maximise the amount of the signal only picked up by channel 3.

    Once this placement was used a kNN classifier can be trained on relevant gestures, e.g. 5 finger flexion. Then next session, after manual calibration is attempted it can be fine tuned until the kNN classifier works.

    Search for something better, or at least more scientific

    Some tools could be made to tell the user to rotate the Myo and show the user how similar the readings are to the previous data gathered.
    Adding live PCA plotting to the live classifiers with a print out of between/within group variance may help quickly tryout different positioning for different gestures.

    enhancement 
    opened by PerlinWarp 0
  • Provide an implementation of common metrics to help with classification and regression

    Provide an implementation of common metrics to help with classification and regression

    Both feature engineering and preprocessing of EMG data will likely be added for any significantly difficult project using pyomyo. If so it would be nice to contribute these implementations back so that efficiency improvements/bug fixes can be shared. It would be nice to include a metrics.py file containing implementations and a plot_metrics.py file that can give some intuition on what each feature captures.

    Some examples of metrics to include are Mean Absolute Value (MAV), Root Mean Square (RMS), Willison Amplitude (WAMP), Waveform Length (WL) and Zero Crossings (ZL). More info can be found in this paper for different metrics. My hope was to implement them and create a notebook showing their feature importance's for different tasks and models but have not had the time so far.

    enhancement 
    opened by PerlinWarp 0
  • Implement FFT Features and Spectrogram for Neurofeedback

    Implement FFT Features and Spectrogram for Neurofeedback

    This was started in the Spectrogram branch and is completed for one channel, although I am not sure about the correctness of my method. Needs moving to all 8 channels and rebasing.

    enhancement 
    opened by PerlinWarp 0
  • Add bleak backend to allow people without dongles to use pyomyo

    Add bleak backend to allow people without dongles to use pyomyo

    The BLED112 dongle allows the Myo to work on any operating system as it acts as a COM port that forwards serial commands send to it over Bluetooth.

    One reason why it's worth doing this is due to the poor cross platform BLE support, however bleak (Bluetooth Low Energy platform Agnostic Klient) may solve this and allow people without a dongle to use pyomyo.

    This feature would also act as a stepping stone for makers of open source BLE EMGs to add support for their hardware to pyomyo.

    Thankfully, Thalmic Labs released (most of the) the specification here.

    enhancement 
    opened by PerlinWarp 0
Owner
PerlinWarp
Recently graduated CS student working on VR and BCIs.
PerlinWarp
[ICRA 2022] An opensource framework for cooperative detection. Official implementation for OPV2V.

OpenCOOD OpenCOOD is an Open COOperative Detection framework for autonomous driving. It is also the official implementation of the ICRA 2022 paper OPV

Runsheng Xu 322 Dec 23, 2022
A python library for face detection and features extraction based on mediapipe library

FaceAnalyzer A python library for face detection and features extraction based on mediapipe library Introduction FaceAnalyzer is a library based on me

Saifeddine ALOUI 14 Dec 30, 2022
Python wrappers to the C++ library SymEngine, a fast C++ symbolic manipulation library.

SymEngine Python Wrappers Python wrappers to the C++ library SymEngine, a fast C++ symbolic manipulation library. Installation Pip See License section

null 136 Dec 28, 2022
Fast image augmentation library and easy to use wrapper around other libraries. Documentation: https://albumentations.ai/docs/ Paper about library: https://www.mdpi.com/2078-2489/11/2/125

Albumentations Albumentations is a Python library for image augmentation. Image augmentation is used in deep learning and computer vision tasks to inc

null 11.4k Jan 9, 2023
Bayesian optimisation library developped by Huawei Noah's Ark Library

Bayesian Optimisation Research This directory contains official implementations for Bayesian optimisation works developped by Huawei R&D, Noah's Ark L

HUAWEI Noah's Ark Lab 395 Dec 30, 2022
Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! Very tiny! Stock Market Financial Technical Analysis Python library . Quant Trading automation or cryptocoin exchange

MyTT Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! to Stock Market Financial Technical Analysis Python

dev 34 Dec 27, 2022
Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.

============================================================================================================ `MILA will stop developing Theano <https:

null 9.6k Dec 31, 2022
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

eXtreme Gradient Boosting Community | Documentation | Resources | Contributors | Release Notes XGBoost is an optimized distributed gradient boosting l

Distributed (Deep) Machine Learning Community 23.6k Dec 31, 2022
A python library for self-supervised learning on images.

Lightly is a computer vision framework for self-supervised learning. We, at Lightly, are passionate engineers who want to make deep learning more effi

Lightly 2k Jan 8, 2023
💡 Learnergy is a Python library for energy-based machine learning models.

Learnergy: Energy-based Machine Learners Welcome to Learnergy. Did you ever reach a bottleneck in your computational experiments? Are you tired of imp

Gustavo Rosa 57 Nov 17, 2022
Lightweight, Python library for fast and reproducible experimentation :microscope:

Steppy What is Steppy? Steppy is a lightweight, open-source, Python 3 library for fast and reproducible experimentation. Steppy lets data scientist fo

minerva.ml 134 Jul 10, 2022
GPU-Accelerated Deep Learning Library in Python

Hebel GPU-Accelerated Deep Learning Library in Python Hebel is a library for deep learning with neural networks in Python using GPU acceleration with

Hannes Bretschneider 1.2k Dec 21, 2022
PyBrain - Another Python Machine Learning Library.

PyBrain -- the Python Machine Learning Library =============================================== INSTALLATION ------------ Quick answer: make sure you

null 2.8k Dec 31, 2022
A python library for implementing a recommender system

python-recsys A python library for implementing a recommender system. Installation Dependencies python-recsys is build on top of Divisi2, with csc-pys

Oscar Celma 1.5k Dec 17, 2022
Neurolab is a simple and powerful Neural Network Library for Python

Neurolab Neurolab is a simple and powerful Neural Network Library for Python. Contains based neural networks, train algorithms and flexible framework

null 152 Dec 6, 2022
Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.

============================================================================================================ `MILA will stop developing Theano <https:

null 9.6k Jan 6, 2023
A library of extension and helper modules for Python's data analysis and machine learning libraries.

Mlxtend (machine learning extensions) is a Python library of useful tools for the day-to-day data science tasks. Sebastian Raschka 2014-2020 Links Doc

Sebastian Raschka 4.2k Jan 2, 2023
Python Library for learning (Structure and Parameter) and inference (Statistical and Causal) in Bayesian Networks.

pgmpy pgmpy is a python library for working with Probabilistic Graphical Models. Documentation and list of algorithms supported is at our official sit

pgmpy 2.2k Jan 3, 2023
A fast, scalable, high performance Gradient Boosting on Decision Trees library, used for ranking, classification, regression and other machine learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.

Website | Documentation | Tutorials | Installation | Release Notes CatBoost is a machine learning method based on gradient boosting over decision tree

CatBoost 6.9k Jan 4, 2023