Skip to main content

Tutorial 6 – Surrogate Model Tutorial

Tutorial Developers: Robert Salati and B.J. Fregly, Rice Computational Neuromechanics Lab, Rice University

Last Updated: 11/4/2025

Before starting the Treatment Optimization process, the user must create a surrogate model of the relevant OpenSim musculoskeletal geometry, which includes fitting muscle-tendon lengths and moment arms as a function of sampled joint positions. A Latin hypercube (LHS) sampling method around a nominal motion trajectory is used to sample muscle-tendon lengths and moment arms throughout a cloud of sample points surrounding the nominal motion trajectory. Surrogate model fitting is performed using polynomial regression, where the user specifies the degree of the polynomials. Once surrogate models of muscle-tendon lengths and moment arms have been fitted, the surrogate muscle-tendon length relationships are differentiated automatically to create surrogate muscle-tendon velocity relationships as a function of joint points and velocities.

Creating surrogate kinematics:

  1. Inside the tutorial directory, open the file surrogateKinematicsScript.m

  2. This file takes your preprocessed directory as an input and uses LHS to seed random values for joint angles throughout the experimental IK trajectory.

    a. LHS is a randomized algorithm, but we are using a pre-set seed (42) for this tutorial to ensure consistency.

  3. Run surrogateKinematicsScript.m

  4. This will create a new directory called surrogateData.

  5. Open the OpenSim model RightLegAndPelvis.osim in the OpenSim GUI.

  6. With RightLegAndPelvis.osim open, click load motion and load surrogateData\IKData\drive_kick1.sto

  7. Animate the motion. It should look like the nominal kicking motion but with a lot of added “noise”. This is caused by random sampling around the trajectory with the LHS algorithm.

Run Muscle Analysis:

With the surrogate kinematics created, the next step is to run the Muscle Analysis Tool to get muscle moment arms and muscle-tendon lengths for the model at the sampled kinematic points.

  1. With RightLegAndPelvis.osim selected, open the Analyze Tool.

  2. Load the settings file MuscleAnalysisSettings.xml and press Run.