personalize your musculoskeletal model webcast example

Dear anyone

I have tried the example from the the Personalize musculoskeletal models webcast since my study interested in having automatic stl from CT for gait analysis.

However when I replace file in RFemurFull.any with my own or even target.stl file from scaling tutorial. When the model is loaded in 3d viewer the right femur went totally missing.

So do we need to modify Target bone in specific way?

best regard

Por

Hi Por,

Most likely you do not specify input correctly. Disappearing from the screen typically indicates unit problem. Please make sure units are the same as in provided example. Alternatively your landmarks might not be correct.

It is quite difficult to guess the reason without exposure to the code.

Regards,
Pavel

Dear Pavel

Here is the code. It could be the landmarks since one stl file is sure didnt have any landmark on. I am interested in finding the way to incoperate personalized bone from stl file into Anybody without having to find landmarks coorniate manually sinc we have lot of patient bone stl data from CT but adding landmarks one by one would not be practical.

Due to forum limit I could not up load the code but the basic code is from

http://wiki.anyscript.org/images/6/6f/Personalization_demo.zip

and I used the target bone stl from tutorial just to test

http://www.anybodytech.com/fileadmin/AnyBody/Docs/Tutorials/chap10_Scaling/Downloads/TargetFemur.stl

I change simple just change the target bone file name into in
RFemurFull.any to

// Target bone created from the same template mesh
#ifndef TARGET_FEMUR
#path TARGET_FEMUR “…/…/Data/TargetFemur.stl”
#endif

Unfortunately it is not sufficient just to change the STL. You need to employ corresponding landmarks and take care of the units. I believe the STL from the tutorials is in m, whereas the example in the webcast was in mm.

Please read the tutorials.

Kind regards,
Pavel

Thanks you so much for your reply

This might be silly question to ask but is there a way we could visualize landmarks of the source bone (aka landmarks to use for points0) from AMMR. Either print out or show in the model view window to be use as the reference for picking coresponding landmarks on CT images or the patient specific STL in meshlab ?

I am sorry I am rather new to Anybody

Hi, you can use this code:

AnyDrawPointCloud ptcl = { // read more in help
 Points = ...myPointsHere...;
 RGB={1,0,0};
 Points3D=On;
};

It needs to be defined inside of the same ref. frame as your surface object.
Regards,
Pavel

This probably simple question but it puzzled me for a few days
I have been trying to use patient specific data in my model and after obtain landmark co-ornidates which from primary test by substitute into Scaling topic tutorial 3 (just one bone morphing). I receive the error say

" ‘Points1’ : Index [1] out of range for ‘AnyFloat[1][3]’"

what could be the problem

I have following code;


AnyInputFile LL =
{
FileName = “PatientData/H”+Main.PatientData.PatientName+"_left_N.txt";
};

  // trochanter major
  AnyFloat GT = Scale * {
     {-CTResolutionX * LL.Data[1][1], CTResolutionY * LL.Data[0][1], CTResolutionZ * LL.Data[2][1]}   
  };    
  // trochanter minor
  AnyFloat  LT  = Scale * {
     {-CTResolutionX * LL.Data[1][2], CTResolutionY * LL.Data[0][2], CTResolutionZ * LL.Data[2][2]}   
  };  
// M. Gastrocnemius lateralis and medialis  

  AnyFloat GASTRL = Scale * {
     {-CTResolutionX * LL.Data[1][3], CTResolutionY * LL.Data[0][3], CTResolutionZ * LL.Data[2][3]}   
  };    
  AnyFloat GASTRM = Scale * {{-CTResolutionX * LL.Data[1][4], CTResolutionY * LL.Data[0][4], CTResolutionZ * LL.Data[2][4]}   
  };

  // Epicondyles

  AnyFloat EPIL=  Scale * {{-CTResolutionX * LL.Data[1][5], CTResolutionY * LL.Data[0][5], CTResolutionZ * LL.Data[2][5]}   
  };
  AnyFloat EPIM = Scale * {{-CTResolutionX * LL.Data[1][6], CTResolutionY * LL.Data[0][6], CTResolutionZ * LL.Data[2][6]} };   

AnyFunTransform3DLin2 GeometryTransformLin =
{
// Target points from patient specific data
Points1 =
{
// trochanter major
{.GT[0], .GT[1], .GT[2]},

  // trochanter minor
  
  {.LT[0], .LT[1], .LT[2]},
  

  // M. Gastrocnemius lateralis and medialis   
  {.GASTRL[0], .GASTRL[1], .GASTRL[2]},
  {.GASTRM[0], .GASTRM[1], .GASTRM[2]},

  // Epicondyles lateralis and medialis  
  {.EPIL[0], .EPIL[1], .EPIL[2]},
 {.EPIM[0], .EPIM[1], .EPIM[2]} 
 
};

Thank you in advance for helping me out

Hi,

I think the problem is that you are constructing column vectors and then try to manipulate them. Those should be row vectors. Please try this code,I hope it works:


PAnyInputFile LL = {
FileName = "PatientData/H"+Main.PatientData.PatientName+"_left_N.txt"; 
}; 

// trochanter major
AnyFloat GT = Scale * {-CTResolutionX * LL.Data[1][1], CTResolutionY * LL.Data[0][1], CTResolutionZ * LL.Data[2][1]}; 
// trochanter minor
AnyFloat LT = Scale * {-CTResolutionX * LL.Data[1][2], CTResolutionY * LL.Data[0][2], CTResolutionZ * LL.Data[2][2]}; 
// M. Gastrocnemius lateralis and medialis 
AnyFloat GASTRL = Scale * {-CTResolutionX * LL.Data[1][3], CTResolutionY * LL.Data[0][3], CTResolutionZ * LL.Data[2][3]}; 
AnyFloat GASTRM = Scale * {-CTResolutionX * LL.Data[1][4], CTResolutionY * LL.Data[0][4], CTResolutionZ * LL.Data[2][4]};

// Epicondyles
AnyFloat EPIL= Scale * {-CTResolutionX * LL.Data[1][5], CTResolutionY * LL.Data[0][5], CTResolutionZ * LL.Data[2][5]};
AnyFloat EPIM = Scale * {-CTResolutionX * LL.Data[1][6], CTResolutionY * LL.Data[0][6], CTResolutionZ * LL.Data[2][6]}; 

.....

AnyFunTransform3DLin2 GeometryTransformLin = 
{
// Target points from patient specific data
Points1 = { 
// trochanter major
.GT,
// trochanter minor
.LT,
// M. Gastrocnemius lateralis and medialis 
.GASTRL,
.GASTRM,
// Epicondyles lateralis and medialis 
.EPIL,
.EPIM 
};

Hi Pavel
I am sorry to bother you again but think this might benefit other who are dealing with large amount of samples ( number of patients )

I review [Webcast] - Personalize your musculoskeletal models based on medical image data and download the example code and try to incoperated into my own project however seems that function STL_size

AnyInt size = STL_Size(src, 1); // get size of the stl

from file FemurScalingFunction.auto

is self-define function would you mind share the code for it ?

Por

Hi Por,

I am not sure what you mean by self-define, but it is probably only available in the later versions of AMS. What is yours?

Possibly you can do a self-defined function using the following class: AnyFunExMonoPy
Please read the reference manual for more information

Kind regards,
Pavel

My version is 5.3.1.3556

Then you either need to update the AnyBody Modeling System, or use the alternative i suggested.

Kind regards,
Pavel

Dear Pavel

I finally could update my AMR version ( due to some admin stuff of local server issue)

I tried to run program with my own STL as the target ( file in attachment)
but it got this error
From Personalize your musculoskeletal models based on medical image data
file : FemurScalingFunction.auto
line : AnyMatrix P1 = 0.001*STL_Vertices(trg, vertices , 1);

Error in function : Vertex index should not exceed the total number of vertices

what could be the cause this ?

Hi,

Array of indices ‘vertices’ probably contains an index that is outside of the STL size range. You can use STL_Size function to find out the size of an STL.

Here is an example:


  AnyFunTransform3DLin2 rightfemurfwd = 
  {
    AnyFile src = "SourceGeometry/femur.stl";
    AnyFile tgt = SUBJECT_STL_PATH+...FemurRFileName;
    AnyInt VertNum = 1600;
    AnyInt size = STL_Size(src,1);
    AnyInt vertices = iarr(1,VertNum)*floor(size[0]/VertNum);
    AnyMatrix UnscaledPoints0 = 0.001*STL_Vertices(src, vertices, 1);
    Points0 = .TSeg2ScaleFrame(UnscaledPoints0);
    Points1 = 0.001*STL_Vertices(tgt, vertices, 1);//*{{1, 0, 0},{0, 1, 0},{0, 0, -1}};
    Mode = VTK_LANDMARK_AFFINE;

  };


Regards,
Pavel