Transform a labelmap with a transorm and save it

Hi,

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

lblmap_node.SetAndObserveTransformNodeID(transform_node.GetID())

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:

segmentation_node.SetAndObserveTransformNodeID(transform_node.GetID())
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:
image
instead of being like this:
image

Am I missing something here? I appreciate any suggestions.

Best,
Saeed

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.
https://discourse.slicer.org/t/resample-scalar-volumes-scripting-in-python/19736/11?u=s_arbabi