# ITK python vessel segmentation

**URL:** https://discourse.itk.org/t/itk-python-vessel-segmentation/1590
**Category:** Beginner Questions
**Tags:** python
**Created:** [February 11, 2019, 12:25am UTC](https://discourse.itk.org/t/itk-python-vessel-segmentation/1590 "2019-02-11T00:25:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![albert](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@albert](https://discourse.itk.org/u/albert)
#### Post date: [February 11, 2019, 12:25am UTC](https://discourse.itk.org/t/itk-python-vessel-segmentation/1590/1 "2019-02-11T00:25:45Z")

</div>

Hi all,

I am new to ITK and trying to do some work about brain vessel segmentation using ITK python. But I have no idea how to use those filters such as HessianRecursiveGaussianImageFilter and Hessian3DToVesselnessMeasureImageFilter in python using itk python module. Is there any detailed documentation about the usage of the these filters in python?

Thank you so much.

---

<div class="post-metadata">

### Author: ![jhlegarreta](https://discourse.itk.org/user_avatar/discourse.itk.org/jhlegarreta/32/476_2.png) [@jhlegarreta](https://discourse.itk.org/u/jhlegarreta)
#### Post date: [February 11, 2019, 4:17pm UTC](https://discourse.itk.org/t/itk-python-vessel-segmentation/1590/2 "2019-02-11T16:17:10Z")

</div>

Hi @albert,  
you may find some C++ use case of the `itk::Hessian3DToVesselnessMeasureImageFilter` and `itk::HessianRecursiveGaussianImageFilter` filters in the [ITK SegmentBloodVessels example](https://itk.org/ITKExamples/src/Filtering/ImageFeature/SegmentBloodVessels/Documentation.html).

The example is unfortunately missing the Python code 🙇‍♂️ 🙇‍♀️ . Both filters have [their Python wrapping](https://github.com/InsightSoftwareConsortium/ITK/tree/master/Modules/Filtering/ImageFeature/wrapping), so it should be fairly straightforward 🚀 to [contribute](https://itk.org/ITKExamples/Documentation/Contribute/index.html) to the example with the missing Python code.

Let me know should you need some help contributing with the Python code.

HTH,  
JON HAITZ

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [February 11, 2019, 7:18pm UTC](https://discourse.itk.org/t/itk-python-vessel-segmentation/1590/3 "2019-02-11T19:18:26Z")

</div>

I went ahead and implemented [the Python version of SegmentBloodVessels here](https://github.com/InsightSoftwareConsortium/ITKExamples/blob/8f86c1f4330f5758c4ff7846005f035905414683/src/Filtering/ImageFeature/SegmentBloodVessels/Code.py) 🐍 . @albert @jhlegarreta please take a look and also review [the pull request](https://github.com/InsightSoftwareConsortium/ITKExamples/pull/88).

@albert a good exercise and way to contribute to the community, as suggested by @jhlegarreta, is to provide a Python conversion for the [multi-scale vessel enhancement example](https://itk.org/ITKExamples/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Documentation.html).

---

<div class="post-metadata">

### Author: ![albert](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@albert](https://discourse.itk.org/u/albert)
#### Post date: [February 11, 2019, 8:36pm UTC](https://discourse.itk.org/t/itk-python-vessel-segmentation/1590/4 "2019-02-11T20:36:01Z")

</div>

@jhlegarreta @matt.mccormick, thank you for your quick answers. I have tried implementing the python script using these filters by myself and it works. But I’m unclear how to contribute to provide the missing python code for the examples.

---

<div class="post-metadata">

### Author: ![jhlegarreta](https://discourse.itk.org/user_avatar/discourse.itk.org/jhlegarreta/32/476_2.png) [@jhlegarreta](https://discourse.itk.org/u/jhlegarreta)
#### Post date: [February 12, 2019, 12:15am UTC](https://discourse.itk.org/t/itk-python-vessel-segmentation/1590/5 "2019-02-12T00:15:39Z")

</div>

Sounds awesome @albert !

First you’d need to create a [GitHub](https://github.com/) account if you haven’t got one, then you’d fork the [ITKExamples repository](https://github.com/InsightSoftwareConsortium/ITKExamples). You’d then clone it, and configure your `origin` and `upstream` remotes to point to your fork and the upstream/ITK repositories respectively.

Then the you typically create a new branch, e.g.

```auto
 git checkout -b AddMyExample origin/master

```

where `AddMyExample` should be a meaningful name for your example. You’d then add your files to the commit, add a meaningful, self-contained and complete commit message, push your branch to your `origin`, and `GitHub` would suggest opening a Pull Request. You’d be willing to add reviewers to approve or suggest modifications to the PR. You can add me or other fellows, for example.

If by _(…) implementing the Python script (…)_ you mean the _multi-scale vessel enhancement example_ Matt pointed, that would be it. Do not forget to add your Python `Code.py` file to the `CMakeLists.txt` file, and to the reSTructured Text (`*.rst`) file that is finally rendered, much like Matt did for his PR. Matt also took advantage to increase consistency in the code style, which would also be great for the mentioned example if necessary.

If by _(…) implementing the Python script (…)_ you mean a complete new example, that would also be great. You’d need to create a new folder in the same category of the mentioned examples, and provide the `CMakeLists.txt` file, the `*.rst` file, the C++ `Code.cxx` and Python `Code.py` files, and the SHA512 files of the images produced. Once you have your output images, ITK provides [a few ways](https://itk.org/ITKExamples/Documentation/Contribute/UploadBinaryData.html) to generate the hashes.

The complete contributing manual is found [here](https://itk.org/ITKExamples/Documentation/Contribute/index.html).

Let us know if this works for you.

Thanks for your contributions.  
JON HAITZ
