Transform a labelmap with a transorm and save it


I have a labelmap and I’m transforming it using a transform node:


but then when I save this labelmap_node and open it later it seems like it hasn’t been transformed:

slicer.util.saveNode(lblmap_node, path)

I’ve seen threads here about hardening the transform, or exporting the node in the world coordinate system. I finally extract the segmentation out of labelmap, apply the transform of segmentation node and convert it into labelmap again:

slicer.modules.segmentations.logic().ExportVisibleSegmentsToLabelmapNode(segmentationNode, segmentationLblmap,  reference_volume_node)

It works but weiredly it cuts an area of labelmap shown in the image bellow:
instead of being like this:

Am I missing something here? I appreciate any suggestions.


I found the solution to this using transformableNode.HardenTransform().
But my question is why the shape changes after hardenning the transform? in my case the shape of fixed image is 135x300x177 and shape of moving labelmap before transfer is 135x300x189, but after setAndObserveTransform and hardening transform its shape is 141x308x192. which is something I don’t understand!!

Resample Scalar Volume worked.