Forums Anyscript.org  

Go Back   Forums Anyscript.org > Professional Forum > Debug model

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 03-13-2017, 02:36 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default GMFoot MoCap and RBF Scaling

New error:

Code:
ERROR(SCR.PRS1) :   D:/D..s/A..s/A..)/A..n/Beta/M..t/S..g/RBFLandmarksCalcaneus.any(2)  :   'Transform'  :  Object already declared at  : 
  D:\Documents\Anyscripts\AMMR.v1.6.2-MyDemo - Copy (2)\Application\Beta\MoCap-GMFoot\Scaling\RBFLandmarksTalus.any(2)  :  'Transform'
HumanModel.any

Code:
AnyFolder HumanModel={
  
  
  
//    // Select the body model:
//    // ----------------------
//    // This file contains a list of all body parts, select them to create
//    // the body model wanted.
//    #include  "BodyPartsSetup.any"
//    
    // This file creates the body model from the selected list.
    #include  "<ANYBODY_PATH_BODY>BodyModels\GenericBodyModelFoot\BodyModel.any"

 
 AnyFolder StrengthParameters={
    AnyVar SpecificMuscleTensionSpine= 150; //N/cm^2
    AnyVar StrengthIndexLeg= 1.53; 
    AnyVar SpecificMuscleTensionShoulderArm= 150; //N/cm^2
    
    AnyVar PlantarFasciaStiffnessCoeffPh = 0.2;
    AnyVar PlantarFasciaStiffnessCoeffMt = 0.5;
  };
  
  //Choose between scaling laws
  //#include "<ANYBODY_PATH_BODY>Scaling\ScalingUniform.any"
  //#include "<ANYBODY_PATH_BODY>Scaling\ScalingLengthMass.any" 
  //#include "<ANYBODY_PATH_BODY>Scaling\FootScaling\ScalingLengthMassFat.any" 
  //#include "<ANYBODY_PATH_BODY>\Scaling\FootScaling/ScalingLengthMassFatRBF.any"
    #include "ScalingLengthMassFatRBF.any"
    
  Scaling = {
    //This is the file which set the segments lenghts
	
    #include "AnyManRBF.any" 
	
    GeometricalScaling.Right.Foot = {#include "../Scaling/RBFLandmarksTalus.any"};
    GeometricalScaling.Right.Foot = {#include "../Scaling/RBFLandmarksCalcaneus.any"};
    
    //MorphingLandmarks = {AnyFolder &SegRef = Main.Studies.HumanModel.BodyModel.Right.Leg.Seg;};
    //#include "<ANYBODY_PATH_BODY>Scaling\FootScaling\MorphingLandmarks.any"
  };
  #include "FootType.any"
};
ScalingLengthMassFatRBF.any

Code:
// AnyFolder &Talus = Foot;
		
        AnyFolder Talus = {
        AnyVar LengthScale  = ...AnthroSegmentLengths.Right.TalusLength / ...StandardParameters.Right.Talus.Length;
        AnyVar ms = ...MassScaling.Right.Talus.MassScale;
        AnyVar ls = LengthScale;
        
        #ifndef CUSTOM_SCALING_Right_Talus
        AnyFunTransform3DLin ScaleFunction = {
          ScaleMat = {{(.ms/.ls)^0.5, 0, 0},{0, .ls, 0},{0, 0, (.ms/.ls)^0.5}} ;
          Offset = {0, 0, 0};
        };
        #else
        
        #endif
        
      };
        
		//AnyFolder &Calcaneus = Foot;
		
	  AnyFolder Calcaneus = {
        AnyVar LengthScale  = ...AnthroSegmentLengths.Right.CalcaneusLength / ...StandardParameters.Right.Calcaneus.Length;
        AnyVar ms = ...MassScaling.Right.Calcaneus.MassScale;
        AnyVar ls = LengthScale;
        
        #ifndef CUSTOM_SCALING_Right_Calcaneus
        AnyFunTransform3DLin ScaleFunction = {
          ScaleMat = {{(.ms/.ls)^0.5, 0, 0},{0, .ls, 0},{0, 0, (.ms/.ls)^0.5}} ;
          Offset = {0, 0, 0};
        };
        #else
        
        #endif
        
      };
Regards,
Zach
Reply With Quote
  #12  
Old 03-13-2017, 02:44 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 926
Default

Code:
Code:
AnyFolder HumanModel={
  
  
  
//    // Select the body model:
//    // ----------------------
//    // This file contains a list of all body parts, select them to create
//    // the body model wanted.
//    #include  "BodyPartsSetup.any"
//    
    // This file creates the body model from the selected list.
    #include  "<ANYBODY_PATH_BODY>BodyModels\GenericBodyModelFoot\BodyModel.any"

 
 AnyFolder StrengthParameters={
    AnyVar SpecificMuscleTensionSpine= 150; //N/cm^2
    AnyVar StrengthIndexLeg= 1.53; 
    AnyVar SpecificMuscleTensionShoulderArm= 150; //N/cm^2
    
    AnyVar PlantarFasciaStiffnessCoeffPh = 0.2;
    AnyVar PlantarFasciaStiffnessCoeffMt = 0.5;
  };
  
  //Choose between scaling laws
  //#include "<ANYBODY_PATH_BODY>Scaling\ScalingUniform.any"
  //#include "<ANYBODY_PATH_BODY>Scaling\ScalingLengthMass.any" 
  //#include "<ANYBODY_PATH_BODY>Scaling\FootScaling\ScalingLengthMassFat.any" 
  //#include "<ANYBODY_PATH_BODY>\Scaling\FootScaling/ScalingLengthMassFatRBF.any"
    #include "ScalingLengthMassFatRBF.any"
    
  Scaling = {
    //This is the file which set the segments lenghts
	
    #include "AnyManRBF.any" 
	
    GeometricalScaling.Right.Talus = {#include "../Scaling/RBFLandmarksTalus.any"};
    GeometricalScaling.Right.Calcaneus = {#include "../Scaling/RBFLandmarksCalcaneus.any"};
    
    //MorphingLandmarks = {AnyFolder &SegRef = Main.Studies.HumanModel.BodyModel.Right.Leg.Seg;};
    //#include "<ANYBODY_PATH_BODY>Scaling\FootScaling\MorphingLandmarks.any"
  };
  #include "FootType.any"
};
Try this.
Reply With Quote
  #13  
Old 03-13-2017, 02:47 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default GMFoot MoCap and RBF Scaling

Hi Pavel,

Code:
ERROR(SCR.PRS9) :   D:/Documents/A..s/A..)/Body/A..n/FootGM/Seg.any(223)  :   'ScaleFunction'  :  Unresolved object
Model loading skipped
Zach
Reply With Quote
  #14  
Old 03-13-2017, 03:00 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 926
Default

Main.any:
Code:
Main = {
 ...  
  #define CUSTOM_SCALING_Right_Talus
  #define CUSTOM_SCALING_Right_Calcaneus
  
  #if MotionAndParameterOptimizationModel
  #include "Model/Kinematics.any"
  #endif 
  ... 
}; //Main
ScalingLengthMassFat.any:
Code:
      AnyFolder Right ={
                
        AnyFolder Foot  = {
          AnyVar LengthScale = ...AnthroSegmentLengths.Right.FootLength / ...StandardParameters.Right.Foot.Length; 
          AnyVar WidthScale = ...AnthroSegmentLengths.Right.FootWidth / ...StandardParameters.Right.Foot.Width;
          AnyVar HeightScale = ...AnthroSegmentLengths.Right.FootHeight / ...StandardParameters.Right.Foot.Height;
          AnyVar ms = ...MassScaling.Right.Foot.MassScale;
          AnyVar ls = LengthScale;
          AnyVar ws = WidthScale;
          AnyVar hs = HeightScale;
          
          AnyFunTransform3DLin ScaleFunction = {
            ScaleMat = {{.hs, 0, 0},{0, .ls, 0},{0, 0, .ws}};
            Offset = {0, 0, 0};
          };
       };
        
       // AnyFolder &Talus = Foot;
		
       AnyFolder Talus = {
         AnyVar LengthScale  = ...AnthroSegmentLengths.Right.TalusLength / ...StandardParameters.Right.Talus.Length;
         AnyVar ms = ...MassScaling.Right.Talus.MassScale;
         AnyVar ls = LengthScale;
         
         #ifndef CUSTOM_SCALING_Right_Talus
         AnyFunTransform3DLin ScaleFunction = {
           ScaleMat = {{(.ms/.ls)^0.5, 0, 0},{0, .ls, 0},{0, 0, (.ms/.ls)^0.5}} ;
           Offset = {0, 0, 0};
         };
         #else
         
         #endif
         
       };
       AnyFolder Calcaneus = {
         AnyVar LengthScale  = ...AnthroSegmentLengths.Right.TalusLength / ...StandardParameters.Right.Talus.Length;
         AnyVar ms = ...MassScaling.Right.Talus.MassScale;
         AnyVar ls = LengthScale;
         
         #ifndef CUSTOM_SCALING_Right_Talus
         AnyFunTransform3DLin ScaleFunction = {
           ScaleMat = {{(.ms/.ls)^0.5, 0, 0},{0, .ls, 0},{0, 0, (.ms/.ls)^0.5}} ;
           Offset = {0, 0, 0};
         };
         #else
         
         #endif
         
       };
HumanModel.any:
Code:
  Scaling = {
    #include "AnyManRBF.any" 
    
      GeometricalScaling.Right.Talus = {#include "../Scaling/RBFLandmarksTalus.any"};
	GeometricalScaling.Right.Calcaneus = {#include "../Scaling/RBFLandmarksCalcaneus.any"};
  };
You will get an error that there is a circular dependency in the definition of foot scaling function, which is fair enough - this is how you specified height/length of foot in AnyManRBF.any:

Code:
  // Those two folders are used by the TD leg
  AnyFolder Right ={
    AnyVar ThighLength = Main.TrialSpecificData.Anthropometrics.ThighLength ;
    AnyVar ShankLength =Main.TrialSpecificData.Anthropometrics.ShankLength ;
    AnyVar FootLength = ...BodyModel.Right.Leg.Seg.Calcaneus.TuberCalcanei.sRel[1] - ...BodyModel.Right.Leg.Seg.DistalPhalange2.ToeTip.sRel[1]; //Back of heel (tuber calcanei) to second toe tip.
    AnyVar FootWidth = abs(...BodyModel.Right.Leg.Seg.Metatarsal5.MtPhalJoint.sRel[2] - ...BodyModel.Right.Leg.Seg.Metatarsal1.MtPhalJoint.sRel[2]); //MPjnt1 center to MPjnt5 center.
    AnyVar FootHeight = ...BodyModel.Right.Leg.Seg.Talus.AnkleJoint.sRel[0] - ...BodyModel.Right.Leg.Seg.Calcaneus.MedialProcess.sRel[0]; //vertical from base of heel (medial process) to ankle joint.
    AnyVar TalusLength = 0.03808687;
The model cannot compute distances and use them for constructing scaling functions, because it starts looping. So try using fixed values as TalusLength for now. Once you have all bones morphed - you can simply use identity matrix to redefine foot scaling function.

Kind regards,
Pavel
Reply With Quote
  #15  
Old 03-13-2017, 03:55 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default GMFoot MoCap and RBF Scaling

Hi Pavel I see, complex models require complicated solutions..

So I have been morphing the individual bones of the FreePostureGM model and nearly completed every bone in the foot. How would I start defining a matrix scaling function, is this similar to the process I have been following? If so is this essentially just combing the picked points on all the bones as one matrix?

Alternatively, Is there a way to scale a whole foot stl? I have been able to merge my individual segmented bones into one stl file see attached WholeModelMorphed.zip file - it's not perfect, but shows you what i mean.

I appreciate your time and I understand these are not easy questions Pavel.
Kind Regards,
Zach
Attached Files
File Type: zip WholeModelMorphedZW.zip (20.81 MB, 1 views)

Last edited by Zach_Welshman; 03-13-2017 at 07:57 PM. Reason: Adding information
Reply With Quote
  #16  
Old 03-15-2017, 05:12 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default GMFoot MoCap and RBF Scaling

Hi Pavel I found a solution, but i'm not sure if it is appropriate.

In the Scaling folder in MoCap-GMFoot I have changed the points picked from the SkinLandmarks to random landmarks on the GM segments to corresponding points on my foot.

Scaling folder/ RBFLandmarks.any
Code:
....

AnyFolder MorphingLandmarks = {
  
  AnyFolder &SegRef = .....BodyModel.Right.Leg.Seg;
  
  
 
  
  //Matrix of the point cloud in foot ref frame.
  AnyMatrix MorpingPointCloud0 = 
  
  FunCEx("GMfoot_picked_points_25.pp", Main.FootPrintFolderPath +"/Scaling");
//  {
//    SegRef.Calcaneus.MorphingNode1.sRel,
//    SegRef.Talus.MorphingNode4b.sRel,
//    SegRef.Calcaneus.MorphingNode2.sRel,
//    SegRef.Calcaneus.MorphingNode3.sRel,
//    SegRef.Talus.MorphingNode1b.sRel,
//    SegRef.Talus.MorphingNode2b.sRel,
//    SegRef.Talus.MorphingNode3b.sRel,
//    SegRef.Navicular.MorphingNode2.sRel,
//    SegRef.Navicular.MorphingNode1.sRel,
//    SegRef.Metatarsal5.MorphingNode1.sRel,
//    SegRef.Metatarsal1.MorphingNode1.sRel,
//    SegRef.Metatarsal3.MorphingNode1.sRel,
//    SegRef.Talus.MorphingNode5b.sRel,
//    SegRef.DistalPhalange1.MorphingNode1.sRel,
//    SegRef.DistalPhalange2.MorphingNode1.sRel,
//    SegRef.DistalPhalange5.MorphingNode1.sRel
//  };

//{{-0.005, 0.115, -0.006}, 
//  {-0.028, 0.081, 0.003}, 
//  {-0.004, 0.078, -0.035}, 
//  {-0.005, 0.084, 0.034}, 
//  {0.044, 0.118, -0.008}, 
//  {0.068, 0.06, -0.038}, 
//  {0.055, 0.077, 0.035}, 
//  {0.029, 0.023, -0.032}, 
//  {0.06, 0.012, -0.002}, 
//  {-0.01, 0.012, 0.058}, 
//  {0.002, -0.063, -0.033}, 
//  {0.035, -0.027, 0.016}, 
//  {-0.018, -0.06, 0.015}, 
//  {0.003, -0.132, 0}, 
//  {-0.005, -0.124, 0.025}, 
//  {-0.012, -0.08, 0.065}};
  
  
  
  AnyInt Size = 26;
  AnyFunEx FunCEx = 
  {
    AnyMatrix Return = {iarr(1,.Size)*0,iarr(1,.Size)*0,iarr(1,.Size)*0}';
    AnyFunExMonoPy ReadMLFile =
    {
      ModuleFile = "ReadMeshlabIn.py";
      ArgList = 
      {
        AnyStringVar filename = "";
        AnyStringVar path = "";
      };
    };
  };
  AnyMatrix MorpingPointCloud1Millimeter =  FunCEx("MBFOOT5_picked_points_25.pp", Main.FootPrintFolderPath +"/Scaling");
  
  AnyMatrix MorpingPointCloud1 =  MorpingPointCloud1Millimeter*0.001;
  
  
};//MorphingLandmarks
Thanks,
Zach
Attached Files
File Type: zip Scaling.zip (1.07 MB, 0 views)
Reply With Quote
  #17  
Old 03-15-2017, 05:14 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 926
Default

Hi Zach,

Could you elaborate what you are trying to do and why? If you have all or almost bones in the foot morphed - why would you want to morph a rigid foot?

Thanks,
Pavel
Reply With Quote
  #18  
Old 03-15-2017, 05:15 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 926
Default

I would still like to hear what you are trying to do.

Thanks,
Pavel
Reply With Quote
  #19  
Old 03-15-2017, 05:25 PM
Zach_Welshman Zach_Welshman is offline
Member
 
Join Date: Sep 2016
Posts: 38
Default GMFoot MoCap and RBF Scaling

Hi Pavel, my main goal is to analyse kinematic differences (to start with) in the segments within the GM model between flat and high arched foot types that have been systematically described through a statistical shape model.
Regards,
Zach

Last edited by Zach_Welshman; 03-15-2017 at 05:29 PM. Reason: adding information
Reply With Quote
  #20  
Old 03-15-2017, 05:36 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 926
Default

So you want to scale all bones using the same transformation? All source bones are in the same ref. frame, and the target bones are too. Yes, that could work, but it will only change the shape of the bones, it might make things easier. Effectively, instead of having many different functions - you refer to the common foot morphing function. But you would need to have all CUSTOM_SCALING_... defines

You should be careful because this morphing does not necessarily transform joint nodes into patient-specific joint nodes. Possibly you could implement a some sort of calibration analysis, where you find patient-specific joint nodes.

I looked at the morphed foot - looks like a moprhed foot Not sure how good it will be for your application. Just try.

Regards,
Pavel
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:22 PM.