<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body class=" hasGoogleVoiceExt">
<div>
<div style="font-family:Calibri,sans-serif; font-size:11pt">RAS/LPS conversion is more complex than just inverting the sign of the first two coordinates of a point. There may be also modeling/resampling transform mismatch.<br>
<br>
See detailed explanation and sample conversion code in the Transform files section of this page:<br>
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/Transforms<br>
<br>
Andras</div>
</div>
<div dir="ltr">
<hr>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">From:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt"><a href="mailto:emily-hammond@uiowa.edu">Hammond, Emily M</a></span><br>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">Sent:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt">ý2015-ý02-ý02 15:59</span><br>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">To:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt"><a href="mailto:insight-users@itk.org">insight users</a></span><br>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">Subject:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt">[ITK] [ITK-users] applying transform to point</span><br>
<br>
</div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hello all,
<div><br>
</div>
<div>Here is the flow of my program.</div>
<div><br>
</div>
<div>1. read in fiducial points noted with Slicer (to my understanding to get from Slicer to ITK, invert the first two coordinates)</div>
<div>2. read in transform from files with TransformFileReaderTemplate class. This reads in the transforms as a list and I can add multiple transforms to the list.</div>
<div>3. apply the transforms in the list (in order) to the fiducials using the TransformPoint method for each transform. Here is the code I am using to apply the transforms.</div>
<div><br>
</div>
<div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// create iterator to parse through the transform list</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>TransformListType::const_iterator itTrans = this->m_TransformList.begin();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>for(; itTrans != this->m_TransformList.end(); itTrans++ )</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// determine what type of transform it is</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>if( !strcmp( (*itTrans)->GetNameOfClass(), "AffineTransform" ) )</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// extract transform</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>AffineTransformType::Pointer affineTrans = static_cast< AffineTransformType * >( (*itTrans).GetPointer() );</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// apply to landmarks</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>LandmarksType::const_iterator itLM = this->m_TransformedMovingLandmarks.begin();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>for(; itLM != this->m_TransformedMovingLandmarks.end(); itLM++ )</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="font-size:10pt; white-space:pre"></span><span style="font-size:10pt">this->m_TransformedMovingLandmarks[ itLM->first ] = affineTrans->TransformPoint( itLM->second );</span></div>
<div><span class="Apple-tab-span" style="font-size:10pt; white-space:pre"></span><span style="font-size:10pt">}</span></div>
<div><span class="Apple-tab-span" style="font-size:10pt; white-space:pre"></span><span style="font-size:10pt">}</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>else if( !strcmp( (*itTrans)->GetNameOfClass(), "BSplineTransform" ) )</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// extract transforms</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>BSplineTransformType::Pointer bsplineTrans = static_cast< BSplineTransformType * >( (*itTrans).GetPointer() );</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// apply to landmarks</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>LandmarksType::const_iterator itLM = this->m_TransformedMovingLandmarks.begin();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>for(; itLM != this->m_TransformedMovingLandmarks.end(); itLM++ )</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="font-size:10pt; white-space:pre"></span><span style="font-size:10pt">this->m_TransformedMovingLandmarks[ itLM->first ] = bsplineTrans->TransformPoint( itLM->second );</span></div>
<div><span class="Apple-tab-span" style="font-size:10pt; white-space:pre"></span><span style="font-size:10pt">}</span></div>
<div><span class="Apple-tab-span" style="font-size:10pt; white-space:pre"></span><span style="font-size:10pt">}</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>else</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>std::cerr << "TransformType is not recognized." << std::endl;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
</div>
<div><br>
</div>
<div><span style="font-size:13.3333330154419px">NOTE: m_TransformedMovingList is initialized to the original read in fiducial list</span></div>
<div><br>
</div>
<div>4. read out the transform fiducials (invert first two coordinates for observation in Slicer purposes)</div>
<div>5. Compare the results using Slicer</div>
<div><br>
</div>
<div>Problem: This method works just fine with scaling and translation transforms (given the last coordinate is inverted instead of the first two -> first question), however, once rotation (and shearing) is applied the result is wrong. Can anyone give some
insight? I'm assuming there is some coordinate system conversion that needs to take place on the transform.</div>
<div><br>
</div>
<div>Thanks!</div>
<div>Emily Hammond</div>
</div>
</div>
</body>
</html>