<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE-CH" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">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() ).
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Are filters of a pipeline not supposed to be used in a loop (where, in my case, the given transform changes at any loop)?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:DE-CH">I guess the issue formulated this way is a common issue.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:DE-CH"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:DE-CH">Thank you for your help.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:DE-CH"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:DE-CH">Fabio.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></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" style="mso-fareast-language:DE-CH">From:</span></b><span lang="EN-US" style="mso-fareast-language:DE-CH"> D'Isidoro Fabio
<br>
<b>Sent:</b> Sonntag, 1. Januar 2017 19:48<br>
<b>To:</b> <a href="mailto:insight-users@itk.org">insight-users@itk.org</a><br>
<b>Subject:</b> ExtractImageFilter.Update() inside loop works until 24th iteration<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal">Hallo,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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(). <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></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. <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The important parts of the code are:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">interpolatorRayCast =
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:#6F008A">itk</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">.RayCastInterpolateImageFunction[MovingImageType, ScalarType].New()<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">filterRayCast =
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:#6F008A">itk</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">.ResampleImageFilter[MovingImageType, MovingImageType].New()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">filterRedim =
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:#6F008A">itk</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">.ExtractImageFilter[MovingImageType, FixedImageType].New()</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">filterRayCast.SetInput( movingImageReader.GetOutput() )<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">filterRayCast.SetInterpolator( interpolatorRayCast )<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">…<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">filterRedim.SetInput(filterRayCast.GetOutput())<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">…<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:blue">for</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> dx
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:blue">in</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> translation_range_x:<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:blue">for</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> dy
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:blue">in</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> translation_range_y:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:blue">for</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> dz
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:blue">in</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> translation_range_z:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">…
<o:p></o:p></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 )<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span><span style="font-size:9.5pt;font-family:Consolas;color:black">filterRedim.Update()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"> value = metric.GetValue()
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I believe the pipeline might not be set properly, but I don’t know where.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">In attachment you find the code and the required inputs.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Any help would be highly appreciated, thank you!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Fabio.<o:p></o:p></span></p>
</div>
</body>
</html>