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:
Inside the tutorial directory, open the file
surrogateKinematicsScript.mThis 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.
Run
surrogateKinematicsScript.mThis will create a new directory called
surrogateData.Open the OpenSim model
RightLegAndPelvis.osimin the OpenSim GUI.With
RightLegAndPelvis.osimopen, click load motion and loadsurrogateData\IKData\drive_kick1.stoAnimate 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.
With
RightLegAndPelvis.osimselected, open the Analyze Tool.Load the settings file
MuscleAnalysisSettings.xmland press Run.