how to calculate muscle force

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
User avatar
Neha Sahu
Posts: 38
Joined: Sun Oct 10, 2021 7:54 pm

how to calculate muscle force

Post by Neha Sahu » Fri Oct 04, 2024 8:53 am

hello all,
I am using MocoInverse for optimization , i want to optimize spring force for lifting task with the cost function that can minimize muscle force and joint reaction force on L5S1 joint. Can anyone help with this , i am new to MOCO. Also i am unable to find any function have can directly give muscle force file. please suggest how to find muscle force in MOCO.

User avatar
Nicholas Bianco
Posts: 1050
Joined: Thu Oct 04, 2012 8:09 pm

Re: how to calculate muscle force

Post by Nicholas Bianco » Mon Oct 07, 2024 12:53 pm

Hi Neha,

With MocoInverse, you can set the "output_paths" property and it will calculate any model quantities specified at those Output paths and include them in a table as part of the MocoInverseSolution.

Best,
Nick

User avatar
Neha Sahu
Posts: 38
Joined: Sun Oct 10, 2021 7:54 pm

Re: how to calculate muscle force

Post by Neha Sahu » Wed Oct 09, 2024 6:34 am

Thank you for reply, but i am unable to find matlab code for getting muscle force and this output path property is not described that well, if you could give me any reference , it would be great help.
regards
neha sahu

User avatar
Nicholas Bianco
Posts: 1050
Joined: Thu Oct 04, 2012 8:09 pm

Re: how to calculate muscle force

Post by Nicholas Bianco » Wed Oct 09, 2024 8:57 pm

Hi Neha,

Please refer to my recent post on this thread for more guidance: viewtopicPhpbb.php?f=1815&t=18886&p=51523&start=0&view=.

Best,
Nick

User avatar
Neha Sahu
Posts: 38
Joined: Sun Oct 10, 2021 7:54 pm

Re: how to calculate muscle force

Post by Neha Sahu » Wed Oct 09, 2024 11:30 pm

Thank you for your reply , i will try that. I am facing issue in mocoinverse this error , my matlab crashed everytime. please suggest what to do.
Attachments
moco.png
moco.png (42.56 KiB) Viewed 565 times

User avatar
Neha Sahu
Posts: 38
Joined: Sun Oct 10, 2021 7:54 pm

Re: how to calculate muscle force

Post by Neha Sahu » Thu Oct 10, 2024 3:28 am

Also when i am using analyze tool I am facing issue.
a. when using analysis tool muscle analysis, matlab crash.
b. when using analysis tool , I get active force , fibre force , how to I get muscle force directly , and how I can calculate muscle force with these results.
Attachments
other analyze.png
when run this error shows.
other analyze.png (99.77 KiB) Viewed 555 times
analyzetool.png
when run this matlab crash
analyzetool.png (80.41 KiB) Viewed 555 times

User avatar
Nicholas Bianco
Posts: 1050
Joined: Thu Oct 04, 2012 8:09 pm

Re: how to calculate muscle force

Post by Nicholas Bianco » Thu Oct 10, 2024 10:41 am

Hi Neha,

Your problem appears to be infeasible (i.e., the problem cannot enforce the dynamics constraints in the direct collocation problem). I'm not sure about the MUMPS memory issue, but it might be related to Ipopt entering "restoration mode" in order to address the infeasibility issue.

I would recommend:
  • Simplify the model and/or problem (e.g., remove muscles, remove external loads, disable some cost function terms, etc).
  • Add strong CoordinateActuators at every degree-of-freedom (see ModOpAddReserves).
  • Try accessing the underlying MocoStudy via initialize() (see snippet below), which will enable debugging options.
  • Once you get a problem to converge, start adding complexity back to your problem/model until you get back to the problem you want to solve.
Some helpful code:

Code: Select all

inverse = MocoInverse();
% your inverse problem configuration here
inverseSolution = inverse.solve();
solution = inverse.getMocoSolution();

% If your problem failed, you can still access it for debugging purposes using "unseal".
solutionUnsealed = solution.unseal();

% Using analyze() to get muscle forces.
outputPaths = StdVectorString();
outputPaths.add('/forceset/vaslat_r|tendon_force');
outputs = study.analyze(solutionUnsealed , outputPaths);
Best,
Nick

User avatar
Neha Sahu
Posts: 38
Joined: Sun Oct 10, 2021 7:54 pm

Re: how to calculate muscle force

Post by Neha Sahu » Fri Oct 11, 2024 1:15 am

Thank you for your reply. I will try to solve this , if get any issue , i will post that.

User avatar
Neha Sahu
Posts: 38
Joined: Sun Oct 10, 2021 7:54 pm

Re: how to calculate muscle force

Post by Neha Sahu » Wed Oct 16, 2024 9:46 pm

Hello sir, i have reduce convergence torelance and increase mesh size then i am able to run analyze tool for Muscle analysis, so the result it is giving is active force , passive fibre force and fibre force , how i supposed to calculate total muscle force.
Also now i need to add spring parameter as design parameter , for that i am using .osim model that have pointtopoint spring attached to it, using Moco Bound to optimize the spring stiffness and rest length. Its not working. can you suggest something.
Also i want to use Min joint reaction force as the cost function with min muscle activation , if i am using that Matlab crash, i this thats to heavy.
can you suggest something please.

User avatar
Neha Sahu
Posts: 38
Joined: Sun Oct 10, 2021 7:54 pm

Re: how to calculate muscle force

Post by Neha Sahu » Thu Oct 17, 2024 8:43 am

Error using bounded
Java exception occurred:
java.lang.RuntimeException: casVector should be 1-dimensional, but has size 0 x 0.
Thrown at MocoCasOCProblem.h:108 in convertToSimTKVector().

at org.opensim.modeling.opensimMocoJNI.MocoStudy_solve(Native Method)

at org.opensim.modeling.MocoStudy.solve(MocoStudy.java:282)


............. i am getting this error while using mocobound for spring stiffness.
how to resolve this.

POST REPLY