NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkPCADeformationModelTransform.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 
16 
17 #ifndef itkPCADeformationModelTransform_h
18 #define itkPCADeformationModelTransform_h
19 
20 #include <iostream>
21 #include <itkImage.h>
22 #include <itkTransform.h>
23 #include <itkExceptionObject.h>
24 #include <itkMatrix.h>
25 
26 #include <itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h>
27 
28 namespace itk
29 {
30 
68 template <
69  class TScalarType=float, // Type for coordinate representation type (float or double)
70  unsigned int NDimensions = 3 > // Number of dimensions
71 class ITK_EXPORT PCADeformationModelTransform : public Transform< TScalarType, NDimensions, NDimensions>
72 {
73 public:
76  typedef Transform< TScalarType, NDimensions, NDimensions > Superclass;
77  typedef SmartPointer<Self> Pointer;
78  typedef SmartPointer<const Self> ConstPointer;
79 
81  typedef itk::Vector< TScalarType, NDimensions > VectorPixelType;
82  typedef itk::Image< VectorPixelType, NDimensions > FieldType;
84 
86  typedef typename FieldType::Pointer FieldPointer;
87  typedef typename FieldType::ConstPointer FieldConstPointer;
88  typedef ImageRegionIterator<FieldType> FieldIterator;
89  typedef ImageRegionConstIterator<FieldType> FieldConstIterator;
90 
91  typedef std::vector<FieldConstPointer> FieldConstPointerArray;
92 
93  typedef std::vector<FieldPointer> FieldPointerArray;
94  typedef std::vector<FieldConstIterator> FieldIteratorArray;
95 
96  typedef itk::ContinuousIndex<TScalarType,NDimensions> ContinuousIndexType;
97 
101 
103  typedef VectorLinearInterpolateNearestNeighborExtrapolateImageFunction<FieldType, TScalarType> FieldInterpolatorType;
104  typedef typename FieldInterpolatorType::Pointer FieldInterpolatorPointer;
105  typedef std::vector<FieldInterpolatorPointer> FieldInterpolatorPointerArray;
106 
107 
109  itkNewMacro( Self );
110 
112  itkTypeMacro( PCADeformationModelTransform, Transform );
113 
115  itkStaticConstMacro(InputSpaceDimension, unsigned int, NDimensions);
116  itkStaticConstMacro(OutputSpaceDimension, unsigned int, NDimensions);
117 
119  virtual void SetNumberOfComponents(unsigned int numberOfParameters);
120 
122  void SetFieldArray(unsigned int i, FieldType *field)
123  {
124  if (this->m_FieldArray[i] != field) {
125  this->m_FieldArray[i] = field;
126  this->Modified();
127  }
128  }
130  FieldType *GetFieldArray(unsigned int i)
131  {
132  niftkitkDebugMacro(<<"Returning FieldArray address " << this->m_FieldArray[i] );
133  return this->m_FieldArray[i].GetPointer();
134  }
135 
137  virtual FieldPointer GetSingleDeformationField();
138 
140  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
141 
143  typedef typename Superclass::ScalarType ScalarType;
144 
146  typedef typename Superclass::ParametersType ParametersType;
147 
150 
152  typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
153  typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
154 
156  typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
157  typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
158 
160  typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
161  typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
162 
164  typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputPointType;
165  typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
166 
169  void SetParameters(const ParametersType & parameters);
170 
171  const ParametersType & GetParameters( void ) const;
172 
174  virtual void SetFixedParameters( const ParametersType & );
175 
177  const ParametersType& GetFixedParameters(void) const;
178 
180  virtual const JacobianType GetJacobian( const InputPointType & point ) const;
181  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & point,
182  JacobianType & jacobian ) const;
183 
186  virtual OutputPointType TransformPoint(const InputPointType &point ) const;
187 
188 
190  void SetIdentity( void )
191  {
192  this->m_Parameters.Fill( 0.0 );
193  m_meanCoefficient = 0.0;
194  }
195 
201  virtual bool IsLinear() const { return false; }
202 
205  virtual void Initialize() throw ( ExceptionObject );
206 
207 protected:
210 
212  virtual ~PCADeformationModelTransform();
213 
215  void PrintSelf(std::ostream &os, Indent indent) const;
216 
217 
220  TScalarType m_meanCoefficient; // coefficient of mean, 0 if id, 1 otherwise
221  unsigned int m_NumberOfFields; // number of PCA fields (mean, eigen-fields)
222 
223  FieldPointerArray m_FieldArray;
224  FieldPointer m_SingleField; // combined field, prepared when requested
225 
227  FieldInterpolatorPointerArray m_Interpolators;
228 
229 
230 private:
231  PCADeformationModelTransform(const Self & other); //purposely not implemented
232  const Self & operator=( const Self & ); //purposely not implemented
233 
234 }; //class PCADeformationModelTransform
235 
236 } // namespace itk
237 
238 
239 #ifndef ITK_MANUAL_INSTANTIATION
240 #include "itkPCADeformationModelTransform.txx"
241 #endif
242 
243 #endif /* __itkPCADeformationModelTransform_h */
FieldType::Pointer FieldPointer
Definition: itkPCADeformationModelTransform.h:86
Transform< TScalarType, NDimensions, NDimensions > Superclass
Definition: itkPCADeformationModelTransform.h:76
FieldType::SizeType FieldSizeType
Definition: itkPCADeformationModelTransform.h:100
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
FieldInterpolatorType::Pointer FieldInterpolatorPointer
Definition: itkPCADeformationModelTransform.h:104
std::vector< FieldConstPointer > FieldConstPointerArray
Definition: itkPCADeformationModelTransform.h:91
Superclass::ScalarType ScalarType
Definition: itkPCADeformationModelTransform.h:143
FieldType::PixelType DisplacementType
Definition: itkPCADeformationModelTransform.h:83
Definition: niftkMeshSmoother.cxx:19
void SetFieldArray(unsigned int i, FieldType *field)
Definition: itkPCADeformationModelTransform.h:122
vnl_vector_fixed< TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType
Definition: itkPCADeformationModelTransform.h:161
Definition: niftkITKAffineResampleImage.cxx:74
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
Superclass::JacobianType JacobianType
Definition: itkPCADeformationModelTransform.h:149
#define niftkitkDebugMacro(x)
Definition: itkUCLMacro.h:29
FieldType * GetFieldArray(unsigned int i)
Definition: itkPCADeformationModelTransform.h:130
Vector< TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVectorType
Definition: itkPCADeformationModelTransform.h:152
vnl_vector_fixed< TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType
Definition: itkPCADeformationModelTransform.h:160
std::vector< FieldConstIterator > FieldIteratorArray
Definition: itkPCADeformationModelTransform.h:94
VectorLinearInterpolateNearestNeighborExtrapolateImageFunction< FieldType, TScalarType > FieldInterpolatorType
Definition: itkPCADeformationModelTransform.h:103
void SetIdentity(void)
Definition: itkPCADeformationModelTransform.h:190
std::vector< FieldInterpolatorPointer > FieldInterpolatorPointerArray
Definition: itkPCADeformationModelTransform.h:105
CovariantVector< TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType
Definition: itkPCADeformationModelTransform.h:156
itk::Vector< TScalarType, NDimensions > VectorPixelType
Definition: itkPCADeformationModelTransform.h:81
itk::ContinuousIndex< TScalarType, NDimensions > ContinuousIndexType
Definition: itkPCADeformationModelTransform.h:96
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
SmartPointer< Self > Pointer
Definition: itkPCADeformationModelTransform.h:77
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
FieldType::ConstPointer FieldConstPointer
Definition: itkPCADeformationModelTransform.h:87
ImageRegionIterator< FieldType > FieldIterator
Definition: itkPCADeformationModelTransform.h:88
std::vector< FieldPointer > FieldPointerArray
Definition: itkPCADeformationModelTransform.h:93
itk::Image< VectorPixelType, NDimensions > FieldType
Definition: itkPCADeformationModelTransform.h:82
SmartPointer< const Self > ConstPointer
Definition: itkPCADeformationModelTransform.h:78
Point< TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputPointType
Definition: itkPCADeformationModelTransform.h:164
ImageRegionConstIterator< FieldType > FieldConstIterator
Definition: itkPCADeformationModelTransform.h:89
Vector< TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVectorType
Definition: itkPCADeformationModelTransform.h:153
Superclass::ParametersType ParametersType
Definition: itkPCADeformationModelTransform.h:146
FieldType::IndexType FieldIndexType
Definition: itkPCADeformationModelTransform.h:98
Point< TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputPointType
Definition: itkPCADeformationModelTransform.h:165
PCA deformation model transformation.
Definition: itkPCADeformationModelTransform.h:71
virtual bool IsLinear() const
Definition: itkPCADeformationModelTransform.h:201
itk::Array2D< double > JacobianType
Definition: EulerAffine2DJacobianTest.cxx:28
CovariantVector< TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType
Definition: itkPCADeformationModelTransform.h:157
FieldType::RegionType FieldRegionType
Definition: itkPCADeformationModelTransform.h:99
PCADeformationModelTransform Self
Definition: itkPCADeformationModelTransform.h:75