Working with Static Optimization
Static Optimization is a method for estimating muscle activations and muscle forces that satisfy the positions, velocities, accelerations, and external forces (e.g., ground reaction forces) of a motion. The technique is called "static" since calculations are performed at each time frame, without integrating the equations of motion between time steps. Because there is no integration, Static Optimization can be very fast and efficient, but it does ignore activation dynamics and tendon compliance. (See Hicks et al., (2015) for more details regarding this and similar modeling and simulation choices and their pros and cons.)
Overview
In this tutorial, you will learn how to perform a Static Optimization analysis on a single stride gait trial and assess gastrocnemius activation and force production in a simplified example model (gait10dof18musc).
As with any analysis or simulation, the quality of the Static Optimization results largely depends on the inputs: the model, motion, and forces. The model should have mass, anthropometry, and strength that represent the experimental participant; while the degrees of freedom and muscle geometry should be appropriate for the questions being asked (e.g., studying an upper body motion would require a more detailed upper extremity muscle set and skeletal geometry). The motion should contain smooth, realistic accelerations and all external forces during the motion (e.g., ground reaction forces) should be accurately measured and applied to the model. Additional forces (i.e., reserves and residuals) are often needed but should be small enough to not confound analysis. Any issues with your inputs will give you poor results or cause the tool to fail.
In this this tutorial, you will:
- Get an initial Static Optimization analysis running without error messages or crashes
- Improve the activation and force results by using improved motion data
- Learn how to reduce actuation from reserve and residual actuators
- Add passive forces and observe their effect on muscle activation
Before You Get Started
(1) Before completing the tutorial, make sure you have reviewed the following readings from the User's Guide and completed the prerequisite tutorials.
User Guide Readings | Prerequisite Tutorials | Helpful Readings |
---|---|---|
(2) Install OpenSim version 4.0.
(3) Find the model, setup, and data files in the folder Downloaded folder WorkingWithStaticOptimization, at the top of this page. This folder contains a scaled model, external forces, motion (from Inverse Kinematics analysis), template actuation files, and the results of RRA.
The tutorial begins in the workflow where the model is scaled, Inverse Kinematics run, and Residual Reduction Analysis performed. The tutorial is divided into the following four studies:
Study 1: Static Optimization is failing!
In Study 1, you will load a model, create a setup file, and run Static Optimization. Then you will learn how to troubleshoot an under-actuated model.
| |
You must specify the three inputs to Static Optimization: (i) the model, (ii) the motion of interest, and (iii) any external forces (e.g., ground reaction forces). The tool is using the current model in the GUI (subject01), so you just need to input motion and any external forces.
The tool will now step through each time frame of the input motion. At each time, updating the model coordinates, external loads, and calculating the muscle forces and activations needed to generate the model's accelerations. | |
While the analysis was running (or when it was finished), you may have noticed the following output in the GUI's "Messages" window. You may have also seen that the analysis ran very slowly. | |
Once the Static Optimization tool has finished, the results are saved to your ResultsSO folder:
|
What exactly is happening? This error message, "Optimizer Failed..." is informing you that the optimizer could not find an adequate solution at the time indicated. Remember that Static Optimization is trying to calculate activations and muscle forces that satisfy the model's coordinate accelerations calculated from the specified kinematics file. If the model's actuators cannot generate sufficient forces to match these accelerations, this "Optimizer Failed..." error will appear. The Static Optimization tool has produced a set of results to help with troubleshooting, but these outputs are not valid.
An under-actuated model is the product of muscles not being strong enough to generate the required forces and/or model coordinates not having any actuation whatsoever (muscles or other actuators). In this particular model, there are no muscles that control lumbar flexion/extension and so all the other lower limb muscles are trying to control trunk motion, without much success.
One possible solution is to add extra muscles that cross the lumbar joint. However in this series of studies we are only interested in Gastrocnemius activation during walking. Adding additional muscles will add extra complexity to the model that is likely not required for our analysis. Instead of lumbar muscles, we will add a torque actuator at the lumbar joint.
We will also add reserve and residual actuators to the model. Reserve actuators can add extra actuation during portions of the gait cycle where muscles are not able to generate sufficient accelerations (e.g., during a spike in acceleration). Residual actuators are "hand of God" forces that account for (what should be small) discrepancies between the model, measured motions, and forces; in other words, these actuators ensure that Newton's 2nd law, F=ma, is satisfied throughout the analysis. For more details, see section 3.1.3 of Hicks et el., (2015). Typically, these residual actuators are added to the model's body that is connected to ground (in this particular case, residual actuators will be added to the pelvis body).
You will now add a set of additional actuators, including a lumbar actuator, reserve actuators at the other joints, and residual actuators at the pelvis. Then you will rerun the analysis;
- Re-open the Static Optimization tool (if you have already closed it), and load your saved setup file.
- You can add additional actuation by going to the Actuators input box in the Actuators and External Loads tab, clicking Edit... > Add and selecting the gait10dof18musc_Strong_actuators.xml from your working folder. The actuator file is a pre-made file that contains specifications for actuators for each coordinate in the model (i.e., reserves and residuals plus an actuator to control the lumbar extension degree of freedom).
- We want to append these actuators to the existing set of muscles, rather than replacing the muscles, so select the button Append to model's force set
- Go to Main Settings, change the output directory to /ResultsSO_StrongActuators, so you don't print over your previous results.
- Save this new version of the setup file and rerun the analysis. Looking into the GUI message window you will see that the last error message is now gone, meaning that the model can generate sufficient forces.
Firstly, plot the Lumbar actuator reserves from the output file Scaled_Model_StaticOptimization_force.sto. | |
Now add the new Gastrocnemius muscle activation curve to your plot from before. This figure shows that the Gastrocnemius activation was significantly reduced. The reduction is due to the additional torques generated by the actuators added to the model. | |
Plot the moments produced by the right ankle reserve actuator from the output file Scaled_Model_StaticOptimization_force.sto. On a separate figure, plot the Fx, Fy, and Mz residual actuator forces. |
We now have a working Static Optimization analysis. A functioning analysis does not mean that the results are valid; rather, we have a place to start iterating from to improve the output. In the following studies, we will gradually improve the quality of the inputs to get a better result. Review the questions below to better understand the problems with the current set of results.
Questions:
- The activation and force results are very noisy; why do you think this is? We will learn how to fix this in Study 2.
- The Mz contribution is between ±50 Nm. What is the contribution of the residual actuator force for Fx, and Fy? How large are these residual actuator forces in comparison to the peak ground reaction forces measured doing the motion? What improvements could you make to any of the inputs (model, kinematics, external forces) to reduce the size of the residual forces? Study 2 will address these residual results.
- The peak ankle extension moment from Inverse Dynamics was 120 Nm. How does this peak ankle moment compare to the peak moment generated by the ankle reserve actuator. (e.g., as a percentage)? Do you think the reserve actuator peak should be this large? How might we address this issue? We will learn how to fix this in Study 3.
Study 2: Improving the input kinematics
The aim of Study 2 is to assess how improving the input kinematics affects muscle activations and forces that Static Optimization outputs. Static Optimization is trying to compute muscle forces that generate the accelerations seen in the input kinematics. If these accelerations are noisy, there will be noise in the muscle activations and forces. In Study 1, we saw noisy activations and forces that are most likely the result of noisy motion data. We will investigate two methods for improving the motion data: (i) filtering the input kinematics and (ii) using the Residual Reduction Algorithm (RRA) to smooth the kinematics.
Filtering the kinematics will spline-fit the motion data and filter the coordinate positions, reducing noise in the accelerations. If you use IK results as inputs to Static Optimization, you should always filter them, either externally (e.g., with Matlab or Python) or by using the OpenSim filters.
Since RRA uses a forward dynamics simulation (i.e., the model's equations of motion are integrated forward in time), the output kinematics will be consistent accelerations that are great to use in Static Optimization. If you are using RRA results, you don't need to do any additional filtering. Using RRA also has the added benefit of generating a more "dynamically consistent" model and set of kinematics and forces. We are not going to go in depth into RRA in this particular tutorial so if you are unfamiliar with RRA please refer to the User's Guide. You can also complete the tutorial The Strength of Simulation: Estimating Leg Muscle Forces in Stance and Swing to learn more about how to use and troubleshoot with RRA.
Run two Static Optimization analyzes with the changes described below;
(i) The first will use the same setup and input kinematics as Study 1 (including actuators), but this time;
- Launch the Static Optimization tool and load your setup file, making sure you're still appending the file with reserve and residual actuators.
- Filter the motion by checking the Filter coordinates box. Use the default 6Hz cut-off.
- Change the output directory name to \ResultsSO_StrongActuators_Filter.
(ii) The second will use a motion from an existing RRA solution.
- Launch the Static Optimization tool and load your setup file, making sure you're still appending the file with reserve and residual actuators.
- Use the motion subject_adjusted_Kinematics_q.sto (these are the kinematics generated by RRA).
- Be sure to NOT filter the kinematic data
- Change the step interval to 10
- Make sure the time is set to 0.3 to 1.5s
- Change the output folder to /ResultsSO_StrongActuators_RRA
- Save a new version of the setup file (e.g., StaticOptimization_SetupRRA)
You should now have four analysis results in separate folders
- ResultsSO: Static Optimization, no actuation, unfiltered IK motion. (from Study 1)
- ResultsSO_StrongActuators: Static Optimization, with actuation, unfiltered IK motion. (from Study 1)
- ResultsSO_StrongActuators_filtered: Static Optimization, with actuation, filtered IK motion.
- ResultsSO_StrongActuators_RRA: Static Optimization, with actuation, RRA motion.
Generate figures that compare the Gastrocnemius activations for the three different kinematics inputs (2. unfiltered, 3. filtered, and 4. RRA) where reserve and residual actuators were included (i.e., skip case 1). You can rename the curves by right clicking on the curve name in Curves List. | |
Plot the Fx residual for the three kinematics inputs (2. unfiltered, 3. filtered, and 4. RRA). Explore some of the other forces and activation results from the analysis. |
Questions
- Describe the changes in muscle activation for the three different motion inputs.
- Why did the residual forces decrease from the Unfiltered to Filtered condition? Why did the residual forces decrease further when using the motion from RRA?
- Which kinematic input should be used for the Static Optimization analysis? Explain your reason(s).
Study 3: Tuning the reserve and residual actuators
In Study 1 we added actuators to assist each coordinate of the model. However, we saw that these reserve actuators contributed a significant amount of the total joint torque that we would prefer the muscles to provide. In this Study, you will reduce the strength of the reserve actuators and observe the resulting changes in reserve actuator torques and Gastrocnemius muscle activation and forces.
The current actuators file has optimal forces of 100 N for each force actuator (i.e., residuals FX and FY) and optimal torques of 100 N-m for each torque actuator (i.e., residual MZ, and reserve coordinate actuators). When trying to minimize the sum of activations squared, the optimizer can use small activation values to these force and torque actuators generate large forces or torques. For example, with an optimal torque of 100 N-m, an activation of 0.5 will generate a torque of 50 N-m. If, instead, the optimal torque were 1 N-m, the optimizer must now use very high activations to produce any meaningful torques. In this latter case (optimal torque = 1) , an activation of 0.5 would only generate 0.5 N-m, and an activation of 50 is necessary to generate 50 N-m of torque. Thus, when the optimal force is very low (~1 N or 1 N-m) the optimizer can still choose to use the reserve actuators when needed, but the cost is so high relative to the muscles that the optimizer will preferentially use muscles to generate joint torques and only use the reserve actuators when the muscles cannot generate sufficient torque.
<optimal_force>100</optimal_force> | Edit the actuators file and change each actuator's optimal force from 100 to 1. The easiest way to change this is by editing the file directly in a text editor like Notepad++ (download Notepad++). However, you can use any text editor.
|
Perform another Static Optimization analysis using the RRA adjusted kinematics.
Once the analysis finished plot the Gastrocnemius activation when using the strong actuators (optimal force at 100) vs the normal actuators (optimal force at 1). | |
Plot and compare the lumbar actuator moment, ankle reserve actuator force and the Fx residual force when using the strong actuators (optimal force at 100) and normal actuators (optimal force at 1) |
Questions:
- How do the Gastrocnemius muscle force change between the analysis using strong actuators (optimal force at 100) and the normal (optimal force at 1) actuators? What about the moment generated by the ankle actuators? If there are differences, explain why.
- How does the lumbar actuator reserve moment change between using the large vs. small optimal_force? Why might this be the case? (Hint: observe whether or not there are muscles that control the lumbar extension degree of freedom.)
- What is the peak Fx residual force? Why does the value stay the same between the strong and normal actuator case? (Hint: refer to the section earlier in the tutorial where we discuss why we need residual forces and moments. Are there other actuators in the model that could generate these forces?)
Study 4: Static Optimization with a passive element
In this Study, you will add an ankle spring to the model and observe the effect on Gastrocnemius activation. Make sure you're using OpenSim 4.0 or a more recent version of the software.
The first step is to add a coordinate spring to the model. You will do this by running a GUI script that loads the current model, adds a coordinate spring to the right ankle, and saves it as a new model.
A new model will appear in the GUI. In the navigator pane, notice the name of the model now has 'ankle_spring' appended. Expand the model hierarchy to find the spring under Forces>Other Forces. From the Property Editor, you can observe and edit the spring's properties. For example, You will be able to see that the spring name is 'AnkleLimitSpringDamper'. Also, observe that a new model has been saved to your WorkingWithStaticOptimization folder called 'subject01_spring.osim'. |
Now that you have a new model with an ankle spring, you will re-run the Static Optimization analysis using the same setup from Study 3 (with normal reserve actuators). Rename the output folder to \ResultsSO_NormalActuators_RRA_Spring
Plot the AnkleLimitSpringDamper moment from the file Scaled_Model_StaticOptimization_force.sto | |
Plot the Gastrocnemius activation from the analyzes with and without the Spring (the results should be in the folder ResultsSO_NormalActuators from Study 4 and the latest folder, ResultsSO_Spring) |
Questions:
- Why did the Gastrocnemius activation decrease when the ankle spring was added?
- Optional: try increasing or decreasing the spring stiffness. How does this affect the Gastrocnemius activation?
- Optional: are any other muscle affected by adding the ankle spring?
References
- Hicks J.L., Uchida T.K., Seth A, Delp S.L. (2015). Is My Model Good Enough? Best Practices for Verification and Validation of Musculoskeletal Models and Simulations of Movement. Journal of Biomechanical Engineering, 137(2)
OpenSim is supported by the Mobilize Center , an NIH Biomedical Technology Resource Center (grant P41 EB027060); the Restore Center , an NIH-funded Medical Rehabilitation Research Resource Network Center (grant P2C HD101913); and the Wu Tsai Human Performance Alliance through the Joe and Clara Tsai Foundation. See the People page for a list of the many people who have contributed to the OpenSim project over the years. ©2010-2024 OpenSim. All rights reserved.