opensim-core
opensim-core copied to clipboard
AnalyzeTool Muscle Analysis Moment Flag
When requesting a MuscleAnalysis with the AnalyzeTool, the tool does not toggle the MuscleAnalysis to compute moments (and moment arms) even when setComputeMoments(true)
is specified for the MuscleAnalysis. A check was done with getComputeMoments()
, which indicates that the option to compute moments was set to true. However, the printed .xml file of the AnalyzeTool does not have the flag indicated to compute moments and thus they are not calculated.
My recollection is that this flag/property was not intended to be set explicitly but for internal use so that we know moment arms or moments are to be computed. This suggests that this shouldn't be exposed as a property as it would be confusing. The question from a user perspective is whether you can specify a list of Muscles and Coordinates and then ask for MomentArms or Moments
Would it be possible to update the MuscleAnalysis so that moments and moment arms can be calculated with this flag? These result quantities are helpful in analysis. I can manually change the printed xml file to compute moments and moment arms with setting this flag to true, but I would like to have this an automated option when running for many different models.
@cclancy8 do you have a snippet of code / files to reproduce?
It looks like the flag that setComputeMoments()
changes might actually be what should control that behavior: https://github.com/opensim-org/opensim-core/blob/master/OpenSim/Analyses/MuscleAnalysis.cpp#L642
Yes - I use setComputeMoments(true)
. I also check with getComputeMoments()
and get back true, but when I open the xml, the flag is unchanged. I had to manually change the xml and read that file in order to have the AnalyzeTool calculate moments/moment arms in the MuscleAnalysis. This is my code:
MA = MuscleAnalysis();
MA.setComputeMoments(true);
MA.getComputeMoments() %prints out 1
myAnalyzeTool.updAnalysisSet().adoptAndAppend(MA);
I'm guessing you only ever run this using the .xml file then, and not using the myAnalyzeTool
object? I was able to reproduce your issue (i.e., the .xml file is incorrect), and then when I went to double check by peeking into the analyze tool object, it looks correct:
a = myAnalyzeTool.updAnalysisSet().adoptAndAppend(MA);
b = MuscleAnalysis.safeDownCast(a);
b.getComputeMoments()
This prints a 1 out too
That's correct, I run the AnalyzeTool from the xml (see below). Is there another way to run it with the automation of computing moments/moment arms?
analyze = AnalyzeTool("XXX.xml");
analyze.run();
If you've got myAnalyzeTool
object all setup correctly, then in theory it should be as simple as myAnalyzeTool.run();
. FYI, while that should work, it's still definitely a bug that the writing to file is incorrect and Ayman will look into that soon
@carmichaelong , for some reason running the object itself gives me an error that a model has not been set even though I do set it. It looks like @aymanhab might be fixing this, though. Thank you!
@cclancy8 Please let us know if this has been fixed in the latest development build. Thank you.
@aymanhab Thank you! With the development build from continuous-integration#2085 , the compute_moments
flag of the muscle analysis can now be set to true as shown on the printed xml file. However, if I run the analysis tool object itself ( myAnalyzeTool.run();
), I still get an error. It is fine if I run from the printed xml file.
Hi, I intended to post this issue and found this. In both Python and MATLAB setting setComputeMoments
to "true" doesn't take any action and I have to adjust it manually in the XML file.