Rotation Transform Error

Hello, Everyone.

I am performing a 3D multistage registration. 1st Stage is a Translation transform initiated with an identity transform. The second stage is a Rotation transform.

It is pops up the following errors right after the first iteration:

ExceptionObject caught !

itk::ExceptionObject (0x563b1e8ede50)
Location: "void itk::MattesMutualInformationImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType, TMetricTraits>::ComputeResults() const [with TFixedImage = itk::Image<float, 3>; TMovingImage = itk::Image<float, 3>; TVirtualImage = itk::Image<float, 3>; TInternalComputationValueType = double; TMetricTraits = itk::DefaultImageToImageMetricTraitsv4<itk::Image<float, 3>, itk::Image<float, 3>, itk::Image<float, 3>, double>]" 
File: /home/9679247/Documentos/General-Sources/InsightToolkit-5.1.2/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx
Line: 312
Description: itk::ERROR: itk::ERROR: MattesMutualInformationImageToImageMetricv4(0x563b1e6a4c60): All samples map outside moving image buffer. The images do not sufficiently overlap. They need to be initialized to have more overlap before this metric will work. For instance, you can align the image centers by translation.

Also:

ExceptionObject caught !

itk::ExceptionObject (0x55d97dcea7d0)
Location: "itk::Versor::Set( const VectorType )" 
Description: Trying to initialize a Versor with a vector whose magnitude is greater than 1

I tried varying the initial transform initialization method:

First I verified the way I am sing the previous stage transform into the next stage:

 registrationR->SetInitialTransform( initialTransformRotation );
          registrationR->InPlaceOn();

          // Connecting previous stage transform to the next stage;
          registrationR->SetMovingInitialTransform(
            initialTransformTranslation);

Then I check some possibilities for the Initial transform. I tried:
Initial transform with SetIdentity(), to make it an Identity transfom.
Also, I tried to use the CenteredTransformInitializer class, defining MomentsOn() method.
None of the strategies above sounded to solve this problem.

Any help is very welcomed.

Which module do you use for registration?

As the error message states, the registration fails because the images do not sufficiently overlap.

I would recommend to pre-align the images before registration as described here. If that solves your problem then you can experiment with automatic initialization methods. Note that you need to harden the transform on the image that you pass to the registration module because most (if not all) registration modules ignore parent transforms of the input volumes.

1 Like

Ouh, Didn’t let it clear.
I am WRITING a pipeline with ITK classes.

And I tried previous initialization methods (MomentsOn) and previous stage transform.
I’ll write that post on ITK discourse.

Thanks anyway @lassoan .

1 Like

Note that Elastix (available in Slicer via SlicerElastix extension, but you can use it as a standalone command-line application, or as a Python package) is a nice solution for this, as you don’t need to write any code, just define each registration stage in a text file (parameter map file) and Elastix takes care of instantiating all the classes, setting parameters, connecting the stages. Elastix also defines a number of metrics and optimizers in addition to the stock ITK classes.

All right. Thanks again.