[Insight-users] 2D deformable registration

ping chen miw2k@yahoo.com
Wed May 19 03:35:50 EDT 2004


Hi Luis, 

I try to use the deformation field to warp a image. i
use the deformation field generated by
DeformableRegistration1.cxx, in which displacement for
x and displacement for y are both generated, also a
vector displacement image VectorDeformationField.mhd
is generated. 

the 1st way for me to use the generated x y
displacement, i use itkCompose2DVectorImageFilter to
combine x displacement and y displacement into a
vector image. and then use this vector image to set
the deformation field for the warper. 

the problem with this way is that the warped result
from this way is different from the warped image from
the DeformableRegistration1.cxx, though similiar. 

the 2nd way, i just generated the imagereader to
directly read VectorDeformationField.mhd, and then use
this reader output to set the deformation field of the
warper.

the problem with this way is that this method didnt
work. the output of warper is exactly the same as the
moving image. 

below is part of the code: the 1st way
typedef itk::Compose2DVectorImageFilter<
               InputImageType,DeformationFieldType>
FilterType;
 FilterType::Pointer filter = FilterType::New();
 filter->SetInput1(inputreader1->GetOutput());
 filter->SetInput2(inputreader1->GetOutput());
 filter->Update();
  warper->SetInterpolator( interpolator );
  warper->SetOutputSpacing(
towarpreader->GetOutput()->GetSpacing() );
  warper->SetOutputOrigin(
towarpreader->GetOutput()->GetOrigin() );
  warper->SetDeformationField( filter->GetOutput() );
  warper->SetInput( towarpreader->GetOutput() );
  	try
    {
       warper->Update();
    }

the 2nd way:
typedef itk::Vector< float, 2 >    VectorPixelType;
typedef itk::Image<  VectorPixelType, 2 >
DeformationFieldType;
typedef itk::ImageFileReader< DeformationFieldType >
FieldReaderType;
typedef itk::WarpImageFilter<
                          InputImageType, 
                          InputImageType,
                          DeformationFieldType  >    
WarperType;
  warper->SetInput( towarpreader->GetOutput() );
  	try
    {
       warper->Update();
    }
WarperType::Pointer warper = WarperType::New();
  InterpolatorType::Pointer interpolator =
InterpolatorType::New();
  warper->SetInterpolator( interpolator );
  warper->SetOutputSpacing(
towarpreader->GetOutput()->GetSpacing() );
  warper->SetOutputOrigin(
towarpreader->GetOutput()->GetOrigin() );
 
warper->SetDeformationField(fieldreader1->GetOutput());
  warper->SetInput( towarpreader->GetOutput() );
  	try
    {
       warper->Update();
    }

I cant figure out why  the warped result from 1way is
different from the warped result from
DeformableRegistration1.cxx, and why the 2nd way
doesnt work. do you have any suggestions? Thanks.

-Ping 


--- ping chen <miw2k@yahoo.com> 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@kitware.com> wrote:
> > 
> > Hi Ping,WarperType::Pointer warper =
WarperType::New();
  InterpolatorType::Pointer interpolator =
InterpolatorType::New();
  warper->SetInterpolator( interpolator );
  warper->SetOutputSpacing(
towarpreader->GetOutput()->GetSpacing() );
  warper->SetOutputOrigin(
towarpreader->GetOutput()->GetOrigin() );
 
warper->SetDeformationField(fieldreader1->GetOutput());


> > 
> > 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@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
> 
=== message truncated ===


	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/



More information about the Insight-users mailing list