<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi,
<div class=""><br class="">
</div>
<div class="">ITK’s native python wrappers with the NumpyBridge should be able to be extended to support the Hessian pixel type. It should require some modification to this file:</div>
<div class=""><a href="https://github.com/InsightSoftwareConsortium/ITKBridgeNumPy/blob/master/wrapping/itkPyBuffer.wrap" class="">https://github.com/InsightSoftwareConsortium/ITKBridgeNumPy/blob/master/wrapping/itkPyBuffer.wrap</a></div>
<div class=""><br class="">
</div>
<div class="">Hopefully someone more familiar with the code can provide the details.</div>
<div class=""><br class="">
</div>
<div class="">For SimpleITK, you are correct in that we don’t have direct hessian support for the forth coming 1.0 release. But the support is close. You can see progress in an ITK external module here:</div>
<div class=""><a href="https://github.com/SimpleITK/itkSimpleITKFiltersModule/tree/master/include" class="">https://github.com/SimpleITK/itkSimpleITKFiltersModule/tree/master/include</a></div>
<div class=""><br class="">
</div>
<div class="">There are ways this module could be used if significantly motivated. SimpleITK 1.0 currently has the code to support extending it during the build process, but that is not documented or announced yet.</div>
<div class=""><br class="">
</div>
<div class="">In the mean time, to compute a Hessian or Structure Tension you can always compute the individual derivates with the RecursiveGaussianImageFilter.</div>
<div class=""><br class="">
</div>
<div class="">HTH,</div>
<div class="">Brad</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On Mar 24, 2017, at 4:52 AM, Nicolas Cedilnik <<a href="mailto:nicolas.cedilnik@inria.fr" class="">nicolas.cedilnik@inria.fr</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class="">Hello,<br class="">
<br class="">
I am very new to ITK and looking for help.<br class="">
I am trying to obtain hessian matrix values, in order to extract information about the detected vessels orientation. I'd be fine directly obtaining eigenvalues and eigenvectors.<br class="">
I have compiled ITK with python wrappers and the BridgeNumpy module.<br class="">
<br class="">
What I've managed to do so far:<br class="">
<pre class=""># read my image
pixelType = itk.F
imageType = itk.Image[pixelType, 3]
readerType = itk.ImageFileReader[imageType]
reader = readerType.New()
reader.SetFileName("/path/to/my/image.mha")
# compute Hessian matrix
hessian_filter = itk.HessianRecursiveGaussianImageFilter[imageType].New()
hessian_filter.SetInput(reader.GetOutput())
# compute vesselness image
vesselness_filter = itk.Hessian3DToVesselnessMeasureImageFilter[itk.F].New()
vesselness_filter.SetInput(hessian_filter.GetOutput())
vesselness_filter.Update()
# convert vesselness image to numpy array
itk_py_converter = itk.PyBuffer[imageType]
vesselness_ndarray = itk_py_converter.GetArrayFromImage(vesselness_filter.GetOutput())
# output: x,y,z numpy array corresponding to my input image, which is a good start
</pre>
Unfortunately, if I try to convert the Hessian matrix the same way:<br class="">
<pre class="">buf = itk.PyBuffer[itk.Image.SSRTD33]
hess_matrix_ndarray = buf.GetArrayFromImage(hessian_filter.GetOutput())
</pre>
I run into this error:<br class="">
<pre class="">(...)
KeyError: "itkTemplate : No template [<class 'itkImagePython.itkImageSSRTD33'>] for the itk::PyBuffer class"
</pre>
<b class="">Is this because I did not compile/install properly or because this type of pixel (itkImageSSRTD33) is not implemented in the PyBuffer module?</b><br class="">
<br class="">
Anyway I tried a different approach to obtain hessian matrix values:<br class="">
<pre class="">hessian_filter.GetOutput().GetPixel([x,y,z]).GetNthComponent(n)
</pre>
which works but I don't know <b class="">in what order are</b><b class=""><b class="">
</b>the 6 components</b> and didn't even find out <b class="">how to extract the image boundaries as python standard types?</b><br class="">
<pre class="">In: hessian_filter.GetOutput().GetBufferedRegion()
Out: itkImageRegion3([0, 0, 0], [480, 384, 255]) # this looks OK but...
In: hessian_filter.GetOutput().GetBufferedRegion()[1]
Out: TypeError: 'itkImageRegion3' object does not support indexing # DAMN!
</pre>
As the vesselness filter performs eigenanalysis of the hessian matrix,<b class=""> is there a way to extract the eigenvectors from there</b>?<br class="">
<br class="">
If you've read this far, thanks a lot. Please point me the right direction... I used SimpleITK before and was less confused but unfortunately it is my understanding that it is not possible to use hessian filters in SimpleITK at the moment.<br class="">
<br class="">
Regards,<br class="">
<br class="">
-- <br class="">
Nicolas<br class="">
</div>
_______________________________________________<br class="">
Community mailing list<br class="">
<a href="mailto:Community@itk.org" class="">Community@itk.org</a><br class="">
http://public.kitware.com/mailman/listinfo/community<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>