1 / 25

Slicer and ITK

Slicer and ITK. Raul San Jose. Foreword. ITK as a library of “source code” “Box” of structured reusable source code. Library compile when you compile your application. What did I miss in my C++ book? Standard Template Library (STL) framework: containers and iterators. Template.

jillian-orr
Download Presentation

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 Raul San Jose

  2. Foreword • ITK as a library of “source code” • “Box” of structuredreusablesource code. • Library compile when you compile your application. • What did I miss in my C++ book? • Standard Template Library (STL) framework: containers and iterators. • Template. • Typename. • Typedef. • ITK push the envelope of software design into abstraction.

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

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

  5. How to make the wrapper? • Low level: as another object of your library. • Each ITK filter/pipeline is seen as another class of your library. • High level:wrapper into other languages as tcl/tk, phyton or java. • ITK supports this approach through CableSwig.

  6. vtkConnectVTKITK vtkITK Slicer and ITK • Architecture: 3D Slicer TCL / TK (GUI, VTK Interface) wrapper VTK ITK

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

  8. vtkDataObject Slicer and ITK • Data Flow: ITK – VTK ITK VTK itk::ImportImageContainer

  9. vtkDataObject Slicer and ITK • Data Flow: VTK – ITK VTK ITK itk::ImportImageFilter

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

  11. 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>>

  12. 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

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

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

  15. 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);

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

  17. 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

  18. 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"

  19. 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 } …..

  20. 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 }

  21. 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) }

  22. 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]

  23. 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

  24. Demo

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

More Related