Operating system: Windows 10
Slicer version: 4.11.20210226
Behavior:
Using the python interactor, i’m unable to change a labelmap.
slicer.util.updateSegmentBinaryLabelmapFromArray(segmentArray, segmentationNode, segmentId)
Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘slicer.util’ has no attribute ‘updateSegmentBinaryLabelmapFromArray’
or
updateSegmentBinaryLabelmapFromArray(segmentArray, segmentationNode, segmentId)
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘updateSegmentBinaryLabelmapFromArray’ is not defined
Although ‘updateSegmentBinaryLabelmapFromArray’ is mentioned in the docs, it doesn’t seem to work. Am I missing something? import slicer and import vtk didn’t solve the issue.
Example (marking all pixels in a specific slice):
volumeNode = getNode(‘AB’)
segmentationNode = getNode(‘test’)
segmentId = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName(‘Segment_1’)
segment = segmentationNode.GetSegmentation().GetSegment(segmentId)
segmentArray = slicer.util.arrayFromSegmentBinaryLabelmap(segmentationNode, segmentId)
segmentArray[61,:,:] = 1
slicer.util.updateSegmentBinaryLabelmapFromArray(segmentArray, segmentationNode, segmentId)