Can I move segments from one segmentation to another segmentation using a Script?

Capture

For example, I would like to move the body_trunc and the body_extremities to Organs.

Thanks in advance.

I think this would work

source_segmentation = getNode('BodyContour').GetSegmentation()
source_segment_id = source_segmentation.GetSegmentIdBySegmentName('body_trunc') # repeat for each segment we want to move
target_segmentation = getNode('Organs').GetSegmentation()
target_segmentation.CopySegmentFromSegmentation(source_segmentation, source_segment_id, True)

(the last parameter True is removeFromSource here)
(I don’t know if there is a data copy going on or if there is a way to avoid it)

2 Likes