`CreateClosedSurfaceRepresentation()` does not work when closing a segmentation surfaces

I want to convert a model to a segmentation and close the surface, but using CreateClosedSurfaceRepresentation() doesn’t work, what’s wrong?

seg = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
seg.SetReferenceImageGeometryParameterFromVolumeNode(Vol)
slicer.modules.segmentations.logic().ImportModelToSegmentationNode(model, seg)
seg.CreateClosedSurfaceRepresentation()

(the MRBfile link…)

However, I can achieve the goal by pressing the 'make master` button in the module of segmentation…

If the original representation for the segments will be model nodes, then you can set the master representation to closed surface.

seg = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
seg.SetReferenceImageGeometryParameterFromVolumeNode(Vol)
seg.SetMasterRepresentationToClosedSurface()
slicer.modules.segmentations.logic().ImportModelToSegmentationNode(model, seg)
1 Like

Thank @Sunderlandkyl !
I used seg.SetMasterRepresentationToClosedSurface() to get the following seg. Why is the dyeing area of green slices different from that of other slices?

Probably the slicing of the surface along the coronal plane isn’t able to correctly distinguish between the inside/outside of the model.

It looks like your surface mesh is not actually a closed surface. Displaying the segmentation in 2D and converting it to a labelmap representation is likely going to have unexpected results since the algorithms cannot determine what is “inside” vs what is “outside”,

@Sunderlandkyl How to close the surface?Or tell the algorithms I want “inside” instead of “outside”???

I’m not sure if there is a easy solution to the problem of converting an open surface to a closed one.

@lassoan do you know of an approach that might work?

It is impossible to solve this problem automatically. It is better to generate a closed surface when the surface is created (e.g., enable capping when cutting the surface).

1 Like