New Shape - Fixed Domains C++

Hi

I am trying to use fixed domains in C++ to fit new shapes using meshes.

I have a running version in python following the ellipsoid_fd example, but based on meshes.
I can get a similar version working in C++ using: subject->set_extra_values to get a Subject fixed colomn. However, the particles do not seem to actually be fixed (see below)

The line in C++ which seems to actually result in setting fixed domains is
subject->set_fixed(true);
However this leads the program to crash within Optimize.cpp at SetFixedDomains “this->m_domain_flags = flags;” with Segmentation Fault (core dumped)

The running versions don’t seem to actually fix the particles only constrain them within a new shape model that is calculated. This can result in:

  • assignment of new particle positions to the shapes which are supposed to be fixed, resulting in a poor final shape model.
  • poor assignment of particles to the new shape, not well fitting with the previous shape model
    (it is hard to see which comes first given they are related).

It seems to be calculating a new model, with starting positions of the previously fitted points on their shapes and mean_shape_points on the new shapes - but because the new shapes are not well fitted to the mean shape it gives them undue influence in the new particle positions when this should be based on the previous model. Instead of fitting the model to these shapes, these shapes are changing the model. It would seem more accurate to start the model again initiating new points, but this defeats the purpose of having any original shape analysis and shape model saved.

Ie. I have a shape model with particles of a collection of shapes (70) and I fit a single new shape, it fits the particles but the resulting shape model in analysis is vastly different (and not anatomically plausible) to the original one - as the previously fitted particles which should be fixed are moving in the new optimization.
This is not obvious in an ellipsoid version where the shape model is simple and results in a similar appearing model when new shapes are fit.
However I can demonstrate an example using the cut ellipsoid to provide the shape model particles. The ellipsoid_ cut and ellipsoid_fd (fixed domain) both produce sensible shape models, however when using the cut shape models to fit new shapes - the particles don’t seem to be fixed and we end up with poor correspondances on the new shapes and a poor shape model at the end.

Attached python use case example of this (first run ellipsid_fd and ellipsoid_cut then the new case), and images of the results.

The use of fixed domains seems to be acting differently to it is described or have I misinterpreted along the way?
Is there a way to actually fix the particles so that new shape fitting is constrained by the previous model rather than just calculate a new model?

Thanks
Luke

ellipsoid_fd_cut.py

It looks like the problem here is that ShapeWorks assumes that you aren’t changing the number of particles when using fixed domains, but it gives no error message or failure if that assumption is not true.

In running the 3 scripts there is a mix of 32 and 128 particles. I changed them all to be 32 and everything looks fine to me: