Lecture 8 Registrafion with ITK For more info/gory detail. What is
Transcription
Lecture 8 Registrafion with ITK For more info/gory detail. What is
2/8/12 Lecture 8 Registra.on with ITK Methods in Medical Image Analysis -‐ Spring 2012 BioE 2630 (Pi>) : 16-‐725 (CMU RI) 18-‐791 (CMU ECE) : 42-‐735 (CMU BME) By Dr. John Galeo2 & Dr. Damion Shelton 1 This work by John Galeo2 and Damion Shelton is licensed under a Crea;ve Commons A>ribu;on 3.0 Unported License. To view a copy of this license, visit h>p://crea;vecommons.org/licenses/by/3.0/ or send a le>er to Crea;ve Commons, 171 2nd Street, Suite 300, San Francisco, California, 94105, USA. Permissions beyond the scope of this license may be available by emailing itk@galeo2.net. For more info/gory detail… Please see the following for exhaus;ve detail: Chapter 8 in the ITK So`ware Guide Currently, this does not cover the newer registra;on methods Insight into Images ITK Source Tree Examples/Registra;on/ E.g. Examples/Registra;on/ImageRegistra;on1.cxx ITK Doxygen h>p://www.itk.org/Doxygen40/html/ group__Registra;onFilters.html h>p://www.itk.org/Doxygen40/html/group__Group-‐ Registra;on.html 2 What is registra;on? The process of aligning a target image to a source image More generally, determining the transform that maps points in the target image to points in the source image 3 1 2/8/12 Transform types Rigid (rotate, translate) Affine (rigid + scale & shear) Deformable (affine + vector field) Many others 4 Registra;on in ITK ITK uses an extensible registra;on framework Various interchangeable classes exist Rela;vely easy to “twiddle” the part you’re interested in while recycling prior work 5 ITK terminology Fixed image f(x) -‐ sta;onary in space Moving image m(x) -‐ the fixed image with an unknown transform applied Goal: recover the transform T(x) which maps points in f(x) to m(x) 6 2 2/8/12 Registra;on framework pieces 2 input images, fixed and moving Metric -‐ determines the “fitness” of the current registra;on itera;on Op;mizer -‐ adjusts the transform in an a>empt to improve the metric Interpolator -‐ applies transform to image and computes sub-‐pixel values 7 ITK registra;on flowchart Figure 8.2 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 8 ITK’s “Hello world” example 2D floa;ng point image inputs Please see the so`ware guide (sec;on 8.2) for code specifics I am going to cover what each piece does, not look at code per se 9 3 2/8/12 ITK’s “Hello World” Example: Flow Chart for Everything Figure 8.5 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 10 Input images 2D floa;ng point Floa;ng point avoids loss of precision problems with integer pixel types 11 Transform Transla;onTransform Permits transla.on only in 2D Documenta;on notes similarity to AffineTransform, but improved speed (why…?) 12 4 2/8/12 Transform Coordinate System Figure 8.7 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 13 Metric MeanSquaresImageToImageMetric Sum of squared differences between 2 images on a pixel-‐by-‐pixel basis A bit naïve Works for 2 images that were acquired with the same imaging modality 14 Op;mizer RegularStepGradientDescent Follows the deriva;ve of the metric Step size depends on rapid changes in the gradient’s direc;on Step size eventually reaches a user-‐defined value that determines convergence 15 5 2/8/12 Interpolator LinearInterpolateImageFunc;on Fast and conceptually simple 16 Wrapper ImageRegistra;onMethod Combines all of the previous classes into a master class registration->SetMetric( metric );! registration->SetOptimizer( optimizer );! registration->SetTransform( transform );! registration->SetInterpolator( interpolator);! 17 Other steps Set the region of the fixed image the registra;on will operate on (e.g. to ignore bad data) Ini;alize the transform Twiddle the op;mizer for best performance* *may involve pain and suffering 18 6 2/8/12 Hello world input Figure 8.3 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 19 X & Y transla;on vs. ;me Figure 8.6 (top) from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 20 Metric vs. ;me Figure 8.6 (bo>om) from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 21 7 2/8/12 Registra;on results A`er registra;on converges/terminates you call GetLastTransformParamters to recover the final transform For the Hello World example there are 2 parameters, X & Y transla;on 22 Double checking results Use ResampleImageFilter to apply the transform for the fixed image Take the output, compute a difference image with the moving image, examine the results Good registra;on results in nothing much to see 23 Image comparison Registered moving image Difference before registration Difference after registration Figure 8.4 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 24 8 2/8/12 Keeping tabs on registra;on Registra;on is o`en ;me consuming It’s nice to know that your algorithm isn’t just spinning it’s wheels Use the observer mechanism in ITK to monitor progress See the so`ware guide, 3.2.6 and 8.4 We’ll see this again later, when we discuss how to write your own ITK filters itk::ProgressEvent is one example 25 Observer steps Write an observer class that will process “itera;on” events (Just copy some code from an example) Add the observer to the op;mizer As a generic note, observers can observe any class derived from itk::Object Start registra;on as usual 26 Things observers can do Print debugging info Update GUI Other small management func;ons Should not do anything too processor intensive 27 9 2/8/12 Mul;-‐modality registra;on Remember how I said sum-‐of-‐squares difference is rela;vely naïve? Mutual informa;on helps overcome this problem Sec;on 8.5 shows how to implement a simple MI registra;on 28 Notes about the MI example Significantly, largely the same piece of code as Hello World Mutual Informa;on is a metric, so we can keep the op;mizer, the interpolator, and so on Majority of differences are in tweaking the metric, not in rewri;ng code 29 MI Inputs T1 MRI Proton density MRI Figure 8.9 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 30 10 2/8/12 MI Output: Image Comparison Before After This is an example of a checkerboard visualization Taken from Figure 8.10 of the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 31 Centered transforms More natural (arguably) reference frame than having the origin at the corner of the image In SimpleITK, transforms are automa;cally centered by default! Details are not appreciably different from other rigid registra;ons, see 8.6 32 SimpleITK Registra;on (Python) import SimpleITK as sitk! ! imgT1 = sitk.ReadImage(“MRI_T1.tif”)! imgPD_shifted = sitk.ReadImage(“MRI_PD_shifted.tif”)! ! transform = sitk.AffineTransform()! interp = sitk.LinearInterpolate()! metric = sitk.MattesMutualInformationMetric()! optimizer = sitk.RegularStepGradientDescentOptimizer()! ! params = sitk.Register( imgPD_shifted, imgT1, transform,\! ! ! ! interp, metric, optimizer )! ! print(params)! 33 11 2/8/12 SimpleITK Registra;on (C++) #include <SimpleITK.h>! ! int main(void) {! itk::simple::ImageFileReader reader;! ! itk::simple::Image fixed = reader.SetFileName(“FixedImage.nii” ).Execute();! itk::simple::Image moving = reader.SetFileName(“MovingImage.nii”).Execute();! ! itk::simple::AffineTransform transform;! itk::simple::MattesMutualInformationMetric metric;! itk::simple::LinearInterpolate interpolate;! itk::simple::RegularStepGradientDescentOptimizer optimizer;! ! // Longer form (Python can likewise also set these one at a time):! itk::simple::Registration registration;! registration.SetTransform ( &transform );! registration.SetMetric ( &metric );! registration.SetInterpolate ( &interpolate );! registration.SetOptimizer ( &optimizer );! std::vector<double> params;! ! params = registration.Execute ( fixed, moving );! }! 34 An aside: “ Twiddling” A common cri;cism of many/most registra;on techniques is their number of parameters A successful registra;on o`en depends on a very specific fine-‐tuning of the algorithm “Generalized” registra;on is an open problem WARNINGS for SimpleITK beta 0.3: Beta v. 0.3 currently does NOT allow twiddling of any of the registra;on parameters The beta’s choices of registra;on parameters are not necessarily very good yet. 35 Mul;-‐Resolu;on registra;on Useful to think of this as algorithmic “squin;ng” by using image pyramids Start with something simple and low-‐res Use low-‐res registra;on to seed the next higher step Eventually run registra;on at high-‐res Also called “coarse to fine” 36 12 2/8/12 Mul;-‐resolu;on schema;c Figure 8.36 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 37 Image pyramids Figure 8.37 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 38 Op;miza;on Parameter dependency rears its ugly head You o`en/usually need to adjust op;mizer parameters as you move through the pyramid You can do this using the Observer mechanism 39 13 2/8/12 Mul;-‐resolu;on example Again, mostly the same code as Hello World Use Mul;Resolu;onPyramidImage filter to build fixed and moving pyramids Mul;Resolu;onImageRegistrionMethod is now the overall framework 40 Benefits of mul;-‐resolu;on O`en faster More tolerant of noise (from “squin;ng”) Minimizes ini;aliza;on problems to a certain extent, though not perfect 41 See the so`ware guide for… Detailed list of: Transforms Op;mizers Interpola;on methods You’re encouraged to mix and match! Note: ITKv4’s new registra;on methods are s;ll being developed, and the documenta;on is not yet complete for them. Check Doxygen and ITK source code for ImageRegistra;onMethodv4 42 14 2/8/12 Deformable registra;on ITK has 2 primary techniques: Finite element: treat small image regions as having physical proper;es that control deforma;on Demons: images are assumed to have iso-‐intensity contours (isophotes); image deforma;ons occur by pushing on these contours 43 Model based registra;on Build a simplified geometric model from a training set Iden;fy parameters that control the characteris;cs of the model Register the model to a target image to adapt to a par;cular pa;ent 44 Model based, cont. Uses the Spa;al Objects framework for represen;ng geometry Useful because it derives analy;cal data from the registra;on process, not just a pixel-‐to-‐pixel mapping 45 15 2/8/12 Model-‐based example Note: This is what we want, NOT the output of an actual registra;on Figure 8.60 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 46 Model-‐based reg. schema;c Figure 8.59 from the ITK So`ware Guide v 2.4, by Luis Ibáñez, et al. 47 Model-‐based registra;on: Warning! ITK does not yet directly support generic model-‐ based registra;on “out of the box” ITKv4 does support point-‐set to image registra;on Otherwise, model-‐based reg. requires wri;ng your own custom ITK transform, with new parameters Transform’s new parameters Spa;al Object parameters You must individually map your custom transform’s new parameters to the specific spa;al object parameters you want to allow registra;on to adjust This isn’t too complicated if you know what you’re doing Search Insight Journal for examples 48 16 2/8/12 Speed issues Execu;on ;me can vary wildly Op;mizer (more naïve = faster) Image dimensionality (fewer = faster) Transform (fewer DOF = faster) Interpolator (less precise = faster) 49 New in ITKv4 (ImageRegistra;onMethodv4, etc.) New unified and fully mul;-‐threaded op;miza;on and registra;on framework Unified framework supports sparse and dense metric computa;on Unified framework supports low and high dimensional mapping Improved mul;-‐threaded metrics for rigid, affine and deformable registra;on New metrics support sparse or dense sampling Metrics for landmark or label guided registra;on Automa;c parameter scale es;ma;on for registra;on Automa;c step-‐size selec;on for gradient-‐based registra;on op;mizers Composite transforms and composite transform op;miza;on Displacement field and diffeomorphic velocity field-‐based transforms Be>er support for mul;-‐threading in op;mizers and metrics Addi;onal evolu;onary op;mizers Improved B-‐Spline registra;on approach available and bug fixes to old framework Accurately transform and reorient covariant tensors and vectors List taken from http://www.itk.org/Wiki/ITK_Release_4/Why_Switch_to_ITKv4 50 Take home messages Exactly what parameters do what is not always obvious, even if you are familiar with the code Successful registra;ons can be something of an art form Mul;-‐resolu;on techniques can help Work within the framework! 51 17
Similar documents
The ITK Software Guide Book 2: Design and Functionality Fourth
are credited here, so please visit the Web pages at http://itk.org/ITK/project/parti.html for the names of additional contributors, as well as checking the GIT source logs for code contributions. T...
More informationITK Software Guide - Scientific Computing and Imaging Institute
The Insight Toolkit (ITK) is an open-source software toolkit for performing registration and segmentation. Segmentation is the process of identifying and classifying data found in a digitally sampl...
More information