<div dir="ltr">Thanks for getting back to me.<div><br></div><div>The numbers correspond correctly to what is expected when I do the math directly in MATLAB, and when I do the matrix multiplication I get the same coordinates that are output by ITK for both the translation that works and the rotation that does not.  One curious note is that while I set the center of rotation explicitly, it shows up as a zero vector in the output.  I was able to get the known rotation case to match up the expected coordinates by subtracting newTranslatin()->GetOffset(); from the resulting point, but then of course the known translation case fails.  </div><div><br></div><div>Any further thoughts would be appreciated.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p>--</p><p>AH<br></p><p><br></p><p>Andrew Harris, Honours BSc (Medical Physics)</p><p>PhD (CAMPEP) & MClSc Candidate</p><p>-----------------------------------------------------------------------------------------------</p><p><i>This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.</i></p></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Jun 29, 2017 at 3:04 PM, Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] <span dir="ltr"><<a href="mailto:zivrafael.yaniv@nih.gov" target="_blank">zivrafael.yaniv@nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="m_6079891158934912343WordSection1">
<p class="MsoNormal">The code snippet looks correct. I would advise that you print the transformations to see that you are getting what you expect. The relevant entries, Matrix, Center, Translation, Offset:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Original transform is:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><i>T</i>(<b>x</b>)=<i>A</i>(<b>x</b>−<b>c</b>)+<b>t</b>+<b>c</b><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Where:<u></u><u></u></p>
<p class="MsoNormal"><i>A</i> – matrix<u></u><u></u></p>
<p class="MsoNormal"><b>c</b> – center<u></u><u></u></p>
<p class="MsoNormal"><b>t </b>– translation<u></u><u></u></p>
<p class="MsoNormal"><b><i>t</i></b><i>+<b>c</b> –A</i><b>c</b> – offset<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The inverse should have:<u></u><u></u></p>
<p class="MsoNormal"><i>A</i>^{-1} – matrix<u></u><u></u></p>
<p class="MsoNormal"><b>c</b> – center<u></u><u></u></p>
<p class="MsoNormal">-<i>A</i>^{-1}<b> t </b>– translation<u></u><u></u></p>
<p class="MsoNormal"><b>c</b> - <i>A</i>^{-1}<b> t - </b><i>A</i>^{-1}<b> c</b> - offset<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">        hope this helps<u></u><u></u></p>
<p class="MsoNormal">                  Ziv<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">p.s. When working with ITK always remember that you are dealing with physical space, distances are in mm/km…, volumes in mm^3…. Don’t be tempted to measure things in pixels/voxels.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Andrew Harris <<a href="mailto:aharr8@uwo.ca" target="_blank">aharr8@uwo.ca</a>><br>
<b>Date: </b>Thursday, June 29, 2017 at 1:21 PM<br>
<b>To: </b>"Yaniv, Ziv Rafael (NIH/NLM/LHC) [C]" <<a href="mailto:zivrafael.yaniv@nih.gov" target="_blank">zivrafael.yaniv@nih.gov</a>><br>
<b>Cc: </b>Insight-users <<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>><br>
<b>Subject: </b>Re: [ITK-users] [ITK] applying a transform to an ITK Point object results in it moving the opposite direction from the image<u></u><u></u></span></p>
</div><div><div class="h5">
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks for getting back to me. Using the inverse transform on the point selected in the moving image works to transform the point within a reasonable amount to the homologous feature selected in the fixed image when I use two identical
 images with a known offset of 100 voxels in each direction.  However, upon testing identical images with a known rotation the selected points again fail to line up.  The transform I have been using is the Rigid3DVersorTransform, and the lines of code I'm using
 to set the inverse are: <u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">newTransform->SetCenter(<wbr>oldTransform->GetCenter());<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">oldTransform->GetInverse(<wbr>newTransform);<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Any idea why translation would work but rotation causes a problem?<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p>--<u></u><u></u></p>
<p>AH<u></u><u></u></p>
<p><u></u> <u></u></p>
<p>Andrew Harris, Honours BSc (Medical Physics)<u></u><u></u></p>
<p>PhD (CAMPEP) & MClSc Candidate<u></u><u></u></p>
<p>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-----<u></u><u></u></p>
<p><i>This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended
 recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.</i><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Jun 28, 2017 at 4:50 PM, Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] <<a href="mailto:zivrafael.yaniv@nih.gov" target="_blank">zivrafael.yaniv@nih.gov</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">Hello Andrew,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">In ITK the result of a registration maps points from the fixed image coordinate system to the moving coordinate system, so T(p_f) = p_m and the TRE is || T(p_f) – p_m||. I suspect
 you just need to use the inverse transform.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">You may be interested in this SimpleITK notebook (<a href="http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/67_Registration_Semiautomatic_Homework.html)" target="_blank">http://<wbr>insightsoftwareconsortium.<wbr>github.io/SimpleITK-Notebooks/<wbr>Python_html/67_Registration_<wbr>Semiautomatic_Homework.html)</a>
 which has a linked cursor GUI (gui.<span style="font-size:10.0pt;font-family:"Courier New",serif">
</span>RegistrationPointDataAquisitio<wbr>n). The source code for the UI is here: <a href="https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/gui.py" target="_blank">
https://github.com/<wbr>InsightSoftwareConsortium/<wbr>SimpleITK-Notebooks/blob/<wbr>master/Python/gui.py</a> .
<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">      hope this helps<u></u><u></u></p>
<p class="MsoNormal">             Ziv<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Andrew Harris <<a href="mailto:aharr8@uwo.ca" target="_blank">aharr8@uwo.ca</a>><br>
<b>Date: </b>Wednesday, June 28, 2017 at 3:14 PM<br>
<b>To: </b>Insight-users <<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>><br>
<b>Subject: </b>[ITK-users] [ITK] applying a transform to an ITK Point object results in it moving the opposite direction from the image</span><u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Hi there,
<u></u><u></u></p>
<div>
<p class="MsoNormal">I have been trying for a while to get this working: I want to be able to select corresponding points in a fixed and moving image, and determine how well the moving image is transformed
 to overlay the fixed image by using target registration error.  The problem is, using the same transform I applied to a moving image that translated it to the left, the point selected in the moving image gets translated to the right for example.  <br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p>--<u></u><u></u></p>
<p>AH<u></u><u></u></p>
<p> <u></u><u></u></p>
<p>Andrew Harris, Honours BSc (Medical Physics)<u></u><u></u></p>
<p>PhD (CAMPEP) & MClSc Candidate<u></u><u></u></p>
<p>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-----<u></u><u></u></p>
<p><i>This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended
 recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.</i><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>

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