NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.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 #ifndef itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter_h
16 #define itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter_h
17 
18 #include <itkVector.h>
19 #include <itkImage.h>
20 #include <itkImageToImageFilter.h>
21 #include <itkVectorLinearInterpolateImageFunction.h>
22 #include <itkNearestNeighborInterpolateImageFunction.h>
23 #include <itkPoint.h>
24 #include <itkContinuousIndex.h>
25 
26 namespace itk {
27 
64 template < typename TScalarType, unsigned int NDimensions = 3>
66 public ImageToImageFilter<
67  Image< Vector<TScalarType, NDimensions>, NDimensions + 1>, // Input image is time varying velocity field.
68  Image< Vector<TScalarType, NDimensions>, NDimensions> // Output image is integrated displacement field.
69  >
70 {
71 
72  public:
73 
76  typedef ImageToImageFilter<Image< Vector<TScalarType, NDimensions>, NDimensions + 1>,
79  typedef SmartPointer<Self> Pointer;
80  typedef SmartPointer<const Self> ConstPointer;
81 
83  itkNewMacro(Self);
84 
86  itkTypeMacro(FourthOrderRungeKuttaVelocityFieldIntegrationFilter, ImageToImageFilter);
87 
89  itkStaticConstMacro(Dimension, unsigned int, NDimensions);
90 
92  typedef Vector< TScalarType, NDimensions > TimeVaryingVelocityPixelType;
97  typedef typename TimeVaryingVelocityImageType::PointType TimeVaryingVelocityPointType;
98  typedef typename TimeVaryingVelocityImageType::SpacingType TimeVaryingVelocitySpacingType;
99  typedef typename TimeVaryingVelocityImageType::DirectionType TimeVaryingVelocityDirectionType;
100  typedef TScalarType MaskPixelType;
102  typedef typename MaskImageType::Pointer MaskImagePointer;
104  typedef typename MaskImageType::PointType MaskImagePointType;
105  typedef Vector< TScalarType, NDimensions > DisplacementPixelType;
110  typedef typename DisplacementImageType::PointType DisplacementImagePointType;
111  typedef typename DisplacementImageType::SpacingType DisplacementImageSpacingType;
112  typedef typename DisplacementImageType::DirectionType DisplacementImageDirectionType;
113  typedef VectorLinearInterpolateImageFunction< TimeVaryingVelocityImageType,
115  typedef typename TimeVaryingVelocityFieldInterpolatorType::Pointer TimeVaryingVelocityFieldInterpolatorPointer;
116  typedef Point<TScalarType, NDimensions + 1> TimeVaryingPointType;
119  typedef typename ThicknessImageType::Pointer ThicknessImagePointer;
120  typedef NearestNeighborInterpolateImageFunction<ThicknessImageType, TScalarType> ThicknessImageInterpolatorType;
121  typedef typename ThicknessImageInterpolatorType::Pointer ThicknessImageInterpolatorPointer;
122 
124  itkSetMacro(StartTime, float);
125  itkGetMacro(StartTime, float);
126 
128  itkSetMacro(FinishTime, float);
129  itkGetMacro(FinishTime, float);
130 
132  itkSetMacro(DeltaTime, float);
133  itkGetMacro(DeltaTime, float);
134 
136  itkSetMacro(CalculateThickness, bool);
137  itkGetMacro(CalculateThickness, bool);
138 
140  itkGetMacro(MaxThickness, float);
141 
143  itkGetMacro(MaxDisplacement, float);
144 
146  itkGetMacro(FieldEnergy, float);
147 
149  void SetVoxelsToIntegrateMaskImage(MaskImageType* image) { m_MaskImage = image; }
150 
152  void SetMaxDistanceMaskImage(ThicknessImageType* maxDistance) { m_MaxDistanceMask = maxDistance; }
153 
155  void SetGreyWhiteInterfaceMaskImage(MaskImageType* greyWhiteInterface) { m_GreyWhiteInterface = greyWhiteInterface; }
156 
158  ThicknessImageType* GetCalculatedThicknessImage() { return m_ThicknessImage; }
159 
160  protected:
161 
164  void PrintSelf(std::ostream& os, Indent indent) const;
165 
166  // Called before threaded bit.
167  virtual void BeforeThreadedGenerateData();
168 
169  // The main method to implement in derived classes, note, its threaded.
170  virtual void ThreadedGenerateData(const DisplacementImageRegionType &regionForThread, ThreadIdType threadId);
171 
172  // Called after threaded bit.
173  virtual void AfterThreadedGenerateData();
174 
175  private:
176 
181  void operator=(const Self&);
182 
184  float m_StartTime;
185 
187  float m_FinishTime;
188 
190  float m_DeltaTime;
191 
193  float m_MaxThickness;
194 
196  float m_MaxDisplacement;
197 
199  float m_FieldEnergy;
200 
202  TimeVaryingVelocityFieldInterpolatorPointer m_TimeVaryingVelocityFieldInterpolator;
203 
205  ThicknessImageInterpolatorPointer m_MaxDistanceImageInterpolator;
206 
208  ThicknessImagePointer m_MaxDistanceMask;
209 
211  MaskImagePointer m_MaskImage;
212 
214  MaskImagePointer m_GreyWhiteInterface;
215 
217  bool m_CalculateThickness;
218 
220  ThicknessImagePointer m_ThicknessImage;
221 
223  ThicknessImagePointer m_HitsImage;
224 
226  virtual void GenerateOutputInformation();
227 
229  void IntegrateRegion(const DisplacementImageRegionType &regionForThread, float directionOverride, bool writeToOutput, bool writeToThicknessImage);
230 
232  void IntegratePoint(const float& startTime,
233  const float& endTime,
234  const float& direction,
235  const unsigned int& numberOfTimePoints,
236  const DisplacementImageIndexType& index,
237  const TimeVaryingVelocityImageType* velocityField,
238  const bool& writeToThicknessImage,
239  DisplacementPixelType& displacement);
240 
241 }; // end class
242 
243 } // end namespace
244 
245 #ifndef ITK_MANUAL_INSTANTIATION
246 #include "itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.txx"
247 #endif
248 
249 #endif
MaskImageType::Pointer MaskImagePointer
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:102
void SetGreyWhiteInterfaceMaskImage(MaskImageType *greyWhiteInterface)
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:155
TimeVaryingVelocityImageType::DirectionType TimeVaryingVelocityDirectionType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:99
NearestNeighborInterpolateImageFunction< ThicknessImageType, TScalarType > ThicknessImageInterpolatorType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:120
MaskImageType::PointType MaskImagePointType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:104
TimeVaryingVelocityFieldInterpolatorType::Pointer TimeVaryingVelocityFieldInterpolatorPointer
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:115
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
DisplacementImageType::SpacingType DisplacementImageSpacingType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:111
TimeVaryingVelocityImageType::PointType TimeVaryingVelocityPointType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:97
Vector< TScalarType, NDimensions > DisplacementPixelType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:105
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:4052
SmartPointer< Self > Pointer
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:79
void SetMaxDistanceMaskImage(ThicknessImageType *maxDistance)
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:152
ThicknessImageType::PixelType ThicknessImagePixelType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:118
Definition: niftkITKAffineResampleImage.cxx:74
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
ThicknessImageType::Pointer ThicknessImagePointer
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:119
TimeVaryingVelocityImageType::IndexType TimeVaryingVelocityIndexType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:95
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
DisplacementImageType::PointType DisplacementImagePointType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:110
Point< TScalarType, NDimensions+1 > TimeVaryingPointType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:116
DisplacementImageType::SizeType DisplacementImageSizeType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:109
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
DisplacementImageType::IndexType DisplacementImageIndexType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:108
TimeVaryingVelocityImageType::RegionType TimeVaryingVelocityRegionType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:94
TScalarType MaskPixelType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:100
Image< TimeVaryingVelocityPixelType, NDimensions+1 > TimeVaryingVelocityImageType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:93
FourthOrderRungeKuttaVelocityFieldIntegrationFilter Self
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:75
TimeVaryingVelocityImageType::SpacingType TimeVaryingVelocitySpacingType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:98
void SetVoxelsToIntegrateMaskImage(MaskImageType *image)
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:149
This filter integrates a time varying velocity field, using fourth order Runge-Kutta. This filter is basically a tidied up version of that in ANTS: http://www.picsl.upenn.edu/ANTS/ However, ANTS has the four timepoints back to front. I don't know if this is intentional.
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:65
GLuint index
Definition: glew.h:1798
SmartPointer< const Self > ConstPointer
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:80
ThicknessImageType * GetCalculatedThicknessImage()
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:158
Image< MaskPixelType, NDimensions > MaskImageType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:101
Simultaneous itk::Image and itk::Array (and hence vnl_vector) class.
ThicknessImageInterpolatorType::Pointer ThicknessImageInterpolatorPointer
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:121
const unsigned int Dimension
Definition: niftkBreastDCEandADC.cxx:89
Image< DisplacementPixelType, NDimensions > DisplacementImageType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:106
ImageToImageFilter< Image< Vector< TScalarType, NDimensions >, NDimensions+1 >, Image< Vector< TScalarType, NDimensions >, NDimensions > > Superclass
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:78
VectorLinearInterpolateImageFunction< TimeVaryingVelocityImageType, TScalarType > TimeVaryingVelocityFieldInterpolatorType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:114
~FourthOrderRungeKuttaVelocityFieldIntegrationFilter()
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:163
TimeVaryingVelocityImageType::SizeType TimeVaryingVelocitySizeType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:96
DisplacementImageType::RegionType DisplacementImageRegionType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:107
Image< TScalarType, NDimensions > ThicknessImageType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:117
DisplacementImageType::DirectionType DisplacementImageDirectionType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:112
Vector< TScalarType, NDimensions > TimeVaryingVelocityPixelType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:92
MaskImageType::IndexType MaskImageIndexType
Definition: itkFourthOrderRungeKuttaVelocityFieldIntegrationFilter.h:103