<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Thanks a lot Dan!</span></div><div><span>It works. I will follow your advice and modify the filter so that I can define the threshold via an input.</span></div><div><br><span></span></div><div><span>Thanks again for your time!</span></div><div><br><span></span></div><div><span>Maria</span></div><div><br></div><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">De:</span></b> Dan Mueller &lt;dan.muel@gmail.com&gt;<br><b><span style="font-weight: bold;">Para:</span></b> Maria Alejandra Zuluaga Valencia &lt;mariazulv@yahoo.es&gt;<br><b><span style="font-weight: bold;">CC:</span></b> "insight-users@itk.org"
 &lt;insight-users@itk.org&gt;<br><b><span style="font-weight: bold;">Enviado:</span></b> jueves 7 de julio de 2011 15:36<br><b><span style="font-weight: bold;">Asunto:</span></b> Re: [Insight-users] Problem with Fast marching minimal path extraction<br></font><br>Opps, this time with attachment.<br><br>On 7 July 2011 15:34, Dan Mueller &lt;<a ymailto="mailto:dan.muel@gmail.com" href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>&gt; wrote:<br>&gt; Hi Maria,<br>&gt;<br>&gt; I have located the issue. It is a problem with the Fast Marching<br>&gt; Minimal Path source code.<br>&gt;<br>&gt; The speed functions I used when developing Fast Marching Minimal Path<br>&gt; where for vascular segmentation. These functions were basically white<br>&gt; (1.0) near the vessel centerline and black (0.0) outside the vessels.<br>&gt; Hence the arrival function were relatively smooth and continuous i.e.<br>&gt; there were no sharp changes in intensity (low first
 derivatives).<br>&gt;<br>&gt; The speed function you are trying to use has a dark spot in which you<br>&gt; place a seed point. However, within this dark spot the arrival<br>&gt; function has large changes in intensity (high first derivatives)<br>&gt; because the front is moving slowing through the dark region.<br>&gt;<br>&gt; In the file itkSingleImageCostFunction.txx, in the function<br>&gt; GetDerivative(), there is code at the bottom which sets the derivative<br>&gt; to 0.0 if it is above some constant threshold (currently set at 15.0<br>&gt; arrival time units). The derivatives in your image are much bigger<br>&gt; than 15.0 -- in the order of 50.0. By removing this code, or<br>&gt; significantly increasing the constant, I can get your image to work as<br>&gt; expected.<br>&gt;<br>&gt; In short, change the following lines in<br>&gt; itk::SingleImageCostFunction::GetDerivative from<br>&gt;<br>&gt; &nbsp;// Convert the image function output to the
 cost function derivative<br>&gt; &nbsp;const typename DerivativeType::ValueType DerivativeThreshold = 15.0;<br>&gt; &nbsp;for (int i=0; i&lt;ImageDimension; i++)<br>&gt; &nbsp; &nbsp;{<br>&gt; &nbsp; &nbsp;derivative[i] = static_cast&lt;typename DerivativeType::ValueType&gt;(<br>&gt; output[i] );<br>&gt;<br>&gt; &nbsp; &nbsp;// NOTE: The cost function may undefined / unreachable areas<br>&gt; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (indicated by very large values) which may skew the gradient.<br>&gt; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; To avoid this skewing effect, we reset gradient values larger<br>&gt; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; than a given threshold.<br>&gt; &nbsp; &nbsp;if ( vnl_math_abs(derivative[i]) &gt; DerivativeThreshold )<br>&gt; &nbsp; &nbsp; &nbsp;{<br>&gt; &nbsp; &nbsp; &nbsp;derivative[i] = 0.0;<br>&gt; &nbsp; &nbsp; &nbsp;}<br>&gt; &nbsp; &nbsp;}<br>&gt;<br>&gt; to<br>&gt;<br>&gt;
 &nbsp;// Convert the image function output to the cost function derivative<br>&gt; &nbsp;for (int i=0; i&lt;ImageDimension; i++)<br>&gt; &nbsp; &nbsp;{<br>&gt; &nbsp; &nbsp;derivative[i] = static_cast&lt;typename DerivativeType::ValueType&gt;(<br>&gt; output[i] );<br>&gt; &nbsp; &nbsp;}<br>&gt;<br>&gt; The proper way of solving this is to make the DerivativeThreshold a<br>&gt; user-specified parameter, which depends on the application.<br>&gt;<br>&gt; HTH<br>&gt;<br>&gt; Cheers, Dan<br>&gt;<br>&gt; On 6 July 2011 17:35, Dan Mueller &lt;<a ymailto="mailto:dan.muel@gmail.com" href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>&gt; wrote:<br>&gt;&gt; Hi Maria,<br>&gt;&gt;<br>&gt;&gt; Can you please upload the exact speed image and start/end points you<br>&gt;&gt; are trying to use?<br>&gt;&gt;<br>&gt;&gt; I suspect the issue is because the Fast Marching front (in ITK) does<br>&gt;&gt; not expand into regions which have 0.0 speed values. One
 possibility<br>&gt;&gt; is to scale your speed image to ensure no values are 0.0 (i.e. using<br>&gt;&gt; RescaleIntensityImageFilter with max=1.0 and min=0.01).<br>&gt;&gt;<br>&gt;&gt; To quote the Insight Journal article:<br>&gt;&gt; &nbsp; &nbsp;pg 4. "Choosing an appropriate speed function is the most<br>&gt;&gt; difficult part of the entire process"<br>&gt;&gt;<br>&gt;&gt; Cheers, Dan<br>&gt;&gt;<br>&gt;&gt; On 6 July 2011 17:13, Maria Alejandra Zuluaga Valencia<br>&gt;&gt; &lt;<a ymailto="mailto:mariazulv@yahoo.es" href="mailto:mariazulv@yahoo.es">mariazulv@yahoo.es</a>&gt; wrote:<br>&gt;&gt;&gt; Hi Dan,<br>&gt;&gt;&gt; In order to provide you more information I did a small modification to the<br>&gt;&gt;&gt; SpeedFunctionToPathFilter. I have added an image writer so that I can save<br>&gt;&gt;&gt; what you call the current arrival function. At the same time, I compare the<br>&gt;&gt;&gt; result with a well-known toolbox in matlab that performs the
 fast marching<br>&gt;&gt;&gt; (btw, this is my final purpose; using itk instead of matlab). What I found<br>&gt;&gt;&gt; is that the arrival functions differ significantly (might the problem be on<br>&gt;&gt;&gt; the Fastmarching itself?). Moreover, I do obtain a path in matlab, no matter<br>&gt;&gt;&gt; the end point.<br>&gt;&gt;&gt; To illustrate you the situation I provide you screenshots of the matlab<br>&gt;&gt;&gt; results (example_D_one_.jpg and example_path_one.jpg files) and the arrival<br>&gt;&gt;&gt; function with itk (example_D_two.jpg), since no path is obtained. For this<br>&gt;&gt;&gt; example, I have used an image of mine. I was using your Synthetic-04-Speed<br>&gt;&gt;&gt; to evaluate&nbsp; the filter, but I can't not read zraw in matlab, so that is why<br>&gt;&gt;&gt; I send you this other example. However, I will try to solve the zraw problem<br>&gt;&gt;&gt; so that I can run the matlab code in Synthetic-04-Speed.<br>&gt;&gt;&gt;
 Regarding your saying about the path, perhaps on an image as<br>&gt;&gt;&gt; Synthetic-04-Speed there should be no path when a point is badly placed (due<br>&gt;&gt;&gt; to the completely dark background) but, in the image as the one I am using I<br>&gt;&gt;&gt; think it should get something (as in matlab). I am not an expert but I<br>&gt;&gt;&gt; believe that one of the advantage/disadvantage of minimal paths approaches<br>&gt;&gt;&gt; is the fact that it will always find a path given two points. But, as I said<br>&gt;&gt;&gt; before, according to the results I am sending you, I believe the problem<br>&gt;&gt;&gt; seems to come from the arrival function and not from the path search. What<br>&gt;&gt;&gt; do you think?<br>&gt;&gt;&gt; Since my firewall does not allow me to attach files to emails, you can<br>&gt;&gt;&gt; obtain the screenshots here:<br>&gt;&gt;&gt; <a href="http://www.creatis.insa-lyon.fr/%7Ezuluaga/fm_issues/"
 target="_blank">http://www.creatis.insa-lyon.fr/~zuluaga/fm_issues/</a><br>&gt;&gt;&gt; regards,<br>&gt;&gt;&gt; Maria<br>&gt;&gt;&gt; ps. If you want I can also send you the image of my examples, while I solve<br>&gt;&gt;&gt; the zraw problem. It is very small (184x184x23). I could place it on my<br>&gt;&gt;&gt; server.<br>&gt;&gt;&gt; &nbsp;let me know if that sounds ok.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; ________________________________<br>&gt;&gt;&gt; De: Dan Mueller &lt;<a ymailto="mailto:dan.muel@gmail.com" href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>&gt;<br>&gt;&gt;&gt; Para: Maria Alejandra Zuluaga Valencia &lt;<a ymailto="mailto:mariazulv@yahoo.es" href="mailto:mariazulv@yahoo.es">mariazulv@yahoo.es</a>&gt;<br>&gt;&gt;&gt; CC: "<a ymailto="mailto:insight-users@itk.org" href="mailto:insight-users@itk.org">insight-users@itk.org</a>" &lt;<a ymailto="mailto:insight-users@itk.org"
 href="mailto:insight-users@itk.org">insight-users@itk.org</a>&gt;<br>&gt;&gt;&gt; Enviado: miércoles 6 de julio de 2011 14:43<br>&gt;&gt;&gt; Asunto: Re: [Insight-users] Problem with Fast marching minimal path<br>&gt;&gt;&gt; extraction<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Hi Maria,<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Can you please provide some more information?<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Which synthetic image are you using? Where are you placing the seed point?<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; I would not expect that every seed point will work -- the seed point<br>&gt;&gt;&gt; needs to be in a region which is reachable by the Fast Marching<br>&gt;&gt;&gt; expanding front. For example, placing the seed point in a region with<br>&gt;&gt;&gt; low speed (near 0.0) will not work.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Attached are a few examples using different seed points.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Regards, Dan<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; On 5 July 2011
 17:23, Maria Alejandra Zuluaga Valencia<br>&gt;&gt;&gt; &lt;<a ymailto="mailto:mariazulv@yahoo.es" href="mailto:mariazulv@yahoo.es">mariazulv@yahoo.es</a>&gt; wrote:<br>&gt;&gt;&gt;&gt; Hi,<br>&gt;&gt;&gt;&gt; I am trying to use the minimal path extraction algorithm reported in:<br>&gt;&gt;&gt;&gt; <a href="http://hdl.handle.net/1926/1332" target="_blank">http://hdl.handle.net/1926/1332</a><br>&gt;&gt;&gt;&gt; After some minor compilation errors I managed to make it work. However, I<br>&gt;&gt;&gt;&gt; found the behavior is a bit weird. As an example:<br>&gt;&gt;&gt;&gt; if I test with one of the Synthetic images provided and the path points<br>&gt;&gt;&gt;&gt; given, everything works fine. But, as soon as I change one of the path end<br>&gt;&gt;&gt;&gt; points it stops working. By stop working I mean that the extracted path<br>&gt;&gt;&gt;&gt; contains no points. I've tried with several examples and it is always the<br>&gt;&gt;&gt;&gt;
 case.<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt; As far as I know, no matter how bad I place my end point, I should get a<br>&gt;&gt;&gt;&gt; minimal path connecting the end and start points. Has any one had the same<br>&gt;&gt;&gt;&gt; kind of problem? did you managed to fix it?<br>&gt;&gt;&gt;&gt; thanks,<br>&gt;&gt;&gt;&gt; Maria<br>&gt;<br><br><br></div></div></div></body></html>