Different results Shapeworks studio and Python

Hi,

I have a number of meshes (corresponding to bones on CT images) on which I want to apply particle optimization. When I load the meshes in the Shapeworks studio, align them using ICP (only used grooming step) and then do particle optimization, the saved local particles will match the CT images (correspond to the correct location). !!! = wanted outcome, this functions perfectly !!!

The problem that I have is that when I try to do the same in Python (first do a rigid transform as grooming step and then do the particle optimization), neither the local or world particles will match the CT images. I’ve tried several things to solve this, but can’t find the problem as I think that the same things are done as in ShapeworksStudio.

Therefore I was wondering what the problem could be. I can provide you the full code, but here is already some more inforation on the Python code:

  • The original meshes are set in Python using: subject.set_original_filenames(rel_mesh_files)
    → should correspond to the meshes I normally load into ShapeworksStudio
  • The groomed meshes are found by applying finding a rigid transformation and then saved and set as groomed meshes using: subject.set_groomed_filenames(rel_groom_files).
    → should correspond to the grooming step in ShapeworksStudio using the ICP
  • The rigid transformations are also saved and set using:
    transform = [train_rigid_transforms[i].flatten()]
    subject.set_groomed_transforms(transform)
    → defines transformation between local and world particles I think?

UPDATE:
image

After an extra check, I saw that the local particles indeed do not match the position of the original meshes when using the Python code. When using ShapeworksStudio they do.
So I guess there must be a problem doing the world to local particle transformation, but I have no idea where the problem is located.

If anyone can help, I would be very glad!

Thanks in advance

If you look at our newer python examples, you should see that while they compute the transforms that align the shapes, they do not apply them to the groomed images/meshes, they only set the transform into the ShapeWorks project.

The groomed images/meshes should remain in the original coordinate space. When the transforms are passed into the optimizer, they will be used internally as part of the local to global space transforms. Local particles will then remain in the original CT/MRI space.

Thanks for the quick response and help! Not applying the transforms, but only setting the transforms into the project seems to solve my problem.