Authors: Christian Morrell, Evan Campbell, Ethan Eddy, and Erik Scheme
This repository hosts code for the publication: Context-Informed Incremental Learning Improves Throughput and Reduces Drift in Regression-Based Myoelectric Control. Here we investigate context-informed incremental learning (CIIL) for regression-based myoelectric control. Please cite this publication if using this for research purposes. For any questions related to the work or this repository, please reach out to cmorrell@unb.ca.
This project is managed using uv, a Python project and package manager. Installation is easiest with uv, but requirements can be generated for other workflows.
To setup with uv, simply run uv sync in a shell and a virtual environment should be automatically created. poetry should work natively as well, as it supports pyproject.toml.
For workflows using requirements.txt, a requirements file can be generated using the following commands:
pip install pip-tools
pip-compile pyproject.tomlThis repository contains two primary scripts:
main.py- Used for running the experiment, including data collection and target acquisition.analyze.py- Used to analyze data after running an experiment.
Both scripts provide a command-line interface (CLI), described in detail below.
The CLI for main.py supports two main objectives: configuring participant settings and running the experiment.
python main.py <objective> [arguments]Creates a configuration file for a participant, specifying their information and experimental setup. This will create a participant.json file (printed in the console), which you then use when running the experiment.
Usage:
python main.py config <subject_directory> <device> <dominant_hand> <age> <sex> <experience>Arguments:
subject_directory(str): Directory where participant data will be stored. The directory's name is used as the subject ID.device(str): EMG device to be used. Choices:emager,myo,oymotion,sifi.dominant_hand(str): Participant's dominant hand. Choices:left,right.age(int): Participant's age.sex(str): Participant's sex.experience(str): Level of experience with myoelectric control. Choices:N: NoviceI: IntermediateE: Expert
Example:
python main.py config data/subject-001 myo right 25 M NCollects EMG data for a specific condition and stage of the experiment. The order of the models is based on a latin square. Stages typically go from SGT, to adaptation, to validation. For non-adaptive models, adaptation is not required (and will throw an error if selected).
Usage:
python main.py run <participant> <condition_idx> <stage> [--analyze]Arguments:
participant(str): Path to the participant'sparticipant.jsonfile.condition_idx(int): Index of the current condition (starting from 0).stage(str): Experimental stage. Choices:sgt: Screen-guided trainingadaptation: Adaptive phasevalidation: Validation phase
Example:
python main.py run data/subject-001/participant.json 0 adaptationThe CLI for analyze.py changes the format of resulting figures.
Usage:
python analyze.py [options]Arguments:
-p, --participants(default:'all'): Specify a participant or a list of participants to evaluate. By default, all participants are included.-l, --layout(flag): Layout of plots. Choices:report,presentation,thesis.
Although not needed to run the experiment, some of the logic, such as neural network creation and adaptation, are handled in utility functions found in the utils directory. These functions are used throughout the main scripts, and are broken up into different modules for convenience. A brief description of each module is provided below.
adaptation.py: Handles real-time adaptation logic, including the creation of pseudo-labels.data_collection.py: Convenience interface for handling multiple devices and creating data collection videos.models.py: PyTorch interface for neural network architecture.