<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap:break-word; color:rgb(0,0,0); font-size:14px; font-family:Calibri,sans-serif">
<div>Nick,</div>
<div><br>
</div>
<div>We certainly do NOT want to update the m_OutputTransform at each iteration in the normal case, but we do need an option for getting the currentIterationTransform if requested (even with a potentially huge performance penalty).</div>
<div><br>
</div>
<div>Ultimately we need to make a movie of the deformation field at each iteration, and I don't care if I take a 20x speed penalty for making the movie.</div>
<div><br>
</div>
<div>If you could provide a hint of what needs to be changed (in ITK or ANTS) that would be great.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Hans</div>
<div><br>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; border-bottom:medium none; border-left:medium none; padding-bottom:0in; padding-left:0in; padding-right:0in; border-top:#b5c4df 1pt solid; border-right:medium none; padding-top:3pt">
<span style="font-weight:bold">From: </span>Nick Tustison &lt;<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Sunday, December 2, 2012 1:14 PM<br>
<span style="font-weight:bold">To: </span>Hans Johnson &lt;<a href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>&gt;<br>
<span style="font-weight:bold">Cc: </span>Ali Ghayoor &lt;<a href="mailto:ali-ghayoor@uiowa.edu">ali-ghayoor@uiowa.edu</a>&gt;, ITK &lt;<a href="mailto:insight-developers@itk.org">insight-developers@itk.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [Insight-developers] &quot;itkSyNImageRegistrationMethod&quot; cannot return its metric's transform properly<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap:break-word">Okay, I figured it was just something I wasn't getting (particularly since
<div>I was attempting an answer late last night). &nbsp;I thought more about this</div>
<div>and I think I might have an idea of what the issue might be. &nbsp;</div>
<div><br>
</div>
<div>The SyNImageRegistrationMethod is used to optimize an itk</div>
<div>DisplacementFieldTransform since SyN doesn't fit in the generic&nbsp;</div>
<div>optimization&nbsp;framework. &nbsp;The way optimization works is that we</div>
<div>initially create two additional displacement field transforms (in&nbsp;</div>
<div>addition to&nbsp;m_OutputTransform) called something like</div>
<div><br>
</div>
<div>fixedToMiddleTransform</div>
<div>movingToMiddleTransform</div>
<div><br>
</div>
<div>The first describes the forward and inverse transform from the fixed</div>
<div>image to the middle space. &nbsp;The second describes the forward and</div>
<div>inverse transform from the moving image to the middle space. &nbsp;During</div>
<div>the optimization, we strictly optimize just these two transforms. &nbsp;</div>
<div>m_OutputTransform only gets updated at the end of optimization by&nbsp;</div>
<div>composing the&nbsp;correct forward and inverse fields of the&nbsp;</div>
<div>fixed/movingToMiddleTransform(s). &nbsp;We could potentially do this&nbsp;</div>
<div>composition at each iteration (i.e. update m_OutputTransform) but&nbsp;</div>
<div>that would be unnecessary computation (at least in terms of just getting</div>
<div>the final solution).</div>
<div><br>
</div>
<div>Nick</div>
<div>
<div><br>
</div>
<div><br>
<div>
<div>On Dec 2, 2012, at 11:34 AM, &quot;Johnson, Hans J&quot; &lt;<a href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="word-wrap:break-word; font-size:14px; font-family:Calibri,sans-serif">
<div>Ali,</div>
<div><br>
</div>
<div>You original e-mail is vague in its description of how you deterred that the displacement field has all zero's at every iteration.</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>-- Where you using a debugger?</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>-- How many zero values were listed? &nbsp;</div>
<div><br>
</div>
<div>Why do you need the const_cast in this code? &nbsp;Could that change the behavior? &nbsp;</div>
<div><br>
</div>
<div>The use of const_cast is an indication that you are tyring to do something that is not supported. &nbsp;Either ITK is deficient in not providing a const version of that member function, or you are trying to do something that has been explicitly prohibited.</div>
<div><br>
</div>
<div>Due to the ambiguity in your original posting, it is hard to figure out what your problem is. &nbsp;You know that the the overall program produces a good result at the end, but you are trying to interrogate the process at every iteration, and for that you need
 to get the moving transform at each iteration.</div>
<div><br>
</div>
<div>*** &nbsp;I think that the problem you are having is exposing the current transform at each iteration to the observer. &nbsp;***</div>
<div><br>
</div>
<div>The response from Nick does not seem to address your real problem.</div>
<div><br>
</div>
<div>Please make a more thorough and very clearly stated problem, and then post enough information so that an external developer can replicate your error on their machine QUICKLY and EASILY.&nbsp;</div>
<div><br>
</div>
<div>Keep these facts in mind when requesting help from the ITK developer community:</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>1) We are almost all volunteers. &nbsp;We help out of kindness not financial gain.</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>2)&nbsp;&nbsp;If we can not replicate your error on my computer, we can not fix it.</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>3) Our time is valuable, if we need to guess, work, hard, or decipher code to determine how to replicate your problem, we will not have the time or energy even to get started</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>4) Provide both a) A description of the problem, b) description of how to replicate the problem, *** c) a description of how you believe the code should behave ***, and d) a proposed solution</div>
<div><br>
</div>
<div><br>
</div>
<div>Hans</div>
<div><br>
</div>
<div>PS: Nick Thanks for trying to address this request. &nbsp;The original request was not very clear, and your effort showed that the end result is good (that was never in doubt). &nbsp;The problem is interrogating for the current transform at every iteration.</div>
<div><br>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; border-width:1pt medium medium; border-style:solid none none; padding:3pt 0in 0in; border-top-color:rgb(181,196,223)">
<span style="font-weight:bold">From: </span>Nick Tustison &lt;<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Saturday, December 1, 2012 8:24 PM<br>
<span style="font-weight:bold">To: </span>Ali Ghayoor &lt;<a href="mailto:ali-ghayoor@uiowa.edu">ali-ghayoor@uiowa.edu</a>&gt;<br>
<span style="font-weight:bold">Cc: </span>ITK &lt;<a href="mailto:insight-developers@itk.org">insight-developers@itk.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [Insight-developers] &quot;itkSyNImageRegistrationMethod&quot; cannot return its metric's transform properly<br>
</div>
<div><br>
</div>
<div><base href="">
<div style="word-wrap:break-word">Hi Ali,
<div><br>
</div>
<div>I don't think that there's a deficiency. &nbsp;I just ran the itkSyNImageRegistrationTest</div>
<div>and added the following snippet to write the displacement field to disk starting</div>
<div>at line 275.</div>
<div><br>
</div>
<div>
<div>&nbsp; typedef itk::ImageFileWriter&lt;DisplacementFieldType&gt; WriterType2;</div>
<div>&nbsp; typename WriterType2::Pointer writer2 = WriterType2::New();</div>
<div>&nbsp; writer2-&gt;SetFileName( &quot;/Users/ntustison/Desktop/testDisplacementField.nii.gz&quot; );</div>
<div>&nbsp; writer2-&gt;SetInput( outputTransform-&gt;GetDisplacementField() );</div>
<div>&nbsp; writer2-&gt;Update();</div>
</div>
<div><br>
</div>
<div>The result was a non-zero displacement field that looked reasonable based</div>
<div>on the parameters specified by the test.</div>
<div><br>
</div>
<div>Nick</div>
<div><br>
</div>
<div><br>
<div>
<div>On Dec 1, 2012, at 8:30 PM, &quot;Ghayoor, Ali&quot; &lt;<a href="mailto:ali-ghayoor@uiowa.edu">ali-ghayoor@uiowa.edu</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="font-family:Helvetica; font-size:medium; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; word-wrap:break-word">
<div style="direction:ltr; font-family:Tahoma; font-size:10pt"><font size="3" face="Calibri">Hello Developers,<br>
</font>
<div style=""><span id="OLK_SRC_BODY_SECTION"><font size="3" face="Calibri"></font>
<div>
<div style="word-wrap:break-word">
<div><font size="3" face="Calibri"><br>
</font></div>
<div><font size="3" face="Calibri">In a registration framework, at each iteration, I get the current moving transform from the metric of the &quot;itkSyNImageRegistrationMethod&quot; filter; however, the returned moving transform has a displacement field with all zero
 values at every iteration.&nbsp;</font></div>
<div><font size="3" face="Calibri"><br>
</font></div>
<div><font size="3" face="Calibri">To inspect this deficiency in ITK, I used&nbsp;<span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important">&quot;itkSyNImageRegistrationTest.cxx&quot;,
 and made some modifications in the test code for this purpose.</span></font></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><font size="3" face="Calibri">I
 added an iteration observer to the SyN registration stage:</font></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><font size="3" face="Calibri"><br>
</font></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><font size="3" face="Calibri"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important">&nbsp;
 &nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>typedef CommandIterationUpdate&lt;DisplacementFieldRegistrationType&gt; DisplacementFieldCommandType;&nbsp;</span><br style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">
<span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important">&nbsp;
 &nbsp;&nbsp;typename DisplacementFieldCommandType::Pointer DisplacementFieldObserver = DisplacementFieldCommandType::New();&nbsp;</span><br style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">
<span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important">&nbsp;
 &nbsp;&nbsp;displacementFieldRegistration-&gt;AddObserver( itk::IterationEvent(), DisplacementFieldObserver );&nbsp;</span></font></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><font size="3" face="Calibri"><br>
</font></span></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><font size="3" face="Calibri">Then,
 inside the observer class, I asked for the parameters of the moving transform at the current iteration:</font></span></span></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><font size="3" face="Calibri"><br>
</font></span></span></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><font size="3" face="Calibri"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;
 &nbsp;std::cout &lt;&lt; &quot; parameters: &quot; &lt;&lt; const_cast&lt;TFilter *&gt;( filter )-&gt;GetMetric()-&gt;GetMovingTransform()-&gt;GetParameters() &lt;&lt; std::endl;&nbsp;</span><br style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">
<span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important">&nbsp;
 &nbsp;std::cout &lt;&lt; &quot; fixed parameters &quot; &lt;&lt; const_cast&lt;TFilter *&gt;( filter )-&gt;GetMetric()-&gt;GetMovingTransform()-&gt;GetFixedParameters() &lt;&lt; std::endl;</span></font></span></span></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><font size="3" face="Calibri"><br>
</font></span></span></span></span></div>
<div><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; background-color:transparent; display:inline!important"><span style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:17px; orphans:2; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; float:none; display:inline!important"><font size="3" face="Calibri">However,
 the Parameters of the moving transform is an all zero valued displacement field at each iteration.</font></span></span></span></span></div>
<div><font size="3" face="Calibri">Do you know why the registration filter does not return the right moving transform?&nbsp;<span style="line-height:17px">Could you please help about this problem.</span></font></div>
<div><span class="Apple-style-span" style="line-height:17px"><font size="3" face="Calibri"><br>
</font></span></div>
<div><span class="Apple-style-span" style="line-height:17px"><font size="3" face="Calibri">Thanks,</font></span></div>
<div><span class="Apple-style-span" style="line-height:17px"><font size="3" face="Calibri">Ali</font></span></div>
</div>
</div>
</span></div>
</div>
_______________________________________________<br>
Powered by<span class="Apple-converted-space">&nbsp;</span><a href="http://www.kitware.com/">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://kitware.com/products/protraining.php">http://kitware.com/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">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-developers">http://www.itk.org/mailman/listinfo/insight-developers</a><br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</span><br>
<br>
<hr>
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.&nbsp; If you are not the intended recipient, you are hereby notified that any
 retention, dissemination, distribution, or copying of this communication is strictly prohibited.&nbsp; Please reply to the sender that you have received the message in error, then delete it.&nbsp; Thank you.
<hr>
</div>
</blockquote>
</div>
<br>
</div>
</div>
<div><br>
</div>
</div>
</div>
</span><br>
<br>
<hr>
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.&nbsp; If you are not the intended recipient, you are hereby notified that any
 retention, dissemination, distribution, or copying of this communication is strictly prohibited.&nbsp; Please reply to the sender that you have received the message in error, then delete it.&nbsp; Thank you.
<hr>
</body>
</html>