I’m in python and when I create a volume rendering for a scalar volume node using UpdateDisplayNodeFromVolumeNode from modules.volumerendering.logic, the AnnotationROINode is created automatically.
I want to rename the default AnnotationROINode so that when I work with many volumes their ROI nodes are clearly identifiable in the Subject Hierarchy view.
I use this snippet from the docs to create the volume rendering:
I can see the connection to the AnnotationROI in the Data module if I select the Volume Node.
How do I see this link from python? Is there a way to access the AnnotationROINode without searching for it explicitly by id, name or classname?
Thanks @pieper, I’ve tried calling the UpdateDisplayNodeFromVolumeNode but it appeared to me that it didn’t change anything in the scene and when I tried to turn on volume rendering from the UI the “AnnotationROI_3” still appeared.
As another similar workaround I’ve used for now is creating, naming and registering the node manually using the code like in the attached snippet. I probably miss attaching the roi to the volume because despite that the volume rendering works as expected I create these nodes manually I can’t see the “link” in the data module widget.
I’ve seen that the AnnotationROINode has a .GetVolumeNodeID method that should “Get/Set for the volume node ID associated with this ROI” but it’s empty by default. Do I need to use the setter here to link the ROI with the volume?
Note that we are phasing out Annotations module. If you are building anything new then you may consider using markups ROI instead of annotations ROI. Markups ROI has a number of important advantages, such as you can rotate it without applying a transform.
Probably we will remove annotations module in a year or so. You can find markups manipulation examples in the script repository and we can add more examples as questions are asked.
Yes, that’s why we remove annotations module slowly, in several phases. We have already stopped developing and fixing Annotations module and stated that the module is deprecated. Next step is to update all core modules and extensions to support markups as well, then change modules to create markups node instead by default, then hide Annotations module GUI, and finally remove the module completely. The last step will probably only happen in a few years when some Slicer changes would require too much work to keep Annotations module working. See current plan in the Roadmap.