[Insight-users] Constructing 3D stack from 2D image series (withregistration)

Darren Weber darren.weber.lists at gmail.com
Tue Oct 20 19:25:46 EDT 2009


Hi Luis et al.,

See comments below (stay tuned for a follow-up after exploring the
suggestions).  Thanks for your attention to this interesting problem.

Best,
Darren


On Tue, Oct 20, 2009 at 9:50 AM, Luis Ibanez <luis.ibanez at kitware.com>wrote:

> Hi Darren,
>
>
> This is a very interesting problem.
>
> As you already verified, there is no straight forward way of concatenating
> (or composing) two BSplineDeformableTransforms in ITK.
>
>
Is it a function addition or composition?



> However,
> you could easily write a "GroupTransform" that derives from the
> itkTransform and that holds an array of SmartPointers to Transforms
>
> typedef std::vector< typename TransformType::Pointer >
> TransformArrayType;
> TransformArrayType   m_TransformArray;
>
>
> That you could populate with a method:
>
> AddTransform( const TransformType * t )
> {
> this->m_TransformArray.push_back( t );
> }
>
>
> Then implement the TransformPoint() method as
>
>
> TransformPoint( const PointType & p )
> {
> PointType q = p;
> TransformArrayType::const_iterator TransformIterator;
> TransformIterator titr = this->m_TransformArray.begin();
> TransformIterator tend = this->m_TransformArray.end();
> while( titr != tend )
>  {
>  q = titr->TransformPoint( q );
>  ++titr;
>  }
> return q;
> }
>
>
> and finally, use this GroupTransform as the transform
> that you connect to the ResampleImage Filter for resampling
> all the Microscopy slices to the coordinate system of the first
> slice.
>
>

It would be great if the ResampleImageFilter contained methods like
AddTransform or ComposeTransform (they don't appear in ITK 3.16 doxygen).  A
quick search in the 3.16 headers doesn't pull it up, i.e.:

[ dweber at weber-mbp ~ ]$ grep -l -r -E -e 'AddTransform'
/opt/local/include/InsightToolkit
/opt/local/include/InsightToolkit/IO/itkTransformFileWriter.h
/opt/local/include/InsightToolkit/Review/itkTransformFileWriterWithFactory.h
[ dweber at weber-mbp ~ ]$ grep -l -r -E -e 'ComposeTransform'
/opt/local/include/InsightToolkit
[ dweber at weber-mbp ~ ]$ grep -l -r -E -e 'Compose'
/opt/local/include/InsightToolkit
/opt/local/include/InsightToolkit/BasicFilters/itkCompose2DCovariantVectorImageFilter.h
/opt/local/include/InsightToolkit/BasicFilters/itkCompose2DVectorImageFilter.h
/opt/local/include/InsightToolkit/BasicFilters/itkCompose3DCovariantVectorImageFilter.h
/opt/local/include/InsightToolkit/BasicFilters/itkCompose3DVectorImageFilter.h
/opt/local/include/InsightToolkit/BasicFilters/itkComposeRGBImageFilter.h
/opt/local/include/InsightToolkit/Common/itkAffineTransform.h
/opt/local/include/InsightToolkit/Common/itkAffineTransform.txx
/opt/local/include/InsightToolkit/Common/itkEuler3DTransform.txx
/opt/local/include/InsightToolkit/Common/itkMatrixOffsetTransformBase.h
/opt/local/include/InsightToolkit/Common/itkMatrixOffsetTransformBase.txx
/opt/local/include/InsightToolkit/Common/itkRigid2DTransform.h
/opt/local/include/InsightToolkit/Common/itkRigid2DTransform.txx
/opt/local/include/InsightToolkit/Common/itkRigid3DTransform.h
/opt/local/include/InsightToolkit/Common/itkRigid3DTransform.txx
/opt/local/include/InsightToolkit/Common/itkScaleTransform.h
/opt/local/include/InsightToolkit/Common/itkScaleTransform.txx
/opt/local/include/InsightToolkit/Common/itkSimilarity2DTransform.h
/opt/local/include/InsightToolkit/Common/itkTranslationTransform.h
/opt/local/include/InsightToolkit/Common/itkTranslationTransform.txx
/opt/local/include/InsightToolkit/Common/itkVersor.h
/opt/local/include/InsightToolkit/Review/itkComposeRGBAImageFilter.h
/opt/local/include/InsightToolkit/SpatialObject/itkSpatialObject.txx
/opt/local/include/InsightToolkit/SpatialObject/itkSpatialObjectTreeNode.h





> ....
>
> As you progress with your registration, down the slices stack,
> you add the new pair-wise resulting transform to the Group
> Transform, and have the "equivalent" to the composed transform.
>
>
That sounds like an efficient way to do it.  The pair-wise accumulation
would be faster than throwing an entire series of transforms into an
addition or composition method every time through the loop over the image
series.



>
> Drinking the proper brand of Coffee, this probably can be coded
> in one afternoon.  We will be happy to assist you if you find any
> problem.
>
>
Ah, the search for the elixir of life ;-)



> And... of course, you are strongly encouraged to submit this
> transform to the Insight Journal:
>
>
> mmmm.
> and of course,...
> after checking the IJ, it happens that
>
> Stephan Klein and Marius Staring
> already contributed a similar class to the Insight Journal:
> http://www.insight-journal.org/browse/publication/91
> "Combining Transforms in ITK"
> http://hdl.handle.net/1926/197
>
> In particular, you may want to look at their class:
>
>            itkBSplineCombinationTransform.
>
>
> I just added it to the list of classes to move into ITK 3.18.
>
> http://www.itk.org/Wiki/ITK_Release_Schedule#Insight_Journal_papers_to_Move_for_ITK_3.18
>
>
>
Looks like it handles two transforms.  Perhaps it needs a modification to
handle a vector of transforms, as indicated above.




> ----------------------------
>
> Note however, that after hundreds of compositions,...
> things may start cumulating errors...
>
>
Absolutely!  Aside from numerical computing issues, there are a few
registration "failures" in the series (i.e., the registration optimization
has poor quality input data at some points in the series).  Without any QA,
even one "failure" will introduce a 'rift' in the volume reconstruction of
the series, which would propagate through the rest of a series.   The image
quality varies considerably in the series and there must be some QA work to
get this working.  It is a good case for a GUI to step through each of the
image registrations before 'accepting' the result into a volume
composition.  The idea of using pair-wise registrations and then using
composition of the transforms (without pair-wise resampling) is to (a)
provide automation for calculating all the pair-wise registrations required,
and (b) avoiding cumulative interpolation through the series of transforms
from img002 to imgN.  This assumes that every image in the series will be a
part of a composed volume.  If any of the images are discarded, a new
pair-wise registration is required (e.g., say img005 is discarded, then a
pair-wise registration is required for img006 to img004, which replaces the
previous pair-wise registration from img006 to img005; all the pair-wise
registrations from img006 to imgN remain useful).



>
> When you say that you have "thousands" of slices....
> did you mean that they are really about one thousands slices
> stacked one on top of each other ?
>


About 1800 slices, about 0.5 microns thick (z = 0.5; in-plane resolution is
about 0.05 microns; order of magnitude anisotropy!).




> or are you counting some level of side-by-side mosaicing
> as well ?
>
>
>
>     Please let us know,
>
>
>             Thanks
>
>
>                   Luis
>
>
>
>
> ---------------------------------------------------------------------------------------
> On Fri, Oct 16, 2009 at 8:43 PM, Darren Weber
> <darren.weber.lists at gmail.com> wrote:
> >
> > I don't see a Compose method for the bspline transform class, only a
> > SetBulkTransform.
> >
> >
> > Some code is able to read a series of transforms and report the content
> of
> > the transforms, i.e.:
> >
> >
> > *****************************************
> > section0181_w1
> >
> >
> > section0181_w1 :
> > /Volumes/data/plastic_imgproc/n2_04d/w1/tif/section0179_w1.tif
> > section0181_w1 :
> >
> /Volumes/data/plastic_imgproc/n2_04d/w1/bw_align/section0179to0178_w1_bspline.xfm
> > Number of transforms = 1
> > bspline transform parameters:
> > [-0.00101862, -0.000136816, 0.0428942, -0.0173411, -0.0012381, 0,
> > -0.0152427, -0.0829083, 0.562787, 0.0513636, 0.00563827, 0, -0.0978897,
> > 0.17254, -0.187553, 0.132699, 0.118559, 0, -0.0423971, 0.0390156,
> -0.254502,
> > -0.211898, 0.0186821, 0, 0.000965728, 0.0209634, 0.0971252, 0.0268716,
> > -0.00159635, 0, 0, 0, 0, 0, 0, 0, -0.000822122, -0.0595562, -0.106872,
> > 0.0393177, 0.00243043, 0, 0.0182722, -0.183968, 0.136984, 1.16236,
> 0.064037,
> > 0, 0.0551541, 0.37945, -0.741088, 0.394497, 0.0657694, 0, -0.0302881,
> > -0.371698, 0.340337, 0.463057, -0.00263912, 0, -0.00393346, -0.00450752,
> > 0.209972, 0.0928676, -0.000414552, 0, 0, 0, 0, 0, 0, 0]
> > bspline transform fixed parameters:
> > [6, 6, -5.7771, -6.41285, 5.74946, 6.38521, 1, 0, 0, 1]
> > bspline bulk transform name:
> > IdentityTransform
> > bspline bulk transform parameters:
> > [-59.7311]
> > bspline bulk transform fixed parameters:
> > [-2.00001]
> >
> > section0181_w1 :
> > /Volumes/data/plastic_imgproc/n2_04d/w1/tif/section0180_w1.tif
> > section0181_w1 :
> >
> /Volumes/data/plastic_imgproc/n2_04d/w1/bw_align/section0180to0179_w1_bspline.xfm
> > Number of transforms = 2
> > bspline transform parameters:
> > [-0.00167702, 0.0400107, 0.163826, 0.0494486, 0.000260499, 0, -0.112263,
> > -0.962398, 0.382706, 0.0468105, 0.000545406, 0, -0.013627, 0.032147,
> > 0.303242, -0.248178, 0.0577727, 0, 0.0310104, 0.0608204, -0.450371,
> > 0.0761785, 0.0396465, 0, -0.00145428, -0.0748339, -0.142132, -0.0117953,
> > 0.00109538, 0, 0, 0, 0, 0, 0, 0, -0.000739103, 0.0115463, -0.233451,
> > -0.151604, -0.00148716, 0, -0.124814, -0.51848, -0.0427284, -1.13778,
> > -0.0332992, 0, -0.22645, -1.40995, 1.29008, -0.406795, -0.0169783, 0,
> > -0.014309, 0.492513, -0.433653, -0.484105, 0.0174839, 0, 0.00246247,
> > 0.100723, 0.0245804, -0.038708, 0.000375209, 0, 0, 0, 0, 0, 0, 0]
> > bspline transform fixed parameters:
> > [6, 6, -5.7771, -6.32993, 5.74946, 6.30229, 1, 0, 0, 1]
> > bspline bulk transform name:
> > IdentityTransform
> > bspline bulk transform parameters:
> > [-2.00001]
> > bspline bulk transform fixed parameters:
> > [-59.7206]
> >
> > section0181_w1 :
> > /Volumes/data/plastic_imgproc/n2_04d/w1/tif/section0181_w1.tif
> > section0181_w1 :
> >
> /Volumes/data/plastic_imgproc/n2_04d/w1/bw_align/section0181to0180_w1_bspline.xfm
> > Number of transforms = 3
> > bspline transform parameters:
> > [0.00301806, -0.00652163, -0.144203, 0.0245637, 0.00424984, 0,
> -0.00674302,
> > 0.435562, -0.00178908, 0.420808, -0.021262, 0, -0.0294096, -0.355242,
> > -0.005834, -0.0189256, -0.160569, 0, 0.0709158, 0.736917, -0.210242,
> > -0.212069, -0.0294319, 0, 0.00253275, 0.0315866, -0.071481, -0.0291887,
> > 4.053e-05, 0, 0, 0, 0, 0, 0, 0, 0.00207632, -0.0583709, 0.109967,
> 0.12651,
> > -0.00259079, 0, 0.0616846, 0.0246376, 0.113406, 0.439344, -0.066714, 0,
> > 0.032752, 0.475236, -0.645249, 0.255606, -0.0351145, 0, -0.0414853,
> > -0.154973, 0.331845, 0.634161, 0.0229426, 0, -0.00318072, -0.070252,
> > -0.195498, -0.0416054, 0.000584519, 0, 0, 0, 0, 0, 0, 0]
> > bspline transform fixed parameters:
> > [6, 6, -5.88766, -6.46814, 5.86002, 6.4405, 1, 0, 0, 1]
> > bspline bulk transform name:
> > IdentityTransform
> > bspline bulk transform parameters:
> > [-2.00001]
> > bspline bulk transform fixed parameters:
> > [-59.7214]
> >
> >
> > This is a short report for a series of images from number 178--181 (the
> > image files are named "section%04d_w1.tif").  The idea is to now
> concatenate
> > all the bspline transforms so that image 181 is transformed all the way
> to
> > 178, via 180 and 179.  Is the way to do that something like this:
> >
> >
> > // no bulk transform for bsplineTransform179to178
> > bsplineTransform180to179.SetBulkTransform( bsplineTransform179to178 );
> > bsplineTransform181to180.SetBulkTransform( bsplineTransform180to179 );
> >
> >
> > Will that effectively concatenate the entire series of transforms to get
> > image 180 all the way into the space of image 178?
> >
> > TIA,
> > Darren
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Oct 15, 2009 at 8:47 PM, Richard Beare <richard.beare at gmail.com>
> > wrote:
> >>
> >> I think that most of the transform types have a Compose method so you
> >> can compute the transform between your first slice and any other.
> >>
> >> On Fri, Oct 16, 2009 at 2:30 PM, Xiaofeng Z <xf10036 at hotmail.com>
> wrote:
> >> > There must be a way to combine the transformations together before
> >> > applying
> >> > the combined transformation to the image.  Otherwise, after hundreds
> of
> >> > interpolation, imageN will probably not have much information left.
> >> > From: Darren Weber
> >> > Sent: Thursday, October 15, 2009 5:20 PM
> >> > To: ITK Users
> >> > Subject: [Insight-users] Constructing 3D stack from 2D image series
> >> > (withregistration)
> >> >
> >> > We have a series of several thousand 2D microscope images:
> >> >
> >> > img0001 ... imgN
> >> >
> >> > A simple ITK program uses itkImageSeriesReader to stack the sequential
> >> > images into a 3D volume for output to a .vtk file.  Without any
> >> > coregistration of the image series, the result is a mess (as
> expected).
> >> >
> >> > Another ITK program runs registration algorithm(s) on consecutive
> pairs
> >> > of
> >> > images in the 2D image series (each pair of images is registered
> >> > independently of any other images in the series).  It outputs a
> >> > transform
> >> > file for each image registration, using file names something like:
> >> >
> >> > img0002to0001.xfm
> >> > img0003to0002.xfm
> >> > etc.
> >> >
> >> > What is an efficient way to combine and apply these transforms using
> an
> >> > ITK
> >> > pipeline to 'concatenate' the image series into a 3D stack?
> >> >
> >> > My conception of how this might work, in outline, is:
> >> >
> >> > a)  begin with img0001
> >> > apply transform: none
> >> >
> >> > b) add img0002 to the stack
> >> > apply transform: img0002to0001.xfm
> >> >
> >> > c) add img0003 to the stack
> >> > apply transform: img0002to0001.xfm
> >> > apply transform: img0003to0002.xfm
> >> > (How to concatenate transforms without resampling image data?)
> >> >
> >> > d) add img0004 to the stack
> >> > apply transform: img0002to0001.xfm
> >> > apply transform: img0003to0002.xfm
> >> > apply transform: img0004to0003.xfm
> >> > (How to concatenate transforms without resampling image data?)
> >> >
> >> > etc.
> >> >
> >> >
> >> > In this conception of the problem, the pair-wise registration
> transforms
> >> > are
> >> > 'concatenated' to propagate the registration through the entire
> series.
> >> > What is the most efficient way to do that in ITK?
> >> >
> >> > Is it possible (or reasonable) to associate a transform object (or
> file)
> >> > with each 'element' of an itkImageSeriesReader?  If not, is there
> >> > another
> >> > convention for creating an ITK filter pipeline or registration
> pipeline?
> >> >
> >> > TIA and take care,
> >> > Darren
> >> >
> >> > ________________________________
> >> >
> >> > _____________________________________
> >> > 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
> >> >
> >> > _____________________________________
> >> > 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
> >> >
> >> >
> >
> >
> > _____________________________________
> > 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
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091020/8be4ad37/attachment-0001.htm>


More information about the Insight-users mailing list