Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...


Tip

Download Static Optimization Example Folder


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.)  

...

(1) Before completing the tutorial, make sure you have reviewed the following readings from the User's Guide and completed the prerequisite tutorials.

(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.

Tip

Download Static Optimization Example Folder

 

 

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:

...

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.


 

Image Modified
  • Launch OpenSim and load the model subject01 included in the WorkingWithStaticOptimization folder. This is a simplified, planar, scaled gait model that has only a few degrees of freedom and lumped muscle groups (e.g., the medial gastrocnemius and lateral gastrocnemius are combined into a single gastrocnemius muscle). 
  • Open the Static Optimization tool by choosing Tools > Static Optimization from the drop-down menu.
Image Modified

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.

  • For the motion, you will use a previously calculated inverse kinematics result found in your working folder, subject01_walk_IK.mot. Leave the Filter Coordinates box unchecked (we'll come back to this in Study 2). 
  • Set the Time Range to Process from 0.3 to 1.5 seconds
  • For the Output Directory, add /ResultsSO to the current directory.
  • On the 'Actuators and External Loads' tab, Check the External Loads box and then select subject01_walk_grf.xml as the External Loads. See here for more details about specifying external loads.
  • Save the setup file as StaticOptimization_Setup.xml, then hit Run to begin the analysis. 

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.

 

 


Image Modified

 





Warning
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.


Image Modified

Once the Static Optimization tool has finished, the results are saved to your ResultsSO folder:

  • Launch the plotter
  • Select Y Quantity and choose Load file
  • Navigate to the ResultsSO folder and select the file Scaled_Model_StaticOptimization_activation.sto
  • Plot the Gastrocnemius muscle activations versus time for the right leg.
  • Minimize the plot – we'll come back to it later.

 


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.

...

  • 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.

 


Image Modified

Firstly, plot the Lumbar actuator reserves from the output file Scaled_Model_StaticOptimization_force.sto.

Image Modified

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.

 

 



Image Modified

Image Modified

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. 

...

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 the Residual Reduction Algorithm  (RRA) to smooth the kinematics.

...

  1. ResultsSO: Static Optimization, no actuation, unfiltered IK motion. (from Study 1)
  2. ResultsSO_StrongActuators: Static Optimization, with actuation, unfiltered IK motion. (from Study 1)
  3. ResultsSO_StrongActuators_filtered: Static Optimization, with actuation, filtered IK motion.
  4. ResultsSO_StrongActuators_RRA: Static Optimization, with actuation, RRA motion.

Image Modified

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.

Image Modified

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).

...

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.

Image Modified

Code Block
<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.

  • Open the actuators file gait10dof18musc_Strong_actuators.xml in a text editor
  • Find all the XML tags for optimal_force and change their value from 100 to 1.

  • Save the actuators file as gait10dof18musc_Actuators_Normal.XML

 



Image Modified

 


Perform another Static Optimization analysis using the RRA adjusted kinematics.

  • Load your StaticOptimization_SetupRRA file from the previous Study
  • Change the output directory to /ResultsSO_NormalActuators_RRA
  • Edit the Additional force set files. Delete the old actuators file and add thew new one that you created, Make sure you are still "Appending to the model's force set."

  • Save the setup file
  • Run the analysis

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).

 


Image ModifiedImage Modified

 


Image Modified

 


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?)

...

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.

...



Image Modified

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. 

  • Close the Static Optimization tool pane if it's open.
  • Load the RRA adjusted model subject01.osim in the GUI
  • Click  Scripts > Run...
  • Select the Script file addAnkleSpring.py
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

Image Modified

Plot the AnkleLimitSpringDamper moment from the file Scaled_Model_StaticOptimization_force.sto

Image Modified
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

  1. 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 MovementJournal of Biomechanical Engineering, 137(2)