[Insight-users] 3D deformable registration

Luis Ibanez luis.ibanez at kitware.com
Sun, 09 May 2004 21:28:22 -0400


Hi Ping,

For examples on how to write a deformation field
into a file, please look at the following .cxx files:

Insight/Examples/Registration/

       BSplineWarping1.cxx
       DeformableRegistration2.cxx
       DeformableRegistration3.cxx
       DeformableRegistration4.cxx
       DeformationFieldInitialization.cxx


Regards,


     Luis



-------------------
ping chen wrote:

> Hi Luis, 
>  
> your suggestion is right. and 3d deformable
> registration works great. 
> 
> I have one question. is there any example which shows
> how to use the written displacement field, instead of
> using X->GetDeformationField()? 
> after I finished the registration with
> deformableregistration1.cxx and saved the displacement
> field, I still want to use the displacement field to
> warp new regions. it there any way i can avoid doing
> the registration again, and just use the displacement
> field directly? 
> 
> Thanks,
> Ping 
> 
> 
> --- Luis Ibanez <luis.ibanez at kitware.com> wrote:
> 
>>Hi Ping,
>>
>>The error is that you are passing the output of the
>>FEMRegistrationFilter as deformation field to the
>>WarpImageFilter:
>>
>>
>> >   warper->SetDeformationField( X->GetOutput() );
>>
>>
>>However, GetOutput() in the FEMREgistrationFilter
>>returns
>>the resampled moving image, not the deformation
>>field.
>>
>>
>>Please replace this line with:
>>
>> >   warper->SetDeformationField(
>>X->GetDeformationField() );
>>
>>
>>
>>Doxygen can always help:
>>
>>
> 
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1fem_1_1FEMRegistrationFilter.html
> 
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1fem_1_1FEMRegistrationFilter.html#a24
> 
>>
>>
>>Regards,
>>
>>
>>    Luis
>>
>>
>>-----------------
>>ping chen wrote:
>>
>>
>>>Hi Luis,
>>> 
>>>I tried the way you suggested by using
>>
>>WarpImageFilter, the code i add 
>>
>>>to DeformableRegistration1.cxx is shown below (
>>
>>MaskImageType is exactly 
>>
>>>the same as the InputImageType)
>>>
>>>    typedef itk::Vector< float, 2 >   
>>
>>VectorPixelType;
>>
>>>    typedef itk::Image<  VectorPixelType, 2 >
>>
>>DeformationFieldType;
>>
>>>    typedef itk::WarpImageFilter<
>>>                          MaskImageType,
>>>                          MaskImageType,
>>>                          DeformationFieldType  > 
>>
>>   WarperType;
>>
>>>  typedef itk::LinearInterpolateImageFunction<
>>>                                   MaskImageType,
>>>                                   double         
>>> InterpolatorType;
>>>  WarperType::Pointer warper = WarperType::New();
>>>  InterpolatorType::Pointer interpolator =
>>
>>InterpolatorType::New();
>>
>>>  warper->SetInput( maskreader->GetOutput() );
>>>  warper->SetInterpolator( interpolator );
>>>  warper->SetOutputSpacing(
>>
>>inputreader->GetOutput()->GetSpacing() );
>>
>>>  warper->SetOutputOrigin(
>>
>>inputreader->GetOutput()->GetOrigin() );
>>
>>>  warper->SetDeformationField( X->GetOutput() );
>>>  warper->Update();
>>> 
>>>just like what in DeformableRegistration2.cxx did.
>>> 
>>>but i got below errors:
>>> 
>>>Building dependencies cmake.check_depends...
>>>Building object file DeformableRegistration1.o...
>>>
>>
> /Users/ping/Desktop/deformableR_worksfor2D/DeformableRegistration1.cxx:
> 
>>In
>>
>>>   function `int main(int, char**)':
>>>
>>
> /Users/ping/Desktop/deformableR_worksfor2D/DeformableRegistration1.cxx:417:
> 
>>>error: no
>>>   matching function for call to
>>
>>`itk::WarpImageFilter<MaskImageType,
>>
>>>   MaskImageType, main(int, 
>>>char**):DeformationFieldType>:setDeformationField
>>>   (ImageType*)'
>>>
>>
> /Users/ping/Desktop/InsightToolkit-1.6.0/Code/BasicFilters/itkWarpImageFilter.txx:115:
> 
>>>error: candidates
>>>are: void itk::WarpImageFilter<TInputImage,
>>
>>TOutputImage,
>>
>>>  
>>
> TDeformationField>:setDeformationField(TDeformationField*)
> 
>>[with
>>
>>>   TInputImage = MaskImageType, TOutputImage =
>>
>>MaskImageType, 
>>
>>>TDeformationField
>>>   = main(int, char**):DeformationFieldType]
>>>make[1]: *** [DeformableRegistration1.o] Error 1
>>>make: *** [default_target] Error 2
>>>since i want to count the voxels in regions of
>>
>>each subjects, i need to 
>>
>>>convert the reference brain(for which i have the
>>
>>Alta mask) to each 
>>
>>>subject brain, when i look into the
>>
>>DeformableRegistration1.cxx code, i 
>>
>>>cant find anywhere i can replace the moving image
>>
>>with mask image. to 
>>
>>>me, in DeformableRegistration1.cxx, the only line
>>
>>connected to warped 
>>
>>>image is
>>
> X->WriteWarpedImage((X->GetResultsFileName()).c_str());
> 
>>which 
>>
>>>is defined in itkFEMRegistrationFilter.h,
>>
>>itkFEMRegistrationFilter.txx   
>>
>>>Can you show me a simple way to replace this
>>
>>movingimage input with the 
>>
>>>Mask?
>>> 
>>>Thank you.
>>>Ping
>>>*//* 
>>>*/Luis Ibanez <luis.ibanez at kitware.com>/* wrote:
>>>
>>>
>>>    Hi Ping,
>>>
>>>    Your process of Atlas-Based segmentation can
>>
>>easily
>>
>>>    be done with small modifications of the
>>
>>Example:
>>
>>>    DeformableRegistration1.cxx
>>>    or DeformableRegistration2.cxx
>>>
>>>    You don't need the MaskImageFilter,
>>>    you don't need the AndImageFilter,
>>>
>>>    You simply need to make sure that you use as
>>
>>Moving
>>
>>>    image, the Brain image for which you do have
>>
>>the
>>
>>>    segmentation mask.
>>>
>>>    In the current examples, the input of the
>>
>>WarpImage
>>
>>>    filter is the Moving image. You simply have to
>>>    replace this input with the Mask that is
>>
>>representing
>>
>>>    your segmentation of the Moving image. The
>>
>>WarpImage
>>
>>>    filter will use the deformation field
>>
>>resulting from
>>
>>>    the registration process in order to map the
>>
>>Mask
>>
>>>    into the fixed image.
>>>
>>>    In that way you will obtain a deformed Mask
>>
>>that
>>
>>>    corresponds to a segmentation of the Fixed
>>
>>Image.
>>
>>>    You will f ind this illustrated in the Slided
>>
>>on
>>
>>>    Non-Rigid Registration from the MICCAI 2004
>>
>>Tutorial
>>
>>>    http://www.itk.org/HTML/Tutorials.htm
>>>
>>>    more specifically:
>>>
>>>   
>>
> http://www.itk.org/CourseWare/Training/NonRigidRegistrationMethods.pdf
> 
>>>
>>>    You just need to add an extra ImageFileReader
>>
>>to the
>>
>>>    example, and connect the output of this reader
>>
>>as
>>
>>>    input to the WarpImageFilter. Then set the
>>
>>filename
>>
>>>    of this reader to the filename of the Mask.
>>>
>>>
>>>
>>>    Regards,
>>>
>>>
>>>    Luis
>>>
>>>
>>>    -----------------
>>>    ping chen wrote:
>>>
>>
> === message truncated ===
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs  
> http://hotjobs.sweepstakes.yahoo.com/careermakeover 
>