insightsoftwareconsortium / itkminimalpathextraction Goto Github PK
View Code? Open in Web Editor NEWVessel and tube centerline extraction
Home Page: http://www.insight-journal.org/browse/publication/213
License: Apache License 2.0
Vessel and tube centerline extraction
Home Page: http://www.insight-journal.org/browse/publication/213
License: Apache License 2.0
Why is the (special) cost function (SingleImageCostFunction) not instantiated internally? From the publication it seems that
PathFilterType :: CostFunctionType :: Pointer cost =
PathFilterType :: CostFunctionType :: New ();
PathFilterType :: Pointer pathFilter = PathFilterType :: New ();
pathFilter -> SetCostFunction ( cost );
is expected when employing SpeedFunctionToPathFilter
.
What cases could there be where the cost function here would not be the predefined SingleImageCostFunction?
If there are no other, the instantiation of cost function could be done internally, so that it is not necessary when using SpeedFunctionToPathFilter
.
Trying to solve #61 I found that the interpolator that is used to calculate the gradient is always linear
ITKMinimalPathExtraction/include/itkSingleImageCostFunction.h
Lines 105 to 107 in 2ff1ab5
GetValue
) is employedGetDerivative
)This however does not seem to be the issue of #61 (where a linear interpolator was used anyway), so posting as an issue on its own.
Hi,
Your module seems really cool and is also perfect for my use. Thanks for the great work in advance!
I tried running the example code "DigitalSubtractionAngiographyVesselPath". Unfortunately, I receive an error message at the following point:
Would you by any chance know, why this happens? Should I do anything differently?
Cheers,
heinermh
The existing tests should be improved:
TRY_EXPECT_NO_EXCEPTION
, EXERCISE_BASIC_OBJECT_METHODS
, etc.) to avoid boilerplate code.testStatus
in and change its value as tests fail: requires changing the test design).Hi,
I tested the python example code on my laptop and found the instantiation of SpeedFunctionPathInformation is very slow.
It takes about 7s to run the following line with Core i7-10510U and 8GB RAM.
PathInformationType = itk.SpeedFunctionPathInformation[PointType]
Is there some time-consuming operation during the instantiation? Is there any way to speed it up in python?
Thx.
Hello!
Thanks for this project contributing to ITK!
I try to use this module for paths extraction from angiographic images. But the algorithm works incorrectly sometimes.
Also this error occurs even at the test data. For example, Noise-01-Speed.mhd
My test speed image and start/end points:
test_image.zip
I use python wrappings and GradientDescentOptimizer
:
import itk
def mpe(speed_image, start_point, end_point, way_points=None):
# ITK Types
Point = itk.Point.F2
CostFunction = itk.SingleImageCostFunction.IF2
Interpolator = itk.LinearInterpolateImageFunction.IF2D
PathInformation = itk.SpeedFunctionPathInformation.PD2
MinimalPathExtractor = itk.SpeedFunctionToPathFilter.IF2PPP2
interpolator = Interpolator.New()
cost_function = CostFunction.New()
cost_function.SetInterpolator(interpolator)
optimizer = itk.GradientDescentOptimizer.New()
optimizer.SetNumberOfIterations(1000)
path_info = PathInformation.New()
path_info.SetStartPoint(Point(start_point))
path_info.SetEndPoint(Point(end_point))
if way_points:
for p in way_points:
path_info.AddWayPoint(Point(p))
path_extractor = MinimalPathExtractor.New()
path_extractor.SetInput(speed_image)
path_extractor.SetCostFunction(cost_function)
path_extractor.SetOptimizer(optimizer)
path_extractor.SetTerminationValue(1.0)
path_extractor.AddPathInformation(path_info)
path_extractor.Update()
path = path_extractor.GetOutput(0)
vertices_list = path.GetVertexList()
if vertices_list.Size() == 0:
raise ValueError('Path has not been found')
px = []
py = []
for i in range(vertices_list.Size()):
vertex = vertices_list.ElementAt(i)
px.append(vertex[0])
py.append(vertex[1])
return px, py
I have experienced many cases where I can extract a path with the IterateNeighborhoodOptimizer but where the GradientDescentOptimizer does not start to decent even though the speed function is continuous (based on a binary segmentation), apparently because the initial local gradient is calculated to be zero (even though start- and end-point, speed function etc are kept the same).
I have a vague feeling that this thresholding:
ITKMinimalPathExtraction/include/itkSingleImageCostFunction.hxx
Lines 145 to 152 in 6ae35b9
15.0
:Another possible reason I could imagine is that the floating point precision might not suffice under some circumstances to calculate a non-zero gradient even if there is no extrema in the cost function at the current optimizer position.
I use this CLI for the testing:
https://github.com/romangrothausmann/ITK-CLIs/blob/bfb1312142d505cacd6770e4d5acc23475290c8f/min-path_seg.cxx
Hi everyone,
first of all I would like to thank you for this module, it seems to work great for given example:
https://github.com/InsightSoftwareConsortium/ITKMinimalPathExtraction/blob/master/examples/DigitalSubtractionAngiographyVesselPath.ipynb
Unfortunately when I tried it on my data which are: .png file of vessels and .mdh and .zraw files generated from a DICOM the program from the example returns 0 points as an extracted centerline without any error.
GetVertexList() returns 0 instead of ie. 2200.
I changed nothing in it except of files and Points on a path.
My utils are:
I'm wondering if problem could be in my speed image (.mdh, .zraw) or because my image file is itkImageRGBUC2 instead of itkImageUC2 from the example.
I will be thankful for some advices about it.
Regards
Franek
Going through the code, I am wondering why i
goes up to 2 here (not FullyConnected):
Hello,
I was playing around with the DigitalSubtractionAngiographyVesselPath.ipynb example and noticed that if I change the path file to other points, a lot of times the kernel dies at the last view function (view(dsa, geometries=path, ui_collapsed=True)).
When I use my own image, which is smaller, I am completely unable to find a combination of points that works.
I moved the code to VS Code in hope that I would get an error message but the script just stops executing in the view function after the viewer is initialized.
Here are some examples of paths that failed for me:
Path: [394.00, 203.00] [0.00, 0.00]
Path: [394.00, 203.00] [1.00, 20.00]
Path: [394.00, 203.00] [001.00, 020.00]
Path: [94.00, 203.00] [60.00, 230.00] [250.00, 190.00]
Path: [204.00, 23.00] [120.00, 80.00] [273.00, 19.00] [94.00, 173.00] [394.00, 121.00] [403.00, 237.00]
Apparently the view function is not the problem but the value for path.GetVertexList().Size() is 0 for the paths.
The original path in the example works fine, so I don't think that it is a setup problem.
Can I debug this somehow, are there restrictions for possible points or is this a bug?
Cheers :)
My environment:
cat /etc/os-release:
NAME="Ubuntu"
VERSION="16.04.7 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.7 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
Environment:
Miniconda3
Python=3.9.7
itk=5.3.0
Calling the following python code:
PointType = itk.Point[itk.D,3]
PathInformationType = itk.SpeedFunctionPathInformation[PointType]
I get the error:
**AttributeError: PyCapsule_Import "_ITKCommonPython._C_API" is not valid**
Hello,
Thanks for this project.I want find 3d vessel minimalpath,i try the sample of Synthetic-04-Speed.mhd,and the path result is right,but when i change to my data,the path result is out of image range.i debug the program,and find the data of Synthetic-04-Speed.mhd,that spacing is (1,1,1),origin is (0,0,0),the spacing and origin of my data is (0.65,0.65,3),(127.4,-32.4,56.7).and i make another test,resample my data with spacing(1,1,1),and set origin to (0,0,0),the result is right.
so i want to know how to set the program without change image spacing and origin message?
another demand,there have c++ examples,can share some python examples?
thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.