From Slicer Wiki
Jump to: navigation, search
Home < Documentation < 4.3 < Modules < Annotations

For the latest Slicer documentation, visit the read-the-docs.

Introduction and Acknowledgements

Author(s)/Contributor(s): Nicole Aucoin (SPL, BWH), Kilian Pohl (UPenn), Daniel Haehn (UPenn), Yong Zhang (BWH), Alex Yarmarkovich (Isomics)
Acknowledgements: This work is part of the National Alliance for Medical Image Computing (NA-MIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.
Contact: Nicole Aucoin, <email></email>
Surgical Planning Laboratory (SPL)  
National Alliance for Medical Image Computing (NA-MIC)  
Neuroimage Analysis Center (NAC)  

Module Description

Use Cases

Most frequently used for these scenarios:

  • Use Case 1: using rulers to measure tumor diameters
  • Use Case 2: using ROIs to crop volume rendering


To delete multiple rulers or ROIs from a list press down the Control key and left click to select annotations in the Annotations GUI, then click on the trash can to delete them.

To move multiple rulers or ROIs from one list to another, hold down the Shift key and left click to select a group of annotations, then while still holding down the shift key, left click on the selection to drag and drop it.

Panels and their use

A list of all the panels in the interface, their features, what they mean, and how to use them.

Modify Annotation Properties
Modify Hierarchy Properties
Annotation tool bar with Markups fiducial at the bottom


     * ': 
       ** ': 
        *** ': 

Similar Modules

  • The Markups module provides support for fiducials
  • The Annotations tool bar at the top of the main Slicer window is used to add new annotations to the scene.



Information for Developers

Use the Markups module for fiducials

Fiducials have been moved to the Markups module.

Access to Ruler Locations from Python

Starting from the ID of an Annotation hierarchy node that collects a group of rulers, you can get a ruler location using the following python code:

 # get the first list of annotations
 listNodeID = "vtkMRMLAnnotationHierarchyNode2"
 annotationHierarchyNode = slicer.mrmlScene.GetNodeByID(listNodeID)
 # get the first in the list
 listIndex = 0
 annotation = annotationHierarchyNode.GetNthChildNode(listIndex).GetAssociatedNode()
 coords1 = [0,0,0]
 coords2 = [0,0,0]
 print coords1, coords2

If you have the id of the ruler node, it's more direct:

 rulerID = "vtkMRMLAnnotationRulerNode1"
 ruler = slicer.mrmlScene.GetNodeByID(rulerID)
 coords1 = [0,0,0]
 coords2 = [0,0,0]
 print coords1, coords2

Placing the GUI into Ruler or ROI Place Mode via Python

To programatically set the mouse mode to placing rulers or ROIs use this code from python:

 selectionNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSelectionNodeSingleton")
 # place rulers
 # to place ROIs use the class name vtkMRMLAnnotationROINode
 interactionNode = slicer.mrmlScene.GetNodeByID("vtkMRMLInteractionNodeSingleton")
 placeModePersistence = 1
 # mode 1 is Place, can also be accessed via slicer.vtkMRMLInteractionNode().Place


Individual annotations are transformable (able to be placed under a transform node), but lists are not. In order to apply a transform to a set of annotations, open the python console (View -> Python Interctor) and use the following code. First you'll need to get the transform node MRML id from the Data module (click on Display MRML IDs), and save it to a variable:

 transformNodeID = "vtkMRMLLinearTransformNode5"

Then get the id of the annotation hierarchy list node that holds the annotations that you wish to transform:

 listNodeID = "vtkMRMLAnnotationHierarchyNode3"

Then use this code snippet to apply the transform to all the annotations under the hierarchy node:

 annotationHierarchyNode = slicer.mrmlScene.GetNodeByID(listNodeID)
 numNodes = annotationHierarchyNode.GetNumberOfChildrenNodes()
 for i in range(numNodes):
   annotation = annotationHierarchyNode.GetNthChildNode(i).GetAssociatedNode()

Selection and interaction

This section indicates how to change in the GUI the mouse placing mode to start placing nodes.

For the selection and interaction nodes, make sure that you access the singleton nodes already in the scene (rather than making your own) via (caveat: this call works on displayable managers, you may have to go a different route to get at the application logic):

 vtkMRMLApplicationLogic *mrmlAppLogic = this->GetMRMLApplicationLogic();
 vtkMRMLInteractionNode *inode = mrmlAppLogic->GetInteractionNode();
 vtkMRMLSelectionNode *snode = mrmlAppLogic->GetSelectionNode();

If you can't get at the mrml application logic, you can get the nodes from the scene:

 vtkMRMLInteractionNode *interactionNode = vtkMRMLInteractionNode::SafeDownCast(this->GetMRMLScene()->GetNodeByID("vtkMRMLInteractionNodeSingleton"));

You can then call methods on the nodes or add your own event observers as in


You can see vtkSlicerAnnotationModuleLogic::ProcessMRMLNodesEvents to see how to respond to interaction node changes, but I don't think you'll need to do that.

Slicer4/Base/QTGUI/qSlicerMouseModeToolBar.cxx has a lot of the code you'll need as well, with a slightly different way of getting at the mrml app logic to access the nodes.

The calls you need to make to switch into placing rulers with the mouse are:


If you don't set PlaceModePersistence on the interaction node, the mouse mode/current interaction mode will automatically go back to view transform after one ruler has been placed, and you just need to reset the current interaction mode for future placing (the active place node class name is persistent).