3D Slicer Interactive Modules - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

3D Slicer Interactive Modules

Description:

Any Executable (even MATLAB Wrapped with Shell Script) Can Run in Separate Thread ... Can Used in Shell Scripts or Distributed Applications ... – PowerPoint PPT presentation

Number of Views:163
Avg rating:3.0/5.0
Slides: 17
Provided by: nam4
Category:

less

Transcript and Presenter's Notes

Title: 3D Slicer Interactive Modules


1
3D SlicerInteractive Modules
  • Steve Pieper, PhD

2
Review of Module Types
  • Built-In Modules
  • Few Core Features Linked to Slicer3.cxx
  • Non-Core Modules becoming Loadable
  • Loadable Modules
  • Dynamically Discovered and Loaded
  • Can Access Applications MRML Scene Instance and
    Call SlicerBaseGUI and Related APIs
    (vtkRendering, KWWidgets)
  • Scripted Modules
  • Like Loadable, but Written in Tcl or Python
  • Command Line Modules
  • Can Run as Stand Alone Executables
  • Provide Standard Command Line Parsing, which
    Allows Slicer to Generate GUI Automatically
  • Can be Compiled as Shared Library for Dynamic
    Link to Slicer

3
This Session
  • Discuss Implementation of Loadable and Scripted
    Modules
  • Module Architecture
  • Implementation Options
  • Issues to be Consider
  • Example Interactive Modules
  • Documentation
  • http//www.slicer.org/slicerWiki/index.php/Buildin
    g_a_Slicer_3_Module_GUI
  • (Linked from the developer section of slicer.org)

4
Why Interactve Modules
  • Continuous Feedback
  • Perform Calculation while Adjusting a Value
  • Responding to Render Window Events (e.g. 3D
    Widgets)
  • Periodic Updates / Animations
  • Injecting New Data
  • Connecting to Devices (e.g. OpenIGTLink)
  • Connecting to Servers (e.g. QueryAtlas, FetchMI)
  • Defining New Data Types and Storing State
  • New MRML Nodes can be Displayable (e.g. Volume or
    Model Subclasses)
  • Interaction State in Nodes is Serialized in MRML
    Scene
  • Define Multi-Step Workflows (e.g. EMSegmenter)

5
C Superclasses
  • Modules Inherit Much of their Behavior
  • Look and Feel
  • Application Settings
  • Common API, Wrapping

http//www.na-mic.org/Slicer/Documentation/Slicer3
/html/index.html
6
Classes to Implement
  • Subclasses of
  • vtkMRMLNode
  • vtkSlicerLogic
  • vtkSlicerModuleGUI
  • Default Behavior is Often Adequate
  • Follows VTK Conventions for Object Management and
    Event Handling
  • Use KWWidgets to Define GUI

7
Constructor/Destructor
  • Allocate Widgets in Constructor
  • In Destructor, Set Parent to NULL to Avoid
    Reference Deadlock (and Leaks)
  • Constructor Called at System Start
  • Enter / Exit
  • Called when Module Changes
  • Can be used to Create GUI on the Fly

8
Build GUI / TearDownGUI
  • Initialize the Module
  • Construct the Widgets and Layout of the Page
  • Rely on Slicer-Custom KWWidgets like the
    vtkSlicerNodeSelectorWidget
  • TearDownGUI (Optional) Unpacks

9
Processing Events
  • AddGUIObservers / RemoveGUIObservers
  • List Events to Watch
  • Inherited CallbackFunction CallsProcessGUIEvents
  • ProcessGUIEvents
  • Maps EventsTo Actions

10
Manipulating MRML
  • Modules Should Save Parameter State in MRML Nodes
  • Supports Undo/Redo and Serialization of
    Parameters to Scene File
  • Use of Node Selector Widgets Simplifies
    Input/Output
  • Can be Configured to Allow Creation of New Output
    Nodes or Select Existing Nodes to Overwrite
  • Typically there is a Logic Method to Apply
    Parameters using a VTK Pipeline
  • Parameters Copied from MRML Node to Processing
    Classes
  • End of Pipeline Connected to MRML Volume or Model
    Node

11
Coordinate Issues
  • MRML Volume Nodes
  • Track the IJKtoRAS Transformation Explicitly
  • Map from Pixel Space to Patient Space in
    Millimeters
  • Hold Data in vtkImageData Instance Variable
  • Origin is 0,0,0
  • Spacing is 1,1,1
  • vtkImageChangeInformation Filter is Sometimes
    Needed
  • MRML Model Nodes
  • Vertices are in RAS Millimeters
  • Optionally Copy the TransformNodeID to Put Output
    Node in Same Spot of Transformation Hierarchy as
    Input Node

12
Event Issues
  • Avoid Event Loops
  • VTK Events are Handled Synchronously (on the
    Stack)
  • Modifed Event from Node May Cause GUI to Update
  • GUI Update May Trigger Second Call to
    ProcessGUIEvents
  • Can Use Guard Variables to Only Enter
    ProcessGUIEvents Once
  • Can Perform Atomic Updates
  • node-gtDisableModifiedEventOn()
  • / set a series of parameter values /
  • node-gtDisableModifiedEventOff()
  • node-gtInvokePendingModifiedEvent()

13
Calling Other Modules
  • Interactive Modules
  • Draw on the Public API of the MRML Nodes and
    Logic
  • Command Line Modules
  • Construct Appropriate Parameter Node
  • Invoke Module in Separate Thread
  • Observe Scene Events to Check for Completion
    Status

14
Scripted Modules
  • Map C Methods to Script Code
  • Parameter Node Provides Keyword / Value Pair
    Serialization
  • Code Can Often Be Reloaded
  • Don't Need to Exit Slicer or Reload Data
  • Can Be Significant Time Savings
  • Slicer3/Modules/ScriptedModuleExample
  • in Slicer3 svn trunk, not 3.2 or Stanford
    branches
  • ScriptedModuleExampleClone Procedure
  • Creates All Files Needed for New Module

15
Example Modules
  • Modules/GradientAnisotropicDiffusion (a.k.a GAD)
    is "Prototype" Module to Review
  • Slicer3/Modules/Editor
  • Complex Module with Many Features
  • Interacts with MRML, and Volumes
  • Applies Filter Operations
  • Provides Real-Time Feedback to Mouse Events
  • Available if Python Enabled in your Slicer3 Build
  • PythonGADScriptedModule.py
  • Modules/Python has Several Examples

16
Module Considerations
  • CommandLineModule is an Interactive Module that
    Wraps and Manages the Execution Model
  • Command Line Modules
  • Simpler to Program
  • Pure ITK
  • Any Executable (even MATLAB Wrapped with Shell
    Script)
  • Can Run in Separate Thread
  • Can be Packaged as Executable or Shared Library
  • Can Used in Shell Scripts or Distributed
    Applications
  • Interactive Modules Require Greater Effort but
    have More Flexibility
Write a Comment
User Comments (0)
About PowerShow.com