Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing ©

Slides:



Advertisements
Similar presentations
Surgical Planning Laboratory -1- Brigham and Womens Hospital Slicer Tutorial 7 Saving Data Sonia Pujol, Ph.D. Randy Gollub, M.D.,
Advertisements

Pujol S, Gollub R -1- National Alliance for Medical Image Computing Stochastic Tractography Module Tri Ngo Slicer3 Training Compendium.
Slicer3 for developers – Sonia Pujol, Ph.D. -1- National Alliance for Medical Image Computing Programming into Slicer3 Sonia Pujol, Ph.D. Surgical Planning.
NA-MIC National Alliance for Medical Image Computing © 2010, All Rights Reserved Diffusion Tensor Imaging Tutorial Sonia Pujol, Ph.D.
Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing ©2010,ARR
Tokuda, J National Alliance for Medical Image Computing NA-MIC© 2010, ARR Connecting IGT Device with OpenIGTLink Junichi Tokuda, PhD Slicer3 Training Compendium.
National Alliance for Medical Image Computing © 2010, All Rights Reserved Sonia Pujol, PhD Slicer3Minute Tutorial Sonia.
National Alliance for Medical Image Computing © 2010, ARR Sonia Pujol, PhD Slicer3Minute Tutorial Slicer3 minute tutorial.
NA-MIC National Alliance for Medical Image Computing Diffusion Tensor Imaging tutorial Sonia Pujol, PhD Surgical Planning Laboratory.
NA-MIC National Alliance for Medical Image Computing © 2010, All Rights Reserved Diffusion Tensor Imaging Tutorial Sonia Pujol, Ph.D.
Data Loading & and Visualization Sonia Pujol, Ph.D. Surgical Planning Laboratory Harvard Medical School National Alliance for Medical Image Computing Neuroimage.
Slicer4Minute Tutorial Sonia Pujol, Ph.D. Surgical Planning Laboratory Harvard Medical School Slicer4Minute - Sonia Pujol, Ph.D. NA-MIC ARR
Slicer Welcome Tutorial
NA-MIC National Alliance for Medical Image Computing [Tutorial Name] [List of authors] [Institution] [ of the first author]
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Surgical Planning Laboratory -1- Brigham and Women’s Hospital Slicer Training 1 Loading and Viewing Data Sonia Pujol, Ph.D. Randy.
Pohl K, Konukoglu E -1- National Alliance for Medical Image Computing Measuring Volume Change in Tumors Kilian M Pohl, PhD Ender Konugolu Slicer3 Training.
NA-MIC National Alliance for Medical Image Computing CARMA Registration Alan Morris, Greg Gardner, Salma Bengali, Josh Cates, Rob.
NA-MIC National Alliance for Medical Image Computing CMR Toolkit Threshold Model Module Salma Bengali, Alan Morris, Josh Cates, Rob.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
NA-MIC National Alliance for Medical Image Computing CARMA Registration Salma Bengali, Alan Morris, Greg Gardner, Josh Cates, Rob.
NA-MIC National Alliance for Medical Image Computing Interactive Editor tutorial Sonia Pujol, Ph.D. Surgical Planning Laboratory Harvard.
-1- Pujol S et al. National Alliance for Medical Image Computing 3D Visualization of FreeSurfer Data Sonia Pujol, Ph.D. Silas Mann, B.Sc. Randy Gollub,
-- CTSA at RSNA 2009 PET/CT Analysis using 3D Slicer Jeffrey Yap PhD Ron Kikinis MD Wendy Plesniak PhD Slicer3 Training Compendium.
NA-MIC National Alliance for Medical Image Computing shapeAnalysisMANCOVA_Wizar d Lucile Bompard, Clement Vacher, Beatriz Paniagua, Martin.
-1- 3DSlicer Quantitative Medical Imaging Session: Quick Overview and PET/CT Analysis Jeffrey Yap, Ph.D. Ron Kikinis, M.D. Randy Gollub, M.D., Ph.D Wendy.
NA-MIC National Alliance for Medical Image Computing Fiducials Nicole Aucoin Brigham and Women's Hospital
NA-MIC National Alliance for Medical Image Computing Slicer3 and the NA-MIC kit Sonia Pujol, Ph.D. Instructor of Radiology Surgical Planning.
-1- 3D Visualization. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing 3D Visualization Sonia Pujol, Ph.D. Surgical.
Jeffrey Yap, PhD Ron Kikinis, MD Wendy Plesniak, PhD -1- CTSA at RSNA 2009 PET/CT Analysis using 3D Slicer Jeffrey Yap PhD Ron Kikinis MD Wendy Plesniak.
Surgical Planning Laboratory -1- Brigham and Women’s Hospital Slicer Training 10 EMAtlasBrainClassifier Sonia Pujol, Ph.D. Randy.
Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School -1- National Alliance for Medical Image Computing Programming into Slicer3 Sonia Pujol,
Pujol S., Plesniak, W. -1- National Alliance for Medical Image Computing Neuroimage Analysis Center Harvard CTSC Slicer3 minute tutorial Sonia Pujol, PhD.
DICOM to NRRD Conversion Tutorial Martin Styner 1 University of North Carolina Neuro Image Research and Analysis Lab.
Sonia Pujol, PhD National Alliance for Medical Image Computing © 2010, ARR.
NA-MIC National Alliance for Medical Image Computing Slicer3 Tutorial: Registration Library Case 14 Intra-subject Brain PET-MRI fusion.
PET/CT Analysis using 3D Slicer Jeffrey Yap PhD Ron Kikinis MD Wendy Plesniak PhD Slicer3 Training Compendium.
NA-MIC National Alliance for Medical Image Computing BRAINSCut General Tutorial Eun Young(Regina) Kim University of Iowa
Slicer3 for developers – S.Pujol -1- National Alliance for Medical Image Computing Slicer3 Course for developers Sonia Pujol, Ph.D. Surgical Planning Laboratory.
Surgical Planning Laboratory -1- Brigham and Women’s Hospital Slicer Training 1 Loading and Viewing Data Sonia Pujol, Ph.D. Randy.
Exploring Peritumoral White Matter Fibers for Neurosurgical Planning Sonia Pujol, Ph.D. Ron Kikinis, M.D. Surgical Planning Laboratory Harvard University.
NA-MIC National Alliance for Medical Image Computing Shape analysis using spherical harmonics Lucile Bompard, Clement Vachet, Beatriz.
NA-MIC National Alliance for Medical Image Computing Using Annotations in Slicer 4.0 Yong Zhang, Kilian Pohl June 2010.
Surgical Planning Laboratory -1- Brigham and Women’s Hospital Converting DTI data into Nrrd file format Sonia Pujol, Ph.D. Gordon.
NA-MIC National Alliance for Medical Image Computing Slicer3 Tutorial: Registration Library Case 15 AC-PC Alignment Dominik Meier, Ron.
NA-MIC National Alliance for Medical Image Computing Diffusion Tensor Imaging tutorial Sonia Pujol, PhD Surgical Planning Laboratory.
NA-MIC National Alliance for Medical Image Computing PV Antrum Cut Filter Alan Morris, Salma Bengali, Greg Gardner, Josh Cates, Rob.
-1- Massachusetts General Hospital National Alliance for Medical Image Computing Using Plastimatch for DICOM / DICOM-RT Import Gregory C. Sharp Department.
Diffusion Tensor Analysis in Slicer3
Sonia Pujol, PhD -1- National Alliance for Medical Image Computing Neuroimage Analysis Center Diffusion Tensor Imaging tutorial Sonia Pujol, Ph.D. Surgical.
Surgical Planning Laboratory -1- Brigham and Women’s Hospital 3DSlicer Hands-on session Sonia Pujol, Ph.D.
NA-MIC National Alliance for Medical Image Computing Slicer3 Tutorial Nonrigid Atlas Registration Dominik Meier, Ron Kikinis February.
-1- National Alliance for Medical Image Computing MR-guided prostate interventions using the NA-MIC Kit Danielle Pace, B.CmpH and Sota Oguro, M.D. Surgical.
Pujol S, Gollub R -1- National Alliance for Medical Image Computing Slicer3 Training Tutorial Python Stochastic Tractography Module Doug Terry, Julien.
NA-MIC National Alliance for Medical Image Computing Slicer3 Tutorial Registration Library Case 06: Breast Cancer Follow-up Dominik Meier,
NA-MIC National Alliance for Medical Image Computing BRAINSCut General Tutorial Eun Young(Regina) Kim University of Iowa
Standard Response Evaluation Criteria in Solid Tumors (RECIST) using 3D Slicer Slicer3 Training Compendium Jeffrey Yap, PhD Ron Kikinis, MD Wendy Plesniak,
Standard Response Evaluation Criteria in Solid Tumors (RECIST) using 3D Slicer Slicer3 Training Compendium Image here. Jeffrey Yap, PhD Wendy Plesniak,
National Alliance for Medical Image Computing Slicer3 Plugins Common architecture for interactive and batch processing.
NA-MIC National Alliance for Medical Image Computing Three ways to use the NA-MIC kit Sonia Pujol, Ph.D. Instructor of Radiology Surgical.
Surgical Planning Laboratory -1- Brigham and Women’s Hospital Slicer Tutorial 4 Module: DTMRI Data: Sample Slicer DTI Sonia Pujol,
3D Visualization Sonia Pujol, Ph.D. Instructor of Radiology
Fiber Bundle Volume Measurement
shapeAnalysisMANCOVA_Wizard
3D Visualization of FreeSurfer Data
The SPL Abdominal Atlas
Slicer 3 Tutorial The SPL Abdominal Atlas
Igyne Tutorial Xiaojun Chen, Ph.D.1 Jan Egger, Ph.D., Ph.D.1
Automatic SPHARM Shape Analysis in 3D Slicer
Interactive Editor tutorial
Presentation transcript:

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Programming into Slicer3: The “Hello Python” Tutorial Sonia Pujol, Ph.D. Surgical Planning Laboratory Harvard University Paul Cézanne, Moulin sur la Couleuvre à Pontoise, 1881, Staatliche Museen zu Berlin, Nationalgalerie

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR The NA-MIC Kit

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Slicer3 An end-user application for image analysis An open-source environment for software development A software platform that is both easy to use for clinical researchers and easy to extend for programmers

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Before Slicer3 Slicer2

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Programming into Slicer2 # # 1. Step # set f $fSeg.fStep1 DevAddLabel $f.lTitle "1. Select Input Channels: " WTA pack $f.lTitle -side top -padx $Gui(pad) -pady 1 -anchor w frame $f.fInput -bg $Gui(activeWorkspace)‏ pack $f.fInput -side top -padx 0 -pady 0 -anchor w foreach frame "Left Right" { frame $f.fInput.f$frame -bg $Gui(activeWorkspace)‏ pack $f.fInput.f$frame -side left -padx 0 -pady $Gui(pad) } foreach LABEL "T1 T2" Input "SPGR T2W" { DevAddLabel $f.fInput.fLeft.l$Input " ${LABEL}:" pack $f.fInput.fLeft.l$Input -side top -padx $Gui(pad) -pady 1 -anchor w set menubutton $f.fInput.fRight.m${Input}Select set menu $f.fInput.fRight.m${Input}Select.m eval {menubutton $menubutton -text [Volume($EMAtlasBrainClassifier(Volume,${Input}),node) GetName] - relief raised -bd 2 -width 9 -menu $menu} $Gui(WMBA)‏ eval {menu $menu} $Gui(WMA)‏ TooltipAdd $menubutton "Select Volume defining ${Input}" set EMAtlasBrainClassifier(mbSeg-${Input}Select) $menubutton set EMAtlasBrainClassifier(mSeg-${Input}Select) $menu # Have to update at UpdateMRML too DevUpdateNodeSelectButton Volume EMAtlasBrainClassifier Seg-${Input}Select Volume,$Input pack $menubutton -side top -padx $Gui(pad) -pady 1 -anchor w } frame $f.fAlign -bg $Gui(activeWorkspace)‏ TooltipAdd $f.fAlign "If the input T1 and T2 are not aligned with each other set flag here" pack $f.fAlign -side top -padx 0 -pady 2 -padx $Gui(pad) -anchor w DevAddLabel $f.fAlign.lAlign "Align T2 to T1? " pack $f.fAlign.lAlign -side left -padx $Gui(pad) -pady 1 -anchor w foreach value "1 0" text "On Off" width "4 4" { eval {radiobutton $f.fAlign.r$value -width $width -indicatoron 0\ -text "$text" -value "$value" -variable EMAtlasBrainClassifier(AlignInput) } $Gui(WCA)‏ pack $f.fAlign.r$value -side left -padx 0 -pady 0 }

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR From Slicer2 to Slicer3 Slicer2 Slicer3

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR The New Execution Model Demonstration Python HelloPython Slicer Developer Course 1.0 Sonia Pujol, Ph.D., Surgical Planning Laboratory, Harvard Medical School National Alliance for Medical Image Computing (NAMIC), Grant U54 EB Input/Output Input/output parameters helloPython Input Volume input 0 None Input volume helloPythonOutputVolume Output Volume output 1 None Output filtered

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Slicer3 Execution Model This course is based on the Execution Model which provides a mechanism for incorporating command line programs as Slicer modules. Jim Miller, Dan Blezek, Bill Lorensen (GE)‏ This course uses the Python interpreter that has been integrated to Slicer.

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Pre-requisite This course supposes that you have taken the following tutorial: Slicer3 Data Loading and Visualization, Sonia Pujol Ph.D. The tutorial is available on the Slicer compendium:

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Material This course requires the following material Slicer release version HelloPython.zip oftware_tutorials Disclaimer It is the responsibility of the user of 3DSlicer to comply with both the terms of the license and with the applicable laws, regulations and rules.

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR HelloPython Course Material Unzip the HelloPython.zip archive spgr.nhdr spgr.raw.gz (124 SPGR images)‏ HelloPython.py

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Overview Part A: Integration of the HelloPython.py program into Slicer3 Part B: Implementation of the Laplace operator in the HelloPython module Part C: Image Sharpening using the Laplace operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Part A: Integrating HelloPython into Slicer3

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Python Console Select Window  Python Interactor to launch the Python console of Slicer

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Python Console Slicer’s Python console

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Python Console Select File  Add Volume

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Python Console Load the dataset spgr.nhdr located in the directory HelloPython /

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Run the following code in the Python console Python Console from Slicer import slicer volume1 = slicer.MRMLScene.GetNodeByID(“vtkMRMLScalarVolumeNode1”)‏ data = volume1.GetImageData().ToArray()‏ print data

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Python Console Slicer displays the values of the spgr dataset

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR HelloPython.py Open the file HelloPython.py located in the directory HelloPython

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR HelloPython.py Module Description Module Parameters Execute function

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Module Description #!/usr/bin/env python XML = """ Demonstration Python HelloPython Slicer developer course in Python 1.0 This module was developed by Sonia Pujol, Ph.D., Harvard University. 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 EB

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Module Parameters Input/Output Input/output parameters HelloPythonInputVolume Input Volume input 0 input volume HelloPythonOutputVolume Output Volume output 1 output volume Input Volume Output Volume A file that specifies the image

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Execute Function def Execute (): Slicer = __import__("Slicer")‏ slicer = Slicer.slicer scene = slicer.MRMLScene return

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Integrating HelloPython to Slicer3 Click on the View  Application Settings in the main menu

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Integrating HelloPython to Slicer3 Select Module Settings from the Application Settings GUI

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Integrating HelloPython to Slicer3 Click on the ‘Add a preset’ button, and enter the path to HelloPython.py

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Integrating HelloPython to Slicer3 The path to the HelloPython.py executable is now set-up in Slicer3. Click on the Close to exit the Application Settings window.

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Select File  Exit and re- start Slicer Integrating HelloPython to Slicer3

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR HelloPython module Select the category ‘Demonstration’, and the module ‘Python HelloPython’ in the Modules menu

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR HelloPython Module The program ‘HelloPython’ is now integrated into Slicer3

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Part B: Implementing the Laplace* Operator *named after Pierre-Simon, Marquis de Laplace ( ) Text

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Execute Function def Execute (HelloPythonInputVolume, HelloPythonOutputVolume): Slicer = __import__("Slicer")‏ slicer = Slicer.slicer scene = slicer.MRMLScene inputVolume = scene.GetNodeByID(HelloPythonInputVolume)‏ outputVolume = scene.GetNodeByID(HelloPythonOutputVolume)‏ return Add the I/O code

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR def Execute (HelloPythonInputVolume, HelloPythonOutputVolume): Slicer = __import__("Slicer")‏ slicer = Slicer.slicer scene = slicer.MRMLScene inputVolume = scene.GetNodeByID(HelloPythonInputVolume)‏ outputVolume = scene.GetNodeByID(HelloPythonOutputVolume)‏ laplacian = slicer.vtkImageLaplacian()‏ laplacian.SetInput(inputVolume.GetImageData())‏ return Laplace Operator Add the Laplace operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Input/Output Input/output parameters HelloPythonInputVolume Input Volume input 0 input volume HelloPythonOutputVolume Output Volume output 1 output volume Hello Python Parameters Parameters of the Python Hello Python module Laplace Operator Add a new parameter group for the Laplace operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Hello Python Parameters Parameters of the Python Hello Python module dimensionality Dimensionality of the Laplace operator Dimensionality Laplace Operator Add the Laplace operator’s dimensionality

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR def Execute (HelloPythonInputVolume, HelloPythonOutputVolume, dimensionality=3): Slicer = __import__("Slicer")‏ slicer = Slicer.slicer scene = slicer.MRMLScene inputVolume = scene.GetNodeByID(HelloPythonInputVolume)‏ outputVolume = scene.GetNodeByID(HelloPythonOutputVolume)‏ laplacian = slicer.vtkImageLaplacian()‏ laplacian.SetInput(inputVolume.GetImageData()‏) laplacian.SetDimensionality(dimensionality)‏ return Laplace Operator Set-up the corresponding dimensionality parameter in the Python code

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR def Execute (HelloPythonInputVolume, HelloPythonOutputVolume, dimensionality=3): Slicer = __import__("Slicer")‏ slicer = Slicer.slicer scene = slicer.MRMLScene inputVolume = scene.GetNodeByID(HelloPythonInputVolume)‏ outputVolume = scene.GetNodeByID(HelloPythonOutputVolume)‏ laplacian = slicer.vtkImageLaplacian()‏ laplacian.SetInput(inputVolume.GetImageData()‏) laplacian.SetDimensionality(dimensionality)‏ laplacian.Update()‏ outputVolume.SetAndObserveImageData(laplacian.GetOutput())‏ return Laplace Operator Add code to get the output of the Laplace operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR def Execute (HelloPythonInputVolume, HelloPythonOutputVolume, dimensionality=3): Slicer = __import__("Slicer")‏ slicer = Slicer.slicer scene = slicer.MRMLScene inputVolume = scene.GetNodeByID(HelloPythonInputVolume)‏ outputVolume = scene.GetNodeByID(HelloPythonOutputVolume)‏ laplacian = slicer.vtkImageLaplacian()‏ laplacian.SetInput(inputVolume.GetImageData()‏) laplacian.SetDimensionality(dimensionality)‏ laplacian.Update()‏ outputVolume.SetAndObserveImageData(laplacian.GetOutput())‏ matrix = slicer.vtkMatrix4x4() inputVolume.GetIJKToRASMatrix(matrix)‏ outputVolume.SetIJKToRASMatrix(matrix) return Laplace Operator Place back the Laplacian of the image in the RAS reference system.

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Save the HelloPython.py file and exit Slicer. Integrating HelloPython to Slicer3 def Execute (HelloPythonInputVolume, HelloPythonOutputVolume, dimensionality=3): Slicer = __import__("Slicer")‏ slicer = Slicer.slicer scene = slicer.MRMLScene inputVolume = scene.GetNodeByID(HelloPythonInputVolume)‏ outputVolume = scene.GetNodeByID(HelloPythonOutputVolume)‏ laplacian = slicer.vtkImageLaplacian()‏ laplacian.SetInput(inputVolume.GetImageData()‏) laplacian.SetDimensionality(dimensionality)‏ laplacian.Update()‏ outputVolume.SetAndObserveImageData(laplacian.GetOutput())‏ matrix = slicer.vtkMatrix4x4() inputVolume.GetIJKToRASMatrix(matrix)‏ outputVolume.SetIJKToRASMatrix(matrix) return

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Part C: Image Sharpening with the Laplace Operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Running the Laplace Operator Re-start Slicer and select File  Add Volume

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Running the Laplace Operator Load the dataset spgr.nhdr located in the directory HelloPython /

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Browse to the Category ‘Demonstration’ in the Modules menu, and select the module ‘Python Hello Python’ Running the Laplace Operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Select the input volume ‘spgr.nhdr’, select the output volume ‘Create New Volume’, and click on Apply Running the Laplace Operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Slicer displays the Laplacian of the spgr image. Running the Laplace Operator

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Laplacian of the image Select the module Volumes from the main menu

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Laplacian of the image Set the Active Volume to Output Volume and adjust the Window/Level parameters

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR import Slicer volume1 = Slicer.slicer.MRMLScene.GetNodeByID(“vtkMRMLScalarVolumeNode1”)‏ volume2 = Slicer.slicer.MRMLScene.GetNodeByID(“vtkMRMLScalarVolumeNode2”)‏ plugin = Slicer.Plugin(“Subtract Images”)‏ plugin.Execute(volume1,volume2)‏ Run the following code in the Python console to subtract the Laplacian of the image to the original image Image Sharpening

National Alliance for Medical Image Computing © 2010, ARR Image Sharpening Select the module Data The subtracted image vtkMRMLScalarVolumeNodeA appears in the data tree

National Alliance for Medical Image Computing © 2010, ARR Image Sharpening Click on the links and on the eye icon to display the subtracted image vtkMRMLScalarVolumeNodeA in the viewer

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR original Laplacian filtered Laplacian Image Sharpening

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Conclusion This course demonstrates how to integrate an external program in Python within Slicer3 The Execution Model of Slicer3 provides a simple mechanism for incorporating command line programs as Slicer modules in Python.

Programming into Slicer3. Sonia Pujol, Ph.D., Harvard Medical School National Alliance for Medical Image Computing © 2010, ARR Acknowledgments National Alliance for Medical Image Computing NIH U54EB Neuroimage Analysis Center NIH P41RR013218