itk deformable registration finite elements methods

87
ITK Deformable Registration Finite Elements Methods

Upload: ethan-wilson

Post on 27-Mar-2015

238 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: ITK Deformable Registration Finite Elements Methods

ITK Deformable Registration

Finite ElementsMethods

Page 2: ITK Deformable Registration Finite Elements Methods

Open 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.

Page 3: ITK Deformable Registration Finite Elements Methods

Deformable Registration

Finite Element Methods

for

Deformable Registration

Page 4: ITK Deformable Registration Finite Elements Methods

Deformable Transformation

y

Fixed Image

Transform

x

y

Moving Image

x

Page 5: ITK Deformable Registration Finite Elements Methods

Deformable Transformation

y

Fixed Image

Transform

x

y

Moving Image

x

Page 6: ITK Deformable Registration Finite Elements Methods

Deformable Transformationy

x

Page 7: ITK Deformable Registration Finite Elements Methods

Deformable Transformationy

x

Page 8: ITK Deformable Registration Finite Elements Methods

FEM Gridy

x

FEMGrid

ResamplingGrid

Page 9: ITK Deformable Registration Finite Elements Methods

FEM Gridy

x

FEMGrid

Page 10: ITK Deformable Registration Finite Elements Methods

FEM Gridy

x

FEMGrid

ComputedDeformation

Page 11: ITK Deformable Registration Finite Elements Methods

FEM Gridy

x

FEMGrid

Forces Displacements

Page 12: ITK Deformable Registration Finite Elements Methods

FEM Iterative Linear System

Finite Element Methods

Forces

Displacements

Regularization

F

U

K

Vector N

Vector N

Matrix NxN

Page 13: ITK Deformable Registration Finite Elements Methods

FEM Iterative Linear System

Finite Element Methods

F

U

K

FUK● =

Page 14: ITK Deformable Registration Finite Elements Methods

FEM Iterative Linear System

N = Number of Nodes

FUK

N x N N N● =

Page 15: ITK Deformable Registration Finite Elements Methods

FEM Iterative Linear System

Iteratively Solving a Linear

System

FUK● =

Image based forces

Linearizationof a Physical

ModelNode

Displacements

Page 16: ITK Deformable Registration Finite Elements Methods

FEM Energy Formulation

( ) similarity( ( ), ( ))

smoothness ( )

deformation ( )

t t tE u I x I x u

u

u

Find registration transformation that maximizes

Page 17: ITK Deformable Registration Finite Elements Methods

FEM Energy Formulation

Benefits

Intuitive; easier to express constraints Powerful numerical solutions available Optimality of solutions; easier to debug

Limitations

– Difficult / overhead to implement

Page 18: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

To solve the deformation, consider only displacements of the form

Page 19: ITK Deformable Registration Finite Elements Methods

Deformable Registration

Linear Elements

Page 20: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ1 Element

α1

Shape Function

Page 21: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ2

Element

α2 Shape Function

Page 22: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ3

Element

α3

Shape Function

Page 23: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ3

Elementφ1

φ2

u

α2

α3

Shape Functions

α1

Page 24: ITK Deformable Registration Finite Elements Methods

Deformable Registration

Higher Order Elements

Page 25: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ1 Element

α1

Shape Function

Page 26: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ4

Element

α4

Shape Function

Page 27: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ2

Element

α2 Shape Function

Page 28: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ5

Elementα5

Shape Function

Page 29: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ3

Element

α3

Shape Function

Page 30: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ6

Element

α6

Shape Function

Page 31: ITK Deformable Registration Finite Elements Methods

Deformable Registration

( ) ( )h i iu x s

φ3

Elementφ1

φ2

u

α2

α3

Shape Functions

α1 α6α5

α4

φ5

φ6

φ4

Page 32: ITK Deformable Registration Finite Elements Methods

Deformable Registration

0, 1, ,i

Ei n

Substitute uh into E, then minimizing with respect to αi:

( ) similarity( ( ), ( ))

smoothness ( )

deformation ( )

t t tE u I x I x u

u

u

Page 33: ITK Deformable Registration Finite Elements Methods

BSplines Grid & Image Grid

Calculation

are made in

an Element

by Element

basis

Page 34: ITK Deformable Registration Finite Elements Methods

BSplines Grid & Image Grid

Elements are connected at Nodes at which the displacement is solved

Page 35: ITK Deformable Registration Finite Elements Methods

BSplines Grid & Image Grid

Efficiency is gained by elemental computation

Page 36: ITK Deformable Registration Finite Elements Methods

BSplines Grid & Image Grid

Domain subdivision (Mesh) can be tailored to the underlying geometry of the image.

Page 37: ITK Deformable Registration Finite Elements Methods

FEM Solver

Image MetricDerivative

Physical Assumptions

SolveNewSolution

Start Iteration Loop

End Iteration Loop

Begin Loop by making physical assumptions and then taking the derivative of the similarity metric.

End loop when the solution stabilizes.

Page 38: ITK Deformable Registration Finite Elements Methods

FEM Solver

Image MetricDerivative

Physical Assumptions

SolveNewSolution

Start Iteration Loop

End Iteration Loop F

U

K

UU

U

Old

New

Page 39: ITK Deformable Registration Finite Elements Methods

FEM Solver

F

KUUnew

Start Iteration Loop

If ( Unew – Uold) < ε then Stop

UU

U

Old

New

K FU● =

Page 40: ITK Deformable Registration Finite Elements Methods

KU=F in Code

FEMSolver::AssembleF()

calls

FEMImageMetricLoad::Fe()

itk::FEMSolver::AssembleK()

FEMSolver::Solve()

FEMSolver ::

AddSolution()

itk::FEMRegistrationFilter::IterativeSolve()

Page 41: ITK Deformable Registration Finite Elements Methods

FEM-Based Registration Options

Element Type

– Triangles– Quadrilaterals– Hexahedra– Tetrahedra

Page 42: ITK Deformable Registration Finite Elements Methods

FEM-Based Registration Options

Continuum / Physical Model

– Linear elasticity– Membrane– Other specialized

Page 43: ITK Deformable Registration Finite Elements Methods

FEM-Based Registration Options

Mesh geometry

– Uniform grid vs. adaptive– Anatomy-specific mesh

Page 44: ITK Deformable Registration Finite Elements Methods

FEM-Based Registration Options

Metric

– Mean square– Normalized cross-correlation– Mutual information– Pattern intensity

Page 45: ITK Deformable Registration Finite Elements Methods

ITK FEM Library

Introduction to the ITK

Finite Element Library

Page 46: ITK Deformable Registration Finite Elements Methods

ITK 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

Page 47: ITK Deformable Registration Finite Elements Methods

ITK FEM Library

Applications

– Mechanical modeling– Image registration

Page 48: ITK Deformable Registration Finite Elements Methods

FEM 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

Page 49: ITK Deformable Registration Finite Elements Methods

ITK 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

Page 50: ITK Deformable Registration Finite Elements Methods

Loads

Classes that apply external forces (loads) to elements– Various types– Easily extensible

Page 51: ITK Deformable Registration Finite Elements Methods

Solvers

Provide functionality to obtain and process the solution

Different solution methods different solver classes– Static problems– Time dependent - dynamic problems

Page 52: ITK Deformable Registration Finite Elements Methods

Solvers

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

Page 53: ITK Deformable Registration Finite Elements Methods

Setting 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

Page 54: ITK Deformable Registration Finite Elements Methods

Deformable Registration

FEM-Base Registration

Parameters

Page 55: ITK Deformable Registration Finite Elements Methods

Parameter 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 (0=mean sq, 1=ncc, 2=pattern int, 3=MI)1.0 % Alpha1 % DescentDirection2 % DoLineSearch (0=never, 1=always, 2=if needed)1.e1 % TimeStep1.e-15 % Energy Reduction Factor

Page 56: ITK Deformable Registration Finite Elements Methods

Parameter File : Part 2% ----------------------------------% Information about the image inputs% ----------------------------------2 % ImageDimension256 % Nx (image x dimension)256 % Ny (image y dimension)128 % Nz (image z dimension - not used if 2D)brain_slice1.mhd % ReferenceFileNamebrain_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 WriteDisplacementField to 1.% -------------------------------------------------------------------0 % UseLandmarks?- % LandmarkFileNamebrain_result % ResultsFileName (prefix only)1 % WriteDisplacementField?brain_disp % DisplacementsFileName (prefix only)1 % ReadMeshFile?brain_mesh.fem % MeshFileName

END

Page 57: ITK Deformable Registration Finite Elements Methods

Configuring Parameters #1this->DoMultiRes(true);

this->m_NumLevels = nlev;this->m_MaxLevel = mlev; for (jj=0; jj < ImageDimension; jj++) { m_ImageScaling[jj] = dim;} for (jj=0; jj < this->m_NumLevels; jj++) { this->m_MeshPixelsPerElementAtEachResolution(jj) = p; this->SetElasticity(e, jj); this->SetRho(p, jj); this->SetGamma(g, jj); this->SetNumberOfIntegrationPoints(ip, jj); this->SetWidthOfMetricRegion(w, jj); this->SetMaximumIterations(mit, jj);}

Page 58: ITK Deformable Registration Finite Elements Methods

Configuring Parameters #2

this->SetDescentDirectionMinimize();or

this->SetDescentDirectionMaximize();

this->DoLineSearch( n ); // n = 0, 1, 2 this->SetTimeStep( t );

this->SetEnergyReductionFactor( fbuf );

Page 59: ITK Deformable Registration Finite Elements Methods

Configuring Parameters #3this->m_ImageSize[0] = xdim;this->m_ImageSize[1] = ydim;if (dim == 3) this->m_ImageSize[2] = zdim;

this->SetReferenceFile( imgfile1 );this->SetTargetFile( imgfile2 );

this->UseLandmarks( true );this->SetLandmarkFile( lmfile ); this->SetResultsFile( resfile );

this->SetWriteDisplacements( true );this->SetDisplacementsFile( dispfile );

this->m_ReadMeshFile = true;this->m_MeshFileName = meshfile;

Page 60: ITK Deformable Registration Finite Elements Methods

Deformable Registration

FEM-Based Registration:

Writing the Code

../ Insight / Examples / Registration / DeformableRegistration1.cxx

Page 61: ITK Deformable Registration Finite Elements Methods

Header Declarations

#include "itkImageFileReader.h"

#include "itkImageFileWriter.h“

#include "itkFEM.h"

#include “itkFEMRegistrationFilter.h"

Page 62: ITK Deformable Registration Finite Elements Methods

Type Definitionstypedef itk::Image< unsigned char, 2 > fileImageType;

typedef itk::Image< float, 2 > ImageType;

typedef itk::fem::Element2DC0LinearQuadrilateralMembrane ElementType;

typedef itk::fem::Element2DC0LinearTriangularMembrane ElementType2;

typedef itk::fem::FEMRegistrationFilter< ImageType, ImageType > RegistrationType;

Page 63: ITK Deformable Registration Finite Elements Methods

Registering ObjectsElementType::LoadImplementationFunctionPointer fp1 =

& itk::fem::ImageMetricLoadImplementation< ImageLoadType >::ImplementImageMetricLoad;

DispatcherType::RegisterVisitor( (ImageLoadType*)0 , fp1 );

ElementType2::LoadImplementationFunctionPointer fp2 =

& itk::fem::ImageMetricLoadImplementation< ImageLoadType >::ImplementImageMetricLoad;

DispatcherType2::RegisterVisitor( (ImageLoadType*)0 , fp2 );

Page 64: ITK Deformable Registration Finite Elements Methods

Input / Output

RegistrationType::Pointer registration = RegistrationType::New();

registration->SetConfigFileName( paramname );

registration->ReadConfigFile();

Page 65: ITK Deformable Registration Finite Elements Methods

Material and Element Setup// Create the material propertiesitk::fem::MaterialLinearElasticity::Pointer m;m = itk::fem::MaterialLinearElasticity::New();m->GN = 0;m->E = registration->GetElasticity();m->A = 1.0; // Cross-sectional aream->h = 1.0; // Thicknessm->I = 1.0; // Moment of inertiam->nu = 0.; // Poisson's ratiom->RhoC = 1.0; // Density // Create the element type ElementType::Pointer e1 = ElementType::New();e1->m_mat= dynamic_cast< itk::fem::MaterialLinearElasticity* >( m );registration->SetElement( e1 );registration->SetMaterial( m );

Page 66: ITK Deformable Registration Finite Elements Methods

Running the Registration

registration->RunRegistration();

registration->WriteWarpedImage();

if ( registration->GetWriteDisplacements() )

{

registration->WriteDisplacementField( 0 ); // x

registration->WriteDisplacementField( 1 ); // y

registration->WriteDisplacementFieldMultiComponent();

}

Page 67: ITK Deformable Registration Finite Elements Methods

FEM - Deformable Registration

Example #1

Page 68: ITK Deformable Registration Finite Elements Methods

Fixed Image

Page 69: ITK Deformable Registration Finite Elements Methods

Moving Image

Page 70: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 71: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 72: ITK Deformable Registration Finite Elements Methods

FEM - Deformable Registration

Example #2

Page 73: ITK Deformable Registration Finite Elements Methods

Fixed Image

Page 74: ITK Deformable Registration Finite Elements Methods

Moving Image

Page 75: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 76: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 77: ITK Deformable Registration Finite Elements Methods

FEM - Deformable Registration

Example #3

Page 78: ITK Deformable Registration Finite Elements Methods

Fixed Image

Page 79: ITK Deformable Registration Finite Elements Methods

Moving Image

Page 80: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 81: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 82: ITK Deformable Registration Finite Elements Methods

FEM - Deformable Registration

Example #4

Elasticity value was doubled

Page 83: ITK Deformable Registration Finite Elements Methods

Fixed Image

Page 84: ITK Deformable Registration Finite Elements Methods

Moving Image

Page 85: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 86: ITK Deformable Registration Finite Elements Methods

Registered Image

Page 87: ITK Deformable Registration Finite Elements Methods

Enjoy ITK !