Title: ITK Deformable Registration
1ITK Deformable Registration
Finite Elements Methods
2Open Source Disclaimer
Many of the slides in this talk were taken from
the ITK course presented at MICCAI 2003 by
Dr. James Gee (U. Penn)Brian Avants
(U. Penn)Tessa Sundaram (U. Penn)Dr.
Lydia Ng (AllenInstitue)
Of course, any errors are mine.
3Deformable Registration
Finite Element Methodsfor Deformable
Registration
4Deformable Transformation
y
y
Transform
x
x
Fixed Image
Moving Image
5Deformable Transformation
y
y
Transform
x
x
Fixed Image
Moving Image
6Deformable Transformation
y
x
7Deformable Transformation
y
x
8FEM Grid
y
FEM Grid
Resampling Grid
x
9FEM Grid
y
FEM Grid
x
10FEM Grid
y
FEM Grid
Computed Deformation
x
11FEM Grid
y
FEM Grid
Displacements
Forces
x
12FEM Iterative Linear System
Finite Element Methods
F
Forces
Vector N
U
Vector N
Displacements
K
Matrix NxN
Regularization
13FEM Iterative Linear System
Finite Element Methods
F
F
U
K
U
?
K
14FEM Iterative Linear System
N Number of Nodes
N x N
N
N
?
F
U
K
15FEM Iterative Linear System
Iteratively Solving a Linear System
F
U
K
?
Linearization of a Physical Model
Image based forces
Node Displacements
16FEM Energy Formulation
Find registration transformation that maximizes
17FEM Energy Formulation
Benefits
- Intuitive easier to express constraints
- Powerful numerical solutions available
- Optimality of solutions easier to debug
Limitations
- Difficult / overhead to implement
18Deformable Registration
To solve the deformation, consider only
displacements of the form
19Deformable Registration
Linear Elements
20Deformable Registration
a1
Element
f1
Shape Function
21Deformable Registration
Element
f2
a2
Shape Function
22Deformable Registration
a3
f3
Element
Shape Function
23Deformable Registration
u
a3
f3
Element
a1
f1
f2
a2
Shape Functions
24Deformable Registration
Higher Order Elements
25Deformable Registration
a1
Element
f1
Shape Function
26Deformable Registration
a4
f4
Element
Shape Function
27Deformable Registration
Element
f2
a2
Shape Function
28Deformable Registration
f5
a5
Element
Shape Function
29Deformable Registration
a3
f3
Element
Shape Function
30Deformable Registration
f6
a6
Element
Shape Function
31Deformable Registration
a4
f4
u
a3
f3
Element
f6
a1
a6
f1
a5
f5
f2
a2
Shape Functions
32Deformable Registration
Substitute uh into E, then minimizing with
respect to ai
33BSplines Grid Image Grid
Calculation are made in an Element by Element
basis
34BSplines Grid Image Grid
Elements are connected at Nodes at which the
displacement is solved
35BSplines Grid Image Grid
Efficiency is gained by elemental computation
36BSplines Grid Image Grid
Domain subdivision (Mesh) can be tailored to the
underlying geometry of the image.
37FEM Solver
Start Iteration Loop
- Begin Loop by making physical assumptions and
then taking the derivative of the similarity
metric. - End loop when the solution stabilizes.
Physical Assumptions
Solve
New Solution
Image Metric Derivative
End Iteration Loop
38FEM Solver
Start Iteration Loop
K
Physical Assumptions
Solve
New Solution
U
Image Metric Derivative
F
End Iteration Loop
39FEM Solver
Start Iteration Loop
K
U
Unew
F
If ( Unew Uold) lt e then Stop
40KUF in Code
itkFEMRegistrationFilterIterativeSolve()
itkFEMSolverAssembleK()
FEMSolver Solve()
FEMSolver AddSolution()
FEMSolverAssembleF() calls FEMImageMetricLoad
Fe()
41FEM-Based Registration Options
- Element Type
- Triangles
- Quadrilaterals
- Hexahedra
- Tetrahedra
42FEM-Based Registration Options
- Continuum / Physical Model
- Linear elasticity
- Membrane
- Other specialized
43FEM-Based Registration Options
- Mesh geometry
- Uniform grid vs. adaptive
- Anatomy-specific mesh
44FEM-Based Registration Options
- Metric
- Mean square
- Normalized cross-correlation
- Mutual information
- Pattern intensity
45ITK FEM Library
Introduction to the ITK Finite Element Library
46ITK FEM Library
- Library for solving general FEM problems
- Object oriented
- C classes are used to
- specify the geometry and behavior of the elements
- apply external forces and boundary conditions
- solve problem and post-process the results
47ITK FEM Library
- Applications
- Mechanical modeling
- Image registration
48FEM Basics
- Mesh
- Nodes
- Points in space where solutions are obtained
- Elements
- e.g., 2-D triangular elements
- Loads
- e.g., gravity (body) load
- Boundary conditions
- e.g., nodes fixed in space
49ITK FEM Elements
- Core of the library is the Element class
- Code is in two functionally independent parts
- Geometry and Physics
- Arbitrarily combined to create new elements
- Problem domain is specified by a mesh
Geometry
Physics
50Loads
- Classes that apply external forces (loads) to
elements - Various types
- Easily extensible
51Solvers
- Provide functionality to obtain and process the
solution - Different solution methods ? different solver
classes - Static problems
- Time dependent - dynamic problems
52Solvers
- Use linear system wrappers to link FEM classes
to an external numeric library - Any numeric library can be used to solve the
systems of linear equations in FEM problems - VNL and ITPACK currently supported
53Setting Up a FEM Problem
- Four-step process
- Select element classes
- Discretize problem domain
- Specify boundary conditions
- Specify/Apply external loads
- Two options
- Directly ? create proper objects in code
- Indirectly ? read object definitions from a file
54Deformable Registration
FEM-Base RegistrationParameters
55Parameter File Part 1
------------------------------------------------
--------- Parameters for the single- or
multi-resolution techniques --------------------
------------------------------------- 1 Number
of levels in the multi-resolution pyramid (1
single-res) 1 Highest level to use in the
pyramid 1 1 Scaling at lowest level for each
image dimension 8 Number of pixels per
element 1.e5 Elasticity (E) 1.e4 Density
(RhoC) 1. Image energy scaling 4
NumberOfIntegrationPoints 1
WidthOfMetricRegion 25 MaximumIterations
------------------------------- Parameters for
the registration -------------------------------
0 1.0 Similarity metric (0mean sq, 1ncc,
2pattern int, 3MI) 1.0 Alpha 1
DescentDirection 2 DoLineSearch (0never,
1always, 2if needed) 1.e1 TimeStep 1.e-15
Energy Reduction Factor
56Parameter File Part 2
----------------------------------
Information about the image inputs
---------------------------------- 2
ImageDimension 256 Nx
(image x dimension) 256 Ny
(image y dimension) 128 Nz
(image z dimension - not used if
2D) brain_slice1.mhd ReferenceFileName brain
_slice1warp.mhd TargetFileName
--------------------------------------------------
----------------- The actions below depend on
the values of the flags preceding them. For
example, to write out the displacement fields,
you have to set the value of WriteDisplacementFi
eld to 1. --------------------------------------
----------------------------- 0
UseLandmarks? -
LandmarkFileName brain_result
ResultsFileName (prefix only) 1
WriteDisplacementField? brain_disp
DisplacementsFileName (prefix only) 1
ReadMeshFile? brain_mesh.fem
MeshFileName END
57Configuring Parameters 1
this-gtDoMultiRes(true) this-gtm_NumLevels
nlev this-gtm_MaxLevel mlev for (jj0
jj lt ImageDimension jj) m_ImageScalingjj
dim for (jj0 jj lt this-gtm_NumLevels
jj) this-gtm_MeshPixelsPerElementAtEachResolu
tion(jj) p this-gtSetElasticity(e, jj)
this-gtSetRho(p, jj) this-gtSetGamma(g, jj)
this-gtSetNumberOfIntegrationPoints(ip, jj)
this-gtSetWidthOfMetricRegion(w, jj)
this-gtSetMaximumIterations(mit, jj)
58Configuring Parameters 2
this-gtSetDescentDirectionMinimize() or this-
gtSetDescentDirectionMaximize()
this-gtDoLineSearch( n ) // n 0, 1, 2
this-gtSetTimeStep( t ) this-gtSetEnergyReduction
Factor( fbuf )
59Configuring Parameters 3
this-gtm_ImageSize0 xdim this-gtm_ImageSize1
ydim if (dim 3) this-gtm_ImageSize2
zdim this-gtSetReferenceFile( imgfile1
) this-gtSetTargetFile( imgfile2
) this-gtUseLandmarks( true ) this-gtSetLandmarkF
ile( lmfile ) this-gtSetResultsFile( resfile
) this-gtSetWriteDisplacements( true
) this-gtSetDisplacementsFile( dispfile
) this-gtm_ReadMeshFile true this-gtm_MeshFileN
ame meshfile
60Deformable Registration
FEM-Based Registration Writing the Code
../ Insight / Examples / Registration /
DeformableRegistration1.cxx
61Header Declarations
include "itkImageFileReader.h" include
"itkImageFileWriter.h include
"itkFEM.h" include itkFEMRegistrationFilter.h"
62Type Definitions
typedef itkImagelt unsigned char, 2 gt
fileImageType typedef itkImagelt float, 2 gt
ImageType typedef itkfemElement2DC0LinearQu
adrilateralMembrane
ElementType typedef
itkfemElement2DC0LinearTriangularMembrane
ElementType2 typedef itkfemFEMRegistrationFi
lterlt
ImageType,
ImageType gt
RegistrationType
63Registering Objects
ElementTypeLoadImplementationFunctionPointer
fp1 itkfemImageMetricLoadImplementa
tionlt ImageLoadType
gtImplementImageMetricLoad DispatcherTypeReg
isterVisitor( (ImageLoadType)0 , fp1
) ElementType2LoadImplementationFunctionPoin
ter fp2 itkfemImageMetricLoadImpleme
ntationlt ImageLoadType
gtImplementImageMetricLoad DispatcherType2Re
gisterVisitor( (ImageLoadType)0 , fp2 )
64Input / Output
RegistrationTypePointer registration
RegistrationTypeNew()
registration-gtSetConfigFileName( paramname
) registration-gtReadConfigFile()
65Material and Element Setup
// Create the material properties itkfemMateri
alLinearElasticityPointer m m
itkfemMaterialLinearElasticityNew() m-gtGN
0 m-gtE registration-gtGetElasticity() m-gtA
1.0 // Cross-sectional area m-gth
1.0 // Thickness m-gtI 1.0
// Moment of inertia m-gtnu 0.
// Poisson's ratio m-gtRhoC 1.0
// Density // Create the element
type ElementTypePointer e1
ElementTypeNew() e1-gtm_mat dynamic_castlt
itkfemMaterialLinearElasticity gt( m
) registration-gtSetElement( e1
) registration-gtSetMaterial( m )
66Running the Registration
registration-gtRunRegistration() registration-gtWr
iteWarpedImage() if ( registration-gtGetWriteDisp
lacements() ) registration-gtWriteDisplacementF
ield( 0 ) // x registration-gtWriteDisplacement
Field( 1 ) // y registration-gtWriteDisplaceme
ntFieldMultiComponent()
67FEM - Deformable Registration
Example 1
68Fixed Image
69Moving Image
70Registered Image
71Registered Image
72FEM - Deformable Registration
Example 2
73Fixed Image
74Moving Image
75Registered Image
76Registered Image
77FEM - Deformable Registration
Example 3
78Fixed Image
79Moving Image
80Registered Image
81Registered Image
82FEM - Deformable Registration
Example 4Elasticity value was doubled
83Fixed Image
84Moving Image
85Registered Image
86Registered Image
87Enjoy ITK !