Module 'slicer.util' has no attribute 'updateSegmentBinaryLabelmapFromArray'

Operating system: Windows 10
Slicer version: 4.11.20210226
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’


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)

Currently on readthedocs the only documentation version is

“latest” refers to the very latest Slicer Preview Release that is updated every day. Older versions are documented on the old Slicer wiki, for example

Since we plan to release the current Slicer Preview Release as the new stable version very soon, I would recommend you to switch to the latest Slicer Preview Release now.

1 Like