pearsonm
(Mark Pearson)
February 22, 2023, 12:23am
1
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.
/// bypass the property and show the node anyway.
inline void setShowHidden(bool);
inline bool showHidden()const;
/// This property controls whether subclasses of \a nodeType
/// are hidden or not. If false, only the nodes of 'final' type
/// is \a nodeType are displayed, if true, all the nodes deriving
/// from \a nodeType are visible except for the ones of
/// type \a hideChildNodeTypes.
/// true by default.
inline void setShowChildNodeTypes(bool show);
inline bool showChildNodeTypes()const;
/// If a node is a nodeType, hide the node if it is also
/// a ExcludedChildNodeType. (this can happen if nodeType is a
/// mother class of ExcludedChildNodeType)
inline void setHideChildNodeTypes(const QStringList& nodeTypes);
inline QStringList hideChildNodeTypes()const;
/// Add node type attribute that filter the nodes to
/// display. For example, colormap categories are defined with the "Category"
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.
pearsonm
(Mark Pearson)
February 22, 2023, 3:32am
3
Thanks,
In that case I will add a filter for ‘MultiVolume’ in GetClassName on my list of nodes.