ITKTubeTK icon indicating copy to clipboard operation
ITKTubeTK copied to clipboard

Extract the centerline using TubeTK

Open keesh-elucid opened this issue 2 years ago • 3 comments

Hello, Thanks very much for your example. I have experience with both ITK and Simple ITK, but not TubeTK. The documentation for TubeTK seems a bit sparse.

Does the following notebook extract the centerline? With the test data (DSA-Binary.mha) and a synthetic cylinder, I can only obtain the object itself (written to a VTP file) via vSeg.GetTubeGroup(). https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/examples/BinaryImage/Demo-SegmentVesselsFromBinaryImage.ipynb

thx in adv [email protected]

keesh-elucid avatar Feb 02 '23 01:02 keesh-elucid

Hi,

Yes - I apologize about the complete lack of useful documentation! One goal for this year is to fix that!

But, what you found should do exactly what you need. Right now it only displays the surface of the object, but the centerline and radius (and other details) of that object are written to a ".tre" file in the last cell of that notebook:

SOWriter = itk.SpatialObjectWriter[3].New(vSeg.GetTubeGroup())SOWriter.SetFileName( "BinaryImageVessels.tre" )SOWriter.Update()

Using that file you can access the centerline points and even display them in a jupyter notebook as shown in: https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/examples/Demo-ManipulateTubes.ipynb

Or you can render the centerlines into a image, as shown in https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/examples/Demo-ConvertTubesToImage.ipynb -- in that notebook, the default is to render the tube, but it will instead render only the centerlines if you change the corresponding line to be:

tubesToImageFilter.SetUseRadius(False)

Hope this helps, Stephen

On Wed, Feb 1, 2023 at 8:00 PM keesh elucid @.***> wrote:

Hello, Thanks very much for your example. I have experience with both ITK and Simple ITK, but not TubeTK. The documentation for TubeTK seems a bit sparse.

Does the following notebook extract the centerline? With the test data (DSA-Binary.mha) and a synthetic cylinder, I can only obtain the object itself (written to a VTP file) via vSeg.GetTubeGroup().

https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/examples/BinaryImage/Demo-SegmentVesselsFromBinaryImage.ipynb

thx in adv @.***

— Reply to this email directly, view it on GitHub https://github.com/InsightSoftwareConsortium/ITKTubeTK/issues/135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACEJL7ZLJGOBUVJVTMQV6DWVMBMLANCNFSM6AAAAAAUOMZSR4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives Chair of MONAI Advisory Board

Kitware: Delivering innovation.

aylward avatar Feb 02 '23 13:02 aylward

Thanks, Stephen. Your examples helped me over the initial learning curve. One last question... Since my input segmentation can be a bit rough, I see a fragmented centerline in some cases. What is the best method to iterate over the centerlines (tubes), as I wish to exclude tubes with too few points? thx e.- image

keesh-elucid avatar Feb 07 '23 21:02 keesh-elucid

Hi,

Nice progress!

Here is how to iterate over tubes: https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/examples/Demo-ManipulateTubes.ipynb

To delete a point from a tube (e.g., if its radius is below a threshold), call tube.RemovePoint(id);

See https://itk.org/Doxygen/html/classitk_1_1PointBasedSpatialObject.html#aedd9c5efff6e3fae96c18bd467f27d52

A few suggestions:

  1. Binary morphological erosion and then dilation on your object to remove the spurs / boundary noise from it
  2. Extract the centerline of the object using a larger radius/scale and adjusting the minimum ridgeness and minimum curvature thresholds to limit spurious details
  3. Look at binary image skeletonization: https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/src/Filtering/itktubeBinaryThinningImageFilter3D.h which is available as a python filter via: https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/include/tubeSegmentBinaryImageSkeleton3D.h
  • yes, I really need to work on the documentation!!! So sorry about that!

s

On Tue, Feb 7, 2023 at 4:31 PM keesh elucid @.***> wrote:

Thanks, Stephen. Your examples helped me over the initial learning curve. One last question... Since my input segmentation can be a bit rough, I see a fragmented centerline in some cases. What is the best method to iterate over the centerlines (tubes), as I wish to exclude tubes with too few points? thx e.- [image: image] https://user-images.githubusercontent.com/107575042/217370223-56fdb27d-2291-4d26-816e-eb50fde95522.png

— Reply to this email directly, view it on GitHub https://github.com/InsightSoftwareConsortium/ITKTubeTK/issues/135#issuecomment-1421480763, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACEJL4HLZKJKP4SHV265TLWWK5MLANCNFSM6AAAAAAUOMZSR4 . You are receiving this because you commented.Message ID: @.***>

-- Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives Chair of MONAI Advisory Board

Kitware: Delivering innovation.

aylward avatar Feb 08 '23 10:02 aylward