430 likes | 519 Views
Integration of ITK Into SCIRun. Yarden Livnat Darby Van Uitert Joshua Cates. Aims. Integrate ITK into SCIRun No changes to ITK Minimal changes to SCIRun Easy to apply to all old and new ITK filters. The Players. SCIRun. The Players. SCIRun. ITK. Anisotropic Diffusion Filter.
E N D
Integration of ITK IntoSCIRun Yarden Livnat Darby Van Uitert Joshua Cates
Aims Integrate ITK into SCIRun • No changes to ITK • Minimal changes to SCIRun • Easy to apply to all old and new ITK filters
The Players SCIRun
The Players SCIRun ITK Anisotropic Diffusion Filter Parameters Watershed Filter Filter Filter
Proposed Solution GUI ITK Filter Automated as much as possible
itk_filter.xml XSL sci_filter.h sci_filter.cc sci_filter.tcl sci_filter.xml XML
itk_filter.xml XSL sci_filter.h sci_filter.cc sci_filter_gui.xml XSL sci_filter.tcl sci_filter.tcl sci_filter.xml XML
itk_filter.xml XSL sci_filter.h sci_filter.cc sci_filter_gui.xml XSL sci_filter.tcl sci_filter.tcl sci_filter.xml GUI GUI GUI GUI sci_filter_gui.xml sci_filter_gui.xml sci_filter_gui.xml sci_filter_gui.xml XML
itk_filter.xml XSL sci_filter.h sci_filter.cc sci_filter_gui.xml XSL sci_filter.tcl sci_filter.tcl sci_filter.xml XML sci_filter.xml XSL: • include files, more instantiation information
Trivial • Instantiation information in an XML file to be used during code generation Templated Filters • One module per instantiation 2) Switch statement 3) Dynamic Compilation • Non-templated base classes
Summary Validated with DTD ! XML Files – 3 per filter itk_filter.xml created by ITK developers sci_filter.xml created by developer/ITK user sci_filter_gui.xml created by developer/ITK user
Summary Validated with DTD ! XML Files – 3 per filter itk_filter.xml created by ITK developers sci_filter.xml created by developer/ITK user sci_filter_gui.xml created by developer/ITK user
Summary Validated with DTD ! XML Files – 3 per filter itk_filter.xml created by ITK developers sci_filter.xml created by developer/ITK user sci_filter_gui.xml created by developer/ITK user XSL Files – 3 per system GenerateCC.xsl created by us for GenerateTCL.xsl generating our GenerateXML.xsl specific code
Adding a New Filter ReflectImageFilter Steps: • Write itk_ReflectImageFilter.xml • Write basic sci_ReflectImageFilter.xml • Generate module • Write gui_ReflectImageFilter.xml
<filter-itk name=“itk::ReflectImageFilter”> <description> Reflects an image along a selected direction. </description> <templated> … </templated> <inputs> … </inputs> <outputs> … </outputs> <parameters> … </parameters> <includes> … </includes> </filter-itk> Example – itk_filter.xml
<filter-itk name=“itk::ReflectImageFilter”> <description> Reflects an image along a selected direction. </description> <templated> … </templated> <inputs> … </inputs> <outputs> … </outputs> <parameters> … </parameters> <includes> … </includes> </filter-itk> <templated> <template>InputImageType</template> <template>OutputImageType</template> <defaults> <default> itk::Image< float, 2> </default> <default> itk::Image< float, 2> </default> </defaults> </templated> Example – itk_filter.xml
<filter-itk name=“itk::ReflectImageFilter”> <description> Reflects an image along a selected direction. </description> <templated> … </templated> <inputs> … </inputs> <outputs> … </outputs> <parameters> … </parameters> <includes> … </includes> </filter-itk> <inputs> <input name=“SourceImage” > <type> InputImageType </type> <call> SetInput </call> </input> </inputs> Example – itk_filter.xml
<filter-itk name=“itk::ReflectImageFilter”> <description> Reflects an image along a selected direction. </description> <templated> … </templated> <inputs> … </inputs> <outputs> … </outputs> <parameters> … </parameters> <includes> … </includes> </filter-itk> <parameters> <param> <name> direction </name> <type> int </type> <call> SetDirection </call> </param> </parameters> Example – itk_filter.xml
<filter-itk name=“itk::ReflectImageFilter”> <description> Reflects an image along a selected direction. </description> <templated> … </templated> <inputs> … </inputs> <outputs> … </outputs> <parameters> … </parameters> <includes> … </includes> </filter-itk> <includes> <file> itkReflectImageFilter.h </file> </includes> Example – itk_filter.xml
<filter name=“ReflectImageFilter”> <include href=“” /> <filter-sci> … </filter-sci> </filter> Example – sci_filter.xml
<filter name=“ReflectImageFilter”> <include href=“” /> <filter-sci> … </filter-sci> </filter> <include href=“ITK/itk_ReflectImageFilter.xml”/> Example – sci_filter.xml
<filtername=“ReflectImageFilter”> <include href=“” /> <filter-sci> … </filter-sci> </filter> <filter-sci name=“ReflectImageFilter”> <package> Insight </package> <category> Filters </category> <instantiations use-defaults=“yes”/> <includes> <file>Packages/Insight/Dataflow/ Ports/ITKDatatypePort.h </file> </includes> </filter-sci> Example – sci_filter.xml
Generate Process Steps for module generation • Add to Dataflow/Modules/Filters/sub.mk • Add to Dataflow/GUI/sub.mk Module sub.mk XMLS := \ sci_DiscreteGaussianImageFilter.xml \ sci_ReflectImageFilter.xml \ GUI sub.mk $(SRCDIR)/tclIndex: \ $(SRCDIR)/Switch.tcl \ $(SRCDIR)/ReflectImageFilter.tcl \
Sample Network Default GUI
<filter-gui name=“ReflectImageFilterGUI”> <parameters> <param> … </param> <param> … </param> </parameters> </filter-gui> gui_ReflectImageFilter.xml
<filter-gui name=“ReflectImageFilterGUI”> <parameters> <param> … </param> <param> … </param> </parameters> </filter-gui> <param name= “direction” > <gui> radiobutton </gui> <values> <val> 0 </val> <val> 1 </val> </values> <default> 1 </default> </param> gui_ReflectImageFilter.xml
<filter name=“ReflectImageFilter”> <include href=“” /> <filter-sci> … </filter-sci> </filter> <include href=“ITK/itk_ReflectImageFilter.xml”/> Add GUI to sci_filter.xml itk_filter.xml sci_filter.xml
<filter name=“ReflectImageFilter”> <include href=“” /> <filter-sci> … </filter-sci> </filter> <include href=“ITK/itk_ReflectImageFilter.xml”/> <include href=“Dataflow/Modules/Filters/XML/ gui_ReflectImageFilter.xml”/> Add GUI to sci_filter.xml itk_filter.xml sci_filter.xml gui_filter.xml
Sample Network Defined GUI
ITKDatatype class ITKDatatype : public Datatype { public: string fname; itk::Object::Pointer data_; ITKDatatype(): ITKDatatype(const ITKDatatype); ~ITKDatatype(); virtual void io(Piostream&); static PersistentTypeID type_id; };
ITKField wrap Image ITKField unwrap Image Field copy data Image ITKField wrap Image Field and Image Conversion SCIRun ITK
ITKLatVolField.h template<class Data> class ITKLatVolField : public GenericField< LatVolMesh, ITKFData3d< Data > > { public: ITKLatVolField(); ITKLatVolField(Field::data_location data_at); ITKLatVolField(LatVolMeshHandle mesh, Field::data_location data_at); ITKLatVolField(LatVolMeshHandle mesh, Field::data_location data_at, itk::Object* image); void SetImage(itk::Object* image); . . . private: static Persistent* maker(); };
ITKLatVolField.h template <class Data> class ITKFData3d { public: typedef Data value_type; typedef itk::Image< Data, 3 > image_type; typedef ITKIterator< Data > iterator; typedef ITKConstIterator< Data > const_iterator; iterator *begin_, *end_; const_iterator *const_begin_, *const_end_; const iterator & begin() { return *begin_; } const iterator & end() { return *end_; } … const value_type &operator[]( LatVolMesh::Node::index_type idx) const; … void set_image(itk::Image< Data, 3 >* img); private: typename image_type::Pointer image_; };
ITKLatVolField.h void set_image(itk::Image< Data, 3 >* img) { image_ = img; begin_ = new iterator(image_, image_->GetRequestedRegion()); begin_->GoToBegin(); … } template <class Data> class ITKFData3d { public: typedef Data value_type; typedef itk::Image< Data, 3 > image_type; typedef ITKIterator< Data > iterator; typedef ITKConstIterator< Data > const_iterator; iterator *begin_, *end_; const_iterator *const_begin_, *const_end_; const iterator & begin() { return *begin_; } const iterator & end() { return *end_; } … const value_type &operator[]( LatVolMesh::Node::index_type idx) const; … void set_image(itk::Image< Data, 3 >* img); private: typename image_type::Pointer image_; };
Current ITK Filters DiscreteGaussianImageFilter GradientAnisotropicDiffusionImageFilter CannySegmentationLevelSetImageFilter GradientMagnitudeImageFilter ReflectImageFilter WatershedRelabeler WatershedSegmenter WatershedSegmentTreeGenerator There are almost 200 filters
Example Images Diffused Image Source Image Segmented Image
Watershed Filter Filter Filter What’s Left to Do • Finish recursive filters for ITK mini pipeline • Enable complex GUI’s • Have: Slider, Check and Radio Button • Need: Layout Manager • Port Issue – all are of type ITKDatatype • Same base class issue • Write Documentation • Write more ITK filters
Issues • Const pipes • Object base class (e.g. ImageReader ) • SCIRun2 • Common Component Architecture (CCA) • Separable GUIs • GTK • XML description • Dynamic Compilation • TypeDescription • Compile_info