3D Slicer Architecture

Model, view, controller (MVC) is a software architecture pattern, which promotes software maintenance and re-usability. Each component is responsible for a specific aspect of the application development. The 3D Slicer platform follows this architectural pattern. In 3D Slicer, 'model', or sometimes 'data model', is referred to as 'MRML'; 'view' is the user interface, which can be command line or graphical interface made up of Qt widgets; and 'controller' is referred to as logic (VTK logic). Following best practices, module development in 3D Slicer should follow this architectural pattern.

  • Model Manages data and its attributes.
  • MRML Overview The central data representation for managing 3D Slicer data types, such as volumes, models, tranforms, fiducials, cameras etc annd their visualization
    • MRML Scene A collection of MRML nodes
      • MRML Node A component of the data structure that is capable of storing: raw data, visualization and storage parameters.
        • Attributes Analogous to variables assoicated with a MRML node.
        • References and observers The method to access a MRML node, either through refercing a specific nodes ID or observing when changes to a node occur.
  • View The visual representation of information, that defines what the user sees and interacts with.
    • Graphic User Interface The portion of a Slicer module that the user interacts with.
      • Widget One component of the GUI, for example one specific button that the user can push to trigger an event.
  • Controller Interacts with both the model and the view and controls their functionalities.
    • Logic The portion of the code that performs most of the tasks required by an algorithm.
      • VTK logic Specific portion of the logic that is written and called on to complete one task.

MRML Scene

In 3D Slicer, the MRML scene can be thought of as the workspace, consisting of everything that you interact with, including streaming data, segmentations, models, view layout, etc. In addition, the scene can include components that are not directly visualized. A scene can be saved and loaded at a later time, maintaining the same appearance, data and everything else included in the scene. The scene can also be "closed" removing the scene and providing a fresh workspace (File>close scene or via code: slicer.mrmlScene.Clear() ). All the components in the scene are called MRML nodes. In other words, the MRML scene manages MRML nodes.

MRML Nodes

A MRML nodes can be thought of as a container that holds attributes of the node and references connecting it to other nodes. There are three main node types: data nodes, display nodes, and storage nodes.

  • Data nodes stores data. For example this includes streaming ultrasound images, tracking information and transforms, models, segmented images, etc.
  • Display nodes store the visualization attributes for a data node. For visualizing the same information multiple ways, a data node can be referenced to multiple display nodes.
  • Storage node stores the file name and format for a data node. This is only created when data is loaded from or saved to the persistent storage (disk) or your computer.

Regardless of the node type, each node has the following properties.

  • Attributes can be thought of as variables of MRML nodes. For example, a data node containing an image volume could have attributes storing voxel spacing, position, or orientation. An example of an attribute for a display node is the display name. Similarly, a storage node has a file name attribute.
  • References allow nodes to interact with other nodes of any type. For example, a model node may reference a transform node in order to apply the transform to the model.
  • Events and observers describe a system in which nodes emit events that can be observed by other nodes to allow them to make the appropriate changes. For example, when a transform node is updated, it will emit an event notifying all observers (such as the models that reference it) that it has been modified.

Widget

Widgets are the building blocks or individual components of the graphic user interface. In 3D Slicer, the GUI utilizes the Qt framework that enables the design and development of cross platform (ie. Windows, Mac, and Linux) user interfaces. 3D Slicer can access all the Qt classes. In addition to all these available classes, 3D Slicer provides a selection of widgets for interacting with MRML nodes. These Slicer widgets follow the naming convention qMRML[custom name], where "custom name" differs based on the functionality of the widget.  

Logic

Logic is the bulk of the processing of any application. The logic will control the MRML nodes and the view. For example, if a button within the GUI is dedicated to streaming ultrasound clicking the button will run the logic controlling this connection. Once the connection is established, the logic can output the ultrasound stream for viewing.

  • Best development practices in 3D Slicer encourages the following naming convention for logic functions: vtk[custom logic function]Logic.
  • Any function written in the logic section of a published module can be called on and reused by other developers.