GetNodeByClass(vtkMRMLScalarVolumeNode) returns vtkMRMLMultiVolumeNode

Hi,

I am writing a module to process dynamic nuclear medicine images and I have an issue that might be a bug.

I load 2 DICOM datasets as vtkMRMLScalarVolumeNode but another module also creates a vtkMRMLMultiVolumeNode.

If I try to filter by GetNodesByClass all 3 nodes are returned. Is this the expected behavior?

>>> slicer.mrmlScene.GetNodesByClass('vtkMRMLMultiVolumeNode').GetNumberOfItems()
1
>>> slicer.mrmlScene.GetNodesByClass('vtkMRMLScalarVolumeNode').GetNumberOfItems()
3

Tested on Slicer stable and 5.3.0-2023-02-21

Mark

What you’ve discovered is that vtkMRMLMultiVolumeNode is derived from vtkMRMLScalarVolumeNode. It is a type of vtkMRMLScalarVolumeNode.

If in your module you utilize a qMRMLNodeComboBox for selecting certain nodes in the mrml scene, you can specify to have show child nodes set to off which would exclude vtkMRMLMultiVolumeNodes from populating in this widget.

I don’t believe the GetNodesByClass method has an option to exclude child nodes from being found. Therefore you might have to do this exclusion on your own afterwards.

1 Like

Thanks,

In that case I will add a filter for ‘MultiVolume’ in GetClassName on my list of nodes.

1 Like