NA-MIC National Alliance for Medical Image Computing Slicer 2.x Architecture Steve Pieper, PhD.

Slides:



Advertisements
Similar presentations
NA-MIC National Alliance for Medical Image Computing Slicer Tutorial Module: Segmentation May 26, 2005.
Advertisements

National Alliance for Medical Image Computing User Desktop Slicer 3.0 Architecure AlgorithmsITKVTK Slicer Modules VTK Apps Using ITK.
National Alliance for Medical Image Computing Slicer3 Architecture.
National Alliance for Medical Image Computing Slicer3 plugins Common architecture for interactive and batch processing.
National Alliance for Medical Image Computing Slicer MRML MRML Library provides API for managing medical image data types (Volumes, Models,
National Alliance for Medical Image Computing Anatomy of a plugin Common architecture for interactive and batch processing.
NA-MIC National Alliance for Medical Image Computing 3D Slicer Interactive Modules Steve Pieper, PhD.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
1 ParaView Current Architecture and History Current Architecture and History Issues with the Current Design Issues with the Current Design.
NA-MIC National Alliance for Medical Image Computing Slicer4 Guided Tour Steve Pieper, Ph.D.
NA-MIC National Alliance for Medical Image Computing Slicer Custom Modules Steve Pieper, PhD.
NA-MIC National Alliance for Medical Image Computing Interactive Editor tutorial Sonia Pujol, Ph.D. Surgical Planning Laboratory Harvard.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
NA-MIC National Alliance for Medical Image Computing IGT Software Design and Process Bill Lorensen GE Research.
3D Slicer Architecture and Implementation
NA-MIC National Alliance for Medical Image Computing NAMIC-Kit Update Will Schroeder Jim Miller Bill Lorensen.
Microsoft Visual Basic 2005: Reloaded Second Edition
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Zhonghua Qu and Ovidiu Daescu December 24, 2009 University of Texas at Dallas.
Institute of Informatics & Telecommunications – NCSR “Demokritos” TkRibbon: Windows Ribbons for Tk Georgios Petasis Software and Knowledge Engineering.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
Marcel Casado NCAR/RAP WEATHER WARNING TOOL NCAR.
NA-MIC National Alliance for Medical Image Computing Slicer4 CLI Slicer Execution Model.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
-1- 3D Visualization. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing 3D Visualization Sonia Pujol, Ph.D. Surgical.
Segmentation support in Slicer Csaba Pinter Laboratory for Percutaneous Surgery, Queen’s University, Canada.
Selected Topics in Software Engineering - Distributed Software Development.
NA-MIC National Alliance for Medical Image Computing Slicer Building and Deployment Steve Pieper, PhD.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
Sonia Pujol, PhD National Alliance for Medical Image Computing © 2010, ARR.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
NA-MIC National Alliance for Medical Image Computing ParaView Server Manager Berk Geveci Andy Cedilnik.
NA-MIC National Alliance for Medical Image Computing Slicer and ITK Raul San Jose.
Slicer3 for developers – S.Pujol -1- National Alliance for Medical Image Computing Slicer3 Course for developers Sonia Pujol, Ph.D. Surgical Planning Laboratory.
NA-MIC National Alliance for Medical Image Computing Slicer / ITK / VTK Development Tools Steve Pieper, PhD.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
NA-MIC National Alliance for Medical Image Computing Using Annotations in Slicer 4.0 Yong Zhang, Kilian Pohl June 2010.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing ©
NA-MIC National Alliance for Medical Image Computing Diffusion Tensor Imaging tutorial Sonia Pujol, PhD Surgical Planning Laboratory.
Chapter 5 Introduction to Defining Classes
9-Nov-97Tri-Ada '971 TASH An Alternative to the Windows API TRI-Ada ‘97 Terry J. Westley
August 2003 At A Glance The IRC is a platform independent, extensible, and adaptive framework that provides robust, interactive, and distributed control.
NA-MIC National Alliance for Medical Image Computing Slicer / ITK / VTK Development Tools Steve Pieper, PhD.
Creating a Java Application and Applet
NA-MIC National Alliance for Medical Image Computing 3D Slicer Modules and Extensions Steve Pieper, Ph.D.
NA-MIC National Alliance for Medical Image Computing Slicer3 Update
NA-MIC National Alliance for Medical Image Computing Slicer Architecture Steve Pieper, PhD.
National Alliance for Medical Image Computing User Desktop Slicer 3.0 Architecure AlgorithmsITKVTK Slicer Modules VTK Apps Using ITK.
National Alliance for Medical Image Computing Integrating with Slicer3.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Product Training Program
3D Visualization Sonia Pujol, Ph.D. Instructor of Radiology
3D Slicer module programming
Working in the Forms Developer Environment
Customizing custom.
Developer 2000 CSE 4504/6504 Lab.
3D Slicer Architecture and Implementation
Steve Pieper, PhD Raul San Jose, PhD Alex Yarmarkovich, PhD
In-situ Visualization using VisIt
Activities and Intents
Slicer3 Architecture.
3D Slicer Architecture and Implementation
Interactive Editor tutorial
Presentation transcript:

NA-MIC National Alliance for Medical Image Computing Slicer 2.x Architecture Steve Pieper, PhD

National Alliance for Medical Image Computing Overall Goals Data Model –Mrml Tree –Mrml Nodes –Mrml Data Module Architecture –Flow of Control, Startup Sequence –Standard Developer Widgets –GUI Modules –Editor Modules –I/O Modules Writing Custom Modules

National Alliance for Medical Image Computing Mrml Data Model Tree-structured scene description –Accessible as Mrml(dataTree) Serialized to XML file Compiled to VTK class instances in memory for display and manipulation

National Alliance for Medical Image Computing Mrml

National Alliance for Medical Image Computing Mrml XML <Volume name='all' filePattern='%s.%03d' filePrefix='labels/all' rasToIjkMatrix=' ' rasToVtkMatrix=' ' positionMatrix=' ' description='LR' colorLUT='-1' labelMap='yes' interpolate='no' window='4' level='1' lowerThreshold='0' upperThreshold='0' imageRange='1 124'>

National Alliance for Medical Image Computing Mrml XML Describes the data as it exists on disk Composes the scene by positioning data elements Retains visualization and other state parameters

National Alliance for Medical Image Computing Data Model – the Mrml Tree Mrml Tree is an in-memory data description corresponding to the mrml xml file –vtkMrmlNode subclasses contain the metadata –Mapping of metadata to run-time state is managed mainly in Tcl –vtkMrmlData subclasses are helpers for classes that need C++ help to efficiently manage runtime state

National Alliance for Medical Image Computing vtkMrmlNode

National Alliance for Medical Image Computing Mrml Nodes vtkMrmlNode abstract base class –int ID; –char *Description; –char *Options; –char *Name; –char *Title; –virtual void Write(ofstream& of, int indent); IsA vtkObject Can be subclassed in run time loadable Modules

National Alliance for Medical Image Computing vtkMrmlModelNode vtkMrmlModelNode Example Instance Variables // Strings char *ModelID; char *FileName; char *FullFileName; char *Color; // Numbers float Opacity; // Booleans int Visibility; int Clipping; int BackfaceCulling; int ScalarVisibility;

National Alliance for Medical Image Computing vtkMrmlModelNode - methods vtkMrmlModelNode -- Example Methods SetModelID with 1 arg GetModelID SetFileName with 1 arg GetFileName SetFullFileName with 1 arg GetFullFileName SetColor with 1 arg GetColor SetOpacity with 1 arg GetOpacity VisibilityOn VisibilityOff GetVisibility SetVisibility with 1 arg ClippingOn ClippingOff GetClipping SetClipping with 1 arg BackfaceCullingOn BackfaceCullingOff GetBackfaceCulling SetBackfaceCulling with 1 arg ScalarVisibilityOn ScalarVisibilityOff GetScalarVisibility SetScalarVisibility with 1 arg

National Alliance for Medical Image Computing vtkMrmlModelNode DTD XML Representation Example: DTD entry from Base/tcl/mrml20.dtd: <!ATTLIST Model name NMTOKEN "" fileName CDATA #REQUIRED color NMTOKEN "" description CDATA "" opacity NMTOKEN "1.0" visibility (yes | no) "yes" clipping (yes | no) "no" backfaceCulling (yes | no) "yes" scalarVisibility (yes | no) "no" ignore (yes | no) "no" scalarRange NMTOKENS "0 100">

National Alliance for Medical Image Computing Example Slicer Control Flow Event Manager User Module MainUpdateMRML VTK Visualization Module Modules 6

National Alliance for Medical Image Computing How Mrml Files are Read MainMrmlReadVersion2.x –In Base/tcl/tcl-main/Parse.tcl –Reads xml file and returns tcl list of nodes and values MainMrmlBuildTreesVersion2.0 –In Base/tcl/tcl-main/MainMrml.tcl –Converts list into vtkMrmlTree and vtkMrmlNode instances –Modules can define Module($m,procMRMLLoad) to extend Mrml

National Alliance for Medical Image Computing Editing the MrmlTree Examples MainMrmlAddNode –Creates a new vtkMrmlNode instance and adds it to Mrml(dataTree) and returns nodeId –Use vtkMrmlNode methods to set data Mrml(dataTree) RemoveItem $node –Remove a node Mrml(dataTree) InsertAfterItem $nodeBefore $node –Add your new node to specific spot in the hierarchy DevCreateNewCopiedVolume {Description ""} { VolName ""} –Create a copy node of existing volume with optional new name and description

National Alliance for Medical Image Computing Compiling the Mrml Tree MainUpdateMRML –In Base/tcl/tcl-main/Main.tcl –Is called after read or after changes to the Mrml Tree –Invokes Main*UpdateMRML Models, Volumes, etc Instances VTK classes, reads data, changes render properties, etc to make scene match the MRML Tree Keeps Dev* GUI elements in sync with Tree and Selections –Invokes Modules($m,procMRML) for each Module

National Alliance for Medical Image Computing Rendering To make the newly updated data visible to the user: –Render3D Redraw just the 3D view –RenderSlice Redraw slice view 0, 1, or 2 –RenderSlices Redraw all slice views –RenderAll Redraw 3D and Slices

National Alliance for Medical Image Computing Iterating Through the Mrml Tree set nitems [Mrml(dataTree) GetNumberOfItems] for {set widx 0} {$widx < $nitems} {incr widx} { set item [Mrml(dataTree) GetNthItem $widx] puts “$item is a [$item GetClassName]” }

National Alliance for Medical Image Computing Overall Module Goals Allow Independent Development of Run-Time Loadable Modules –Enforce code independence –Allow modules delivered under different licenses –Support development outside of main cvs prior to code sharing The SLICER_MODULES environment variable –Space-separated list of directories containing slicer module directory trees –Used by cmaker, launch, and tarup –Allows you to keep your own code in a distinct cvs repository/working directory, but integrate with build and distribution scripts

National Alliance for Medical Image Computing Execution Environment Slicer runs inside a VTK Tcl/Tk shell –Uses the vtk executable that gets built when Tcl wrapping is enabled for the VTK build (or the wish84.exe shell on Windows) –vtkSlicerBase is a tcl package that gets pulled in at run time –Each Module is a tcl package –Note that vtkSlicerBase and the Modules can be wrapped for other languages if desired (python, java)

National Alliance for Medical Image Computing What is a Module? C++ code (optional) –VTK Subclasses –ITK Subclasses –Extra Helper code (GSL, OpenGL, etc) Tcl code –Application Logic –User Interface Code

National Alliance for Medical Image Computing Tcl Packages / Modules Includes Tcl code to be interpreted Includes compiled C++ code as a shared library (optional) –Can reference and subclass C++ classes from other packages Package path that can be used to find module- specific logos, data, etc 3D Slicer Application Slicer BaseModule 1Module N… VTKTcl OpenGL Window System Computer Hardware Tcl packages

National Alliance for Medical Image Computing Directory Organization Modules/vtk –cxx CMakeListsLocal.txt lists the source files plus custom build directives –tcl.tcl has standard slicer entry points –builds Platform specific binary directories –Wrapping Standard tcl/java/python wrapping support –data Additional files your module needs (will be included in distribution by tarup.tcl)

National Alliance for Medical Image Computing Flow of Control Outline Base/tcl/Go.tcl is main entry point –Parse command line args –Starts tkcon console –Load vtkSlicerBase and all module packages Uses tcl ‘package require’ command –Run MainBoot

National Alliance for Medical Image Computing Anatomy of A Module See tcl.in tcl.in –For example, Custom CustomInit –Analogous to a Constructor CustomBuildGUI CustomEnter / CustomExit –When user module pane is visible/hidden Custom* –Any other “Methods” for the Module –These procs Edit the MrmlTree and call MainUpdateMRML and Render

National Alliance for Medical Image Computing The Shared Dev* Procs Base/tcl/tcl-shared/Developer.tcl –Interact with MrmlTree –Use standard look and feel conventions DevAddSelectButton –Automatically updating popup menu for Volumes, Models, etc –Adds entries when objects are created DevUpdateNodeSelectButton –Updates to currently selected DevAddButton DevAddLabel DevAddFileBrowse DevInfoWindow, DevErrorWindow, DevWarningWindow… Etc…

National Alliance for Medical Image Computing Event Management The Enter and Exit procs can be used to set up custom mouse/keyboard bindings Base/tcl/tcl-shared/Events.tcl –pushEventManager / popEventManager –Arguments are list of: Widget, event, callback

National Alliance for Medical Image Computing Event Example In EMSegmentInit: foreach s $Slice(idList) { set widget $Gui(fSl${s}Win) append EMSegment(eventManager) " \ {$widget {EMSegmentBindingCallback Sample %x %y}}” } In EMSegmentEnter: pushEventManager $EMSegment(eventManager) In EMSegmentExit: pushEventManager $EMSegment(eventManager)

National Alliance for Medical Image Computing Event Example (continued) EMSegmentBindingCallback calls EMSegmentReadGreyValue $x $y 1 In EMSegmentReadGreyValue: set s $Interactor(s) ;# get the slice window where user clicked scan [MainInteractorXY $s $x $y] "%d %d %d %d" xs ys x y ;# convert to pixels Slicer SetReformatPoint $s $x $y scan [Slicer GetIjkPoint] "%g %g %g" xIjk yIjk zIjk ;# convert to array coords set xIjk [expr int($xIjk)] set yIjk [expr int($yIjk)] set zIjk [expr int($zIjk)] # get the pixel data from the volume set ImageData [Volume($v,vol) GetOutput] set pixel [$ImageData GetScalarComponentAsDouble $xIjk $yIjk $zIjk 0]

National Alliance for Medical Image Computing Progress Bar Progress Bar on Lower part of slicer control window For a vtkProcessObject instance X x AddObserver StartEvent MainStartProgress x AddObserver ProgressEvent "MainShowProgress x" x AddObserver EndEvent MainEndProgress

National Alliance for Medical Image Computing Fiducials Example proc intensities {vol} { # Note: does not account for any transforms applied to Volume catch "m Delete" vtkMatrix4x4 m eval m DeepCopy [Volume($vol,node) GetRasToVtkMatrix] set ids [FiducialsGetPointIdListFromName default] foreach id $ids { set pt [eval m MultiplyPoint [FiducialsGetPointCoordinates $id] 1] set i [expr int([lindex $pt 0])] set j [expr int([lindex $pt 1])] set k [expr int([lindex $pt 2])] set imageData [Volume($vol,vol) GetOutput] set pixel [$imageData GetScalarComponentAsDouble $i $j $k 0] puts "fiducial $id value $pixel at $i $j $k" }

National Alliance for Medical Image Computing Reader Modules Motivation vtkMrmlVolumeNodes can be created by –User Interface –Reading in XML File –Programmatically Once the Node exists, the reader proc provides the vtkImageData when called by MainUpdateMRML

National Alliance for Medical Image Computing Reader Modules Managed by Base/tcl/tcl-modules/Volumes.tcl ReaderModule needs an entry point proc named Vol Init –For example: VolGenericInit –This will be invoked by VolumesInit ReaderModule sets –Volume(readerModules,,procGUI) to fill in type-specific controls as sub-pane of Volumes Modules – Module(Volumes,readerProc, ) so that MainUpdateMRML has a hook to call the reader when if found in the FileType attribute of a vtkMrmlVolumeNode

National Alliance for Medical Image Computing Editor Modules Motivation The Editor manages manually guided segmentation of a –source volume into a working labelmap Editor Modules add to the palette of tools Ed(editor) is an instance of vtkImageEditorEffects –Allows you to apply a filtering pipeline to modify the labelmap

National Alliance for Medical Image Computing Editor Modules Similar to Readers, these are managed by Base/tcl/tcl- modules/Editor.tcl Editor Module needs an entry point proc named Ed Init –For example: EdWatershedInit –This will be invoked by EditorInit EditorModule sets –Ed(,procGUI) to fill in type-specific controls on the this editor type’s own subframe of the editor Segmentation is done In the UI control callbacks –Create a vtk (or vtkITK-based) processing pipeline of vtkImageToImageFilter subclasses –Set parameters from UI elements or Slicer data such as Fiducial locations –call Ed(editor) Apply –Ed(editor) manages progress bar, updating label map, undo (single)

National Alliance for Medical Image Computing Conclusions Slicer provides a usable and extensible application framework for medical image computing research A significant base code provides a reference for many common coding tasks and user interface paradigms

National Alliance for Medical Image Computing Resources

NA-MIC National Alliance for Medical Image Computing Slicer Architecture Supplement Adding A New View Option Nicole Aucoin

National Alliance for Medical Image Computing Adding a new option example To add a new View option, X, to the Scene Options node so can save and restore it via Mrml file: cxx/vtkMrmlSceneOptionsNode.h –add vtkGet/SetStringMacros(ViewX) –declare char *ViewX cxx/vtkMrmlSceneOptionsNode.cxx –Add ViewX in constructor, Write, Copy, PrintSelf

National Alliance for Medical Image Computing Adding a new option, con’t tcl/tcl-main/MainView.tcl –MainViewInit: add to Module(View,presets) list, set View(X) to same default value. –Add a new proc MainViewSetX, with default arg set to default value –MainViewStorePresets: add setting X's Preset from current value –MainViewRecallPresets: add setting X from preset value

National Alliance for Medical Image Computing Adding a new option, con’t tcl/tcl-main/MainOptions.tcl –MainOptionsRetrievePresetValues: set Preset(View,n,X) from the node –MainOptionsUnparsePresets: set the node's X from the Preset

National Alliance for Medical Image Computing Adding a new option, con’t tcl/tcl-main/MainMrml.tcl: – MainMrmlBuildTreesVersion2.0: add to parsing of SceneOptions node, refer to vtkMrmlSceneOptionsNode C++ code