[Insight-users] Request for help with rigid 3D rotation and translation image registration. (no attachment this time)

Greg Harris Gregory-Harris at uiowa.edu
Sat Jul 9 17:45:24 EDT 2005


Hi Luis,

When executing the code


            typedef typename 
MIMRegistrator<TImage,TImage>::VersorRigid3DTransformType 
VersorRigid3DTransformType
;
            typename VersorRigid3DTransformType::Pointer 
VersorRigid3DTransform = m_Registrator->GetVersorRigid3D
Transform();

            typedef typename 
MIMRegistrator<TImage,TImage>::TransformInitializerType 
TransformInitializerType;
            typename TransformInitializerType::Pointer initializer = 
TransformInitializerType::New();

std::cout << "Fixed Image Spacing:  " << 
m_Preprocessor->GetOutputFixedImage()->GetSpacing() << std::endl;
std::cout << "Moving Image Spacing:  " << 
m_Preprocessor->GetOutputMovingImage()->GetSpacing() << std::endl;

            VersorRigid3DTransform->SetIdentity();
            std::cout << "Center: " << 
VersorRigid3DTransform->GetCenter() << std::endl;
            std::cout << "Matrix: " << std::endl << 
VersorRigid3DTransform->GetRotationMatrix();
            std::cout << "Offset: " << 
VersorRigid3DTransform->GetOffset() << std::endl << std::endl;
            initializer->SetTransform(   VersorRigid3DTransform );
            initializer->SetFixedImage(  
m_Preprocessor->GetOutputFixedImage() );
            initializer->SetMovingImage( 
m_Preprocessor->GetOutputMovingImage() );
            initializer->MomentsOn();
            initializer->InitializeTransform();
            std::cout << "Center: " << 
VersorRigid3DTransform->GetCenter() << std::endl;
            std::cout << "Matrix: " << std::endl << 
VersorRigid3DTransform->GetRotationMatrix();
            std::cout << "Offset: " << 
VersorRigid3DTransform->GetOffset() << std::endl;


we get the output


Fixed Image Spacing:  [2, 2, 2]
Moving Image Spacing:  [2, 2, 3]
Center: [0, 0, 0]
Matrix:
1 0 0
0 1 0
0 0 1
Offset: [0, 0, 0]

Center: [-2.07894e+09, 2.31865e+08, -1.09368e+09]
Matrix:
1 0 0
0 1 0
0 0 1
Offset: [2.17714e+09, 2.09183e+09, 2.088e+09]


and when we change MomentsOn() to GeometryOn(), we get the output


Fixed Image Spacing:  [2, 2, 2]
Moving Image Spacing:  [2, 2, 3]
Center: [0, 0, 0]
Matrix:
1 0 0
0 1 0
0 0 1
Offset: [0, 0, 0]

Center: [1, 1, 1]
Matrix:
1 0 0
0 1 0
0 0 1
Offset: [0, 0, 0.5]


Again, these numbers are based on CenterOfGravity from 
itkImageMomentsCalculator
applied to each image;  the center of gravity would not be invalid in a 
multi-modal case.
Switching to GeometryOn() will not find the middle of the brain (or 
head) in the image field.

Can it be that

        m_Image->TransformIndexToPhysicalPoint(indexPosition, 
physicalPosition);

is getting an absurd physicalPosition in ImageMomentsCalculator::Compute()?

Greg



Luis Ibanez wrote:

>
> Hi Greg,
>
>
> The number in the Transform are clearly wrong.
>
>
> Note that the MomentsOn() option only makes sense
> for Same-Modality images. If your images are of
> different modality you may want to stick to the
> GeometryOn() option.
>
> Please make sure that you print out the Versor
> Rigid Transform as soon as you run the Initializer.
>
> It is quite likely that the adaptor that is connecting
> the Transform to an Affine transform may be corrupting
> its values.
>
>
> Please let us know what you find,
>
>
>    Thanks
>
>
>      Luis
>
>
>
> ======================
> Greg Harris wrote:
>
>> Luis,
>>
>> I have looked at Insight/Examples/Registration/ImageRegistration8.cxx,
>> and the main thing I seem to have overlooked is the use of a
>> CenteredTransformInitializer; but when I spliced this behavior in 
>> like this:
>>
>>            /*
>>             *  BEGIN GLITCH:
>>             *
>>             *  In order to faithfully reproduce 
>> Insight/Examples/Registration/ImageRegistration8.cxx
>>             *  as to the use of a CenteredTransformInitializer, we 
>> had to deprecate the
>>             *  SetInitialVersorRigid3DParameters applied to the given 
>> affine transform and
>>             *  hoist the AssignRigidAffineTransform business up where 
>> FixedImage and MovingImage
>>             *  are well-defined.
>>             */
>>
>>            typedef typename 
>> MIMRegistrator<TImage,TImage>::VersorRigid3DTransformType 
>> VersorRigid3DTransformType;
>>            typename VersorRigid3DTransformType::Pointer 
>> VersorRigid3DTransform = m_Registrator->GetVersorRigid3DTransform();
>>
>>            typedef typename 
>> MIMRegistrator<TImage,TImage>::TransformInitializerType 
>> TransformInitializerType;
>>            typename TransformInitializerType::Pointer initializer = 
>> TransformInitializerType::New();
>>
>>            //VersorRigid3DTransform->SetIdentity();
>>            initializer->SetTransform(   VersorRigid3DTransform );
>>            initializer->SetFixedImage(  
>> m_Preprocessor->GetOutputFixedImage() );
>>            initializer->SetMovingImage( 
>> m_Preprocessor->GetOutputMovingImage() );
>>            initializer->MomentsOn();
>>            initializer->InitializeTransform();
>>
>>            /*
>>             *  ... replacing this:
>>             *
>>             *  m_Registrator->SetInitialVersorRigid3DParameters(
>>             *           m_TransformAdaptor->GetITKAffineTransform() );
>>             */
>>
>>            typedef typename 
>> MIMRegistrator<TImage,TImage>::AffineTransformType AffineTransformType;
>>            const typename AffineTransformType::Pointer 
>> GivenAffineTransform = m_TransformAdaptor->GetITKAffineTransform();
>>            AssignRigidAffineTransform < double, 3 > ( 
>> VersorRigid3DTransform, GivenAffineTransform );
>>            m_Registrator->SetInitialVersorRigid3DParameters( 
>> VersorRigid3DTransform->GetParameters() );
>>
>>            /*
>>             * END GLITCH.
>>             *
>>             *  Lesson:  do not use a VersorRigid3DTransform without a 
>> CenteredTransformInitializer.
>>             */
>>
>> then the result of the InitializeTransform is described by
>>
>> Initialized VersorRigid3DTransform's offset:  [2.17714e+09, 
>> 2.09183e+09, 2.088e+09]
>> and center [-2.07894e+09, 2.31865e+08, -1.09368e+09]
>>
>> These numbers are based on CenterOfGravity from 
>> itkImageMomentsCalculator
>> applied to each image;  even though one image is isotropic and one is 
>> anisotropic,
>> the numbers are much too big and result in sampling out-of-field.  
>> And the Spacing
>> values are not uninitialized:
>>
>> Fixed Image Spacing:  [2, 2, 2]
>> Moving Image Spacing:  [2, 2, 3]
>>
>> Greg Harris
>> Iowa Psychiatry Brain Imaging Lab.
>>
>>
>> Luis Ibanez wrote:
>>
>>>
>>>
>>> Hi Greg,
>>>
>>>
>>> You may be using a too advanced example for what you need to do.
>>>
>>>
>>> If you only need to solve for a rigid transform it is likely that
>>> an example such as
>>>
>>>
>>>           Insight/Examples/ImageRegistration8.cxx
>>>
>>>
>>> may have all the elements that you need, except for the need of
>>> replacing the metric for one suitable for Multi-Modality images,
>>> such as Mutual Information.
>>>
>>>
>>>
>>> We will be happy to take a look at your registration problem,
>>> we are currently downloading Brains2 and building it according
>>> to the instructions in your Wiki page.
>>>
>>>
>>> Could you please let us know what types of images you are using ?
>>>
>>>
>>>
>>>    Thanks
>>>
>>>
>>>       Luis
>>>
>>>
>>>
>>>
>>> --------------------------------------
>>> Greg Harris wrote:
>>>
>>>> Dear fellow ITK users,
>>>>
>>>> This is my request for help with rigid 3D rotation and translation
>>>> image registration of the human brain.
>>>>
>>>> Largely as a result of the ITK manual, section 8.4, including the
>>>> statement, "It has been extensively shown that metrics based on
>>>> the evaluation of mutual information is the best way to overcome
>>>> the difficulties of multi-modality registration,"  I have been 
>>>> laboring
>>>> for some months trying to make this happen in our brains2
>>>> project setting.
>>>>
>>>> My present best effort, that began by imitating the SimpleApp
>>>> framework, can be seen in detail in the brains2 CVS source tree,
>>>> where brains2/src/iplProg/MutualRegistration contains C++
>>>> source and a test data set in 3D and a plan for testing called
>>>> PrincipalDebugTesting.tcl.
>>>>
>>>> The files MIMRegistrator.{h,txx} are where we put together the
>>>> registration modules,
>>>>
>>>> #include "itkMultiResolutionImageRegistrationMethod.h"
>>>> #include "itkVersorRigid3DTransform.h"
>>>> #include "itkMattesMutualInformationImageToImageMetric.h"
>>>> #include "itkLinearInterpolateImageFunction.h"
>>>> #include "itkVersorRigid3DTransformOptimizer.h"
>>>> #include "itkRecursiveMultiResolutionPyramidImageFilter.h"
>>>>
>>>> This illustrates our particular taste in what combination to attempt.
>>>>
>>>> The result has been frustrating.  I don't get the exact fit I want 
>>>> even
>>>> when giving it the target transformation as an initial condition; 
>>>> while
>>>> the fit is only slightly off when the difference is translation-only,
>>>> the cases of a rotation-only difference and a rotation-and-translation
>>>> difference seem to find the rotation but not even close as to 
>>>> translation.
>>>>
>>>> This application needs to convert between 3D AffineTransforms and
>>>> the 6-parameter VersorRigid3D.  Is it possible that converting by
>>>> Get-ing and Set-ing the Center, Matrix, and Translation is not the
>>>> approved way to convert between transforms, as done in my file
>>>> CrossOverAffineSystem.txx?  Could that be distorting my translational
>>>> information in proportion to the magnitude of the rotation?  If so,
>>>> could you explain what is needed to get Affine and VersorRigid3D
>>>> transforms to play together?
>>>>
>>>> I know 3D rigid registration comes up on this discussion list 
>>>> repeatedly.
>>>> Is there someone knowledgeable who can look over the
>>>> code?  If you want to run the test cases, you will need to download
>>>> brains2 from psychiatry.uiowa.edu (it's free): 
>>>> http://www.psychiatry.uiowa.edu/wiki/index.php?title=BRAINS_GETTING_STARTED#BRAINS_Registration 
>>>>
>>>> will point you to how to get read-only CVS access to the brains2 
>>>> projects.
>>>>
>>>> With thanks in advance,
>>>>
>>>> Greg Harris
>>>> Iowa Psychiatry Brain Imaging Lab
>>>> The University of Iowa
>>>> Iowa City, IA 52242 USA
>>>>
>>>> _______________________________________________
>>>> Insight-users mailing list
>>>> Insight-users at itk.org
>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
>
>



More information about the Insight-users mailing list