Measuring the moment of a single muscle to the joint

Hi zzs22500,

I would not modify AMMR but copy the to somewhere in your own model.
And then remove the line that search for all muscles and instead only search the rectus.

Best regards
Søren

Hi Søren

I don’t know how to copy them into my model,I commented out the other muscles in LegMuscleNames.any in AMMR’s LegMoments.any. But I found no change in results, where should I comment the muscles? Thank you in advance.

Best regards
zzs22500

Hi zzs22500,

Please do not change files like LegMuscleNames.any it will change results of all models running on this AMMR.

Please try something like this:

Main ={

AnyFolder MyMeasures={

AnyForceMomentMeasure2 KneeNetMomentMuscle =
{
AnyRefFrame &ref = …Seg.Thigh.KneeJoint.RotNode;
//RefPoint = &…Seg.Thigh.KneeJoint.RotNode;
IncludeSegments =
{
&…Seg.Shank, &…Seg.Foot, &…Seg.Talus
};
AnyObjectPtrArray pArrJntReactions = {
&…Jnt.PatellaMovement.Reaction
};
IncludeForces = arrcat(
ObjSearch("…Mus.Vastus* <em>", “AnyMuscle”),
ObjSearch("…TrunkMuscles.PsoasMajor.</em> ", “AnyMuscle”),
ObjSearchRecursive("…JointMuscles", “*”, “AnyMuscle”),
pArrJntReactions
);

AnyVec3 Mlocal=M*ref.Axes;
AnyVar MKneeFlexion=Mlocal[2];
};

AnyBody MyStudy ={

AnyFolder &ref=.MyMeasures;

};

};

};

Check in the ModelTree that you can see the rectus muscles listed in the Main.MyMeasures.KneeMomentMuscles.IncludedForces if not then the search term is incorrect

Best regards
Søren

Hi Søren

Thank you very much for your reply,It helped me a lot. I know modify the LegMuscleNames.any will change results of all models running on this AMMR. But I don’t understand why the modification has no effect on the result of KneeNetMomentMuscle in LowerExtremity.any. Then I added your code to LowerExtremity.any. At this time, the KneeNetMomentMuscle in the chart is the Moment of the rectus femoris muscle to the knee joint? But I still don’t understand how your code selects the rectus femoris. If I measure the Moment of the hamstring muscle, how do I modify the code?

Best regards
zzs22500

Hi zzzs22500,

The reason why it does not change anything to change the muscle list is that it is not used any longer, for finding moments.
Some versions back when it was not possible to make search functions it was needed to find moments, but this is no longer the case

This small example below will measure moment generated of vastus around knee, it can be inserted e.g. in the main file of a mocap model to test

If the moment form other muscles are needed the search can be changed.

When modifying the search ALWAYS check the object IncludeForces in the ModelTree to see if the search did find the muscles intended…if the muscle is not listed the search string was wrong.

    Main ={
      AnyFolder MyMeasures={
        
        AnyForceMomentMeasure2 KneeNetMomentMuscle =  {
          AnyRefFrame &ref =Main.HumanModel.BodyModel.Right.Leg.Seg.Thigh.KneeJoint.RotNode;
          IncludeSegments = {
            &Main.HumanModel.BodyModel.Right.Leg.Seg.Shank, 
            &Main.HumanModel.BodyModel.Right.Leg.Seg.Foot,
            &Main.HumanModel.BodyModel.Right.Leg.Seg.Talus
          };
          AnyObjectPtrArray pArrJntReactions = {
            //note that patella reaction should only be included if all muscles inserting on patella is being measured
&Main.HumanModel.BodyModel.Right.Leg.Jnt.PatellaMovement.Reaction
          };
           //Find the IncludeForces in the modeltree and check it list the muscles needed!!!
          IncludeForces = arrcat(
          ObjSearch("Main.HumanModel.BodyModel.Right.Leg.Mus.Vastus*", "AnyMuscle"),
          //      ObjSearch("Main.HumanModel.BodyModel.Trunk.MusclesSpineRight.PsoasMajor.*", "AnyMuscle"),
          //      ObjSearchRecursive("Main.HumanModel.BodyModel.Right.Leg.JointMuscles", "*", "AnyMuscle"),
          pArrJntReactions
          );
          AnyVec3 Mlocal=M*ref.Axes;
          AnyVar MKneeFlexion=Mlocal[2];
        };
       //Make a ref to the new measure in the study
        Main.Studies.InverseDynamicStudy ={   
          AnyFolder &ref=..MyMeasures;
        };
        
      };
    };

Small update please see this related post:

Note that the patella reaction needs only to be included if muscles inserting on patella is being measured

Thanks, I read the whole conversation I was also looking to solve the same issue. It helped me thanks.
Regards,
Lewis

Hi Søren

I want to use a method to measure the moment of the rectus femoris muscle on the knee joint. But I don’t know if it is correct.

I first measured the moment of the rectus femoris on the hip joint, and then divided it by the arm of force to get the force of the rectus femoris on the hip joint. At this time, the force of the rectus femoris on the knee joint should be equal to the above result, and the direction is opposite.

Then multiply this force by the arm of force of the rectus femoris muscle and the knee joint. Is this result the moment of the rectus femoris muscle to the knee joint? Any help would be greatly appreciated.

Best regards
zzs22500

Hi zzs22500,

Here are some comments:

I first measured the moment of the rectus femoris on the hip joint, and then divided it by the arm of force to get the force of the rectus femoris on the hip joint.

This should be equal to the force you can read out of the muscles as Ft, so i do not see what this gives you.

At this time, the force of the rectus femoris on the knee joint should be equal to the above result, and the direction is opposite.

Yes force in the muscle is same all the way

Then multiply this force by the arm of force of the rectus femoris muscle and the knee joint. Is this result the moment of the rectus femoris muscle to the knee joint? Any help would be greatly appreciated.

This is correct if you have the moment arm of the rectus muscle around the knee and you multiply it by its force you get the moment it creates.

The problem is to find the momentarm of the recuts muscle around the knee joint.

Rectus spans both hip and knee, which complicates the calculation of the moment arm.

We have a built in moment arm study in AMMR which can be enabled, please see

https://anyscript.org/ammr-doc/auto_examples/Validation/plot_EvaluateMomentArms.html?highlight=momentarm

This can calculate the moment arm around the knee joint, but it will assume that the hip joint is locked in a fixed position while doing this, which is not entirely correct if you have motion also in the hip joint.

So i think i would use the moment arm study tto extract the a angle versus moment arm curve then make an interpolation function in the model multiplying it by the force so something like this;

//Skecth code
//first run moment arm study and save knee angles and moment arms 
AnyFunIntePol Momentcurve ={
Type=BSpline;
T={write angle arrray here};
Data={{Wirte moment arm array here};};
};

AnyVar MomentOnJoint = MomentCurve(KneeAngle)* Muscle.Ft;

};

Best regards
Søren

Hi Søren

Thanks again for your reply. I want to know how to enable moment arm study in LowerExtremity.main.any. I have written #define EVALUATE_MOMENT_ARMS 1. But EvaluateMomentsArms in the chart after running is 0. Can you tell me how to enable moment arm evaluation study in LowerExtremity.main.any? Thank you in advance.

Best regards
zzs22500

Just a quick reply,

The evaluate moment arms creates a new study in the BodyModel folder
So you will need to enable it and find this study and run it, that will give you the moment arms.

Best regards
Søren

Hi Søren

I found the study and ran it. Can you tell me how to write the moment arm array in T and Data?I filled the T and Data with the values in parentheses. But there is always an error on the Data line. Any help would be greatly appreciate.


Best regards
zzs22500

Hi zzs22500,

The interpolation function needs to look something like this

AnyFunInterPol mymoment ={
Type=Bspline;
T= {0,3.333,6.66…};
Data= {{0.02,0.03,0.04…}};
};

Note the double curly brackets on Data.

Best regards
Søren

Hi Søren

Thank you for your reply. I have run the moment arm study and saved the knee angle and moment arm. But I got this error when I run it:ERROR(SCR.PRS11) : E:/AMMR…cap/A…0/T…s/A…p/AnyMoCapModel.any(35) : Defined at : E:/AMMR…cap/A…0/T…s/A…p/AnyMoCapModel.any(114) : ‘#include’ unexpected

This is my code. I don’t know where the problem is. I wrote this code in the main LowerExtremity.any- #include “<ANYMOCAP_MODEL>”. I don’t know if the code location is wrong or AnyVar MomentOnJoint is wrong. I hope to get your help, any help would be greatly appreciated. Thank you in advance.
AnyFunInterpol Momentcurve =
{
Type =Bspline;
T={0.0, 3.333333, 6.666666…};
Data={{-0.05683678, -0.05590267, -0.0547922…}};
};
AnyVar MomentOnJoint = Momentcurve(KneeAngle)*Main.HumanModel.BodyModel.Right.Leg.Mus.RectusFemoris1.Ft

Best regards
zzs22500

Hi zzs22500
These lines was just sample values and the by writing "…" i meant that you should add more values.

So you will need to add the real data and remove the … so e.g.


T={0.0, 3.333333, 6.666666};
Data={{-0.05683678, -0.05590267, -0.054792}};

Best regards
Søren

Hi Søren

Thank you for your quick reply. I added all the values, but I omitted a part here because there are too many. I got this error when running:ERROR(SCR.PRS11) : E:/AMMR…cap/A…0/T…s/A…p/AnyMoCapModel.any(35) : Defined at : E:/AMMR…cap/A…0/T…s/A…p/AnyMoCapModel.any(114) : ‘#include’ unexpected. I don't know if the code location is correct or the AnyVar MomentOnJoint line is wrong.

Best regards
zzs22500

In the line MomentOnJoint…. you are missing a ";" at the end of the line.

This is why it complains about the include statement which is the next line...

Best regards
Søren

Hi Søren

I am very sorry for not seeing the ";" :joy: Thank you for your reply. The line of AnyVar MomentOnJoint still seems to be a problem. How can I import the knee joint angle during the gait into the function to get the moment arm of the gait? I don't know how to write it. I got this error when I wrote like this:

ERROR(SCR.EXP0) : E:/AMMR..cap/A..0/T..s/A..p/AnyMoCapModel.any(24) : 'MomentOnJoint' : Error in expression. Please refer to the following error messages for details ...
ERROR(SCR.EXP1) : E:/AMMR..cap/A..0/T..s/A..p/AnyMoCapModel.any(24) : Operator '=' : Illegal operation for given argument types : 'AnyFloat' '=' 'AnyFloat[1]'

AnyVar MomentOnJoint=Momentcurve(Main.HumanModel.BodyModel.Interface.Right.KneeFlexion.Pos)*Main.HumanModel.BodyModel.Right.Leg.Mus.RectusFemoris1.Ft;

Best regards
zzs22500

i think the error is a missing [0] after .Pos

So it should be

AnyVar MomentOnJoint=Momentcurve(Main.HumanModel.BodyModel.Interface.Right.KneeFlexion.Pos[0])*Main.HumanModel.BodyModel.Right.Leg.Mus.RectusFemoris1.Ft;

Hi Søren

Thank you for your reply. I still got this error after adding [0]. But the error disappeared when I changed AnyVar to AnyFloat.

Best regards
zzs22500