[Insight-users] Problem with MultiResImageRegistration2.cxx: Doesn't work with rotation

Albert Gubern bertkrek at gmail.com
Thu Mar 19 05:37:12 EDT 2009


Hi again,

Thanks Luis your answer, it is working correctly in 2D.

Now I'm extending the code to 3D images. I modified the Dimension to 3 and
the optimizer scales (9 for rotation and 3 for translation).

I test the code using the same images with the same command arguments that
you told me before and a new error appears before doing the registration:

##################################################

FixedImage schedule: [4, 4, 4]
[2, 2, 2]
[1, 1, 1]

MovingImage schedule: [4, 4, 4]
[2, 2, 2]
[1, 1, 1]

-------------------------------------
MultiResolution Level : 0

ExceptionObject caught !

itk::ExceptionObject (0100FDF4)
Location: "void __thiscall
itk::MattesMutualInformationImageToImageMetric<class
itk::Image<float,3>,class itk::Image<floa
t,3> >::GetValueAndDerivative(const class itk::Array<double> &,double
&,class itk::Array<double> &) const"
File:
c:\bert\itk_vtk\src\itk\insighttoolkit-3.12.0\code\algorithms\itkMattesMutualInformationImageToImageMetric.txx
Line: 1138
Description: itk::ERROR:
MattesMutualInformationImageToImageMetric(014A27B8): Joint PDF summed to
zero

#######################################

I thought that the error is produced because I'm working with 2d images, but
the registration works if the number of levels of the multiresolution
registration is 1. Can the 3d registration work with 2d images? I know that
with Mean Squares metric it isn't possible but this problem shouldn't appear
with Mattes Mutual information metric because it works with histograms...

However, I test it with 3d images (the same 2d images of the brain repeated
4 times) and the error appear when the number of levels are 4 (works
correctly with 1,2 and 3 levels). Also I've worked with different percentage
of samples (from 20% to 100%) and number of bins (32 and 128) and the error
continues appearing.

I read in
http://www.itk.org/pipermail/insight-users/2009-February/028917.html that it
could be caused by something missed, but I think I do all the necessary
changes to do the 3D registration.

What could the mistake be? Working with 2d images? Something missed?

Thanks in advance,

Albert



2009/3/17 Luis Ibanez <luis.ibanez at kitware.com>

Hi Albert,
>
> Thanks for your detailed post.
>
> We ran the MultiResImageRegistration2.cxx example on
> the two images that your suggested:
>
>   *  BrainProtonDensitySlice.png
>   *  BrainProtonDensitySliceR10X13Y17.png
>
> This led us to find a bug (Thank you very much!), and a new set
> of parameters that are appropriate for these two images.
>
>
> The changes that we identified are;
>
>  cvs diff: Diffing .
> Index: MultiResImageRegistration2.cxx
> ===================================================================
> RCS file:
> /cvsroot/Insight/Insight/Examples/Registration/MultiResImageRegistration2.cxx,v
> retrieving revision 1.49
> diff -r1.49 MultiResImageRegistration2.cxx
> 152c152
> <       optimizer->SetMaximumStepLength( 16.00 );
> ---
> >       optimizer->SetMaximumStepLength(  0.10 );
> 348,349c348,349
> <   optimizerScales[4] = 1.0 / 1e7; // scale for translation on X
> <   optimizerScales[5] = 1.0 / 1e7; // scale for translation on Y
> ---
> >   optimizerScales[4] = 1.0 / 1e3; // scale for translation on X
> >   optimizerScales[5] = 1.0 / 1e3; // scale for translation on Y
> 555a556,557
> >   finalTransform->SetFixedParameters( transform->GetFixedParameters() );
> >
>
>
> The bug we found is that the finalTransform is a new instance
> of an affine transform whose center has not been initialized.
> This leads to an incorrect resampling of the output image.
>
> This bug is fixed by the new line:
>
> >   finalTransform->SetFixedParameters( transform->GetFixedParameters() );
>
>
> The executable can be run with the following parameters:
>
>  MultiResImageRegistration2
>       BrainProtonDensitySlice.png  BrainProtonDensitySliceR10X13Y17.png
>       registered.mha 100 checkerBoardBefore.mha
> checkerBoardAfter.mha 1 32 3000
>
>
>  Please try the code with these changes
>  and let us know if you still find any problems.
>
>
>        Thanks
>
>
>             Luis
>
>
>
>
> ---------------------------------------------------------------------------------------------
> On Mon, Mar 16, 2009 at 6:38 PM, Albert Gubern <bertkrek at gmail.com> wrote:
> > Hi,
> >
> > I'm using MultiResImageRegistration2.cxx in order to correct global pose
> > differences of two images. My goal is a registration of prostate MRI of
> > differents patients for a atlas building. I am testing this example with
> > images from Examples/Data of ITK source: BrainProtonDensitySliceBorder2
> > 0.png as a fixed and BrainProtonDensitySliceR10X13Y17.png as a moving.
> >
> > The registration works if the moving image only has a translation but it
> > doesn't work with the images that i'm testing it (translation and
> rotation).
> >
> > I have tuned the parameters following the instructions of
> > http://www.itk.org/pipermail/insight-users/2007-March/021435.html but it
> is
> > no way to obtain a good result. If I set the translationScales and
> > rotationScales with the same value (for example 1), the result image
> appears
> > correctly rotated but in the right corner of the top of the image
> > (http://img208.imageshack.us/img208/5148/test1.png). Otherwise, if I set
> the
> > translationScales with smaller values than rotationScales ( 1/1000 and 1
> > respectively) the images appears correctly in the center but not enough
> > rotated (http://img24.imageshack.us/img24/9317/test2m.png). The maxStep
> > length is 0.1, the minstepLength 0.001, 100% of samples and 128 number of
> > bins.
> >
> > I tested with a lot of combinations of parameters with and without sense,
> > and I don't understand the behaviour. What is the problem? Is The way how
> I
> > tune the parameters? This framework it isn't right for
> translation+rotation?
> >
> > Thanks in advance,
> >
> > --
> > Albert
> >
> > _____________________________________
> > 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
> >
> >
>



-- 
Albert



-- 
Albert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090319/781b1bfa/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MultiResImageRegistration2.cxx
Type: application/octet-stream
Size: 22332 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090319/781b1bfa/attachment-0001.obj>


More information about the Insight-users mailing list