<div dir="ltr"><div><div>Hello Fabio,<br><br></div>When you say "avoid connecting its components with SetInput(GetOutput())", do you mean that you used the method "DisconnectPipeline()"?<br><br></div>Francois<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 1, 2017 at 5:40 PM, D'Isidoro Fabio <span dir="ltr"><<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="#0563C1" vlink="#954F72" lang="DE-CH">
<div class="m_8626721269194741804WordSection1">
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Update: generalizing the problem, I figured out that any time the final filter is updated inside a loop, after a certain number of iterations the Update() does not work anymore and filter.GetOutput()
returns always the same image as the last working iteration. I guess it’s a memory issue. This issue happens no matter what the final filter of the pipeline is (I tried with ResampleImageFilter, Writer, ExtractImageFilter), and even when using the filter.InPlaceOn()
when possible. This issue happens even if I split the pipeline and avoid connecting its components with SetInput( GetOutput() ).
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Are filters of a pipeline not supposed to be used in a loop (where, in my case, the given transform changes at any loop)?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">I guess the issue formulated this way is a common issue.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Thank you for your help.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Fabio.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> D'Isidoro Fabio
<br>
<b>Sent:</b> Sonntag, 1. Januar 2017 19:48<br>
<b>To:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
<b>Subject:</b> ExtractImageFilter.Update() inside loop works until 24th iteration<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal">Hallo,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-US">I work with ITK Python. I need to explore the domain of an image metric (like in MeanSquaresImageMetric1.cxx) for 2D/3D registration (using RayCastInterpolator). Since the metric works only between 2D/2D or 3D/3D images,
I need to convert the generated DRR (SizeX, SizeY, 1) into a 2D image (SizeX, SizeY) with ExtractImageFilter, before metric evaluation. I then pass to the metric the converted 2D DRR as moving image and the 2D fixed image for similarity metric evaluation (with
IdentityTransform, and NearestNeighbourInterpolator set for the metric). Metric evaluation is done in a loop within a range of the domain for the transform parameters. For each iteration of the loop (that is, different transforms used for generation of the
DRR) the ExtractImageFilter is updated with Update(). <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">The code runs but mysteriously stops working properly at the 24<sup>th</sup> iteration of the loop for the domain range. After the 24<sup>th</sup> iteration I figured no new DRR is generated and the metric value keeps
constant at the value of the 24<sup>th</sup> iteration. I tried with input 3D volumes of different sizes and with different ranges for the transform parameters, but the code stops generating new DRRs always after the 24<sup>th</sup> iteration. <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">The important parts of the code are:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">interpolatorRayCast =
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.<wbr>RayCastInterpolateImageFunctio<wbr>n[MovingImageType, ScalarType].New()<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">filterRayCast =
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.ResampleImageFilter[<wbr>MovingImageType, MovingImageType].New()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">filterRedim =
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.ExtractImageFilter[<wbr>MovingImageType, FixedImageType].New()</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">…<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">filterRayCast.SetInput( movingImageReader.GetOutput() )<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">filterRayCast.SetInterpolator( interpolatorRayCast )<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">…<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">filterRedim.SetInput(<wbr>filterRayCast.GetOutput())<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">…<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue" lang="EN-US">for</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"> dx
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue" lang="EN-US">in</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"> translation_range_x:<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue" lang="EN-US">for</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"> dy
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue" lang="EN-US">in</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"> translation_range_y:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue" lang="EN-US">for</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"> dz
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue" lang="EN-US">in</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"> translation_range_z:<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">…
<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black">transformDRR.SetParameters( transform_parameters )<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span><span style="font-size:9.5pt;font-family:Consolas;color:black">filterRedim.Update()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"> value = metric.GetValue()
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">I believe the pipeline might not be set properly, but I don’t know where.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">In attachment you find the code and the required inputs.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Any help would be highly appreciated, thank you!<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Fabio.<u></u><u></u></span></p>
</font></span></div>
</div>
<br>______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>