<div dir="ltr"><div><div>Could you try to modify your code to:<br><br><p class="MsoNormal"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Filter1.Update()</span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Output1 = Filter1.GetOutput()</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Output1.DisconnectPipeline()<br></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Filter2.SetInput(Output1)</span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Filter2.Update()</span></p>
<span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Output2
</span><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">= Filter2.GetOutput()<br></span><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Output2.DisconnectPipeline()<br><br></span></span></div><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">And let us know if that changes anything?<br><br></span></span></div><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"><span style="font-size:11pt;font-family:"calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Thanks!<br></span></span></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 2, 2017 at 12:23 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="blue" vlink="purple" lang="DE-CH">
<div class="m_-2511634237260232677WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">No, I did not know this option. I just coded this way:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Filter1.Update()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Output1 = Filter1.GetOutput()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Filter2.SetInput(Output1)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Filter2.Update()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Output2
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">= Filter2.GetOutput()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Instead of<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Filter2.SetInput( Filter1.GetOutput() )<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Filter2.Update()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Fabio<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> Francois Budin [mailto:<a href="mailto:francois.budin@kitware.com" target="_blank">francois.budin@<wbr>kitware.com</a>]
<br>
<b>Sent:</b> Montag, 2. Januar 2017 17:59<br>
<b>To:</b> D'Isidoro Fabio <<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>><br>
<b>Cc:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
<b>Subject:</b> Re: [ITK-users] FW: ExtractImageFilter.Update() inside loop works until 24th iteration<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hello Fabio,<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">When you say "avoid connecting its components with SetInput(GetOutput())", do you mean that you used the method "DisconnectPipeline()"?<u></u><u></u></p>
</div>
<p class="MsoNormal">Francois<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Sun, Jan 1, 2017 at 5:40 PM, D'Isidoro Fabio <<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<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() ).
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><u></u><u></u></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)?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">I guess the issue formulated this way is a common issue.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Thank you for your help.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Fabio.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><u></u><u></u></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</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></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().
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></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.    </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">The important parts of the code are:</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></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()</span><u></u><u></u></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()</span><u></u><u></u></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><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">…</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">filterRayCast.SetInput( movingImageReader.GetOutput() )</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">filterRayCast.SetInterpolator( interpolatorRayCast )</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">…</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">filterRedim.SetInput(<wbr>filterRayCast.GetOutput())</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">…</span><u></u><u></u></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:</span><u></u><u></u></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:</span><u></u><u></u></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:</span><u></u><u></u></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">… </span>
<u></u><u></u></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 )</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt">
<span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">                              
</span><span style="font-size:9.5pt;font-family:Consolas;color:black">filterRedim.Update()</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">             value = metric.GetValue() 
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">I believe the pipeline might not be set properly, but I don’t know where.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">In attachment you find the code and the required inputs.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Any help would be highly appreciated, thank you!</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#888888" lang="EN-US"> </span><span style="color:#888888"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#888888" lang="EN-US">Fabio.</span><span style="color:#888888"><u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" 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" 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" 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" 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" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>