Is there a way to define a custom MRML node that can be used with a module developed with the python backend?
As far as I know it is not possible to subclass C++ classes in Python. What we do in cases like yours is that we use vtkMRMLScriptedModuleNode
, a generic class for Python modules, set the module name accordingly, and use its attributes to store data (instead of properties you’d define in a C++ class).
Also it may help looking into this:
I am using the vtkMRMLScriptedModuleNode
to build a module. I am loading/creating multiple vtkMRMLMarkupsFiducialNodes
, but I also need to track other information per node. The current implementation of parameterNodeWrapper
does not integrate well with the current vtkMRMLNodes
.
Another option is to connect the different qt
objects that track the information directly to the vtkMRMLMarkupsFiducialNodes
, which seems cumbersome if possible.
It would help if you described your use case in mode detail.
You can add attributes in the nodes themselves.
I have a python module where many vtkMRMLMarkupsFiducialNodes
are loaded and created and features need to be tracked. What I would like to do is define a new class for the vtkMRMLMarkupsFiducialNodes
where the features I care about are defined as parameters of the object. The idea is for a user to use radio buttons to change which feature from a few options, so I would also like to have this class have better integration with the radio buttons themselves so when different vtkMRMLMarkupsFiducialNodes
are chosen the radio button selection moves with them.
Based on this vague description it still seems a good idea to use the Attributes of the nodes you need to store properties for.
If you insist you can subclass nodes in C++.