Modular and extensible neuromuscular simulation framework for generating physiologically grounded motor-unit activity, muscle force, and EMG signals (surface and intramuscular)
Project description
Welcome to
The modular and extandable simulation toolkit for neurophysiology
Overview
MyoGen is a modular and extensible neuromuscular simulation framework for generating physiologically grounded motor-unit activity, muscle force, and surface EMG signals.
It supports end-to-end modeling of the neuromuscular pathway, from descending neural drive and spinal motor neuron dynamics to muscle activation and bioelectric signal formation at the electrode level. MyoGen is designed for algorithm validation, hypothesis-driven research, and education, providing configurable building blocks that can be independently combined and extended.
Highlights
🧬 Biophysically inspired neuron models — NEURON-based motor neurons with validated calcium dynamics and membrane properties
🎯 Everything is inspectable — Complete access to every motor unit, spike time, fiber location etc. for rigorous algorithm testing
⚡️ Vectorized & parallel — Multi-core CPU processing with NumPy/Numba vectorization for fast computation
🔬 End-to-end simulation — From motor unit recruitment to high-density surface EMG in a single framework
📊 Reproducible science — Deterministic random seeds and standardized Neo Block outputs for exact replication
🧰 Comprehensive toolkit — Surface EMG, intramuscular EMG, force generation, and spinal network modeling
Installation
[!WARNING] Windows users: Install NEURON 8.2.6 before installing MyoGen
uv add MyoGen
# or
pip install MyoGen
NEURON mechanisms compile automatically during installation.
Prerequisites: Python ≥3.12, Linux/Windows/macOS
[!IMPORTANT] System Requirements:
- Linux/macOS: OpenMPI or MPICH (install via package manager)
- Windows: NEURON 8.2.6 required (see warning above)
# Install MPI (Linux)
sudo apt-get install libopenmpi-dev # Ubuntu/Debian
# or
sudo yum install openmpi-devel # RHEL/CentOS
# Install MPI (macOS)
brew install open-mpi
From Source (for development)
# Clone and install
git clone https://github.com/NsquaredLab/MyoGen.git
cd MyoGen
uv sync
# Activate environment
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Compile NEURON mechanisms (required for editable installs)
uv run poe setup_myogen
[!TIP] Install uv first
Optional Dependencies
GPU acceleration (5-10× speedup for convolutions):
pip install cupy-cuda12x
Quick Start
Generate motor unit action potentials (MUAPs):
from myogen import simulator
import quantities as pq
# 1. Generate recruitment thresholds (100 motor units)
thresholds, _ = simulator.RecruitmentThresholds(
N=100,
recruitment_range__ratio=50,
mode="fuglevand"
)
# 2. Create muscle model with fiber distribution
muscle = simulator.Muscle(
recruitment_thresholds=thresholds,
radius_bone__mm=1.0 * pq.mm,
fiber_density__fibers_per_mm2=400 * pq.mm**-2,
fat_thickness__mm=10 * pq.mm,
autorun=True
)
# 3. Set up surface electrode array
electrode_array = simulator.SurfaceElectrodeArray(
num_rows=5,
num_cols=5,
inter_electrode_distances__mm=5 * pq.mm,
electrode_radius__mm=5 * pq.mm,
bending_radius__mm=muscle.radius__mm + muscle.skin_thickness__mm + muscle.fat_thickness__mm,
)
# 4. Create surface EMG simulator
surface_emg = simulator.SurfaceEMG(
muscle_model=muscle,
electrode_arrays=[electrode_array],
sampling_frequency__Hz=2048.0,
MUs_to_simulate=[0, 1, 2, 3, 4] # First 5 motor units
)
# 5. Simulate MUAPs (parallel processing)
muaps = surface_emg.simulate_muaps(n_jobs=-2)
Access MUAP data:
import numpy as np
# Get MUAP from motor unit 0
muap_signal = muaps.groups[0].segments[0].analogsignals[0]
print(f"MUAP shape: {muap_signal.shape}") # (time, rows, cols)
# Extract from specific electrode (row 2, col 2)
electrode_muap = muap_signal[:, 2, 2]
peak_amplitude = np.max(np.abs(electrode_muap.magnitude))
print(f"Peak amplitude: {peak_amplitude:.3f} {electrode_muap.units}")
For full EMG simulation with spike trains, see examples
Documentation
- User Guide — Working with simulation outputs
- API Reference — Complete class documentation
- Examples — Step-by-step tutorials from recruitment to EMG
How to Cite
If you use MyoGen in your research, please cite:
TBD
Contributing
Contributions welcome! See issues if you want to add a feature or fix a bug.
License
MyoGen is AGPL licensed. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file myogen-0.6.10.tar.gz.
File metadata
- Download URL: myogen-0.6.10.tar.gz
- Upload date:
- Size: 4.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35ba359eafe66914f45046ecb2ccc7f823b672747308b98a543c20699f94fcc9
|
|
| MD5 |
00b345d44085625079352d76a52cc520
|
|
| BLAKE2b-256 |
510dc85c6cee21a63df8d54686e39581eb4aa1483fcaecf88d6c8e4b53331ea3
|
Provenance
The following attestation bundles were made for myogen-0.6.10.tar.gz:
Publisher:
build-wheels.yml on NsquaredLab/MyoGen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
myogen-0.6.10.tar.gz -
Subject digest:
35ba359eafe66914f45046ecb2ccc7f823b672747308b98a543c20699f94fcc9 - Sigstore transparency entry: 767736255
- Sigstore integration time:
-
Permalink:
NsquaredLab/MyoGen@fc40c7192b2eba3eeeef91e01ecbc475ab7adda0 -
Branch / Tag:
refs/tags/v0.6.10 - Owner: https://github.com/NsquaredLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@fc40c7192b2eba3eeeef91e01ecbc475ab7adda0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file myogen-0.6.10-cp312-cp312-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: myogen-0.6.10-cp312-cp312-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 7.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89b4712954f227c82d53c65f24dd8bb1e7ea6640bfe693f4ce592e8dac98a23a
|
|
| MD5 |
4846282cad2fd9db4744ef626080905a
|
|
| BLAKE2b-256 |
8dde7d846b8de00379c37e99cce6d1820bb432b1ae785cac6fa152b5af4cbc1f
|
Provenance
The following attestation bundles were made for myogen-0.6.10-cp312-cp312-manylinux_2_17_x86_64.whl:
Publisher:
build-wheels.yml on NsquaredLab/MyoGen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
myogen-0.6.10-cp312-cp312-manylinux_2_17_x86_64.whl -
Subject digest:
89b4712954f227c82d53c65f24dd8bb1e7ea6640bfe693f4ce592e8dac98a23a - Sigstore transparency entry: 767736257
- Sigstore integration time:
-
Permalink:
NsquaredLab/MyoGen@fc40c7192b2eba3eeeef91e01ecbc475ab7adda0 -
Branch / Tag:
refs/tags/v0.6.10 - Owner: https://github.com/NsquaredLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@fc40c7192b2eba3eeeef91e01ecbc475ab7adda0 -
Trigger Event:
push
-
Statement type: