[ITK] [ITK-users] applying transform to point

Andras Lasso lasso at queensu.ca
Mon Feb 2 17:22:21 EST 2015


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.

See detailed explanation and sample conversion code in the Transform files section of this page:
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/Transforms

Andras
________________________________
From: Hammond, Emily M<mailto:emily-hammond at uiowa.edu>
Sent: ‎2015-‎02-‎02 15:59
To: insight users<mailto:insight-users at itk.org>
Subject: [ITK] [ITK-users] applying transform to point

Hello all,

Here is the flow of my program.

1. read in fiducial points noted with Slicer (to my understanding to get from Slicer to ITK, invert the first two coordinates)
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.
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.

// create iterator to parse through the transform list
TransformListType::const_iterator itTrans = this->m_TransformList.begin();
for(; itTrans != this->m_TransformList.end(); itTrans++ )
{
// determine what type of transform it is
if( !strcmp( (*itTrans)->GetNameOfClass(), "AffineTransform" ) )
{
// extract transform
AffineTransformType::Pointer affineTrans = static_cast< AffineTransformType * >( (*itTrans).GetPointer() );

// apply to landmarks
LandmarksType::const_iterator itLM = this->m_TransformedMovingLandmarks.begin();
for(; itLM != this->m_TransformedMovingLandmarks.end(); itLM++ )
{
this->m_TransformedMovingLandmarks[ itLM->first ] = affineTrans->TransformPoint( itLM->second );
}
}
else if( !strcmp( (*itTrans)->GetNameOfClass(), "BSplineTransform" ) )
{
// extract transforms
BSplineTransformType::Pointer bsplineTrans = static_cast< BSplineTransformType * >( (*itTrans).GetPointer() );

// apply to landmarks
LandmarksType::const_iterator itLM = this->m_TransformedMovingLandmarks.begin();
for(; itLM != this->m_TransformedMovingLandmarks.end(); itLM++ )
{
this->m_TransformedMovingLandmarks[ itLM->first ] = bsplineTrans->TransformPoint( itLM->second );
}
}
else
{
std::cerr << "TransformType is not recognized." << std::endl;
}
}

NOTE: m_TransformedMovingList is initialized to the original read in fiducial list

4. read out the transform fiducials (invert first two coordinates for observation in Slicer purposes)
5. Compare the results using Slicer

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.

Thanks!
Emily Hammond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150202/145f605f/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list