Hello everybody!
I’m having a problem with my code when I run it in slicer v4.10.2, and it worked fine on v4.10.1.
This is the code, in which I select a segmentation (already in the scene) and convert it to a LabelmapVolumeNode. Then I take this Labelmap and obtain its voxel array.
segmentationNode = getNode('Segmentation')
try :
segmentLabelmapNode = getNode('res_map')
except:
segmentLabelmapNode = slicer.vtkMRMLLabelMapVolumeNode()
segmentLabelmapNode.SetName('res_map')
# segmentLabelmapNode = slicer.vtkMRMLLabelMapVolumeNode()
# segmentLabelmapNode.SetName('res_map')
slicer.mrmlScene.AddNode(segmentLabelmapNode)
segmentIDs = vtk.vtkStringArray()
segmentationNode.GetSegmentation().GetSegmentIDs(segmentIDs)
referenceNode = segmentationNode.GetNodeReference(slicer.vtkMRMLSegmentationNode.GetReferenceImageGeometryReferenceRole())
slicer.modules.segmentations.logic().ExportSegmentsToLabelmapNode(segmentationNode, segmentIDs, segmentLabelmapNode, referenceNode)
voxelArray = slicer.util.arrayFromVolume(segmentLabelmapNode)
As said, it perfectly works with v4.10.1, but in version 4.10.2 this error pops-up:
File "C:\Program Files\Slicer 4.10.2\bin\Python\slicer\util.py", line 798, in arrayFromVolume
nshape = tuple(reversed(volumeNode.GetImageData().GetDimensions()))
AttributeError: 'NoneType' object has no attribute 'GetDimensions'
Referring to the line where the voxelArray is created. Is there any difference between versions that I’m not aware of? The API documentation I used as a reference was this: Slicer API v4.10.
Thanks in advance!