integration of itk into scirun

43
Integration of ITK Into SCIRun Yarden Livnat Darby Van Uitert Joshua Cates

Upload: jerzy

Post on 25-Feb-2016

26 views

Category:

Documents


2 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Integration of ITK Into SCIRun

Integration of ITK IntoSCIRun

Yarden LivnatDarby Van Uitert

Joshua Cates

Page 2: Integration of ITK Into SCIRun

Aims

Integrate ITK into SCIRun No changes to ITK Minimal changes to SCIRun Easy to apply to all old and new ITK

filters

Page 3: Integration of ITK Into SCIRun

The Players

SCIRun

Page 4: Integration of ITK Into SCIRun

The Players

Anisotropic DiffusionFilter Parameters

SCIRun ITK

Filter

Filter

Watershed Filter

Page 5: Integration of ITK Into SCIRun

Proposed Solution

ITK Filter

Automated as much as possible

GUI

Page 6: Integration of ITK Into SCIRun

XML

itk_filter.xml XSL sci_filter.h sci_filter.cc

sci_filter.tcl sci_filter.xml

Page 7: Integration of ITK Into SCIRun

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

Page 8: Integration of ITK Into SCIRun

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

sci_filter_gui.xmlsci_filter_gui.xml

sci_filter_gui.xmlsci_filter_gui.xml

GUIGUI

GUIGUI

Page 9: Integration of ITK Into SCIRun

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

sci_filter.xml XSL: include files, more instantiation information

Page 10: Integration of ITK Into SCIRun

Templated Filters

1) One module per instantiation Trivial

2) Switch statement

Instantiation information in an XML file to be used during code generation

3) Dynamic Compilation Non-templated base classes

Page 11: Integration of ITK Into SCIRun

Summary

XML Files – 3 per filteritk_filter.xml created by ITK developerssci_filter.xml created by developer/ITK usersci_filter_gui.xml created by developer/ITK user

Validated with DTD !

Page 12: Integration of ITK Into SCIRun

Summary

XML Files – 3 per filteritk_filter.xml created by ITK developerssci_filter.xml created by developer/ITK usersci_filter_gui.xml created by developer/ITK user

Validated with DTD !

Page 13: Integration of ITK Into SCIRun

Summary

XML Files – 3 per filteritk_filter.xml created by ITK developerssci_filter.xml created by developer/ITK usersci_filter_gui.xml created by developer/ITK user

XSL Files – 3 per systemGenerateCC.xsl created by us forGenerateTCL.xsl generating our GenerateXML.xsl specific code

Validated with DTD !

Page 14: Integration of ITK Into SCIRun

Adding a New Filter

ReflectImageFilter

Steps: Write itk_ReflectImageFilter.xml Write basic sci_ReflectImageFilter.xml Generate module Write gui_ReflectImageFilter.xml

Page 15: Integration of ITK Into SCIRun

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>

Page 16: Integration of ITK Into SCIRun

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>

Page 17: Integration of ITK Into SCIRun

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>

Page 18: Integration of ITK Into SCIRun

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>

Page 19: Integration of ITK Into SCIRun

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>

Page 20: Integration of ITK Into SCIRun

Example – sci_filter.xml

<filter name=“ReflectImageFilter”>

<include href=“” />

<filter-sci> … </filter-sci>

</filter>

Page 21: Integration of ITK Into SCIRun

Example – sci_filter.xml

<filter name=“ReflectImageFilter”>

<include href=“” />

<filter-sci> … </filter-sci>

</filter>

<include href=“ITK/itk_ReflectImageFilter.xml”/>

Page 22: Integration of ITK Into SCIRun

Example – sci_filter.xml

<filter name=“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>

Page 23: Integration of ITK Into SCIRun

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 \

Page 24: Integration of ITK Into SCIRun

Sample Network

Page 25: Integration of ITK Into SCIRun

Sample Network

Default GUI

Page 26: Integration of ITK Into SCIRun

gui_ReflectImageFilter.xml

<filter-gui name=“ReflectImageFilterGUI”>

<parameters>

<param> … </param> <param> … </param>

</parameters>

</filter-gui>

Page 27: Integration of ITK Into SCIRun

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>

Page 28: Integration of ITK Into SCIRun

Add GUI to sci_filter.xml

<filter name=“ReflectImageFilter”>

<include href=“” />

<filter-sci> … </filter-sci>

</filter>

<include href=“ITK/itk_ReflectImageFilter.xml”/>

sci_filter.xml

itk_filter.xml

Page 29: Integration of ITK Into SCIRun

Add GUI to 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”/>

sci_filter.xml

itk_filter.xml

gui_filter.xml

Page 30: Integration of ITK Into SCIRun

Sample Network

Defined GUI

Page 31: Integration of ITK Into SCIRun

ITKDatatypeclass ITKDatatype : public Datatype {public:

string fname; itk::Object::Pointer data_;

ITKDatatype():ITKDatatype(const ITKDatatype);~ITKDatatype();

virtual void io(Piostream&);static PersistentTypeID type_id;

};

Page 32: Integration of ITK Into SCIRun

Field and Image Conversion

SCIRun ITK

ITKField wrap Image

ITKField unwrap Image

Field copy data Image

ITKField wrap Image

Page 33: Integration of ITK Into SCIRun

ITKLatVolField.htemplate<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();

};

Page 34: Integration of ITK Into SCIRun

ITKLatVolField.htemplate <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_;

};

Page 35: Integration of ITK Into SCIRun

ITKLatVolField.htemplate <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_;

};

void set_image(itk::Image< Data, 3 >* img) {

image_ = img;

begin_ = new iterator(image_,

image_->GetRequestedRegion());

begin_->GoToBegin();

}

Page 36: Integration of ITK Into SCIRun

Current ITK Filters

DiscreteGaussianImageFilterGradientAnisotropicDiffusionImageFilterCannySegmentationLevelSetImageFilterGradientMagnitudeImageFilterReflectImageFilterWatershedRelabelerWatershedSegmenterWatershedSegmentTreeGenerator

There are almost 200 filters

Page 37: Integration of ITK Into SCIRun

Example Network

Page 38: Integration of ITK Into SCIRun

Example Network

Page 39: Integration of ITK Into SCIRun

Example Network

Page 40: Integration of ITK Into SCIRun

Example Network

Page 41: Integration of ITK Into SCIRun

Example Images

Source Image

Diffused Image

Segmented Image

Page 42: Integration of ITK Into SCIRun

What’s Left to Do Finish recursive filters for ITK mini

pipeline

Enable complex GUI’s Have: Slider, Check and Radio ButtonNeed: Layout Manager

Port Issue – all are of type ITKDatatypeSame base class issue

Write DocumentationWrite more ITK filters

Filter

Filter

Watershed Filter

Page 43: Integration of ITK Into SCIRun

Issues

• Object base class (e.g. ImageReader )• SCIRun2

– Common Component Architecture (CCA)– Separable GUIs

• GTK• XML description

• Dynamic Compilation– TypeDescription– Compile_info

• Const pipes