Skip to main content

Motor Unit Toolbox

PyPI Python versions CI Docs

Overview

Motor Unit Toolbox is a Python package to analyse motor unit (MU) behaviour, from computing basic firing and motor unit action potential (MUAP) properties, to comparing sets of spike trains and tracking MUAPs.

The package is composed of the following modules:

  • props: MU properties such as discharge rate, pulse to noise ratio, silhouette measure, and coefficient of variation of the interspike intervals, as well as MUAP features.
  • spike_comp: compare spike trains between paired or unpaired sets, as well as within sets. Main metrics are rate of agreement, precision, sensitivity, F1 score, true positives, false positives, and false negatives.
  • muap_comp: compare, cluster and track MUAPs within or across recordings.
  • plots: plot spike trains, MUAPs, and grouped MUAPs.
  • utils: convert between lists of firing times and binary spike train matrices.

Table of Contents

Installation

Install the latest release from PyPI (Python 3.10 or newer):

pip install motor-unit-toolbox

The package is imported as motor_unit_toolbox.

To work on the code itself, see the development setup in CONTRIBUTING.md.

Quick start

Spike trains are binary matrices of shape (samples, motor units). The example below builds two synthetic motor units, computes their firing properties and compares them with a second (shifted) decomposition:

import numpy as np

from motor_unit_toolbox import props, spike_comp, utils

fs = 2048                                  # sampling frequency (Hz)
n_samples = 10 * fs                        # 10 s recording
timestamps = np.arange(n_samples) / fs

# Spike times (in samples) of two motor units firing at ~10 Hz and ~15 Hz
rng = np.random.default_rng(0)
firings = [
    np.cumsum(rng.normal(fs / 10, 10, size=95)).astype(int),
    np.cumsum(rng.normal(fs / 15, 10, size=140)).astype(int),
]
spike_trains = utils.firings_to_binary(firings, n_samples)  # (samples, units)

# Firing properties per motor unit
props.get_discharge_rate(spike_trains, timestamps)            # array([10.05, 15.18]) Hz
props.get_coefficient_of_variation(spike_trains, timestamps)  # array([0.047, 0.074])

# Agreement with a second decomposition of the same units (here: shifted by 2 samples)
roa, pairs, lags = spike_comp.rate_of_agreement_paired(
    spike_trains, np.roll(spike_trains, 2, axis=0), fs=fs
)
roa                                                           # array([1., 1.])

Documentation

The full API reference, with every function and its arguments, is at imendezguerra.github.io/motor_unit_toolbox.

Contributing

Contributions are welcome! CONTRIBUTING.md explains how to set up a development environment, run the tests, preview the docs, and what the automated checks (pre-commit and CI) do.

License

This project is licensed under the MIT License.

Citation

If you use this code in your research, please cite it. On GitHub, the Cite this repository button (from CITATION.cff) gives APA and BibTeX formats, or use:

@software{Mendez_Guerra_Motor_Unit_Toolbox,
  author = {Mendez Guerra, Irene},
  title = {{Motor Unit Toolbox}},
  url = {https://github.com/imendezguerra/motor_unit_toolbox}
}

Contact

For any questions or inquiries, please contact:

Irene Mendez Guerra
irene.mendez17@imperial.ac.uk

Metadata

Release files for motor-unit-toolbox 1.2.0

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

Source distribution (sdist)

Source distribution for motor-unit-toolbox 1.2.0
File Size Uploaded Provenance Actions
motor_unit_toolbox-1.2.0.tar.gz 39.6 kB With provenance Details for motor_unit_toolbox-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for motor-unit-toolbox 1.2.0
File Interpreter ABI Platform Actions
motor_unit_toolbox-1.2.0-py3-none-any.whl Python 3 none any Details for motor_unit_toolbox-1.2.0-py3-none-any.whl

Total release size: 68.2 kB

Release files / motor_unit_toolbox-1.2.0.tar.gz

Download URL motor_unit_toolbox-1.2.0.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
866937c35811a19a73a8a318d878c96fa2943b48cd74fa05ccb44764115c2439
BLAKE2b-256 checksum
How to use checksums
14d4065a33453efd34c6054253b47e5137be8ac74b8bbd7accd1c0e5fb0128e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / motor_unit_toolbox-1.2.0-py3-none-any.whl

Download URL motor_unit_toolbox-1.2.0-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1719f73b1f9d4c9c990706fbf3a2a3c704269a1ce56e2531d4562bda381dbf1
BLAKE2b-256 checksum
How to use checksums
ad3994ba1be742d169cd17918446cc8717b2fe72f89053065d73120baedfe24e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Security for motor-unit-toolbox 1.2.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for motor_unit_toolbox-1.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files Full provenance

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