[Insight-users] Re: Mattes MI & 1+1 ES optimizer = overlap exception

Christos Panagiotou C.Panagiotou at cs.ucl.ac.uk
Mon, 03 May 2004 19:59:38 +0100


Dear luis


i thought i was initializing the transform, anyway maybe in an older 
version!

1. the odd thing is that with the MI image 2 image metric and the 
gradient descent i was getting results... I just want to check the 
Mattes metric too)
2. well it seems the MIMRegistrator.txx in MultiResMIRegistration 
application does not initialize the transform too
( i am just pointing this out incase you would like to make any changes)
3. as i pointed out i dont use the CenteredAffineTransform because I use 
the MultiResMIRegistration application

in the MIMApplicationBase.txx you find the following lines of code:

-----------------------MIMApplicationBase.txx----------------------------
/***************************
* Compute overall transform
***************************/
// compose the preprocess and registration transforms
m_Transform->SetIdentity();
m_Transform->Compose( m_Preprocessor->GetPostTransform(), true );
m_Transform->Compose( m_Registrator->GetAffineTransform(), true );
m_Transform->Compose( m_Preprocessor->GetPreTransform(), true );



-----------------------MIMApplicationBase.txx (section end) 
----------------------------

where the GetPreTransform()
returns a transform from the MIMPreprocessor.txx which all it does is to 
center the images :

-----------------------MIMPreprocessor.txx----------------------------
typename AffineTransformType::MatrixType matrix;
typename AffineTransformType::OffsetType offset;

typename CentererType::Pointer centerer;
typename NormalizerType::Pointer normalizer;
typename PermuterType::Pointer permuter;
typename FlipperType::Pointer flipper;

// Process the fixed image
centerer = CentererType::New();
normalizer = NormalizerType::New();

centerer->CenterImageOn();
centerer->SetInput( m_InputFixedImage );

normalizer->SetInput( centerer->GetOutput() );
normalizer->Update();
m_OutputFixedImage = normalizer->GetOutput();

m_PreTransform->SetIdentity();

-----------------------MIMPreprocessor.txx (section end) 
----------------------------

i saw that the centered affine transform has 
CenteredAffineTransformInitializer class
is cant find something similar with the Affine Transform...


4. could you please tell me how should i initialize my affine transform 
( i could try to have a CenteredAffine again but this would render the 
existence of the Preprocessor class as
excessive and unuseful.. ( i think! ) ... should i give it a try just 
because of the fact that the Centered Affine has an initializer? )
(i ll try also to *guess* the values with the method you ve described

5. and finaly something else...
i ve tried the MI image 2 image metric with the gradient descent 
optimizer and registered an MRI volume against an Optical Tomography volume.
The registration was close to the optimum however the graph of 
iterations - metric values was very noisy.
When i say noisy is that the final metric value was something like 2 or 
3 points bigger (well this is not the greates maximization ever...)
than the first and throughout the graph the metric values change 
drasticaly from negative to positive... however as i said
the moving Image has undertaken substantial deformation (affine) to 
match the fixed one...

is this normal? the plots you have in the itk guide are somehow 
averaged? for example 2000 iterations find average of the first 50 then 
next then next etc..?


I really look forward to get some advices for 4 and 5, the first 3 are 
just observations!
thanks again and sorry for the multiple emails!
christos


>
>
> B) About the exception you are getting:
>
> " Too many samples map outside moving
> image buffer: 50703 / 360448 "
>
> It means that the Affine transform that maps the moving
> image is not generating enough overlap with the fixed
> image.
>
>
> I couldn't find in your code, where you are initializing
> the AffineTransform. I would have expected something like:
>
> m_AffineTransform->SetIdentity();
>
> (maybe I missed it...)
>
>
> Even better than that, I would strongly suggest you to use
> the CenteredAffineTransform and the CenteredTransformInitializer.
>
> This initializer will take care of matching the image centers,
> by taking into account their respective origin, pixel spacing
> and number of pixels along every dimension.
>
>
> The fact that you are not even getting the first GetValue()
> result, lead us to suspect that you simply have a poor initialized
> transform. Note that Identity is not neecesarily a good
> initialization. It depends on the origin and pixel spacing of
> both of your images. A fundamental exercise that you should
> perform before even starting your registration is to draw in
> a piece of paper the physical extent of both images in a common
> coordinate system. This will give you a clear idea of what
> your initialization should be for the transform. This is illustrated
> multiple times in the "resampling" section of the SoftwareGuide.
>
>
> A similar effect can be obtained by simply taking a resample
> image filter, feeding it with an itk::IdentityTransform and
> mapping the Moving image into the Fixed image space. That
> will give you a clear view of the current spatial relationship
> between the two images.
>
>