19 #ifndef itkFEMRegistrationFilter_h
20 #define itkFEMRegistrationFilter_h
45 #include "vnl/vnl_vector.h"
47 #include "vnl/vnl_vector_fixed.h"
117 template <
typename TMovingImage,
typename TFixedImage,
typename TFemObjectType>
140 itkStaticConstMacro(ImageDimension,
unsigned int,
141 FixedImageType::ImageDimension);
147 enum Sign { positive = 1, negative = -1 };
199 return m_MovingImage;
205 return m_OriginalMovingImage;
209 void SetFixedImage(FixedImageType* T);
221 void SetInputFEMObject(FEMObjectType* F,
unsigned int level = 0);
223 FEMObjectType * GetInputFEMObject(
unsigned int level = 0);
226 void RunRegistration();
229 void IterativeSolve(SolverType *S);
232 void MultiResSolve();
235 void WarpImage(
const MovingImageType * R);
241 return m_WarpedImage;
245 void ComputeJacobian();
272 void DeleteLandmark(
unsigned int i);
274 void ClearLandmarks();
285 void EnforceDiffeomorphism(
float thresh, SolverType *S,
bool onlywriteimages);
295 m_MeshPixelsPerElementAtEachResolution[which] = i;
304 m_NumberOfIntegrationPoints[which] = i;
314 m_MetricWidth[which] = i;
319 return m_MetricWidth[which];
328 m_Maxiters[which] = i;
336 itkSetMacro(TimeStep, Float);
337 itkGetMacro(TimeStep, Float);
344 itkSetMacro(Alpha, Float);
345 itkGetMacro(Alpha, Float);
351 itkSetMacro(UseLandmarks,
bool);
352 itkGetMacro(UseLandmarks,
bool);
353 itkBooleanMacro(UseLandmarks);
354 #if !defined(ITK_LEGACY_REMOVE)
357 itkLegacyMacro(
void SetUseLandmarksOff())
359 SetUseLandmarks(
false);
363 itkLegacyMacro(
void SetUseLandmarksOn())
365 SetUseLandmarks(
true);
372 itkSetMacro(UseMassMatrix,
bool);
373 itkGetMacro(UseMassMatrix,
bool);
374 itkBooleanMacro(UseMassMatrix);
380 itkSetMacro(EnergyReductionFactor, Float);
381 itkGetMacro(EnergyReductionFactor, Float);
411 m_DescentDirection = positive;
417 m_DescentDirection = negative;
424 itkSetMacro(DoLineSearchOnImageEnergy,
unsigned int);
425 itkGetMacro(DoLineSearchOnImageEnergy,
unsigned int);
433 itkSetMacro(UseNormalizedGradient,
bool);
434 itkGetMacro(UseNormalizedGradient,
bool);
435 itkBooleanMacro(UseNormalizedGradient);
436 #if !defined(ITK_LEGACY_REMOVE)
439 itkLegacyMacro(
void SetUseNormalizedGradientOff())
441 SetUseNormalizedGradient(
false);
445 itkLegacyMacro(
void SetUseNormalizedGradientOn())
447 SetUseNormalizedGradient(
true);
454 itkSetMacro(EmployRegridding,
unsigned int);
455 itkGetMacro(EmployRegridding,
unsigned int);
462 itkSetMacro(LineSearchMaximumIterations,
unsigned int);
463 itkGetMacro(LineSearchMaximumIterations,
unsigned int);
471 return m_FullImageSize;
478 itkGetModifiableObjectMacro(Metric, MetricBaseType);
479 itkSetObjectMacro(Metric, MetricBaseType);
490 void ChooseMetric(
unsigned int whichmetric );
497 return m_WhichMetric;
513 void PrintVectorField(
unsigned int modnum = 1000);
518 void SetMaxLevel(
unsigned int level);
519 itkGetMacro(MaxLevel,
unsigned int);
526 itkSetMacro(CreateMeshFromImage,
bool);
527 itkGetMacro(CreateMeshFromImage,
bool);
528 itkBooleanMacro(CreateMeshFromImage);
529 #if !defined(ITK_LEGACY_REMOVE)
532 itkLegacyMacro(
void SetCreateMeshFromImageOn())
534 SetCreateMeshFromImage(
true);
538 itkLegacyMacro(
void SetCreateMeshFromImageOff())
540 SetCreateMeshFromImage(
false);
545 itkSetObjectMacro( Interpolator, InterpolatorType );
548 itkGetModifiableObjectMacro( Interpolator, InterpolatorType );
553 itkSetMacro(StandardDeviations, StandardDeviationsType);
554 virtual void SetStandardDeviations(
double value);
559 itkGetConstReferenceMacro(StandardDeviations, StandardDeviationsType);
563 itkSetMacro(MaximumKernelWidth,
unsigned int);
564 itkGetConstMacro(MaximumKernelWidth,
unsigned int);
569 itkSetMacro(MaximumError,
double);
570 itkGetConstMacro(MaximumError,
double);
574 FEMRegistrationFilter();
575 ~FEMRegistrationFilter() ITK_OVERRIDE;
577 void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
580 void CreateMesh(
unsigned int ElementsPerSide, SolverType *solver);
583 void ApplyLoads(ImageSizeType Isz,
double* spacing = ITK_NULLPTR);
586 void ApplyImageLoads(MovingImageType* i1, FixedImageType* i2);
591 void CreateLinearSystemSolver();
595 Float EvaluateEnergy();
601 void InterpolateVectorField(SolverType *S);
606 FloatImageType * GetMetricImage(FieldType* F);
609 FieldPointer ExpandVectorField(ExpandFactorsType* expandFactors, FieldType* f);
612 void SampleVectorFieldAtNodes(SolverType *S);
615 Float EvaluateResidual(SolverType *mySolver, Float t);
620 void FindBracketingTriplet(SolverType *mySolver, Float* a, Float* b, Float* c);
626 Float GoldenSection(SolverType *mySolver, Float tol = 0.01,
unsigned int MaxIters = 25);
629 itkSetObjectMacro( Load, ImageMetricLoadType );
630 itkGetModifiableObjectMacro(Load, ImageMetricLoadType );
634 void SmoothDisplacementField();
638 void InitializeField();
642 unsigned int m_DoLineSearchOnImageEnergy;
643 unsigned int m_LineSearchMaximumIterations;
646 vnl_vector<
unsigned int> m_NumberOfIntegrationPoints;
647 vnl_vector<
unsigned int> m_MetricWidth;
648 vnl_vector<
unsigned int> m_Maxiters;
649 unsigned int m_TotalIterations;
650 unsigned int m_MaxLevel;
651 unsigned int m_FileCount;
652 unsigned int m_CurrentLevel;
656 unsigned int m_WhichMetric;
660 vnl_vector<
unsigned int> m_MeshPixelsPerElementAtEachResolution;
672 bool m_UseMassMatrix;
673 bool m_UseNormalizedGradient;
674 bool m_CreateMeshFromImage;
675 unsigned int m_EmployRegridding;
716 double m_MaximumError;
718 unsigned int m_MaximumKernelWidth;
727 #ifndef ITK_MANUAL_INSTANTIATION
728 #include "itkFEMRegistrationFilter.hxx"
FixedImageType * GetFixedImage()
void SetElasticity(Float i, unsigned int which=0)
InterpolationGridType::SizeType InterpolationGridSizeType
Image< float, itkGetStaticConstMacro(ImageDimension)> FloatImageType
Light weight base class for most itk classes.
SmartPointer< const Self > ConstPointer
itk::Image< Element::ConstPointer, ImageDimension > InterpolationGridType
SmartPointer< Self > Pointer
Represent the size (bounds) of a n-dimensional image.
void SetMeshPixelsPerElementAtEachResolution(unsigned int i, unsigned int which=0)
itk::Image< VectorType, itkGetStaticConstMacro(ImageDimension)> FieldType
virtual const RegionType & GetLargestPossibleRegion() const
itk::VectorIndexSelectionCastImageFilter< FieldType, FloatImageType > IndexSelectCasterType
FEM Solver for time dependent problems; uses Crank-Nicolson implicit discretization scheme...
FieldType::Pointer FieldPointer
InterpolationGridType::PointType InterpolationGridPointType
TMovingImage MovingImageType
itk::ImageRegionIteratorWithIndex< FloatImageType > FloatImageIterator
void SetNumberOfIntegrationPoints(unsigned int i, unsigned int which=0)
FEMRegistrationFilter Self
Generate a rectilinar mesh from an image. The result is stored in a FEMObject.
TFemObjectType FEMObjectType
void SetWidthOfMetricRegion(unsigned int i, unsigned int which=0)
FixedArray< double, ImageDimension > StandardDeviationsType
Float GetElasticity(unsigned int which=0)
FixedImageType::PointType PointType
itk::fem::ImageToRectilinearFEMObjectFilter< TMovingImage > ImageToMeshType
Load::ArrayType LoadArray
itk::Vector< float, itkGetStaticConstMacro(ImageDimension)> VectorType
itk::VectorExpandImageFilter< FieldType, FieldType > ExpanderType
FloatImageType * GetJacobianImage()
FixedImageType * GetWarpedImage()
ImageSizeType GetImageSize()
void SetRho(Float r, unsigned int which=0)
Expand the size of a vector image by an integer factor in each dimension.
Linear elasticity material class.
TFixedImage FixedImageType
void SetElement(Element::Pointer e)
ExpanderType::ExpandFactorsType ExpandFactorsType
General image pair load that uses the itkFiniteDifferenceFunctions.
FieldType * GetDisplacementField()
A templated class holding a n-Dimensional vector.
MaterialLinearElasticity MaterialType
FixedImageType::PixelType PixelType
ImageBaseType::PointType PointType
FixedImageType::SizeType ImageSizeType
void SetMaterial(MaterialType::Pointer m)
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
InterpolatorType::Pointer InterpolatorPointer
ImageToImageFilter< TMovingImage, TFixedImage > Superclass
FiniteDifferenceFunctionLoad< MovingImageType, FixedImageType > ImageMetricLoadType
const SizeType & GetSize() const
Warps an image using an input displacement field.
FEM Image registration filter. The image registration problem is modelled here with the finite elemen...
VectorInterpolateImageFunction< FieldType, CoordRepType > InterpolatorType
void SetDescentDirectionMaximize()
itk::ImageRegionIteratorWithIndex< FixedImageType > ImageIterator
SolverCrankNicolson< ImageDimension > SolverType
unsigned int GetWidthOfMetricRegion(unsigned int which=0)
void SetDisplacementField(FieldType *F)
Abstract base element class.
itk::WarpImageFilter< MovingImageType, FixedImageType, FieldType > WarperType
VectorLinearInterpolateImageFunction< FieldType, CoordRepType > DefaultInterpolatorType
void SetDescentDirectionMinimize()
Base class for filters that take an image as input and produce an image as output.
MovingImageType * GetMovingImage()
itk::ImageRegionIteratorWithIndex< FieldType > FieldIterator
LinearSystemWrapperItpack LinearSystemSolverType
Base class for all vector image interpolaters.
Extracts the selected index of the vector that is the input pixel type.
ImageBaseType::SizeType SizeType
MovingImageType * GetOriginalMovingImage()
LinearSystemWrapper class that uses Itpack numeric library functions to define and solve a sparse lin...
MetricBaseType::Pointer MetricBaseTypePointer
static ITK_CONSTEXPR_VAR double e
The base of the natural logarithm or Euler's number
std::vector< typename LoadLandmark::Pointer > LandmarkArrayType
void SetGamma(Float r, unsigned int which=0)
void SetMaximumIterations(unsigned int i, unsigned int which)
Templated n-dimensional image class.
PDEDeformableRegistrationFunction< FixedImageType, MovingImageType, FieldType > MetricBaseType
Linearly interpolate a vector image at specified positions.
unsigned int GetMetricType()
ImageBaseType::IndexType IndexType