I have a segmentation node, which is a object of type `<MRMLCorePython.vtkMRMLSegmentationNode(0xcf8dfe0) at 0x7f89a3712a00>`

So if I understand this correctly then that means it can have any number of binary segmentations attached to it.

From this segmentation node I can follow/tweak the procedure done in SegmentEditorEffect.py to get the following:

```
segmentationNode = self.scriptedEffect.parameterSetNode().GetSegmentationNode()
visibleSegmentIds = vtk.vtkStringArray()
segmentationNode.GetDisplayNode().GetVisibleSegmentIDs(visibleSegmentIds)
sourceVolumeNode = slicer.vtkMRMLScalarVolumeNode()
slicer.mrmlScene.AddNode(sourceVolumeNode)
sourceVolumeNode.SetAndObserveTransformNodeID(segmentationNode.GetTransformNodeID())
slicer.vtkSlicerSegmentationsModuleLogic.CopyOrientedImageDataToVolumeNode(self.scriptedEffect.sourceVolumeImageData(), sourceVolumeNode)
mergedLabelmapNode = slicer.vtkMRMLLabelMapVolumeNode()
slicer.mrmlScene.AddNode(mergedLabelmapNode)
slicer.vtkSlicerSegmentationsModuleLogic.ExportSegmentsToLabelmapNode(segmentationNode, visibleSegmentIds, mergedLabelmapNode, sourceVolumeNode)
labelImage = sitk.ReadImage(sitkUtils.GetSlicerITKReadWriteAddress(mergedLabelmapNode.GetName()))
labelImage_np = sitk.GetArrayFromImage(labelImage)
```

This now allows me to extract all the binary segmentations from the segmentation node and returns them all in a single 3D numpy array, where the values of the array are either 0,1,2,â€¦ with 0 meaning there is no segmentation label for that point, 1=segment_1, 2=segment_2 as so on.

This was quite a few steps to get there, but so far so good. Now with the numpy array I can do my own manipulation of these segments and get a new segmentation, which I would like to then load back into the original segmentation node. But so far I have been unable to do this correctly.

I have looked at the documentation and I see that there are some methods called

`slicer.util.arrayFromVolume`

and `updateVolumeFromArray`

, which gives the underlying numpy array for a volume, which would be the ideal case if I could do something similar for the segmentation, since that would allow direct manipulation of the numpy array, and then the nodes are automatically updated with this information if I understand correctly? but I guess nothing like this exist for the segmentation node?

So, how can I manipulate a segmentation node as a numpy array, and make sure the manipulation is also done in the segmentation node?