Questions on the MoCap model

Dear experts,

I am a novice when it comes to rigid body (inverse) dynamics so please excuse me if I sound naive. Also, I have a bunch of questions, so I’d appreciate your patience.

With the disclaimer out of the way, let me ask my questions regarding the MoCap model provided with AMS:

[ol]
[li]I want to be able to change the cost function used to compute muscle forces. Where is it located? I have looked through all the .ANY files in the MoCap model and I can’t seem to find it.[/li][li]I was recently made aware by one of the experts at AnyBody that sRelOpt for a given marker is the location of that marker in its anatomical frame, which happens to be different from its local coordinate system.[/li][LIST=1]
[li]Also, while positioning the model, I changed the sRelOpt to bring them as close as possible to the experimental markers. That is a good practice, isn’t it?[/li][/ol]

[li]This one is related to the previous question. What is the purpose of sRelOptScalingOnOff?[/li][li]In the experimental data set that we have, the person does not move their legs so the GRF is essentially the weight of the person. Now, should I comment out the force plates from the computation like as follows: [/li]```
#define HumanModelPresent 1
// #include “…/Input/ForcePlates.any”
#undef HumanModelPresent


[/LIST]

[ul]
[li]If I did that, then how will AnyBody enforce equilibrium? Is the "hand of God" going to be applied at the pelvis? If so, then, I suspect that the muscle forces in the ankle//hip/ knee are far from being realistic. Is that correct? Conversely, if the residual correction (i.e., the "hand of God") is being applied at the pelvis, then again, I suspect, the forces in the muscles of the elbow, as an example, shouldn't have a major effect on them (due to the residual correction.) Does that make sense?[/li][li]If I cannot comment out force plates, then should I fix the feet in all degrees of freedom and have the forces from the force plates percolate through the joints (via balance of forces/moments using inverse dynamics)?[/li][/ul]

[ol]
[li]I noticed      something odd while I was positioning the model inside [b]TrialSpecificData.any[/b].      When I changed the [b]AnyVar BodyMass[/b] to the experimental subject's      weight, the [b]MotionAndParameterOptimizationModel[/b] part of the model      would crash with the following error message: [b]ERROR(OBJ.MCH.KIN3) :      'ObjectName' : Kinematic analysis failed in time step 'integer'[/b].[/li][/ol]

[ul]
[li]This cannot be due to the fact that I had the force plates commented out, can it? Why would scaling of body segments and optimal positioning of markers (in the [b]MotionAndParameterOptimizationModel[/b]) fail because of missing forces? That doesn’t make any sense to me. It has to something else.[/li][li]By the way, changing the subject's height had no impact on the solver. It breezed through the [b]MotionAndParameterOptimizationModel[/b].[/li][/ul]
Thank you for your time and consideration,


Vikas Kaul

P.S.: This editor makes life a bit tricky particularly when you are numbering bullets. I couldn't get it to make the final bullet number be 5.

Hi Vikas,

I will try to give you some answers on your questions:

[ul]
[li] A1: The cost function is controlled through settings in the AnyBodyStudy please see http://wiki.anyscript.org/index.php/All_about_Kinetics#Where_do_I_change_the_cost_function_for_the_muscles.3F[/li]
[li] A2: sRelOpt values are scaled with the model so if you between subjects has markers on same locations these values are meant to remain constant. It is good practice to provide a good estimate on their location wrt to the bone. So try to make makers have the correct location wrt to the bone (not the free floating recorded marker)[/li]
[li] A3: If this is on it means that the sRelOpt values is automatically scaled[/li]
[li] A4: If you have forceplate data available then use these with the force plate. You are right in your assumption, if you exclude the forceplate and keep the hand of god on pelvis legs will have no other load than their own weight.[/li]
[li] If you have markers on the entire body and no forceplate data, I would use these to drive the motion and then use the reactions like in the Standing model (support elements) to carry the loads[/li]
[li] A5: I do not understand this error message sorry, except that it tells that the kinematic analysis failed in a timestep. To change the subject height you will need to both change the height in the trial specific folder and also change the individual segment lengths below. [/li][/ul]
I hope these answers helps you move on, otherwise please write again.

Best regards
Søren

Hello Søren,

Thank you very much for an impressive turn-around time!

[ul]
[li]Thank you for the link. I found the criterion folder (but it took a while looking for it because it is available only in the Mod[FONT=&quot]el tab of the Model tree and then in Studies->InverseDynamicStudy->Inve[FONT=&quot]rseDynamics->C[FONT=&quot]riterion[/FONT][/FONT]!) I would’ve expected an important measure/variable like the cost function would be more [FONT=&quot]visible.[/FONT][/FONT][/li][LIST]
[li][FONT=&quot][FONT=&quot][FONT=&quot]Howe[FONT=&quot]ver, [FONT=&quot]how do I go about writing my own OR editing one of the exi[FONT=&quot]sting cost functions OR switching the cost function (currently, set as MR_Polynomial) to something else that is available?[/FONT][/FONT][/FONT] All I seem to have the option of changing is the iterations ([FONT=&quot][FONT=&quot][FONT=&quot]currently set at 20,000[/FONT][/FONT]).[/FONT][/FONT][/FONT][/FONT][/li][li][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot]FYI: When I looked at AnyEnum in the Reference Manual to see how I can edit the cost function, I notice[FONT=&quot]d the option to open/download demo files[/FONT] at the bottom. However, when I click on the Open Main file, a[FONT=&quot][FONT=&quot] script error [FONT=&quot]message[/FONT][/FONT][/FONT] pops up[FONT=&quot] that says “Automation server can[FONT=&quot]'t create[FONT=&quot] object”, code 0, line 317, char 13.[/FONT] [/li][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[LIST]
[li][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot]I will download the file and see what I can figure out.[/li][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[/ul]
[/LIST]

[li]To be sure, you mean to say that my approach is fine. In other words, I should be changing sRelOpt before running the MotionAndParameterOptimizationModel[FONT=&quot] part of the analysis. Correct?[/FONT][/li][li]When I plot r for the position of a marker or a segment, etc. in the Chart View window, are the values for r in the global coordinate system? If not, then which coordinate system is it - the anatomical or the local coordinate system?[/li][li]So, is it correct to say that I should first play with sRelOpt and then also leave the sRelOptScalingOnOff on?[/li]> If you have markers on the entire body and no forceplate data, I would use these to drive the motion and then use the reactions like in the Standing model (support elements) to carry the loads
Sure, but do you suspect the effect on muscle forces in the elbow will be substantial if all that is being done is moving the arm (which is a few links away from the pelvis)? I know this is hard to answer but I am trying to get a sense of how far from ideal is my approach (where ideal is having the force plates enabled).
[li]Thank you.[/li][/LIST]
Best,

Vikas

Hi Vikas,

Please go through this tutorial : http://www.anybodytech.com/fileadmin/AnyBody/Docs/Tutorials/chapX_MuscleRecruitment/Inverse_dynamics.html

It explain more or less all option available to change the cost function it also contains some of the math behind. I think this will help you a lot.

Concerning the error you got on the Enum I ma not sure what went wrong usually there is next to the main file a zip file did you try this option?

When you enter a value in sRelOpt it will be the initial guess on the marker position wrt to the bone it is attached on. When the optimization is running the maker may be moved by the optimizer this depends on if the optx opty optz settings are on or off.

So to answer your question it is a good idea to provide a good guess on the marker location before running the analysis it will make things easier for the optimizer, and for the markers which are not optimized (see red arrows) the location you provide to sRelOpt will change the results in the end.

So adjust sRelOpt so that markers are placed wrt to the bone as in the experiment, and leave the sreloptscaling on. By doing this you can easily move to another subject.

If your main topic is the arms the what goes on in the legs may not be of major interest, but the closer towards the legs you go the higher impact you will see, muscle are connecting all body parts in this way.

Best regards
Søren

Hi Søren,

Thank you again for your reply. I have resolved my concern (partially). It turns out all I needed to do was add a line or so of AnyScript code to the AnyBodyStudy folder. Apparently, I was looking for such AnyScript lines of code, which were missing because MR_Polynomial is the default cost function.

So, now I can switch between cost functions. My next concern is: how do I edit a cost function? For instance, if I want to scale a cost function with some parameter, how can I accomplish that? Is there an example/demo file that shows the code that does something like this?

Thank you.

Hi Vikas,

I have updated the wiki page a little please see
http://wiki.anyscript.org/index.php/All_about_Kinetics#Where_do_I_change_the_cost_function_for_the_muscles.3F

I hope it will explain some of it.

Please describe in which direction you would like to change the cost function I have not yet understood what you try to achieve, if I knew I might be able to suggest the correct settings.

Best regards
Søren

Hi Søren,

Thank you yet again for your quick turn around time.

A few weeks ago, a representative from AnyBody gave a demonstration of how a cost function was edited to take differences in volumes of muscles in to account. This webcast was in relation to a grand prize challenge that AnyBody won.

While I understand how I can switch between available options of cost functions, thanks to your patience, I would like to be to make changes like that to a given cost function much like what the AnyBody representative was talking about.

Thank you,

Vikas

Hi Vikas,

Ok now I understand

[COLOR=black]The current version of AMS incorporates the features needed to handle the normalization he incorporates, the feature is available, but it has not been implemented into the AMMR models yet. [/COLOR]

[COLOR=black]Take a look at the AnyBodyStudy object in the reference manual and look for the “[/COLOR]Nfactor_SearchName[COLOR=black]” terms[/COLOR]

[COLOR=black]So the procedure is to add the normalization factor to each muscle in the model which is picked up by the recruitment solver.[/COLOR]
[COLOR=black]So in each muscle you write eg. AnyVar MyNormalizationTerm =xxx[/COLOR]
[COLOR=black]And in the anybody study you define the Nfactor_searchname(s) = MyNormalizationTerm[/COLOR]

[COLOR=black]I do not have any examples on hand I can provide, if it is something you would like to try I would start playing with it on the simple arm model to understand how it works… [/COLOR]

Best regards
Søren

Thank you very much, Søren.

Now, given this context, is it correct to say that I can not write my own cost function in AnyBody? In other words, AnyBody will let me change parameters within a cost function, or, switch among several available cost functions but there is no way for me to write my own cost function. Right?

Hi Vikas,

When you alter the cost function you need to stick with the different options available, you can not simply write your own equation with no strings attached.

The new option for normalization makes it possible to do a lot of different things since you can write freely a normalization factor. For the definition of this term you are free to write expressions based on values available at load time and also position related terms.

Which type of cost function are you looking to create if it is not like the one in the grand knee challenge?

Best regards
Søren

Hi Søren,

As you very well know, there are many cost functions published in the literature. At some point I may be doing a sensitivity analysis and, in that light, I wanted to have a sense of whether I will have the option of checking the effect on muscle forces due to a wide set of cost functions or not.

Apparently, I will not have that option. And that is fine; I just wanted to know a definitive answer.

Hi Vikas,

You do not have complete freedom to formulate the function this is correct, but using the search term you can still write your own expressions for normalization.

In general we strive to make the formulation of the cost function as flexible as possible while maintaining numeric efficiency :wink:

Best regards
Søren

Hi Søren,

I understand the balance that you have to keep.

Thank you,

Vikas

Dear Soren,

I tried to specify my own normalization term the ways you suggested but i get the error ‘MyNormalizationTerm’ : Unresolved object.

  1. I added the AnyVar MyNormalizationTerm to each muscle of the MusPar.any file of the leg
  2. In my Study i added:
    Main.Study.InverseDynamics.Criterion.PrimaryTerm.Nfactor_SearchName = MyNormalizationTerm;

I am using AMMR 1.6.3 and AMS 6.0.
Did i miss something?

Thanks,
Anabella