I am facing an issue of segmentation node being broken when loading from a file. When I segment it and work with it, it is being displayed pretty accurately. But when I load it from a mrml file it has some extra pieces in the parts where it should be an empty pit.
Setting the segmentation node’s master representation to a closed surface representation fixes that, but it messes up the 2d view. I used the function SetSourceRepresentationToClosedSurface() to change the master/source representation.
I found two functions in the in the vtkMRMLSegmentationDisplayNode. That functions are void SetPreferredDisplayRepresentation2D(const char*) void SetPreferredDisplayRepresentation3D(const char*)
But I can’t seem to find what string I should pass in this function. There is no additional docstring in the .h file. In fact, there is no declarationg of this function in the .h file.
Rendering of the closed surface representation in slice views may have rendering artifacts if the surface is too complex. You can try to smooth and simplify the surface to avoid this.
Alternatively, you can use binary labelmap as source representation. In that case, 2D views are always correct. However, you may need to set higher resolution to preserve more details.
There is no fixed set of representation names, because any extension can specify additional representations. However, for convenience, the most commonly used representation names are available from the vtkSegmentationConverter class. For example:
You can set the segmentation higher resolution labelmap when importing a model as described here. If you confirm that this solves your problems and you cannot figure out how to achieve it using Python scripting then let us know.