Warping With Landmarks

I’m attempting to warp a template onto a patient using a landmark. From my understanding of the 3-Matic Scripting guide, the landmark input into the warping command should be a list of three floats. When I attempt to execute the command though, I get a ValueError stating that the inputs must be convertible to a tuple with a length of 3. I don’t understand why I’m getting this error. Could I please get some help figuring out how to properly execute the warping command with landmarks?

Also, before you ask, yes I’ve tried converting the coordinate lists to tuples instead. It yields the same error.

Here is the script that I’m running:


Here is the output:
image
Here is the error message:

Thank you in advance for your assistance,

Ian

Hi Ian,

The requirement for fixed landmarks and moving_landmarks parameters is to have the point coordinates/coordinates of points in a list as below:
22-9-2021 11-12-11 AM

you can try to script as below:

fixed_landmarks = [point1.coordinates, point2.coordinates,…] # point coordinates should be in the form of tuple : (x, y, z)
moving_landmarks = [template_point1.coordinates, template_point2.coordinates,…]
trimatic.warp_part(fixed_entity=dataset, moving_entity=template, bad_countour_correspondence=True, fixed_landmarks=fixed_landmarks, moving landmarks= moving_landmarks)

Please let me know if this doesn’t work :)

Kind regards,
Imanina

Hello Imanina,

Thank you for your help. That did seem to fix that error in the script, but now I’m running into another error. The code is failing to warp the part because “at least one moving landmark could not be located on the moving entity”

Here is the code that’s producing the error. The variable “template” and all the objects in “dataset” are trimatic.Part. As you can see in line 5, I tried to prevent the error by calculating the nearest point (trimatic.compute_closest_point) on the actual template entity in question within the error, so I have no idea why it’s possible for the error to occur.

Thank you in advance for your assistance,
Ian

Hi Ian,

As we don’t have a full picture of why this problem happened, i would suggest you to check on this 2 things first:

  1. Trying creating points given as output to the compute_closest_point, just to see where they are.
  2. Check the points in the moving entity and see if the output points from the closest point are present there. To get the points you need part.get_triangles(), the first object it returns will be a list of points.

From this you can review if the points are actually exist or not, and find the root of the cause from there.

If you’re still unclear, please contact your nearest AE and we can set up a meeting to go through the issues.

Kind regards,
Imanina

Hi Imanina,

I greatly appreciate your assistance with the issue I was having. I found the cause of the error. The reason that 3-Matic couldn’t locate the moving landmark was because the script I wrote registered and scaled the moving entity after defining the moving landmark’s coordinates. I switched around a few things in the script and now it runs as expected. The new code is in the picture below.

All the best,
Ian