Page 1 of 1

How to get Multipliers of Static Optimization?

Posted: Tue Apr 07, 2020 9:48 pm
by hoonkim
Dear all,

I used static optimization to get muscle forces and activation. Additionally, I would like to get the multipliers such as f(Lm) (a multiplier based on force-length relationship) and f(Vm) (a multiplier based on force-velocity relationship).

I tried to use muscle analysis tool to get the normalized fiber length. However, I could not get normalized fiber length from Muscle Analysis with Static Optimization results (control.xml). I've seen that Muscle Analysis with CMC worked in my previous studies. But, for this current study, I would like to static optimization to get the muscle forces.

It would be very helpful if anyone tell me how to get the multipliers of static optimization.
Thank you so much.

Sincerely,

Hoon

Re: How to get Multipliers of Static Optimization?

Posted: Thu Apr 09, 2020 12:16 am
by mitkof6
Hi,

You can access the multipliers as follows:

Code: Select all

muscleSet = model.getMuscles()
muscle = muscleSet.get("muscle_name")
f_max = muscle.getMaxIsometricForce()
f_l = muscle.getActiveForceLengthMultiplier(state)
f_v = muscle.getForceVelocityMultiplier(state) 
f_pe = muscle.getPassiveForceMultiplier(state)
cosa = muscle.getCosPennationAngle(state)
fm = f_max * (a * f_l * f_v + f_pe) * cosa

Re: How to get Multipliers of Static Optimization?

Posted: Sun Apr 26, 2020 6:56 pm
by hoonkim
Thank you for your answer.
I tried the code in MATLAB and the code for the f_l (getActiveForceLengthMultiplier(state)) works. :D
However, the f_v with getForceVelocityMultiplier did not work. The output for the getForceVelocityMultiplier was "1" for all time points.
Do you have any tips for me to run the getForceVelocityMultiplier correctly?
Thank you.

Sincerely,

Hoon

Re: How to get Multipliers of Static Optimization?

Posted: Tue Apr 28, 2020 2:25 am
by clnsmith
Sounds like the state might only realized to the position stage.

Try running this line before accessing the multipliers.

model.realizeVelocity(state)

Re: How to get Multipliers of Static Optimization?

Posted: Tue Apr 28, 2020 12:38 pm
by hoonkim
Thank you for the tips.
I tried to use the "model.realizeVelocity(state)". But, I realized the code is for OpenSim 4.x.
So, I used the "osimModel.computeStateVariableDerivatives(osimState)" for OpenSim 3.3.
But, I got the same results (values are all "1").
Below are two sets of my codes for the multipliers.
Could you provide me with more tips?
Thank you so much for any comments and tips.

Sincerely,

Code: Select all

for t = 1:size(RRAKinematics,1)
    for r = 0:size(RRAKinematics,2)-1
        osimState.updY().set(r,RRAKinematics(t,r+1));
    end
    osimModel.equilibrateMuscles(osimState);
    muscles = osimModel.getMuscles();
    currentmuscle = muscles.get(m-1);
    f_L(t,m) = currentmuscle.getActiveForceLengthMultiplier(osimState);
    osimModel.computeStateVariableDerivatives(osimState);
    f_V(t,m) = currentmuscle.getForceVelocityMultiplier(osimState);
end

Re: How to get Multipliers of Static Optimization?

Posted: Wed Apr 29, 2020 11:44 am
by mitkof6
Hi,

Just a suggestion. Maybe you have to set the coordinate speeds as well before realizing to velocity stage. I think with

osimState.updY().set(r,RRAKinematics(t,r+1));

you are setting only the coordinates and not the velocities. I would use the following syntax:

model.updCoordinateSet().get(coordinate_name).setValue(state, q)
model.updCoordinateSet().get(coordinate_name).setSpeedValue(state, qdot)

because with the index r you may set the value of the wrong coordinate. Also, the Y vector contains all the states that might change order.

Re: How to get Multipliers of Static Optimization?

Posted: Wed Apr 29, 2020 3:48 pm
by hoonkim
Thank you so much for your suggestion.

Below is my code based on your suggestion.

Code: Select all

for m = 1:80
   for t = 1:size(RRAKinematics,1) % the number of time
      for r = 0:size(RRAKinematics,2)-1 % the number of coordination 
         CurrentCoord = osimModel.getCoordinateSet().get(r);
         osimModel.updCoordinateSet().get(char(CurrentCoord)).setValue(osimState, RRAKinematics(t,r+1))
         osimModel.updCoordinateSet().get(char(CurrentCoord)).setSpeedValue(osimState, RRAVelocity(t,r+1))
      end
         osimModel.equilibrateMuscles(osimState);
         currentmuscle = osimModel.getMuscles().get(m-1);
         osimModel.computeStateVariableDerivatives(osimState);
         f_L(t,m) = currentmuscle.getActiveForceLengthMultiplier(osimState);
         f_V(t,m) = currentmuscle.getForceVelocityMultiplier(osimState);
   end
end
I checked the f_L and f_V for "glmax123_r" and the values were nice. Because I got good shape for the values of "glmax123_r", I thought other muscle's values would be good. :)
However, f_V for other muscles such as "soleus_r" or "recfem_r" was not reasonable.
I checked that f_V worked ONLY for muscles across hip joint, while f_L worked for all muscles.
Could you provide me with some more tips?
Thank you so much for your help, always.

Sincerely,

Hoon

Re: How to get Multipliers of Static Optimization?

Posted: Thu Apr 30, 2020 12:42 am
by mitkof6
Can you try removing the equilibrate muscles function call? Also, can you provide plots so that we can understand they the curves are not good. Again, my guess is that you are not setting the coordinates properly. Can you check if the column names of the RRA storage agree with the order of coordinates?