I have a segmentation node that I want to save on disk. In order to save it with saveNode, I need to convert it to a labelmap, but the way I convert it makes the result different:
here is how the segmentation looks like:
Here are two different ways I convert the segmentation to labelmap and result of each:
- Using “ExportAllSegmentsToLabelmapNode”
this way the labelmap is totally overlap with segmentation, and that’s what is desirable
I run this in Interactor:
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, lblmap, slicer.vtkSegmentation.EXTENT_REFERENCE_GEOMETRY)
here’s how it looks when I overlap to the segmentation shown above:
and the other way is:
- Using “ExportVisibleSegmentsToLabelmapNode”
this way the labelmap is not a full overlap with segmentation, and I don’t want this to happen, simply because it’s not true segmentation mask of all voxels.
Here is the interactor code if I want to reproduce (here ref is the reference image node):
slicer.modules.segmentations.logic().ExportVisibleSegmentsToLabelmapNode(seg, lblmap, ref)
and here’s how it looks compared to original segmentation:
It’s not clear to me why converting segmentation to labelmap should produce different results, especially that the result is unrealistic when I provide the reference image to it (which I expected the other way around).
Still that would be fine if I could use it in my code, but when I save the generated (visually looking fine) labelmap, and then load it into slicer, it seems to have incorrect position, since I see nothing overlaying image. How should I handle this?
(Slicer version: 5.0.2 r30822 / a4420c3)