1 / 22

Slicer and ITK

Slicer and ITK. Steve Pieper, PhD Raul San Jose, PhD Alex Yarmarkovich, PhD. Overview. Embedding ITK vtkITK framework Filtering Example Generic Reader Example. How to use ITK?. “Conventional Way”: Develop your own application. My application. Rendering Library. GUI. My Algorithm.

maren
Télécharger la présentation

Slicer and ITK

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Slicer and ITK Steve Pieper, PhD Raul San Jose, PhD Alex Yarmarkovich, PhD

  2. Overview • Embedding ITK • vtkITK framework • Filtering Example • Generic Reader Example

  3. How to use ITK? • “Conventional Way”: Develop your own application My application Rendering Library GUI My Algorithm My classes ITK pipeline

  4. How to use ITK? • “Embedding”: Develop inside your platform (Slicer way) My platform Rendering Module (vtk) GUI Module ITK Pipeline Core Library (vtk) Library wrappers ITK

  5. vtkImageExport vtkImageImport Slicer and ITK • Data Flow: VTK – ITK – VTK VTK VTK ITK itk::VTKImageImport itk::VTKImageExport

  6. vtkITKMyFilter VTK VTK ITK itk::VTKImageImport vtkImageExport vtkImageImport itk::MyFilter itk::VTKImageExport vtkITK: Overview

  7. vtkITK: Base classes vtkITKImageToImageFilter2DFF vtkImageToImageFilter vtkITKImageToImageFilterUSUS vtkITKImageToImageFilterF2F2 vtkITKImageToImageFilter vtkITKMyFilter vtkITKImageToImageFilterF3F3 vtkImageExport vtkImageImport vtkITKImageToImageFilterFF itk::VTKImageExport<itk::Image<float>,3>> itk::VTKImageImport<itk::Image<float>,3>>

  8. vtkITK: Example • Case: Perform a edge-preserving filtering as a preprocessing before segmentation. • Algorithm: Anisotropic diffusion process. • Code: itk::GradientAnisotropicDiffusionImageFilter. • http://www.itk.org/Doxygen16/html/classitk_1_1GradientAnisotropicDiffusionImageFilter.html

  9. vtkITK: Wrapping #include "vtkITKImageToImageFilterFF.h" #include "itkGradientAnisotropicDiffusionImageFilter.h" #include "vtkObjectFactory.h" class VTK_EXPORT vtkITKGradientAnisotropicDiffusionImageFilter : public vtkITKImageToImageFilterFF { public: static vtkITKGradientAnisotropicDiffusionImageFilter *New(); vtkTypeRevisionMacro(vtkITKGradientAnisotropicDiffusionImageFilter, vtkITKImageToImageFilterFF);

  10. vtkITK: Wrapping void SetConductanceParameter ( double value ) { DelegateITKInputMacro ( SetConductanceParameter, value ); }; double GetConductanceParameter () { DelegateITKOutputMacro(GetConductanceParameter) ; }; double GetTimeStep () { DelegateITKOutputMacro(GetTimeStep) ; }; m_Filter.GetPointer()->SetConductanceParameter(value)

  11. vtkITK: Wrapping protected: //BTX typedef itk::GradientAnisotropicDiffusionImageFilter<Superclass::InputImageType, Superclass::InputImageType> ImageFilterType; vtkITKGradientAnisotropicDiffusionImageFilter() : Superclass ( ImageFilterType::New() ){}; ~vtkITKGradientAnisotropicDiffusionImageFilter() {}; ImageFilterType* GetImageFilterPointer() { return dynamic_cast<ImageFilterType*> ( m_Filter.->GetPointer() ); //ETX private: vtkITKGradientAnisotropicDiffusionImageFilter(const vtkITKGradientAnisotropicDiffusionImageFilter&); // Not implemented. void operator=(const vtkITKGradientAnisotropicDiffusionImageFilter&); // Not implemented. }; vtkStandardNewMacro(vtkITKGradientAnisotropicDiffusionImageFilter);

  12. Slicer Module ITKFilters.tcl • Modules methods: core methods • procITKFiltersInit • procITKFiltersBuildGUI • procITKFiltersBuildVTK • procITKFiltersEnter • procITKFiltersExit • Other methods: callback methods • procITKFiltersApply • …..

  13. Slicer Module procITKFiltersInit set m ITKFilters set Module($m,author) “NAMIC people" set Module($m,row1List) "Help Main" set Module($m,row1Name) "{Help} {Main}" set Module($m,row1,tab) Main set Module($m,procGUI) ITKFiltersBuildGUI set Module($m,procVTK) ITKFiltersBuildVTK set Module($m,procMRML) ITKFiltersUpdateGUI set Module($m,procEnter) ITKFiltersEnter set Module($m,procExit) ITKFiltersExit

  14. Slicer Module procITKFiltersInit set ITKFilters(filters) " GradientAnisotropicDiffusionImageFilter “ set ITKFilters($filter,params) "SetConductanceParameter SetNumberOfIterations \ SetTimeStep" set param SetConductanceParameter set ITKFilters($filter,$param) 1 set ITKFilters($filter,$param,text) "Conductance" set ITKFilters($filter,$param,maxmin) "1 10“ set ITKFilters($filter,$param,res) 0.1 set ITKFilters($filter,$param,widget) "scale"

  15. Slicer Module procITKFiltersBuildGUI set fMain $Module(ITKFilters,fMain) set f $fMain foreach frame "Top Middle Floating Bottom" { frame $f.f$frame -bg $Gui(activeWorkspace) pack $f.f$frame -side top -padx 0 -pady $Gui(pad) -fill x } …..

  16. Slicer Module procITKFiltersBuildGUI "scale" { eval {label $fwidget.l$param -text $ITKFilters($filter,$param,text) \ -width 12 -justify right } $Gui(WLA) eval {entry $fwidget.e$param -justify right -width 4 \ -textvariable ITKFilters($filter,$param) } $Gui(WEA) eval {scale $fwidget.s$param \ -from [lindex $ITKFilters($filter,$param,maxmin) 0] \ -to [lindex $ITKFilters($filter,$param,maxmin) 1] \ -variable ITKFilters($filter,$param)\ -orient vertical \ -resolution $ITKFilters($filter,$param,res) } $Gui(WSA) pack $fwidget.l$param $fwidget.e$param $fwidget.s$param \ -side left -padx $Gui(pad) -pady 0 }

  17. Slicer Module procITKFiltersApply #Preparing INPUT and OUTPUT volume If {$v2 == -5} { set name [Volume($v1,node) GetName] set v2 [DevCreateNewCopiedVolume $v1 "" ${name}_filter ] set node [Volume($v2,vol) GetMrmlNode] Mrml(dataTree) RemoveItem $node set nodeBefore [Volume($v1,vol) GetMrmlNode] Mrml(dataTree) InsertAfterItem $nodeBefore $node MainUpdateMRML } else { set v2name [Volume($v2,node) GetName] set continue [DevOKCancel "Overwrite $v2name?"] if {$continue == "cancel"} { return 1 } # They say it is OK, so overwrite! Volume($v2,node) Copy Volume($v1,node) }

  18. Slicer Module procITKFiltersApply #Caster vtkImageCast _cast _cast SetOutputScalarTypeToFloat _cast SetInput [Volume($v1,vol) GetOutput] _cast Update #Create Object vtkITK$filter _filter foreach param $ITKFilters($filter,params) { _filter $param $ITKFilters($filter,$param) } _filter SetInput [_cast GetOutput]

  19. Slicer Module procITKFiltersApply _filter AddObserver StartEvent MainStartProgress _filter AddObserver EndEvent MainEndProgress _filter AddObserver ProgressEvent "MainShowProgress _filter" _filter Update #Assign output [Volume($v2,vol) GetOutput] DeepCopy [_filter GetOutput] #Destroy pipeline _cast Delete _filter SetOutput "" _filter Delete

  20. Demo

  21. Enjoy!

  22. itk::VTKImageImport vtkImageExport vtkImageImport itk::VTKImageExport vtkConnectVTKITK ITK CableSwig VTK VTK ITK itkMyFilterFF Slicer Module vtkConnectVTKITK

More Related