<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
I am very new to ITK and looking for help.<br>
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>
I have compiled ITK with python wrappers and the BridgeNumpy module.<br>
<br>
What I've managed to do so far:<br>
<pre># 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>
<pre>buf = itk.PyBuffer[itk.Image.SSRTD33]
hess_matrix_ndarray = buf.GetArrayFromImage(hessian_filter.GetOutput())
</pre>
I run into this error:<br>
<pre>(...)
KeyError: "itkTemplate : No template [<class 'itkImagePython.itkImageSSRTD33'>] for the itk::PyBuffer class"
</pre>
<b>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>
<br>
Anyway I tried a different approach to obtain hessian matrix values:<br>
<pre>hessian_filter.GetOutput().GetPixel([x,y,z]).GetNthComponent(n)
</pre>
which works but I don't know <b>in what order are</b><b><b> </b>the
6 components</b> and didn't even find out <b>how to extract the
image boundaries as python standard types?</b><br>
<pre>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> is there a way to extract the eigenvectors from there</b>?<br>
<br>
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>
<br>
Regards,<br>
<br>
-- <br>
Nicolas<br>
</body>
</html>