[Insight-users] 3D deformable registration

ping chen miw2k at yahoo.com
Wed, 28 Apr 2004 12:43:20 -0700 (PDT)


--0-568452714-1083181400=:84880
Content-Type: text/plain; charset=us-ascii

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 find 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:

> Hi Luis, 
> 
> The problem I want to solve is take out same regions
> of brains with registration. we have reference brain
> images and its region mask, then by MaskImageFilter,
> we can get the region of reference brain, then by
> using the transformation information given by
> deformableRegistration1, we warp the region of the
> reference image, and get the region from the subject
> brain.
> 
> I have used the MaskImageFilter to get the region i
> need. and then i try to use WarpImageFilter to get the
> warped region. 
> 
> 
> I have three questions. 
> 
> 
> through deformableRegistration1, the registration of
> the fixed 3d brain image and moving 3d brain images
> has finished.
> 
> 1. in deformableRegistration1, the transformation
> information is saved by X->WriteDisplacementField,
> right? since we are dealing with 3d dataset, we need
> to uncomment X->WriteDisplacementField(2); right?
> 
> or can we just use 
> X->WriteDisplacementFieldMultiComponent(); is this
> for save the whole transform information? 
> 
> 2. how to use the above saved transform information
> in warpimagefilter in 
> warper->SetDeformationField( ???); 
> 
> 3. warp the region image of the reference image to
> subject image with the available transform
> information, or warp the region mask(binary) of
> reference image and then add MaskImageFilter with the
> whole warped brain will produce the same results? 
> 
> -Emily
> 
> 
> --- Luis Ibanez wrote:
> 
>>Hi Emily,
>>
>>
>>1) You can mask a region of an image by
>> using the AND image filter.
>> 
>>
> 
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1AndImageFilter.html
> 
>> This will work ok if both the mask and
>> the image are of the same pixel type and
>> are of "integer" type: {char, short, int,
>> long}.
>>
>>
>>2) You resample the moving image, using the
>> WarpImageFilter and providing the deformation
>> field. Note that the WarpImageFilter requires
>> you to specify an Origin (in physical space)
>> and a size (in pixels) for the output image.
>>
>> What you could do is to take the region from the
>> moving image and figure out what will be its
>> bounding box once it is mapped to the coordinate
>> system of the fixed image. Once you have such
>> bounding box, you simply feed this information
>> into the origin and size provided to the Warp
>> ImageFilter.
>>
>> The resulting image will only have the size of
>> that specified bounding box.
>>
>>
>>
>>
>>Regards,
>>
>>
>> Luis
>>
>>
>>------------------
>>ping chen wrote:
>>
>>
>>>Hello, 
>>>
>>>I have used DeformableRegistration1.cxx to
>>
>>register 3d
>>
>>>MRI brain images and i got the warped whole brain
>>>image and also the DisplacementField. 
>>>
>>>I have two problems:
>>>1. If I have a mask of one region, how i can use
>>
>>this
>>
>>>mask to take out that only region from the 3d
>>
>>images?
>>
>>>2. I wonder how i can use this transform
>>
>>information
>>
>>>from DeformableRegistration1 to warp this region,
>>>instead of a whole brain?
>>>
>>>Thank you.
>>>emily
>>>
>>>
>>> 
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs 
> http://hotjobs.sweepstakes.yahoo.com/careermakeover 
> 



_______________________________________________
Insight-users mailing list
Insight-users at itk.org



		
---------------------------------
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs 
--0-568452714-1083181400=:84880
Content-Type: text/html; charset=us-ascii

<DIV>
<DIV>
<DIV>Hi Luis,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I&nbsp;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)</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp; typedef itk::Vector&lt; float, 2 &gt;&nbsp;&nbsp;&nbsp; VectorPixelType;<BR>&nbsp;&nbsp;&nbsp; typedef itk::Image&lt;&nbsp; VectorPixelType, 2 &gt; DeformationFieldType;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; typedef itk::WarpImageFilter&lt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MaskImageType, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MaskImageType,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeformationFieldType&nbsp; &gt;&nbsp;&nbsp;&nbsp;&nbsp; WarperType;<BR>&nbsp; typedef itk::LinearInterpolateImageFunction&lt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 MaskImageType,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&nbsp; InterpolatorType;<BR>&nbsp; WarperType::Pointer warper = WarperType::New();<BR>&nbsp; InterpolatorType::Pointer interpolator = InterpolatorType::New();</DIV>
<DIV>&nbsp; warper-&gt;SetInput( maskreader-&gt;GetOutput() );<BR>&nbsp; warper-&gt;SetInterpolator( interpolator );<BR>&nbsp; warper-&gt;SetOutputSpacing( inputreader-&gt;GetOutput()-&gt;GetSpacing() );<BR>&nbsp; warper-&gt;SetOutputOrigin( inputreader-&gt;GetOutput()-&gt;GetOrigin() );<BR>&nbsp; warper-&gt;SetDeformationField( X-&gt;GetOutput() );<BR>&nbsp; warper-&gt;Update();</DIV>
<DIV>&nbsp;</DIV>
<DIV>just like what in DeformableRegistration2.cxx did. </DIV>
<DIV>&nbsp;</DIV>
<DIV>but i got below errors:</DIV>
<DIV>&nbsp;</DIV>
<DIV>Building dependencies cmake.check_depends...<BR>Building object file DeformableRegistration1.o...<BR>/Users/ping/Desktop/deformableR_worksfor2D/DeformableRegistration1.cxx: In <BR>&nbsp;&nbsp; function `int main(int, char**)':<BR>/Users/ping/Desktop/deformableR_worksfor2D/DeformableRegistration1.cxx:417: error: no<BR>&nbsp;&nbsp; matching function for call to `itk::WarpImageFilter&lt;MaskImageType, <BR>&nbsp;&nbsp; MaskImageType, main(int, char**):DeformationFieldType&gt;:setDeformationField<BR>&nbsp;&nbsp; (ImageType*)'<BR>/Users/ping/Desktop/InsightToolkit-1.6.0/Code/BasicFilters/itkWarpImageFilter.txx:115: error: candidates</DIV>
<DIV>are: void itk::WarpImageFilter&lt;TInputImage, TOutputImage, <BR>&nbsp;&nbsp; TDeformationField&gt;:setDeformationField(TDeformationField*) [with <BR>&nbsp;&nbsp; TInputImage = MaskImageType, TOutputImage = MaskImageType, TDeformationField <BR>&nbsp;&nbsp; = main(int, char**):DeformationFieldType]<BR>make[1]: *** [DeformableRegistration1.o] Error 1<BR>make: *** [default_target] Error 2<BR></DIV>
<DIV>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-&gt;WriteWarpedImage((X-&gt;GetResultsFileName()).c_str()); which is defined in itkFEMRegistrationFilter.h, itkFEMRegistrationFilter.txx&nbsp;&nbsp; Can you show me a simple way to replace this movingimage&nbsp;input with the Mask?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thank you.</DIV>
<DIV>Ping</DIV>
<DIV><B><I></I></B>&nbsp;</DIV>
<DIV><B><I>Luis Ibanez &lt;luis.ibanez at kitware.com&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi Ping,<BR><BR>Your process of Atlas-Based segmentation can easily<BR>be done with small modifications of the Example:<BR><BR>DeformableRegistration1.cxx<BR>or DeformableRegistration2.cxx<BR><BR>You don't need the MaskImageFilter,<BR>you don't need the AndImageFilter,<BR><BR>You simply need to make sure that you use as Moving<BR>image, the Brain image for which you do have the<BR>segmentation mask.<BR><BR>In the current examples, the input of the WarpImage<BR>filter is the Moving image. You simply have to<BR>replace this input with the Mask that is representing<BR>your segmentation of the Moving image. The WarpImage<BR>filter will use the deformation field resulting from<BR>the registration process in order to map the Mask<BR>into the fixed image.<BR><BR>In that way you will obtain a deformed Mask that<BR>corresponds to a segmentation of the Fixed Image.<BR><BR>You will find this
 illustrated in the Slided on<BR>Non-Rigid Registration from the MICCAI 2004 Tutorial<BR><BR>http://www.itk.org/HTML/Tutorials.htm<BR><BR>more specifically:<BR><BR>http://www.itk.org/CourseWare/Training/NonRigidRegistrationMethods.pdf<BR><BR><BR>You just need to add an extra ImageFileReader to the<BR>example, and connect the output of this reader as<BR>input to the WarpImageFilter. Then set the filename<BR>of this reader to the filename of the Mask.<BR><BR><BR><BR>Regards,<BR><BR><BR>Luis<BR><BR><BR>-----------------<BR>ping chen wrote:<BR><BR>&gt; Hi Luis, <BR>&gt; <BR>&gt; The problem I want to solve is take out same regions<BR>&gt; of brains with registration. we have reference brain<BR>&gt; images and its region mask, then by MaskImageFilter,<BR>&gt; we can get the region of reference brain, then by<BR>&gt; using the transformation information given by<BR>&gt; deformableRegistration1, we warp the region of the<BR>&gt; reference image, and get the region from the subject<BR>&gt;
 brain.<BR>&gt; <BR>&gt; I have used the MaskImageFilter to get the region i<BR>&gt; need. and then i try to use WarpImageFilter to get the<BR>&gt; warped region. <BR>&gt; <BR>&gt; <BR>&gt; I have three questions. <BR>&gt; <BR>&gt; <BR>&gt; through deformableRegistration1, the registration of<BR>&gt; the fixed 3d brain image and moving 3d brain images<BR>&gt; has finished.<BR>&gt; <BR>&gt; 1. in deformableRegistration1, the transformation<BR>&gt; information is saved by X-&gt;WriteDisplacementField,<BR>&gt; right? since we are dealing with 3d dataset, we need<BR>&gt; to uncomment X-&gt;WriteDisplacementField(2); right?<BR>&gt; <BR>&gt; or can we just use <BR>&gt; X-&gt;WriteDisplacementFieldMultiComponent(); is this<BR>&gt; for save the whole transform information? <BR>&gt; <BR>&gt; 2. how to use the above saved transform information<BR>&gt; in warpimagefilter in <BR>&gt; warper-&gt;SetDeformationField( ???); <BR>&gt; <BR>&gt; 3. warp the region image of the reference image
 to<BR>&gt; subject image with the available transform<BR>&gt; information, or warp the region mask(binary) of<BR>&gt; reference image and then add MaskImageFilter with the<BR>&gt; whole warped brain will produce the same results? <BR>&gt; <BR>&gt; -Emily<BR>&gt; <BR>&gt; <BR>&gt; --- Luis Ibanez <LUIS.IBANEZ at KITWARE.COM>wrote:<BR>&gt; <BR>&gt;&gt;Hi Emily,<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;1) You can mask a region of an image by<BR>&gt;&gt; using the AND image filter.<BR>&gt;&gt; <BR>&gt;&gt;<BR>&gt; <BR>&gt; http://www.itk.org/Insight/Doxygen/html/classitk_1_1AndImageFilter.html<BR>&gt; <BR>&gt;&gt; This will work ok if both the mask and<BR>&gt;&gt; the image are of the same pixel type and<BR>&gt;&gt; are of "integer" type: {char, short, int,<BR>&gt;&gt; long}.<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;2) You resample the moving image, using the<BR>&gt;&gt; WarpImageFilter and providing the deformation<BR>&gt;&gt; field. Note that the WarpImageFilter requires<BR>&gt;&gt; you to specify
 an Origin (in physical space)<BR>&gt;&gt; and a size (in pixels) for the output image.<BR>&gt;&gt;<BR>&gt;&gt; What you could do is to take the region from the<BR>&gt;&gt; moving image and figure out what will be its<BR>&gt;&gt; bounding box once it is mapped to the coordinate<BR>&gt;&gt; system of the fixed image. Once you have such<BR>&gt;&gt; bounding box, you simply feed this information<BR>&gt;&gt; into the origin and size provided to the Warp<BR>&gt;&gt; ImageFilter.<BR>&gt;&gt;<BR>&gt;&gt; The resulting image will only have the size of<BR>&gt;&gt; that specified bounding box.<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;Regards,<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt; Luis<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;------------------<BR>&gt;&gt;ping chen wrote:<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;&gt;Hello, <BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;I have used DeformableRegistration1.cxx to<BR>&gt;&gt;<BR>&gt;&gt;register 3d<BR>&gt;&gt;<BR>&gt;&gt;&gt;MRI brain images and i got the
 warped whole brain<BR>&gt;&gt;&gt;image and also the DisplacementField. <BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;I have two problems:<BR>&gt;&gt;&gt;1. If I have a mask of one region, how i can use<BR>&gt;&gt;<BR>&gt;&gt;this<BR>&gt;&gt;<BR>&gt;&gt;&gt;mask to take out that only region from the 3d<BR>&gt;&gt;<BR>&gt;&gt;images?<BR>&gt;&gt;<BR>&gt;&gt;&gt;2. I wonder how i can use this transform<BR>&gt;&gt;<BR>&gt;&gt;information<BR>&gt;&gt;<BR>&gt;&gt;&gt;from DeformableRegistration1 to warp this region,<BR>&gt;&gt;&gt;instead of a whole brain?<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;Thank you.<BR>&gt;&gt;&gt;emily<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; <BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;_______________________________________________<BR>&gt;&gt;Insight-users mailing list<BR>&gt;&gt;Insight-users at itk.org<BR>&gt;&gt;http://www.itk.org/mailman/listinfo/insight-users<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; __________________________________<BR>&gt; Do you Yahoo!?<BR>&gt; Win a
 $20,000 Career Makeover at Yahoo! HotJobs <BR>&gt; http://hotjobs.sweepstakes.yahoo.com/careermakeover <BR>&gt; <BR><BR><BR><BR>_______________________________________________<BR>Insight-users mailing list<BR>Insight-users at itk.org<BR></BLOCKQUOTE></DIV></DIV><p>
		<hr size=1><font face=arial size=-1>Do you Yahoo!?<br><a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/hotjobs_mail_signature_footer_textlink/evt=23983/*http://hotjobs.sweepstakes.yahoo.com/careermakeover">Win a $20,000 Career Makeover at Yahoo! HotJobs </a>
--0-568452714-1083181400=:84880--