[Insight-users] Interpretation of output results from CenteredRigid2DTransform

Michael Jackson mike.jackson at bluequartz.net
Wed Jul 29 14:30:50 EDT 2009


Below is the code I am using to run the registration.. Any helpful  
comments are much appreciated.

/*  Begin Code Dump */
int  
R3DRotationRegistrationThread 
::registerImages(ImportFilterType::Pointer fxImageImport,
                                                    
ImportFilterType::Pointer mvImageImport,
                                                   bool rotationOnly)
{

R3DSliceInfo::Pointer fxSliceInfo = _registrationData- 
 >getFixedSliceInfo();
   R3DSliceInfo::Pointer mvSliceInfo = _registrationData- 
 >getMovingSliceInfo();

   MetricType::Pointer         metric        = MetricType::New();
   OptimizerType::Pointer      optimizer     = OptimizerType::New();
   InterpolatorType::Pointer   interpolator  = InterpolatorType::New();
   RegistrationType::Pointer   registration  = RegistrationType::New();

   registration->SetMetric (        metric        );
   registration->SetOptimizer(     optimizer     );
   registration->SetInterpolator(  interpolator  );

   TransformType::Pointer  transform = TransformType::New();
   registration->SetTransform( transform );
   registration->SetFixedImage(    fxImageImport->GetOutput()    );
   registration->SetMovingImage(   mvImageImport->GetOutput()   );
   registration->SetFixedImageRegion(  fxImageImport->GetOutput()- 
 >GetBufferedRegion() );

   typedef ImageType::SpacingType SpacingType;
   typedef ImageType::PointType OriginType;
   typedef ImageType::RegionType RegionType;
   typedef ImageType::SizeType SizeType;

   ImageType::Pointer fixedImage = fxImageImport->GetOutput();

   const SpacingType fixedSpacing = fixedImage->GetSpacing();
   const OriginType fixedOrigin = fixedImage->GetOrigin();
   const RegionType fixedRegion = fixedImage- 
 >GetLargestPossibleRegion();
   const SizeType fixedSize = fixedRegion.GetSize();

   TransformType::InputPointType centerFixed;

   centerFixed[0] = fixedOrigin[0] + fixedSpacing[0] * fixedSize[0] /  
2.0;
   centerFixed[1] = fixedOrigin[1] + fixedSpacing[1] * fixedSize[1] /  
2.0;

   ImageType::Pointer movingImage = mvImageImport->GetOutput();

   const SpacingType movingSpacing = movingImage->GetSpacing();
   const OriginType movingOrigin = movingImage->GetOrigin();
   const RegionType movingRegion = movingImage- 
 >GetLargestPossibleRegion();
   const SizeType movingSize = movingRegion.GetSize();

   TransformType::InputPointType centerMoving;

   centerMoving[0] = movingOrigin[0] + movingSpacing[0] *  
movingSize[0] / 2.0;
   centerMoving[1] = movingOrigin[1] + movingSpacing[1] *  
movingSize[1] / 2.0;

   float cor[2] = {0.0f, 0.0f};
   fxSliceInfo->getImageCoordinate(cor);
   TransformType::InputPointType center;
   center = centerFixed;

   typedef OptimizerType::ScalesType OptimizerScalesType;
   OptimizerScalesType optimizerScales(transform- 
 >GetNumberOfParameters());

   float rads = 0.0f;
   const double translationScale =  1000000.0;
   float stepValues[2] = { 0.1f, 0.0001f};
   {
     mvSliceInfo->getRotationAngleRadians(rads);
     transform->SetCenter(center);
     transform->SetTranslation(centerFixed - center);
     transform->SetAngle(rads);
     stepValues[0] = 10.01f;
     stepValues[1] = 0.001f;
     optimizerScales[0] = 1.0;
     optimizerScales[1] = translationScale;
     optimizerScales[2] = translationScale;
     optimizerScales[3] = 0.000010;
     optimizerScales[4] = 0.000010;
     optimizer->SetMaximumStepLength(stepValues[0]);
     optimizer->SetMinimumStepLength(stepValues[1]);
   }

   registration->SetInitialTransformParameters(transform- 
 >GetParameters());
   optimizer->SetScales(optimizerScales);
   optimizer->SetNumberOfIterations(200);

On Jul 29, 2009, at 1:00 PM, Luis Ibanez wrote:

> Hi Michael,
>
> The values that are printed by the CommandIterationUpdate
> are not relative to the initial Transform values. They are indeed
> the current transform values.
>
> The common mistakes in registration are:
>
>    1)  Failing to initialize the Transform properly
>         (Are you using the transform initializer ?)
>
>    2)  Failing to set the parameter scales properly.
>         (are you scaling rotations with respect to translations?)
>
>    3)  Using unbalanced values in the settings of the optimizer
>         E.g. a step length that is too large..
>
>
> If you want more details...
> then we were need more details about your registration setup   :-)
>
>
>  Regards,
>
>
>        Luis
>
>
> ----------------------------------------------------------------------
> On Tue, Jul 28, 2009 at 12:22 PM, Michael Jackson <mike.jackson at bluequartz.net 
> > wrote:
> I am running some code and I am not sure I am interpreting the  
> results correctly:
>
>  I have a CenteredRigid2DTransform that I use to register a pair of  
> images. During setup I have access to values for the rotation that  
> put me "in the ballpark" and so I use that to set the initial  
> transform parameters. (lets say for argument sake that the value for  
> the rotation is 0.6 radians).
>
>  As the registration proceeds I use a CommandIterationUpdate object  
> (straight out of the Itk guide) to monitor the registration. What  
> concerns me is that the rotation shown during the output of the  
> registration is a value like 2.21E-5.
>
>  Question 1: Is the value that I see during the registration (as  
> printed to the screen through the CommandIterationUpdate object)  
> _relative_ to the initial rotation?
>
>  If Question 1 answer is, "No it is absolute" then what might I be  
> doing wrong?
>
> If code is needed to elaborate on my question I can try and strip  
> things down to try and show what I am doing.
>
> Thanks for any help.
> _________________________________________________________
> Mike Jackson                  mike.jackson at bluequartz.net
> BlueQuartz Software                    www.bluequartz.net
> Principal Software Engineer                  Dayton, Ohio
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>



More information about the Insight-users mailing list