Lesson 4: Including a custom scaling law into a musculoskeletal model

Hi,

In AMMR-public\Body\AAUHuman\LegTLEM\MusPar.any you could see that

   F0 = .StrengthScale[Segment]*.PCSAfactor*PCSA; // Maximum force output at optimum fiber length

This is the place where you have to add DesignVar if the value that you specified corresponds to the definition. But this value is a function of other parameters that affect it - so you will get the following warning: ‘Set Value’ operation on this value-object has broken symbolic dependency. (‘Reset Value’ to re-establish this dependency) .

You could also change the muscle strength by modifying values of those parameters that are used in the equation.

Kind regards,
Pavel

Hi Pavel
Many thanks for your help! the muscle strength is changed successful. thank for your advice.
I have tow question about the custom scaling:
1. I want scale the tibial bone using the custom scaling, but the bone look bad after scaling ( the attachment picture) , i dont know why? because the femoral bone was scaled good.
2. when the bone was scaled, i find the length of bone was short than the original bone, why?
could you give me some suggestions?

Hi,

  1. You may want to use a different radial basis function - try RBF_Triharmonic, i think that might work better. Or RBF_Thinplate (please check the naming in the ref. manual).
  2. Do you mean that the scaled bone is shorter than the target STL? Or that the morphed bone is shorter than the generic bone in AnyBody?

Regards,
Pavel

hi pavel

 i mean  the scaled bone is shorter than the target STL.

many thanks!

Could you make a screenshot? How did you measure the difference? I think it might be shorter only if it was not morphed correctly. Or some scaling factor is involved.

It is hard to say from what i know.

Kind regards,
Pavel

Hi Pavel

 could you tell me how to integrate the ParameterIdentification of a standing reference trial and the motion optimization of a walking gait in MotionAndParameterOptimizationModel of the MoCap_LowerBody ?
 how can i modify the lower extrimity model ? 

i want use a standing reference trial to get the segment lengths and the local coordinates of all markers in clusters placed on the thigh and shank during kinematics optimization. Then the optimal segment lengths and the local coordinates of all markers were used to as initial condition of the model to track the marker trajectories of one walking gait for caculating the joint angle. and finely, Joint angles and ground reaction forces were input to the inverse dynamic analysis to output joint forces

Many thanks!

Best wishes!

chen

Hi Chen,

Well, you need to add another parameter optimization study that will process your calibration trial and save the lengths of the segments. After that you need to run the actual parameter optimization study without optimizing segment lengths.

A good start would be to learn how the normal parameter optimization works, how the values are being written out. Learn about saving variables, etc.

Maybe you could break up the task and ask more detailed questions that seem to cause the bottleneck for you.

Kind regards,
Pavel

1 Like

Hi Pavel

  Many thanks for your answers!  i have break up the task successful, thank you for your help!

i still have a question about the custom scaling. the scaled bone is shorter than the target STL. there are not any scaling factor which are involved. i dont know where is wrong?

  the attachment file is the  screenshot.

Best Wishes!

chen

Hi Pavel

 I also found the morphed femur is lettle short than the target femur (the attachment file is the screenshot).
my morphing steps as fellowing:

first; I add the CustomScaling.any here
AnyFolder Studies ={

#include "Model\CustomScaling.any"

#if  MotionAndParameterOptimizationModel
#include "Model/Kinematics.any"  
#endif    

#if InverseDynamicModel
#include "Model/InverseDynamics.any"  
#endif    

};

the CustomScaling.any file include :

HumanModel.Scaling.GeometricalScaling = {

#define CUSTOM_SCALING_Left_Thigh
////

Left.Thigh = {

#include “MyScalingLaw.any”
};

};

second: as your saying for other learner, I make a copy of the ScalingLMF.any in MY model folder and modify HumanModel.any to use a local file, not “<ANYBODY_PATH_BODY>\ScalingLMF.any”. And inside of MY copy file I did these:
AnyFolder Thigh = {

     AnyVar LengthScale  = ...AnthroSegmentLengths.Left.ThighLength / ...StandardParameters.Left.Thigh.Length;
    AnyVar ms = ...MassScaling.Left.Thigh.MassScale;
    AnyVar ls = LengthScale;
    
    #ifdef CUSTOM_SCALING_Left_Thigh
     AnyFunTransform3D &ScaleFunction = MyScalingLaw.Transform;
    AnyFunTransform3D &TSeg2ScaleFrame = ....BodyModel.Left.Leg.Seg.Thigh.Scale.T0;
    AnyMessage scaling_message_Left_Thigh = 
    {
      TriggerPreProcess = On;
      Type = MSG_Warning;
      Message = "Custom scaling for 'Left.Thigh' segment is used! Please specify a scaling law should an 'Unresolved object' error occur";
    };           

   #else 
   
    AnyFunTransform3DLin ScaleFunction = {
      ScaleMat = {{(.ms/.ls)^0.5, 0, 0},{0, .ls, 0},{0, 0, (.ms/.ls)^0.5}};
      Offset = {0, 0, 0};
    };
 #endif  
    
  };

finally, the source femur was morphed to the target bone.
and then I use rigid-body registeration to register the target bone to the morphed bone , and found the length is not right
could you help me to point out the wrong or give a right example?

Best wishes!

Chen

Hi Chen,

Sorry for the long reply - tried to make your model work first, it did not come out of the box. Once implemented I could see your problem.

Good news is that your implementation seems to be correct. Now the bad news - I tried to visualize the used landmarks for the tibia against the source bone, it does not match. It seems that the bone geometry was exported either from a model with scaling or somehow shifted when the landmarks were selected. That seems to cause inaccuracies - i will let you check this problem. Please export the bone from an unscaled model in the local ref. frame or check the filepath to the drawing file and use this one for tests.

An excellent test is to make a simple model, where you load your bone and visualize landmarks, like this:


Main = {
  AnyFixedRefFrame testDrawing = {
    AnyDrawSurf tibia = {FileName="../../tibia";RGB={0,1,1};};
    AnyDrawPointCloud ptcl = {
      Points =     {{0.0122141,-0.442217,-0.0377735},
      {0.0141793,-0.426277,-0.0386263},
      {0.0416551,-0.451245,0.0220238},
      {0.0359463,-0.432359,0.0223423},
      {0.0584999,-0.432983,0.033011},
      {0.0540509,-0.413879,9.22658e-05},
      {0.0435347,-0.415063,-0.0126945},
      {0.0601262,-0.421991,-0.0434251},
      {0.0853385,-0.423686,-0.0217134},
      {0.0846106,-0.451423,-0.0396747},
      {0.0757759,-0.490944,-0.0416145},
      //{0.0526548,-0.602698,-0.00484032},
      //{0.0831415,-0.608437,-0.0315587},
      {0.101591,-0.78933,-0.0038602},
      {0.0518697,-0.791053,-0.0306033},
      {0.0439387,-0.790758,-0.00976694}};
    Points3D=On;PointStyle.Size=0.0025;PointStyle.Style=PointStyleSphere;RGB={1,0,0};
    };
  };
};

Typically having consistent input helps.

Kind regards,
Pavel

Hi pavel
Many thanks for your attention!
First, I have visualized the used landmarks and check the position, all points have right location.
Second, I exported the bone geometry from the MoCap model, there are not any scaling in this process
So, I realy can not found the wrong. I guess that the source bone just morphed the surface and the length was not changed.
I dont know how to explain this problem, and I send the test mode to you (peg@anybodytech.com)
Could help me check and debug it? Is it possible that the the scaling reference frame of MoCap model influence the morphing ?
Thank you again for your time and attention

Best Wishes!

chen

Hi Chen,

The MoCap model is not the right one to use - it contains some scaling. You should find a model, which uses ScalingStandard (no scaling).

Regards,
Pavel

Hi Pavel

 You are right!  Thank you very much!!

Best Wishes!

chen