Every script below is directly runnable, e.g.:
python examples/getting_started/optimization/pulse_width_optimization.pyEach script anchors its own default asset paths (.bioMod files, etc.) to its own location on disk (Path(__file__)), so they can be run from anywhere, not just from inside their own folder.
Minimal, single-muscle examples. Start here.
optimization/— Optimal control (OCP) examples using the Ding2007 model unless noted:force_tracking.py— pulse width optimization to track a target force curve.frequency_optimization.py— Ding2003 model, matches a target end force with a fixed 1 Hz stimulation (no optimization on stimulation itself).pulse_intensity_optimization.py— Hmed2018 model, pulse intensity optimized to match a target end force.pulse_width_optimization.py— pulse width optimized to match a target end force while minimizing muscle force.pulse_width_optimization_mhe.py— same problem solved with a moving time horizon (MHE), usingFesMhe.
initial_value_problem/— Forward simulation (no optimization) viaIvpFes:model_integration.py— integratesDingModelFrequencyWithFatiguefor 300 s to show fatigue's effect on force over time.pulse_mode_example.py— comparessingle/doublet/tripletpulse modes on the same model.
identification/:muscle_model_id.py— simulates then identifies a Hmed2018 pulse-intensity model's parameters usingOcpFesIdandDataExtraction.
multibody/— Same pulse width/intensity optimizations as above, but driving a musculoskeletal arm model throughFesMskModel:pulse_width_optimization_multibody.py,pulse_intensity_optimization_multibody.py.
force_model/— Parameter identification (simulate then re-identify) fording2003_model_id.py,ding2007_model_id.py,hmed2018_model_id.py.fatigue_model/WIP.py— placeholder; fatigue model identification is not implemented yet (work in progress, see contributing guide if you want to pick this up).
One self-contained example per FES model not already covered above: marion2009_example.py, marion2013_example.py, veltink1992_example.py (also demonstrates the combined VeltinkRienerModelPulseIntensityWithFatigue).
Full musculoskeletal, FES-driven motion examples:
reaching/reaching_task.py— Arm26 reaching task (see README).elbow_flexion/—elbow_flexion_task.py(pulse width) andfrequency_optimization_multibody.py(frequency + pulse intensity).shoulder_abduction/—abduction_fes_driven.pyvsabduction_muscle_driven.py: same task, FES-driven vs. classic muscle-driven for comparison.cycling/— hand-cycling task, the most involved example set:cycling_inverse_kinematics.py— warm-starts the cycling motion with inverse kinematics/dynamics.cycling_with_different_driven_methods.py— same cycling task, switchable betweentorque_driven/muscle_driven/fes_drivendynamics.cycling_pulse_width_mhe.py— hand-cycling MHE, usesFesMheMsk(see README).cycling_bayesian_mhe.py— Bayesian optimization of per-muscle cost-function weights on top ofcycling_pulse_width_mhe.py, requiresscikit-optimize.cycling_standard_clinics.py— simulates how long a standard (non-optimized) clinical stimulation protocol can be sustained before fatigue failure.physiological_weight_calculation.py,cost_functions.py— helper modules (muscle scaling, custom cost functions) imported by the scripts above, not meant to be run directly.
force_length_velocity/muscle_relationships_comparison.py— compares enabling/disabling the force-length, force-velocity and passive-force relationships (see README).
model_viewer.py— live-animates a.bioModmodel with slider-controlled joint angles.Arm26/,Seth/,Wu/— the.bioModmusculoskeletal model files used as defaults across the examples above.