[ITK] Obtaining Hessian matrix values

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Fri Mar 24 10:03:20 EDT 2017


Hi,

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:
https://github.com/InsightSoftwareConsortium/ITKBridgeNumPy/blob/master/wrapping/itkPyBuffer.wrap

Hopefully someone more familiar with the code can provide the details.

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:
https://github.com/SimpleITK/itkSimpleITKFiltersModule/tree/master/include

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.

In the mean time, to compute a Hessian or Structure Tension you can always compute the individual derivates with the RecursiveGaussianImageFilter.

HTH,
Brad


On Mar 24, 2017, at 4:52 AM, Nicolas Cedilnik <nicolas.cedilnik at inria.fr<mailto:nicolas.cedilnik at inria.fr>> wrote:

Hello,

I am very new to ITK and looking for help.
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.
I have compiled ITK with python wrappers and the BridgeNumpy module.

What I've managed to do so far:

# 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



Unfortunately, if I try to convert the Hessian matrix the same way:

buf = itk.PyBuffer[itk.Image.SSRTD33]
hess_matrix_ndarray = buf.GetArrayFromImage(hessian_filter.GetOutput())


I run into this error:

(...)
KeyError: "itkTemplate : No template [<class 'itkImagePython.itkImageSSRTD33'>] for the itk::PyBuffer class"


Is this because I did not compile/install properly or because this type of pixel (itkImageSSRTD33) is not implemented in the PyBuffer module?

Anyway I tried a different approach to obtain hessian matrix values:

hessian_filter.GetOutput().GetPixel([x,y,z]).GetNthComponent(n)


which works but I don't know in what order are the 6 components and didn't even find out how to extract the image boundaries as python standard types?

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!


As the vesselness filter performs eigenanalysis of the hessian matrix, is there a way to extract the eigenvectors from there?

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.

Regards,

--
Nicolas
_______________________________________________
Community mailing list
Community at itk.org<mailto:Community at itk.org>
http://public.kitware.com/mailman/listinfo/community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170324/b8b8b6d6/attachment-0001.html>


More information about the Community mailing list