[Insight-users] demons deformable filter

Luis Ibanez luis.ibanez at kitware.com
Tue, 13 Jan 2004 18:36:52 -0500


Hi Corinne,


You probably want to start by creating new classes


     itkDemons5RegistrationFunction
     itkDemons5RegistrationFilter


You can simply copy & rename them from the
currently existing DemonsRegistration classes,
and then do the following modifications on them:




A) itk::Demons5RegistrationFunction still derives
    from itk::PDEDeformableRegistrationFunction so
    it has access to the protected member variable:

         m_DeformationField


    This variable is not set by default, so you have
    to modify the itkDemons5RegistrationFunction and
    add in the InitializeIteration() method the following
    lines

>   // update variables in the equation object
>   DemonsRegistrationFunctionType *f = 
>     dynamic_cast<DemonsRegistrationFunctionType *>
>     (this->GetDifferenceFunction().GetPointer());
> 
>   if ( !f )
>     {
>     itkExceptionMacro(<<"FiniteDifferenceFunction not of type DemonsRegistrationFunctionType");
>     }
> 
>   f->SetDeformationField( this->GetDeformationField() );
 >
     This will set the pointer on the function.

     Make sure that this new lines of code are BEFORE
     the line invoking

            Superclass::InitializeIteration();


B) Now, you can modify itkDemons5RegistrationFunction
    for computing an estimation of the gradient by using
    finite differences. For this you take the point on
    the fixed image coordinate frame where you want to
    compute the gradient of the deformed moving image.

    From this point you generate 2 x N points
    (N = image dimension).  Those points are computed
    as P +- delta[i].

    For example in 2D you will get points like:

                 Py+
                 |
                 |
         Px- ----P----Px+
                 |
                 |
                 Py-

    Then you take those points and map them through
    the deformation field, so you will get points
    Qx+,Qx-,Qy+,Qy-  (and so on if you are in N>2).

    With these points you can use the interpolator
    and get intensity values from the moving image
    and finally compute the gradient vector as

       Gx = (Qx+ - Qx-) / (2.0 * xspacing)
       Gy = (Qy+ - Qy-) / (2.0 * yspacing)
        (and so on if you are in N > 2).





This may not be very elegant but should give you
a reasonable estimation of the gradient of the
deformed moving image.


BTW If you get it working and you are willing to
contribute this code back to ITK we will be happy
to include it in the toolkit. Probably with better
names for the files.



Regards,


   Luis


--------------------------
Corinne Mattmann wrote:

> Hi,
> 
> I am using the demons deformable filter but as I have images with just
> one "material" - therefore basically black-white-images with smoothed
> transitions - the registration is not perfect. In fact, the quality of
> the registration depends on the similarity of the two initial images.
> That's why I would like to try another demons-formula taken out of
> Jean-Philippe Thirion's paper "Fast Non-Rigid Matching of 3D Medical
> Images" (formula 5). For that formula you need to calculate the gradient
> of the reconstructed moving image at each iteration.
> Can you tell me how I can get to this gradient in the function
> ComputeUpdate(...) in itkDemonsRegistrationFunction.txx?
> 
> Thanks very much,
> Corinne
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>