Title: Integrating with Slicer3
1Integrating with Slicer3
2NA-MIC Kit Goals
- Software and Methodologies for Medical Image
Computing - Facilitate Research
- Promote Interoperability
- Stable, Cross-Platform Run Time Environment
- Full Set of Core Features
- Avoid Duplicated Effort
- Flexible Module Architecture
- Plug-ins should be As Simple As Possible
3Slicer3 data model
Provided by D. Gering
4Slicer3 Observer MVC Pattern
- MRML (Model)
- For Scene Description and Application State
- MRML Nodes are Persistent and Undoable
- Scene and Nodes are Observable
- Logic Encapsulate VTK and ITK Pipelines
(Controller) - Observe MRML to Configure Pipelines
- Help Create/Manage Nodes
- No UI Components (no Widgets, Actors, Mappers,
Renderers or RenderWindows) - GUI (View)
- Observe and Edit MRML
- Interact with User and Display Hardware
- Modules Should Follow Same Conventions
GUI
Widgets
Renderers
Edit
Observe
Logic
Observe
Edit
Observe
Edit
MRML Nodes
Observe means generic event mechanisms are
used to pass information. Edit means code can
directly call methods. Example GUI can call
methods in Logic classes,but Logic cannot call
GUI methods. MRML cannot call Logic or GUI
methods. There can be many observers for any
event.
5Variety of levels of integration
Slicer Libs ModuleDescriptionParser GenerateCLP vtkITK MRML Non-slicer specific support libraries
Slicer Base Application logic Widgets Common infrastructure for Slicer applications
Built in modules Slice viewers Models Fiducials Transforms Full access to Slicer internals
Loadable modules Query Atlas QDEC Volume rendering ChangeTracker EMSegment Full access to Slicer internals
Scripted modules Editor Teem Two Tensor Tractography VMTK Limited access to Slicer internals
Command line modules Registration Restricted access to Slicer internals
Daemon OpenIGTLink Stochastic Tractography Access to MRML
6Base Features vs. Modules
Features Base Modules
Visualization MRML Models, Volumes, Volume Rendering, Fiducials, Continuum Meshes, Labeled Data Can create custom MRML Nodes and behavior
Filtering None Implemented as Modules using ITK or other Libraries
Registration Transform Display and Edit, Save/Restore Calculate Transforms, Resample Data
Segmentation Label Maps, Parcellated Surfaces Segmentation Algorithms in ITK or other Libraries
Quantification Label, Image, Volume Statistics Numpy access to MRML Applications in Python or MATLAB
Real-time Integration VTK Rendering, KWWidgets framework, Tracker Support (as Transforms) Direct Manipulation of the MRML Scene 2D/3D Widgets Device Interfaces, OpenIGTLink Module
Diffusion Imaging DWI, DTI, Fiber Bundles Tractography, Clustering, Atlases
Applications Bundles of Modules in Distribution Registration, Editor, some Filters, Customized Extensions, Domain-specific code, Optimized Interfaces
7Each module has
an entry in the module menu
a panel of user interface controls
8Built in module
vtkMRMLNode.h
vtkSlicerModuleGUI.h
vtkSlicerModuleLogic.h
- vtkSlicerYourModuleGUI.h
- BuildGUI()
- ProcessGUIEvents()
- ProcessLogicEvents()
- ProcessMRMLEvents()
- vtkMRMLYourModuleNode.h
- GetNodeTagName()
- Copy()
- ReadXMLAttributes()
- WriteXML()
- vtkSlicerYourModuleLogic.h
- ProcessMRMLEvents()
- ProcessLogicEvents()
9Loadable module
vtkMRMLNode.h
vtkSlicerModuleGUI.h
vtkSlicerModuleLogic.h
- vtkSlicerYourModuleGUI.h
- BuildGUI()
- ProcessGUIEvents()
- ProcessLogicEvents()
- ProcessMRMLEvents()
- vtkMRMLYourModuleNode.h
- GetNodeTagName()
- Copy()
- ReadXMLAttributes()
- WriteXML()
- vtkSlicerYourModuleLogic.h
- ProcessMRMLEvents()
- ProcessLogicEvents()
- YourModule.so
- GetLoadableModuleDescription()
- GetLoadableModuleLogic()
- GetLoadableModuleGUI()
10Qt Loadable Module
vtkMRMLNode.h
qSlicerAbstractModuleWidget.h
qSlicerAbstractModuleLogic.h
- qSlicerYourModuleWidget.h
- initialize()
- showModuleAction()
- setup()
- setLogic()
- vtkMRMLYourModuleNode.h
- GetNodeTagName()
- Copy()
- ReadXMLAttributes()
- WriteXML()
- qSlicerYourModuleLogic.h
- initialize()
- setup()
qSlicerAbstractModule.h
QtPlugins
qSlicerYourModule.ui
- qSlicerYourModule.h
- showModuleAction()
- setup()
- setLogic()
Q_EXPORT_PLUGIN2(qSlicerYourModule,
qSllicerYourModule)
qSlicerYourModule.qrc
- http//wiki.slicer.org/slicerWiki/images/b/bc/QtPo
rtInSlicer.ppt
11Tcl scripted module
vtkMRMLScriptedModuleNode.h
vtkSlicerScriptedModuleGUI.h
vtkSlicerScriptedModuleLogic.h
YourModuleNode.tcl
- YourModuleGUI.tcl
- proc YourModuleBuildGUI
- proc YourModuleProcessGUIEvents
- proc YourModuleProcessLogicEvents
- proc YourModuleProcessLogicEvents
YourModuleLogic.tcl
- YourModule.tcl
- package provide YourModule x.y
12Python scripted module
vtkMRMLScriptedModuleNode.h
vtkSlicerScriptedModuleGUI.h
vtkSlicerScriptedModuleLogic.h
- YourModuleGUI.py
- def BuildGUI()
- def ProcessGUIEvents()
- def ProcessLogicEvents()
- def ProcessLogicEvents()
13Command line module
vtkMRMLCommandLineModuleNode.h
vtkCommandLineModuleGUI.h
vtkCommandLineModuleLogic.h
- YourModule.xml
- ltimagegt
- ltgeometrygt
- ltintegergt
- ltdoublegt
- ltfilegt
- YourModule.py
- XML
- def toXML()
- def Execute()
- YourModule (exe)
- YourModule xml
- YourModule.so
- XMLModuleDescription
- GetXMLModuleDescription()
- ModelEntryPoint()
or
or
14All modules are created equal
an entry in the module menu
a panel of user interface controls
15Extensions
- Keep the base package lean and mean
- Modules have individual identity
- Per-module web site, svn, downloads, mailing
lists, wiki - Allow users to assemble their own set of tools
- Customized Bundles by task or application
- Easy to download compatible extensions
- Analogous to Firefox extensions
- Integrate extension builds into
developer/nightly/release processs - NITRC Supplement to NA-MIC helping to pay for
needed infrastructure (Neuroimaging Informatics
Tools and Resources Clearinghouse) - NITRC can host neuroimaging projects (gforge
implementation)
16Extensions distribution
17Extension module
18Daemon
YourTool
slicerget.tcl name gt image.nrrd
cat image.nrrd slicerput.tcl name
19Variety of levels of integration
Slicer Libs ModuleDescriptionParser GenerateCLP vtkITK MRML Non-slicer specific support libraries
Slicer Base Application logic Widgets Common infrastructure for Slicer applications
Built in modules Slice viewers Models Fiducials Transforms Full access to Slicer internals
Loadable modules Query Atlas QDEC Volume rendering ChangeTracker EMSegment Full access to Slicer internals
Scripted modules Editor Teem Two Tensor Tractography VMTK Limited access to Slicer internals
Command line modules Registration Restricted access to Slicer internals
Daemon OpenIGTLink Stochastic Tractography Access to MRML
20By the numbers
Built-in Loadable Scripted CLI
Slicer 13 31 10 107
Extensions (17) - 2 18 26
21Future
- More Qt
- More Python, more numpy
- Interactive modules to fill gap between Loadable
Modules and Command Line Modules - Restricted access to Slicer internals
- Simple methods to control interaction and display
22Module Terminology
- 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 - Extensions
- Loadable or Command Line Modules hosted on 3rd
party site
23Loadable Modules
- http//www.slicer.org/slicerWiki/index.php/Slicer3
How_to_implement_an_Interactive_Module_GUI - http//www.slicer.org/slicerWiki/index.php/Slicer3
Loadable_ModulesHOWTO - Create vtkSlicerModuleGUI Subclass
- Override Virtual Methods for CreateGUI,
ProcessMRMLEvents, etc. - Provide Custom vtkMRMLNode Subclass(es) to
Represent, Save and Restore state - Create Logic Classes to Implement Module
Functionality - Create CMake Configuration Files to Build and
Install Shared Libraries for Runtime Discovery
and Packaging
24Scripted Modules
- A Generic ScriptedModule Module Provides Mapping
of C Method Entry Points to a Corresponding
Naming Convention for Scripts - vtkMRMLScriptedModuleNode, vtkSlicerScriptedModule
Logic, vtkSlicerScriptedModuleGUI - Scripts are Dynamically Discovered at Runtime
- A Generic ScriptedModuleNode Allows Save/Restore
of Keyword / Value Pairs to Represent Module
State - Full API of Slicer, MRML, KWWidgets, VTK,
available (except where not wrappable these APIs
have been designed for scriptability) - Editor is extensive Tcl-based Module
- Several Python examples are included in current
svn trunk - Python modules can also access Numpy routines for
Numerical processing (Volumes and other
DataArrays are directly mapped to Numpy arrays
for easy manipulation)
25Command Line Modules
- Use the GenerateCLP command (provided with
Slicer) to convert XML description of program
arguments into a C .h file - Main program of module uses PARSE_ARGS macro
provided by .h file to instance variables
corresponding to parameters defined in XML file - PARSE_ARGS also defines a --xml argument that
returns original XML string on stdout - Slicer parses the XML to create GUI for each
module - Are Covered Extensively in the HelloWorld
Tutorial - Note Command Line Modules can be written in any
language. C utilities are provided, but can be
emulated / recreated as needed.