<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Yeah, that should be easy to do and I don't know that it would be a substantive <div>penalty---just unnecessary for minimum functionality. It requires two instances of the <div>itkComposeDisplacementFieldsImageFilter. If you take a look at the GenerateData()</div><div><div>function in itkSyNImageRegistrationMethod.hxx starting at line 537 and </div><div>going to line 550 you can see what I described in the last email to update </div><div>the output transform. </div><div><br></div><div><div><i> typedef ComposeDisplacementFieldsImageFilter<DisplacementFieldType, DisplacementFieldType> ComposerType;</i></div><div><i><br></i></div><div><i> typename ComposerType::Pointer composer = ComposerType::New();</i></div><div><i> composer->SetDisplacementField( this->m_MovingToMiddleTransform->GetInverseDisplacementField() );</i></div><div><i> composer->SetWarpingField( this->m_FixedToMiddleTransform->GetDisplacementField() );</i></div><div><i> composer->Update();</i></div><div><i><br></i></div><div><i> typename ComposerType::Pointer inverseComposer = ComposerType::New();</i></div><div><i> inverseComposer->SetDisplacementField( this->m_FixedToMiddleTransform->GetInverseDisplacementField() );</i></div><div><i> inverseComposer->SetWarpingField( this->m_MovingToMiddleTransform->GetDisplacementField() );</i></div><div><i> inverseComposer->Update();</i></div><div><i><br></i></div><div><i> this->m_OutputTransform->SetDisplacementField( composer->GetOutput() );</i></div><div><i> this->m_OutputTransform->SetInverseDisplacementField( inverseComposer->GetOutput() );</i></div></div><div><br></div><div>We create two instances of the composer filter to create the forward and inverse </div><div>displacement fields and assign those to the output transform. We would need to </div><div>take that snippet and copy that to wherever you wanted to query for the current </div><div>transform. The iterative optimization all takes place in the StartOptimization() </div><div>function. I'm assuming you could copy the snippet to somewhere around line </div><div>222 within a conditional where the metric value is assigned and the two transforms </div><div>to the middle have already been optimized for that iteration. </div><div><br></div><div>Nick</div><div><br></div><div><br><div><br></div><div><br><div><div>On Dec 2, 2012, at 3:31 PM, "Johnson, Hans J" <<a href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<div style="word-wrap: break-word; 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; 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 <<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>><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 <<a href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>><br>
<span style="font-weight:bold">Cc: </span>Ali Ghayoor <<a href="mailto:ali-ghayoor@uiowa.edu">ali-ghayoor@uiowa.edu</a>>, ITK <<a href="mailto:insight-developers@itk.org">insight-developers@itk.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [Insight-developers] "itkSyNImageRegistrationMethod" 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). I thought more about this</div>
<div>and I think I might have an idea of what the issue might be. </div>
<div><br>
</div>
<div>The SyNImageRegistrationMethod is used to optimize an itk</div>
<div>DisplacementFieldTransform since SyN doesn't fit in the generic </div>
<div>optimization framework. The way optimization works is that we</div>
<div>initially create two additional displacement field transforms (in </div>
<div>addition to 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. The second describes the forward and</div>
<div>inverse transform from the moving image to the middle space. During</div>
<div>the optimization, we strictly optimize just these two transforms. </div>
<div>m_OutputTransform only gets updated at the end of optimization by </div>
<div>composing the correct forward and inverse fields of the </div>
<div>fixed/movingToMiddleTransform(s). We could potentially do this </div>
<div>composition at each iteration (i.e. update m_OutputTransform) but </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, "Johnson, Hans J" <<a href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>> 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? </div>
<div><br>
</div>
<div>Why do you need the const_cast in this code? Could that change the behavior? </div>
<div><br>
</div>
<div>The use of const_cast is an indication that you are tyring to do something that is not supported. 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. 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>*** I think that the problem you are having is exposing the current transform at each iteration to the observer. ***</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. </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. We help out of kindness not financial gain.</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>2) 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. The original request was not very clear, and your effort showed that the end result is good (that was never in doubt). 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 <<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>><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 <<a href="mailto:ali-ghayoor@uiowa.edu">ali-ghayoor@uiowa.edu</a>><br>
<span style="font-weight:bold">Cc: </span>ITK <<a href="mailto:insight-developers@itk.org">insight-developers@itk.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [Insight-developers] "itkSyNImageRegistrationMethod" cannot return its metric's transform properly<br>
</div>
<div><br>
</div>
<div><base href="x-msg://6709/">
<div style="word-wrap:break-word">Hi Ali,
<div><br>
</div>
<div>I don't think that there's a deficiency. 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> typedef itk::ImageFileWriter<DisplacementFieldType> WriterType2;</div>
<div> typename WriterType2::Pointer writer2 = WriterType2::New();</div>
<div> writer2->SetFileName( "/Users/ntustison/Desktop/testDisplacementField.nii.gz" );</div>
<div> writer2->SetInput( outputTransform->GetDisplacementField() );</div>
<div> writer2->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, "Ghayoor, Ali" <<a href="mailto:ali-ghayoor@uiowa.edu">ali-ghayoor@uiowa.edu</a>> 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 "itkSyNImageRegistrationMethod" filter; however, the returned moving transform has a displacement field with all zero
values at every iteration. </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 <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">"itkSyNImageRegistrationTest.cxx",
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">
<span class="Apple-tab-span" style="white-space:pre"> </span>typedef CommandIterationUpdate<DisplacementFieldRegistrationType> DisplacementFieldCommandType; </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">
typename DisplacementFieldCommandType::Pointer DisplacementFieldObserver = DisplacementFieldCommandType::New(); </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">
displacementFieldRegistration->AddObserver( itk::IterationEvent(), DisplacementFieldObserver ); </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>
std::cout << " parameters: " << const_cast<TFilter *>( filter )->GetMetric()->GetMovingTransform()->GetParameters() << std::endl; </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">
std::cout << " fixed parameters " << const_cast<TFilter *>( filter )->GetMetric()->GetMovingTransform()->GetFixedParameters() << 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? <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"> </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. If you are not the intended recipient, you are hereby notified that any
retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. 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. If you are not the intended recipient, you are hereby notified that any
retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
<hr>
</div>
</blockquote></div><br></div></div></div></div></body></html>