# Updating segmentation using numpy and transforms

**URL:** <https://discourse.slicer.org/t/updating-segmentation-using-numpy-and-transforms/35975>\
**Category:** Support\
**Tags:** segmentation, transforms, segmentations, segment-editor\
**Created:** [May 7, 2024, 10:34pm UTC](https://discourse.slicer.org/t/updating-segmentation-using-numpy-and-transforms/35975 "2024-05-07T22:34:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![metrobobbi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/metrobobbi/32/68912_2.png) [@metrobobbi](https://discourse.slicer.org/u/metrobobbi)\
**Post date:** [May 7, 2024, 10:34pm UTC](https://discourse.slicer.org/t/updating-segmentation-using-numpy-and-transforms/35975/1 "2024-05-07T22:34:25Z")

</div>

Hello,  
I downloaded some Contrast-enhanced CT scans and I used the Curved Planar Reformat extension in order to generate a straight volume of the aorta.  
I have the need to edit the segmentations on the straightened space and, for instance, delete the first half of the vessel.  
What I tried is the following:

```auto

straight_volume_node = slicer.util.getNode("straight_volume_node")
seg_node = slicer.util.getNode("segmenation")
straighteningTransformNode = slicer.util.getNode("straighteningTransform")

seg_node.SetAndObserveTransformNodeID(straighteningTransformNode.GetID())

aorta_array = arrayFromSegmentBinaryLabelmap(seg_node, "aorta", straight_volume_node)

#suppose the shape is (200,400,400)

aorta_array[100:,:,:] = 0

slicer.util.updateSegmentBinaryLabelmapFromArray(
                 aorta_array,
                 seg_node,
                 "aorta",
                 straight_volume_node,
             )

seg_node.SetAndObserveTransformNodeID(None)

```

However, this does not work, the segmentation is not aligned with the original volume.  
How can I fix this ?
