Issue with version inconsistency

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! :blush:

I would recommend to update to current Slicer version and let us know if you have still have questions.

Slicer-4.10 was released several years ago. While sometimes some people volunteer to help out people who get stuck on older Slicer versions, in general we all work with and provide support for current stable or preview releases. Slicer commercial partners may be able to help with any Slicer version, but of course you need to pay for their services.