Static and Dynamic Optimization via Matlab
Posted: Tue Jan 17, 2023 10:09 am
Hi OpenSim experts,
We aim to compare several biomechanical parameters (muscle forces, joint contact forces, etc.) between different running speeds. To this purpose we are using dynamic optimization (DO) in Matlab (CasADi optimization; De Groote 2016) to determine muscle forces over a period of steady-state running. However we encountered an issue when we performed the JRA. Specifically, we noticed that the muscle forces determined with DO are not included in the calculation of the joint contact forces because loading a TendonForce-file with the computed muscle forces from DO gives exactly the same ankle contact force as loading a TendonForce-file with the muscle forces multiplied by 0.1. As a result, our ankle contact force is ~2.7x body weight, which is substantially lower than the 10.7x BW reported by Edwards (2008) at a similar running speed. When we manually sum the muscle forces with the ankle contact force from the JRA tool, we do obtain a similar value of ~11x BW.
Note that we obtained similar results when we manually loaded the muscle forces from DO in the JRA tool in the OpenSim GUI and subsequently computed the ankle contact force, thus it is not a Matlab issue perse. We therefore thought that this issue could be caused by the use of DO instead of Static Optimization (SO) and therefore also performed the JRA analysis with muscle forces derived from SO. This yielded values comparable to published values.
While the muscle forces differ between DO and SO, we noticed another more important difference that explains why the JRA output is not correct when using the DO output. Specifically, after running the SO-tool in OpenSim we noticed that not only the muscle forces (80 columns) were saved to the force_file, but also the lumbar ext/bend/rot (3 columns), reserve_Actuators (31 columns), and external loads (18 columns) were saved. In contrast, when we performed the DO (or SO) in Matlab, most of these output were not saved to the force_file output. For example, we only have the time and muscle forces of the DO-output (nColumns = 81), and therefore we were wondering how to get the values for the lumbar ext/bend/rot, reserve_Actuators, and external loads in the force_file of the DO-output (and also SO-output) in Matlab so we can load all variables in the JRA tool to correctly compute joint contact forces?
Note that we did think of the possibility to run the SO for all trials, and only overwrite the muscle forces from the SO output with the DO output and then load this file into the JRA tool. However, this is problematic for the following reasons:
- First, the contribution of the reserve actuators likely differs between the DO and SO, and this may influence the computed contact forces?
- Second, when we perform the SO in Matlab, some outputs are also missing, which therefore also produced incorrect results in the JRA tool.
This therefore suggests that the only options are 1) to obtain the missing values from Matlab, or 2) manually perform the SO in the OpenSim GUI. Of course, the latter is very time-consuming and not preferred. Moreover, we noticed that the computed muscle forces differ between the SO ran in OpenSim and Matlab (See figure below). Since we now have two options for SO (SO in Matlab and SO-tool OpenSim), we are wondering which of these methods should produce the most accurate results and why do they differ?
We aim to compare several biomechanical parameters (muscle forces, joint contact forces, etc.) between different running speeds. To this purpose we are using dynamic optimization (DO) in Matlab (CasADi optimization; De Groote 2016) to determine muscle forces over a period of steady-state running. However we encountered an issue when we performed the JRA. Specifically, we noticed that the muscle forces determined with DO are not included in the calculation of the joint contact forces because loading a TendonForce-file with the computed muscle forces from DO gives exactly the same ankle contact force as loading a TendonForce-file with the muscle forces multiplied by 0.1. As a result, our ankle contact force is ~2.7x body weight, which is substantially lower than the 10.7x BW reported by Edwards (2008) at a similar running speed. When we manually sum the muscle forces with the ankle contact force from the JRA tool, we do obtain a similar value of ~11x BW.
Note that we obtained similar results when we manually loaded the muscle forces from DO in the JRA tool in the OpenSim GUI and subsequently computed the ankle contact force, thus it is not a Matlab issue perse. We therefore thought that this issue could be caused by the use of DO instead of Static Optimization (SO) and therefore also performed the JRA analysis with muscle forces derived from SO. This yielded values comparable to published values.
While the muscle forces differ between DO and SO, we noticed another more important difference that explains why the JRA output is not correct when using the DO output. Specifically, after running the SO-tool in OpenSim we noticed that not only the muscle forces (80 columns) were saved to the force_file, but also the lumbar ext/bend/rot (3 columns), reserve_Actuators (31 columns), and external loads (18 columns) were saved. In contrast, when we performed the DO (or SO) in Matlab, most of these output were not saved to the force_file output. For example, we only have the time and muscle forces of the DO-output (nColumns = 81), and therefore we were wondering how to get the values for the lumbar ext/bend/rot, reserve_Actuators, and external loads in the force_file of the DO-output (and also SO-output) in Matlab so we can load all variables in the JRA tool to correctly compute joint contact forces?
Note that we did think of the possibility to run the SO for all trials, and only overwrite the muscle forces from the SO output with the DO output and then load this file into the JRA tool. However, this is problematic for the following reasons:
- First, the contribution of the reserve actuators likely differs between the DO and SO, and this may influence the computed contact forces?
- Second, when we perform the SO in Matlab, some outputs are also missing, which therefore also produced incorrect results in the JRA tool.
This therefore suggests that the only options are 1) to obtain the missing values from Matlab, or 2) manually perform the SO in the OpenSim GUI. Of course, the latter is very time-consuming and not preferred. Moreover, we noticed that the computed muscle forces differ between the SO ran in OpenSim and Matlab (See figure below). Since we now have two options for SO (SO in Matlab and SO-tool OpenSim), we are wondering which of these methods should produce the most accurate results and why do they differ?