Tree view node types and subclassing

Hello, I am modifying the Data module (copying the widget contents to a new module and calling it another name), and would like to only show some scalar volumes on it’s tree view. For that, I could use instead of this:

subjectHierarchyTreeView.nodeTypes = ["vtkMRMLScalarVolumeNode"]

, something like this:

subjectHierarchyTreeView.nodeTypes = ["vtkMRMLScalarVolumeSubclassNode"]

I tried to subclass the vtkMRMLScalarVolumeNode:

class vtkMRMLScalarVolumeSubclassNode(slicer.vtkMRMLScalarVolumeNode):

    @staticmethod
    def GetClassName():
        return "vtkMRMLScalarVolumeSubclassNode"

and succeed in using it as a scalar volume, but it still maintains the original ClassName as show in the Data module “Node information”:

ClassName: vtkMRMLScalarVolumeNode

I don’t even know if is the right way to create a new node type, but it’s what I came with for now. I would be grateful for any clarifications on how to create subtypes of nodes.

You cannot override the class name of a C++ class in Python.

The subject hierarchy selector will have filtering capabilities based on attribute values, by until then you need to use workarounds.

For example you can choose to show nodes in a certain branch. Or use qMRMLNodeComboBox, as it can filter nodes by custom attributes.