A Python package for musculoskeletal modelling (version 0.4.2)
Project description
msk_modelling_python
A Python package for musculoskeletal modelling and biomechanical data analysis.
Inspired by BOPS (Batch OpenSim Processing Scripts).
Author: Basilio Goncalves, PhD — University of Vienna
ufind.univie.ac.at · github.com/basgoncalves
Requirements
- Python ≥ 3.8 (3.11 recommended)
- OpenSim ≥ 4.3
- Windows (primary target; Linux/macOS untested)
Optional: Visual Studio Code, MOKKA
Quick Start — pip install
1. Create and activate a virtual environment
# Python venv
python -m venv msk
.\msk\Scripts\activate # Windows
source msk/bin/activate # Linux / macOS
# Or Conda / Miniconda
conda create -n msk python=3.11
conda activate msk
2. Install
pip install uv
uv pip install msk-modelling-python
3. Launch
GUI interface (default):
python -m msk_modelling_python
Batch mode:
python -m msk_modelling_python -b msk_modelling_python/settings.py
Video batch mode:
python -m msk_modelling_python -b video_batch.json
Note: do not paste the descriptive text after these commands. On Windows
cmd.exe,#is not a comment character, so a trailing# ...is passed to the program as arguments and causesunrecognized arguments.
Development Setup — work from source
1. Clone into your virtual environment's site-packages
.\msk\Scripts\activate
cd .\msk\Lib\site-packages
git clone https://github.com/basgoncalves/msk_modelling_python.git
2. Install dependencies
cd msk_modelling_python
pip install -r requirements.txt
3. Set up OpenSim Python bindings
cd "C:\OpenSim 4.5\sdk\Python"
python setup_win_python38.py
python -m pip install .
Add to your PATH environment variable:
C:\OpenSim 4.5\bin
C:\OpenSim 4.5\lib
Verify:
import opensim as osim
osim.Model() # should not raise
4. Launch
python -m msk_modelling_python
Usage
GUI (default)
python -m msk_modelling_python
Opens the full interface with tabs for batch processing, video analysis, EMG, model scaling, and results viewing.
Batch mode
Edit msk_modelling_python/settings.py (see BatchSettings, CEINMSSettings) then run:
python -m msk_modelling_python -b msk_modelling_python/settings.py
Pipeline: C3D export → model scaling → IK → ID → static optimisation → muscle analysis → CEINMS.
Video batch mode
python -m msk_modelling_python -b video_batch.json
{
"videos": ["path/to/video1.mp4", "path/to/video2.mp4"],
"model": "full_body",
"detect_interval": 1,
"output_dir": "path/to/output"
}
Code Structure
| Package | Description |
|---|---|
gui/ |
GUI widgets — batch processing, C3D export, EMG, CEINMS, video analysis |
utils/ |
Core processing — OpenSim (IK, ID, SO, MA), CEINMS, EMG, model scaling, C3D |
core/ |
Session and analysis runner (shared by GUI and batch modes) |
config/ |
Settings load/save |
record/ |
Screen/video recording, camera utilities, pose-estimation pipeline |
models/ |
Bundled OpenSim model files (.osim) and geometry meshes |
movement_detector/ |
Rule-based classifier: segments pose landmarks into labelled movement types |
settings.py |
Central config — edit BatchSettings, CEINMSSettings, UISettings, RecordingSettings |
Contact
Basilio Goncalves — basilio.goncalves@univie.ac.at
ResearchGate
References
Thelen, D. G. (2003) J. Biomech. Eng. 125, 70–77
Lloyd, D. G. et al. (2003) J. Biomech. 36, 765–776
Delp, S. L. et al. (2007) IEEE Trans. Biomed. Eng. 54, 1940–1950
Pizzolato, C. et al. (2015) J. Biomech. 48, 3929–3936
Hicks, J. L. et al. (2015) J. Biomech. Eng. 137
Rajagopal, A. et al. (2016) IEEE Trans. Biomed. Eng. 63, 2068–2079
Goncalves, B. A. M. et al. (2023) Gait Posture 106, S68
Goncalves, B. A. M. et al. (2024) Med. Sci. Sport. Exerc. 56, 402–410
Changelog
v0.4.2 (2026-06-11)
Video Analysis tab
- Fix crash on scroll/zoom: invalid 8-digit colour
#00000088(Tkinter accepts only 6-digit hex) broke the canvas redraw - Fix video frame jumping to the top-left corner while scrubbing the timeline (now uses the shared centred redraw)
- Compact the under-video controls and add a draggable horizontal sash to resize the video pane
- Move pose detection settings (interval, smoothing) above the action buttons
- Reduce tracked ROI box jitter between frames (exponential smoothing + dead-zone)
- Fix Export Outputs: now runs
record/video_analyzer.pyto generate the OpenSim.mot(path resolution was wrong), passing the GUI's poses/anchors to skip re-detection - Wire
movement_detectorinto Export: writes<video>_motion_segments.json(standing / walking / running / squatting / jumping / …)
Player profiles
- Add
utils/player_profile.py: per-player anthropometry, limb proportions, saved calibration, OpenSim/CEINMS model paths and detection settings, stored one folder per player - Add a Player dropdown (New/Edit) to the Video Analysis tab; selecting a player applies their calibration, models and detection settings, and Export writes a player snapshot
Batch / settings
- Add multi-session batch: process many sessions in one run via a single
SESSIONS = {session_folder: static_trial_name}dict insettings.py - Tolerant static-trial matching (
static01/static_01/Static_01all match;Noneauto-detects) - Remove
SESSION_DIR/session_folder/static_trial_namefromBatchSettings—SESSIONSis the single source of truth - Lenient
-bsettings-path handling so batch runs from any working directory
Logging
- One log file per run (
app_*.logfor GUI,batch_*.logfor batch) — no more empty second log
Carried over from earlier 0.4.2 work
- Fix
utils/__init__.pytruncatedemg_normaliseimport block (IndentationError on startup) - Fix
utils/openSim.pytruncated_Teeclass in__main__block (SyntaxError) - Fix
utils/dev.pytruncated parallel worker error handler - Fix
utils/__init__.pyCEINMS import collision: useimportlib.utilto loadceinms.pyexplicitly - Fix
settings.DOFs→settings.BatchSettings.dof_listinutils/__init__.pyandutils/dev.py - Fix IK NaN crash: interpolate missing marker values in TRC files before running
InverseKinematicsTool - Add Video Analysis GUI tab: process pre-recorded videos → OpenSim MOT/TRC via MediaPipe pose estimation
- Add video batch mode (
-b video_batch.json) - Add
movement_detectormodule: rule-based pose landmark classifier with gap-filling - Move OpenSim model files into dedicated
models/package - Add
RecordingSettings.DEFAULT_VIDEO_ANALYSIS_MODELandOUTPUT_DIR_TEMPLATE
v0.4.1 (2026-06-09)
- Fix GUI crash on startup:
model_scalingwidget importsmarker_weightsfromBatchSettings - Fix
batch_c3d_exportwidget to read EMG defaults fromBatchSettingsattributes
v0.4.0
- New settings and GUI entry point; cleaned up stale files
- n8n-inspired workflow pipeline with full OpenSim batch processing example
- Batch pipeline fixes, GUI stability improvements, OpenSim late-load
v0.3.6
- Updated utils; added CEINMS support with troubleshooting and calibration executables
v0.0.20
- CEINMS2 integration via pip packaging
v0.0.17
- Version bump with new images and path adjustments
Version: 0.4.2
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 msk_modelling_python-0.4.2.tar.gz.
File metadata
- Download URL: msk_modelling_python-0.4.2.tar.gz
- Upload date:
- Size: 81.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daaebb5c96d7b514af41f48399571c4519fec3d9b341417c48c70ffdafbe4a3c
|
|
| MD5 |
56f6b6a40e69611258544d4eb39e62ea
|
|
| BLAKE2b-256 |
92712ce9cdc429d227bbc7867767e80a2757e5c722bc6ac85ce9fe8abf369a01
|
File details
Details for the file msk_modelling_python-0.4.2-py3-none-any.whl.
File metadata
- Download URL: msk_modelling_python-0.4.2-py3-none-any.whl
- Upload date:
- Size: 81.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd4902631bdeb4039137b14ed7fdf9496d1ff8e4330196f297738b3115655b4d
|
|
| MD5 |
4d0282d438144afff811c5820ce409d4
|
|
| BLAKE2b-256 |
221a2a68777d210f0da775778d469423a5c77179df7007b0348936ccb373a59b
|