Hi Pavel,
First, I apologize for asking again and bothering you with my questions, but I spent too much time to figure out this problem and I couldn’t do it.
I just want to clarify that my problem is specifically about defining the local coordinates, and I want to emphasize that the scaling process is working well.
I used the model that you used in the webcast “Personalize your musculoskeletal model” as it is, and added the section that you send in the last post for defining the local coordinate on the tibia. ( I didn’t add anything of my own model. I used your model as it is with its own landmarks). I only added a line to draw the local coordinates on the model to see where it lands.
AnyFunTransform3D &AnthropometricScaling =...Scaling.GeometricalScaling.Right.Shank.ScaleFunction;
AnyMatrix proximal_tibial_landmarks_source = {
{0.0421311, -0.417261 , 0.0076043},
{0.0524158, -0.415519 , -0.005842},
{0.0504895, -0.417367 , 0.0029397},
{0.0231782, -0.428228 , 0.0041235},
{0.0087279, -0.437196 , 0.0308129},
{0.0352268, -0.428144 , 0.0506333},
{0.0777616, -0.42567 , 0.0306338},
{0.093775 , -0.418601 , -0.006715},
{0.073548 , -0.427378 , -0.034583},
{0.0359883, -0.429557 , -0.021760},
{0.0326333, -0.446978 , 0.0076968},
{0.073622 , -0.443837 , -0.028317},
{0.0373438, -0.446294 , -0.014700},
{0.0120185, -0.445433 , 0.0244233},
{0.0133248, -0.448197 , 0.0397956},
{0.0461639, -0.447477 , 0.0548501},
{0.0886141, -0.440804 , 0.0198169},
{0.070131 , -0.482118 , 0.0434376},
{0.0796165, -0.454165 , 0.0434672},
{0.0874448, -0.480437 , 0.0280284}};
AnyMatrix distal_tibial_landmarks_source = {
{0.082874 , -0.556316 , 0.0316961},
{0.0727126, -0.655067 , 0.0307637},
{0.0533289, -0.557545 , 0.0201804},
{0.0792458, -0.55134 , -0.001744},
{0.0742106, -0.643431 , -0.001879},
{0.0527515, -0.647375 , 0.0155517},
{0.0509596, -0.763376 , 0.0197978},
{0.0428092, -0.796114 , 0.0034402},
{0.0468567, -0.797333 , 0.0347876},
{0.0506022, -0.802705 , 0.0193561},
{0.0998085, -0.814651 , 0.0018608},
{0.0883566, -0.801911 , 0.0064930},
{0.0859482, -0.782631 , -0.011355},
{0.100225 , -0.782613 , 0.0137955},
{0.0868853, -0.75546 , 0.0179042},
{0.0771755, -0.756288 , -0.002916},
{0.07928 , -0.703497 , 0.0242642},
{0.0689144, -0.807856 , 0.0361676},
{0.0622607, -0.807041 , -0.004303}
};
AnyMatrix proximal_tibial_landmarks_target = {
{-71.6207, 30.8218 , -776.802},
{-57.3601, 30.3031 , -775.329},
{-65.837 , 26.7602 , -775.763},
{-76.4937, 44.2466 , -785.001},
{-98.9736, 39.1999 , -789.424},
{-102.512, 14.8001 , -783.359},
{-69.2545, -2.08682 , -782.556},
{-40.595 , 3.81419 , -779.137},
{-30.273 , 32.5008 , -784.674},
{-51.1075, 50.1846 , -788.474},
{-72.5643, 40.7791 , -802.373},
{-31.2547, 30.1724 , -805.641},
{-54.547 , 47.6829 , -807.104},
{-95.1286, 40.8064 , -800.465},
{-102.402, 31.5811 , -805.18},
{-98.5779, -0.192415, -797.878},
{-59.01 , -8.30906 , -798.775},
{-82.3525, -3.45649 , -822.226},
{-76.8977, -12.3271 , -806.035},
{-64.141 , -13.7685 , -817.435}};
AnyFunTransform3DLin2 RegProximalLandmarks = { // aligning proximal target bone with expected anthropometrically scaled generic bone
Points0 = 0.001*.proximal_tibial_landmarks_target;
Points1 = .AnthropometricScaling(.proximal_tibial_landmarks_source);
};
AnyMatrix P0 = arrcat(
distal_tibial_landmarks_source,
proximal_tibial_landmarks_source
);
AnyMatrix P1 = arrcat(
AnthropometricScaling(distal_tibial_landmarks_source),
RegProximalLandmarks(0.001*proximal_tibial_landmarks_target)
);
AnyFunTransform3DLin2 reg = {
PreTransforms={&.AnthropometricScaling};
Points0 = .TSeg2ScaleFrame(.P0);
Points1 = .P1;
Mode = VTK_LANDMARK_AFFINE;
};
AnyFunTransform3DRBF rbf = { // we will only use an RBF transformation, because full STL is not available
PreTransforms = {&.reg};
RBFDef.Type = RBF_Triharmonic;
PolynomDegree = 1;
Points0 = .reg.Points0;
Points1 = .reg.Points1;
BoundingBoxOnOff = On;
BoundingBox.Type = BB_Cartesian;
BoundingBox.ScaleXYZ={2,2,2}*1.2;
BoundingBox.DivisionFactorXYZ ={1,1,1}*3;
};
AnyFunTransform3DLin2 inv = {
Points0 = .reg.Points1;
Points1 = .reg.Points0;
Mode = VTK_LANDMARK_RIGIDBODY;
};
AnyFunTransform3DIdentity ScalingFunction = {
PreTransforms = {&.rbf, &.inv};
};
Main.HumanModel.BodyModel.Right.Leg.Seg.Shank = {
AnyRefNode new = {
AnyFloat posvec = Main.HumanModel.Scaling.GeometricalScaling.Right.Shank.inv({{0,0,0},{1,0,0},{0,1,0}}*1.0);
sRel = posvec[0];
ARel = RotMat(posvec[0],posvec[1],posvec[2]);
AnyDrawRefFrame new = {ScaleXYZ = {1,1,1}*0.2;RGB={0,0,1};};
};
};
The result is shown in the attached figure. The scaling was perfect. However, the newly defined tibia local coordinate was shown on the chest not at the tibia!! This is exactly the issue that i am facing for more than one month. Whenever I define a local coordinate inside the segment folder by using the inverse transformation, it appears in a different location than what I was expecting.
Can you please advise!
Best
Shady