Repository navigation
Conversation
fab9e5d to
a54d31a
Compare
a54d31a to
f038a79
Compare
f038a79 to
9261229
Compare
|
Hi Mark, the rhythm mapping in
None of this changes the myo_sim#196 results as far as I can see; it's mainly so the mapping can be cited and reused. |
|
I pushed 9b61084 onto this branch: two more open EMG sources for the shoulder and the back, following your adapter pattern (CLI, mm-evalkit plugins, entry points, synthetic tests).
A shared helper, |
|
Thanks @fl0fischer — great catch on all 5 points, and very happy to keep Pushed a follow-up commit addressing all 5 rhythm items in
|
|
@M-Colley I pushed three commits on top of your 2315cc4: the BHaM hand dataset as source What we saw. In BHaM's Biodex tasks the arm is strapped: the humerus to the thorax, the forearm to a support, the elbow at 90 deg. Only the tested joint moves against the dynamometer. The optimizer still had to balance every dof with muscles, so a strapped dof needed zero net muscle torque. In isometric wrist flexion it therefore recruited the triceps (about 0.2 MVC peak) just to cancel the wrist flexors' elbow torque, which the strap carries in reality. The change (opt-in, default unchanged):
How Effect on BHaM (7 subjects, 378 trials, myoarm_r of myo_sim 0.2.5 and of the rebuilt hand in MyoHub/myo_sim#147):
Happy to rename things or move the per-trial hook somewhere you'd prefer, for example a typed field on |
ed56937 to
e55e532
Compare
|
Thanks @fl0fischer — A few notes on the
|
e55e532 to
7ad8c48
Compare
|
Current-head guideline review
Validation: source/diff, existing discussion and check-run metadata reviewed; no runtime tests run in this review. CI: pre-commit: success; Core (ubuntu-latest, py3.11, mjlab): success; Core (ubuntu-latest, py3.11, cpu): success; docs: success. Merge: not auto-approved. Apply the current human design/implementation-approval gate; agent review is not eligible human approval. |
|
Addressed #895 boundary review in 04ccdf9 (preserving all @fl0fischer commits intact): moved upper-limb and hand dataset adapters and coordinate mappers into myosuite.integrations.emg.upper_limb_sources (with scripts/validation/emg_upper_limb.py kept as a PEP 562 compatibility facade) and registered all 7 sources in the shared workflow so wheel mm-evalkit entry points run directly without a source checkout. Added explicit MyoHub/myo_sim#189 capability gating (ScapulothoracicCapabilityError, has_myosim_scapulothoracic_rhythm, require_myosim_scapulothoracic_rhythm, require_myosim_rhythm=True). |
|
Automated cross-repo audit (compatibility, composition, reuse) of
Nothing here blocks merging on its own; the items are for the next revision. Generated by Claude Code |
…rces Adds two open datasets to the EMG validation framework, so the shoulder and the back can be checked against recorded EMG: - ultramocap2025 (Fritsche et al., Sci. Data 2026; figshare 10.6084/m9.figshare.28741943, CC BY 4.0): right biceps, triceps long head and middle deltoid sEMG at 2 kHz with 100 Hz OpenSim IK. It covers five arm tasks at several speeds in 13 participants. The bilateral upper-extremity model's SC and glenohumeral chain is rebuilt into a thoracohumeral rotation and decomposed into MoBL-ARMS angles. pro_sup is shifted from that model's supination-zero convention. - maurice2020 (Maurice et al., IEEE TNSRE 2020; Zenodo 10.5281/zenodo.1472214, CC BY 4.0): right anterior deltoid and erector spinae longissimus sEMG at 1 kHz during overhead pointing, with and without an arm-support exoskeleton, plus 60 Hz Xsens-style 48-DoF joint angles. One trial is one pointing movement. The T-pose URDF shoulder chain is mapped to MoBL-ARMS angles, and lumbar angles go to flex_extension/lat_bending. Stale trailing rows in some joint-angle files are dropped, and trials they do not cover are skipped. Shared helper thoracohumeral_to_upper_limb_coords() decomposes a humerus-in-thorax rotation along the target model's own shoulder axes. Both sources are registered in the CLI, the mm-evalkit plugins and pyproject entry points, following the existing adapters. Checks: - New synthetic tests: decomposition round trip, Xsens T-pose/hanging arm, and both sources (incl. stale joint-angle rows). test_emg_cli, test_emg_validation and test_emg pass (16 tests). - Real data: the model upper-arm direction matches the source kinematics within a constant 2.7 deg (rest offset), and the forearm within 7 deg (AndyData). - EMG/kinematics alignment was checked on raw data: biceps bursts during flexion, and anterior deltoid vs arm elevation gives r = 0.86. - End to end with myo_sim 0.2.5, myoarm_r vs myotorso_arm_r: ultramocap2025 (16 trials) and maurice2020 (24 trials).
…, and JSON source
Adds the BHaM hand biomechanics dataset to the EMG validation framework, so the extrinsic forearm muscles and the thumb muscles of the hand models can be checked against recorded EMG: - diaz2026 (Diaz et al., Sci. Data 13, 646 (2026), https://doi.org/10.1038/s41597-026-06939-4; data on Kaggle, https://doi.org/10.34740/kaggle/ds/7895310, CC BY 4.0): 30 adults, dominant arm, MVC-normalised EMG envelopes. - Biodex elbow/wrist session: surface FDS, FDP, EDC, FCR, FCU, ECR, ECU, BIC, TRIlong and BRD during isometric wrist/elbow flexion and extension (50 and 100 % MVC) and isokinetic range of motion. The posture follows the protocol. The measured dynamometer torque, referenced to the relaxed rest level for isometric tasks, drives the tested joint, and every other arm coordinate is held by the straps and support. - Hand session: fine-wire FPL, EPL, EPB, APL, OPP, FPB, ADD and FDI during seven thumb/index range-of-motion tasks. The published OpenSim IK (MoBL-ARMS arm + ARMS hand) is mapped onto the model, reusing the emg2pose hand mapping. ARMS thumb CMC flexion, MP and IP axes point the other way round from the MoBL-ARMS thumb, so those angles change sign. The IK stores wrist flexion/deviation in radians and the rest in degrees. - Channels bind by muscle name. FDI goes to DI1d+DI1s, ADD to AdPt+AdPo and FPB to FPBs+FPBd on the rebuilt hand (MyoHub/myo_sim#147). On the MoBL-ARMS hand, FDI goes to RI2, and ADD and FPB stay unbound. One trial is one published trial band. The adapter reads the full BiomechanicsDataset.hdf5 or any subset with the same layout. It is registered in the CLI, the mm-evalkit plugins and the pyproject entry points, following the existing adapters, with a synthetic test. The dynamometer angle is in degrees (its derivative equals the reported velocity), but its wrist zero is not anatomical: each subject's wrist range sits between 11 deg towards extension and 46 deg towards flexion of the raw zero. The wrist angle is therefore centred on the subject's range in that task, with neutral 5 deg towards extension from mid-range (typical active range: 80 deg flexion, 70 deg extension). The elbow zero is anatomical (full extension). B001 and B017 are skipped unless asked for, as the collection notes advise. Checked end to end with validate_emg.py on 7 subjects (B002, B003, B005, B009, B015, B024, B027; repetitions 1-3 of every Biodex and range-of-motion task, 378 trials), as an A/B between myoarm_r of myo_sim 0.2.5 and the rebuilt hand of MyoHub/myo_sim#147. Unit and sign conventions were checked on the same data: the IK flexion equals twice the coupled wrist_hand_r3, dynamometer velocity and torque correlate positively, and muscle moment arms fix the flexion signs. In wrist flexion both models recruit FDS/FDP far less than measured (peak 0.01-0.13 vs 0.38-0.46 MVC). This is expected while the power grip on the dynamometer handle is not modelled.
Names the ULTRA-MoCap adapter after its first author and year, like maurice2020 and diaz2026: dataset key and mm-evalkit entry point `ultramocap2025` -> `fritsche2026` (published 2026: Fritsche et al., Sci. Data 13, 622), `UltraMoCap2025Source` -> `Fritsche2026Source`, and `ULTRAMOCAP_CHANNELS` -> `FRITSCHE2026_CHANNELS`. The CLI, plugin, pyproject entry points and tests follow; the default data folder becomes `downloads/emg/fritsche2026`. Behaviour is unchanged.
…eir support Adds an opt-in StaticOptimizationConfig.supported_dofs for dofs whose load an external support carries (a strap, a brace, a dynamometer). Their reserves cost nothing, as the free-joint residuals already do without contacts. A muscle crossing such a dof then no longer needs antagonists to cancel its torque there. Before, every dof had to be balanced by muscles, so in isometric wrist flexion with a strapped elbow the optimizer recruited the triceps to cancel the wrist flexors' elbow torque. - The default () keeps the current behaviour. - The EMG validation reserve and co-contraction metrics leave supported dofs out, because their reserves are the support's load, not a model deficit. - A trial opts in through meta["supported_dofs"] (dof addresses), next to meta["controlled_qpos_adr"]. validate_emg.py passes it on. - diaz2026 declares the strapped coordinates of its Biodex trials: the shoulder girdle, forearm rotation and wrist deviation in every task, plus the elbow in wrist tasks and the wrist in elbow tasks, where the hand grips the handle. The 45 deg plane of elevation in the elbow range of motion is marked as an estimate from the paper's Fig. 7. A unit test shows the artefact going away: a strapped elbow takes a wrist flexor's 2.5 N m, and the triceps stays at zero. On BHaM (7 subjects, 378 trials, myoarm_r of myo_sim 0.2.5 and of MyoHub/myo_sim#147): - Wrist tasks: the predicted triceps drops from 0.22 to 0.00 MVC peak, and the rebuilt model's ECU drops from 0.91-0.99 to 0.54-0.61. - Elbow tasks: the rebuilt model's ECU drops from 0.84-1.00 to 0.05-0.23 and FCU from 0.47-0.76 to 0.05-0.08 (measured 0.19-0.42). - What remains on the rebuilt model: FCR saturates (1.0) in wrist range of motion, against 0.6 measured. - Measured co-activation of the strapped elbow muscles (0.2-0.3 MVC) is stabilisation that minimum-effort optimization does not predict. Those channels therefore lose their correlation.
…tegrations and gate myo_sim#189 rhythm (#895)
…map across upper-limb adapters
…ingerprint on myo-sim 0.2.5
f81f4c0 to
e8a27da
Compare
Note
Draft (
Post-3.0) (stacked onfeat/emg-validation-cli): Deferred from Milestone3.2so the3.2review queue stays focused; requires maintainer scope/design agreement before entering review (AGENTS.md).Stack (4/4) — 3-Layer Musculoskeletal & EMG Validation Split
MyoHub/myo_sim): Add muscle operating-range and moment-arm CI tests myo_sim#197 — fast (<3 s), dataset-free structural muscle operating-range & moment-arm coupling CI gates.MyoHub/myosuitebiomechanics):feat/emg-signal->dev)feat/emg-validation->feat/emg-signal)MyoHub/myosuiteCLI +mm_evalkit.datasetsplugins):3. Add EMG validation A/B CLI, gait dataset adapters, and custom manifests #813 (
feat/emg-validation-cli->feat/emg-validation)4. Add upper-limb and hand EMG adapters for Quesada 2024, emg2pose, NinaPro DB5, and GRABMyo #814 (
feat/emg-upper-limb-sources->feat/emg-validation-cli) <- this PRSummary
Adds upper-limb, trunk, and hand open-source EMG dataset adapters plus biomechanical coordinate/torque mappers in
scripts/validation/emg_upper_limb.py, wires them intoscripts/validation/validate_emg.py, and registers them asmm_evalkit.datasetsentry-point plugins (quesada2024,emg2pose,ninapro-db5,grabmyo,ultramocap2025,maurice2020) alongsidemm-evalkit's built-inultra-mocap/gait120/wangworkflows (PR 4 of 4, stacked onfeat/emg-validation-cli):map_upper_limb_to_qpos&map_upper_limb_torques_to_qfrc: maps ISB/OpenSim thoracohumeral elevation plane, elevation, internal rotation, elbow flexion, pronation, and wrist flexion/deviation ontomyoarm_rwith Seth et al., Front. Neurorobot. 2019 (https://doi.org/10.3389/fnbot.2019.00090) scapulothoracic + clavicular rhythm (abd21/flx01, reading directly frommyo_sim/build/data/scapulothoracic.jsonrhythm.framesonceMyoHub/myo_sim#189lands) soDELT1..3,SUPSP,INFSP,SUBSC, andTMINoperate at physiological fiber lengths and moment arms.thoracohumeral_to_upper_limb_coords,buet_arm_to_upper_limb_coords,xsens_urdf_to_upper_limb_coords: decomposes bilateral upper-extremity/trunk and 48-DoF Xsens URDF shoulder/lumbar chains onto the target model's shoulder and trunk coordinates.map_emg2pose_to_hand_qpos,map_cyberglove_to_hand_qpos,map_grabmyo_gestures_to_qpos: maps UmeTrack 20-DOF wrist sEMG hand poses, 22-sensor CyberGlove II grasp postures, and canonical forearm/wrist gesture postures ontomyohand_r/myoarm_r.[project.entry-points."mm_evalkit.datasets"]):quesada2024(Quesada2024UpperLimbSource): 12-channel 2 kHz MVC-normalized shoulder/elbow sEMG + joint angles & inverse-dynamics torques across single-joint (SJ) and multi-joint (MJ) tasks — Quesada et al. 2024 (https://doi.org/10.5281/zenodo.11209323).ultramocap2025(UltraMoCap2025Source): 13-participant 2 kHz right-arm biceps, triceps long head, and middle deltoid sEMG + 100 Hz Vicon OpenSim IK across five arm tasks — Fritsche et al., Sci. Data 2026 (https://doi.org/10.1038/s41597-026-06687-5; Figshare: https://doi.org/10.6084/m9.figshare.28741943).maurice2020(Maurice2020Source): AndyData 12-participant 1 kHz anterior deltoid and erector spinae longissimus sEMG + 60 Hz Xsens 48-DoF joint angles during overhead pointing with/without a passive exoskeleton — Maurice et al., IEEE TNSRE 2020 (https://doi.org/10.1109/TNSRE.2019.2945368; Zenodo: https://doi.org/10.5281/zenodo.1472214).emg2pose(Emg2PoseHandSource): Meta 16-channel 2 kHz wrist sEMG + 20-DOF hand kinematics (HDF5) — Salter et al., NeurIPS Datasets & Benchmarks 2024 (https://arxiv.org/abs/2412.02725; https://github.com/facebookresearch/emg2pose; see also Verma 2025emg2tendon, https://arxiv.org/abs/2508.08269).ninapro-db5/ninapro_db5(NinaProDB5Source): 16-channel dual-Myo forearm sEMG + 22-sensor CyberGlove II hand kinematics (MAT) — Pizzolato et al., PLOS ONE 2017 (https://doi.org/10.1371/journal.pone.0186132; Zenodo: https://doi.org/10.5281/zenodo.1000116).grabmyo(GrabMyoSource+ pure-NumPyread_wfdb_record): PhysioNetgrabmyo28-channel 2048 Hz forearm (F1..F16) + wrist (W1..W12) sEMG (Format 16.hea/.datwithout externalwfdbdependency) — Pradhan et al., Sci. Data 2022 (https://doi.org/10.1038/s41597-022-01836-y; PhysioNet: https://doi.org/10.13026/7e30-4407).Verification
pytest myosuite/tests/test_emg.py myosuite/tests/test_emg_validation.py myosuite/tests/test_emg_cli.py myosuite/tests/test_packaging_and_core_fixes.py myosuite/tests/test_import_footprint.py -vruff check/ruff format --check/mypyUpdate: merged #813 (which carries #812's move of
musculoskeletal_fingerprintto MyoHub/myo_sim#210). The merge conflicted intest_emg_cli.pyaroundtest_camargo2021_source_synthetic; both sides are kept, with the fingerprint skip marker on the Camargo test.test_emg_trial_supported_dofs_roundtrip_and_auto_forwardingalso skips without that API. Local checks (CI is out of credits): this stack's tests 42 passed with myo_sim#210, 36 passed and 6 skipped on myo-sim 0.2.5; the five verification modules 349 passed, 3 skipped on both. #835 (stacked here) is untouched.Ownership & Reuse (
REVIEW.md)myosuite/integrations/emg/upper_limb_sources.py,myosuite/biomechanics/emg_validation.py— third-party upper-limb/hand EMG dataset readers and analysis workflow).StaticOptimizer(myosuite/biomechanics/static_optimization.py) and Add musculoskeletal EMG validation modes and model fingerprinting #812/Add EMG validation A/B CLI, gait dataset adapters, and custom manifests #813 EMG validation contracts.Compatibility & Checks
Post-3.0,stack:stackedon Add EMG validation A/B CLI, gait dataset adapters, and custom manifests #813): gated on parent EMG stack (Add musculoskeletal EMG validation modes and model fingerprinting #812/Add EMG validation A/B CLI, gait dataset adapters, and custom manifests #813) and maintainer scope review.