RTK  2.0.0
Reconstruction Toolkit
rtkFourDROOSTERConeBeamReconstructionFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef rtkFourDROOSTERConeBeamReconstructionFilter_h
19 #define rtkFourDROOSTERConeBeamReconstructionFilter_h
20 
23 #ifdef RTK_USE_CUDA
26 #else
29 #endif
35 
37 #include <itkSubtractImageFilter.h>
38 #include <itkAddImageFilter.h>
39 
40 #include <itkResampleImageFilter.h>
42 #include <itkIdentityTransform.h>
43 
44 
45 namespace rtk
46 {
195 template< typename VolumeSeriesType, typename ProjectionStackType>
197 {
198 public:
203  typedef ProjectionStackType VolumeType;
204  typedef itk::CovariantVector< typename VolumeSeriesType::ValueType, VolumeSeriesType::ImageDimension - 1> CovariantVectorForSpatialGradient;
206  typedef CovariantVectorForSpatialGradient DVFVectorType;
207 
209  typedef typename itk::Image< typename VolumeSeriesType::PixelType,
210  VolumeSeriesType::ImageDimension> CPUVolumeSeriesType;
211 #ifdef RTK_USE_CUDA
212  typedef typename std::conditional< std::is_same< VolumeSeriesType, CPUVolumeSeriesType >::value,
214  itk::CudaImage<CovariantVectorForSpatialGradient, VolumeSeriesType::ImageDimension> >::type SpatialGradientImageType;
215  typedef typename std::conditional< std::is_same< VolumeSeriesType, CPUVolumeSeriesType >::value,
217  itk::CudaImage<CovariantVectorForTemporalGradient, VolumeSeriesType::ImageDimension> >::type TemporalGradientImageType;
218  typedef typename std::conditional< std::is_same< VolumeSeriesType, CPUVolumeSeriesType >::value,
220  itk::CudaImage<DVFVectorType, VolumeSeriesType::ImageDimension> >::type DVFSequenceImageType;
221  typedef typename std::conditional< std::is_same< VolumeSeriesType, CPUVolumeSeriesType >::value,
222  itk::Image<DVFVectorType, VolumeSeriesType::ImageDimension - 1>,
223  itk::CudaImage<DVFVectorType, VolumeSeriesType::ImageDimension - 1> >::type DVFImageType;
224  typedef typename std::conditional< std::is_same< VolumeSeriesType, CPUVolumeSeriesType >::value,
226  CudaAverageOutOfROIImageFilter >::type AverageOutOfROIFilterType;
227  typedef typename std::conditional< std::is_same< VolumeSeriesType, CPUVolumeSeriesType >::value,
229  CudaLastDimensionTVDenoisingImageFilter >::type TemporalTVDenoisingFilterType;
230 #else
231  typedef itk::Image<CovariantVectorForSpatialGradient, VolumeSeriesType::ImageDimension> SpatialGradientImageType;
232  typedef itk::Image<CovariantVectorForTemporalGradient, VolumeSeriesType::ImageDimension> TemporalGradientImageType;
233  typedef itk::Image<DVFVectorType, VolumeSeriesType::ImageDimension> DVFSequenceImageType;
234  typedef itk::Image<DVFVectorType, VolumeSeriesType::ImageDimension - 1> DVFImageType;
235  typedef AverageOutOfROIImageFilter <VolumeSeriesType, VolumeType> AverageOutOfROIFilterType;
236  typedef TotalVariationDenoisingBPDQImageFilter<VolumeSeriesType, TemporalGradientImageType> TemporalTVDenoisingFilterType;
237 #endif
238 
240  itkNewMacro(Self)
241 
242 
244 
246  void SetInputVolumeSeries(const VolumeSeriesType* VolumeSeries);
247  typename VolumeSeriesType::ConstPointer GetInputVolumeSeries();
249 
251  void SetInputProjectionStack(const ProjectionStackType* Projection);
252  typename ProjectionStackType::Pointer GetInputProjectionStack();
254 
256  void SetMotionMask(const VolumeType* mask);
257  typename VolumeType::Pointer GetMotionMask();
259 
261  void SetDisplacementField(const DVFSequenceImageType* DVFs);
262  void SetInverseDisplacementField(const DVFSequenceImageType* DVFs);
263  typename DVFSequenceImageType::Pointer GetDisplacementField();
264  typename DVFSequenceImageType::Pointer GetInverseDisplacementField();
266 
267  typedef rtk::FourDConjugateGradientConeBeamReconstructionFilter<VolumeSeriesType, ProjectionStackType> FourDCGFilterType;
268  typedef itk::ThresholdImageFilter<VolumeSeriesType> ThresholdFilterType;
269  typedef itk::ResampleImageFilter<VolumeType, VolumeType> ResampleFilterType;
272  typedef rtk::WarpSequenceImageFilter<VolumeSeriesType, DVFSequenceImageType, VolumeType, DVFImageType> WarpSequenceFilterType;
273  typedef rtk::UnwarpSequenceImageFilter<VolumeSeriesType, DVFSequenceImageType, VolumeType, DVFImageType> UnwarpSequenceFilterType;
274  typedef itk::SubtractImageFilter<VolumeSeriesType, VolumeSeriesType> SubtractFilterType;
275  typedef itk::AddImageFilter<VolumeSeriesType, VolumeSeriesType> AddFilterType;
277  typedef rtk::TotalNuclearVariationDenoisingBPDQImageFilter<VolumeSeriesType, SpatialGradientImageType> TNVDenoisingFilterType;
278 
279  typedef typename Superclass::ForwardProjectionType ForwardProjectionType;
280  typedef typename Superclass::BackProjectionType BackProjectionType;
281 
283  void SetForwardProjectionFilter(ForwardProjectionType fwtype) ITK_OVERRIDE;
284 
286  void SetBackProjectionFilter(BackProjectionType bptype) ITK_OVERRIDE;
287 
289  virtual void SetWeights(const itk::Array2D<float> _arg);
290 
292  itkSetMacro(DisableDisplacedDetectorFilter, bool)
293  itkGetMacro(DisableDisplacedDetectorFilter, bool)
294 
295  // Regularization steps to perform
296  itkSetMacro(PerformPositivity, bool)
297  itkGetMacro(PerformPositivity, bool)
298  itkSetMacro(PerformMotionMask, bool)
299  itkGetMacro(PerformMotionMask, bool)
300  itkSetMacro(PerformTVSpatialDenoising, bool)
301  itkGetMacro(PerformTVSpatialDenoising, bool)
302  itkSetMacro(PerformWaveletsSpatialDenoising, bool)
303  itkGetMacro(PerformWaveletsSpatialDenoising, bool)
304  itkSetMacro(PerformWarping, bool)
305  itkGetMacro(PerformWarping, bool)
306  itkSetMacro(PerformTVTemporalDenoising, bool)
307  itkGetMacro(PerformTVTemporalDenoising, bool)
308  itkSetMacro(PerformL0TemporalDenoising, bool)
309  itkGetMacro(PerformL0TemporalDenoising, bool)
310  itkSetMacro(PerformTNVDenoising, bool)
311  itkGetMacro(PerformTNVDenoising, bool)
312  itkSetMacro(ComputeInverseWarpingByConjugateGradient, bool)
313  itkGetMacro(ComputeInverseWarpingByConjugateGradient, bool)
314  itkSetMacro(UseNearestNeighborInterpolationInWarping, bool)
315  itkGetMacro(UseNearestNeighborInterpolationInWarping, bool)
316  itkGetMacro(CudaConjugateGradient, bool)
317  itkSetMacro(CudaConjugateGradient, bool)
318 
320  itkSetMacro(UseCudaCyclicDeformation, bool)
321  itkGetMacro(UseCudaCyclicDeformation, bool)
322 
323  // Regularization parameters
324  itkSetMacro(GammaTVSpace, float)
325  itkGetMacro(GammaTVSpace, float)
326  itkSetMacro(GammaTVTime, float)
327  itkGetMacro(GammaTVTime, float)
328  itkSetMacro(GammaTNV, float)
329  itkGetMacro(GammaTNV, float)
330  itkSetMacro(LambdaL0Time, float)
331  itkGetMacro(LambdaL0Time, float)
332  itkSetMacro(SoftThresholdWavelets, float)
333  itkGetMacro(SoftThresholdWavelets, float)
334  itkSetMacro(PhaseShift, float)
335  itkGetMacro(PhaseShift, float)
336 
338  itkGetMacro(NumberOfLevels, unsigned int)
339  itkSetMacro(NumberOfLevels, unsigned int)
340 
342  itkGetMacro(Order, unsigned int)
343  itkSetMacro(Order, unsigned int)
344 
345  // Iterations
346  itkSetMacro(MainLoop_iterations, int)
347  itkGetMacro(MainLoop_iterations, int)
348  itkSetMacro(CG_iterations, int)
349  itkGetMacro(CG_iterations, int)
350  itkSetMacro(TV_iterations, int)
351  itkGetMacro(TV_iterations, int)
352  itkSetMacro(L0_iterations, int)
353  itkGetMacro(L0_iterations, int)
354 
355  // Geometry
356  itkSetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry)
357  itkGetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry)
358 
360  virtual void SetSignal(const std::vector<double> signal);
361 
362 protected:
363  FourDROOSTERConeBeamReconstructionFilter();
364  virtual ~FourDROOSTERConeBeamReconstructionFilter() ITK_OVERRIDE {}
365 
367  void GenerateData() ITK_OVERRIDE;
368 
369  void GenerateOutputInformation() ITK_OVERRIDE;
370 
371  void GenerateInputRequestedRegion() ITK_OVERRIDE;
372 
373  // Inputs are not supposed to occupy the same physical space,
374  // so there is nothing to verify
375 #if ITK_VERSION_MAJOR<5
376  void VerifyInputInformation() ITK_OVERRIDE {}
377 #else
378  void VerifyInputInformation() const ITK_OVERRIDE {}
379 #endif
380 
396 
397  // Booleans :
398  // should warping be performed ?
399  // should conjugate gradient be performed on GPU ?
400  // should wavelets replace TV in spatial denoising ?
410  bool m_UseNearestNeighborInterpolationInWarping; //Default is false, linear interpolation is used instead
414 
415  // Regularization parameters
418  float m_GammaTNV;
422  bool m_DimensionsProcessedForTVSpace[VolumeSeriesType::ImageDimension];
423  bool m_DimensionsProcessedForTVTime[VolumeSeriesType::ImageDimension];
424 
426 
428  unsigned int m_Order;
429  unsigned int m_NumberOfLevels;
430 
431  // Iterations
436 
437  // Geometry
439 
440  // Signal
441  std::vector<double> m_Signal;
442 
443 private:
444  FourDROOSTERConeBeamReconstructionFilter(const Self &); //purposely not implemented
445  void operator=(const Self &); //purposely not implemented
446 
447 };
448 } //namespace ITK
449 
450 
451 #ifndef ITK_MANUAL_INSTANTIATION
452 #include "rtkFourDROOSTERConeBeamReconstructionFilter.hxx"
453 #endif
454 
455 #endif
rtk::ThreeDCircularProjectionGeometry::ConstPointer m_Geometry
Denoises along the last dimension, reducing the L0 norm of the gradient.
VolumeSeriesType::ConstPointer GetInputVolumeSeries()
rtk::IterativeConeBeamReconstructionFilter< VolumeSeriesType, ProjectionStackType > Superclass
void SetInputVolumeSeries(const VolumeSeriesType *VolumeSeries)
Applies an N-D + time Motion Vector Field to an N-D + time sequence of images.
AverageOutOfROIImageFilter< VolumeSeriesType, VolumeType > AverageOutOfROIFilterType
STL namespace.
Finds the image sequence that, once warped, equals the input image sequence.
Applies 3D total variation denoising to a 3D + time sequence of images.
Applies a total variation denoising, only alm_SingularValueThresholdFilterong the dimensions specifie...
itk::Image< DVFVectorType, VolumeSeriesType::ImageDimension > DVFSequenceImageType
ProjectionStackType::Pointer GetInputProjectionStack()
Implements 4D RecOnstructiOn using Spatial and TEmporal Regularization (short 4D ROOSTER) ...
TotalVariationDenoisingBPDQImageFilter< VolumeSeriesType, TemporalGradientImageType > TemporalTVDenoisingFilterType
Projection geometry for a source and a 2-D flat panel.
itk::CovariantVector< typename VolumeSeriesType::ValueType, VolumeSeriesType::ImageDimension-1 > CovariantVectorForSpatialGradient
itk::Image< DVFVectorType, VolumeSeriesType::ImageDimension-1 > DVFImageType
Applies 3D Daubechies wavelets denoising to a 3D + time sequence of images.
SpatialWaveletsDenoisingFilterType::Pointer m_WaveletsDenoisingSpace
void SetDisplacementField(const DVFSequenceImageType *DVFs)
void SetInverseDisplacementField(const DVFSequenceImageType *DVFs)
void SetForwardProjectionFilter(ForwardProjectionType fwtype) override
itk::Image< typename VolumeSeriesType::PixelType, VolumeSeriesType::ImageDimension > CPUVolumeSeriesType
virtual void SetSignal(const std::vector< double > signal)
Mother class for cone beam reconstruction filters which need runtime selection of their forward and b...
void SetBackProjectionFilter(BackProjectionType bptype) override
itk::ImageToImageFilter< VolumeSeriesType, VolumeSeriesType >::Pointer m_DownstreamFilter
Implements part of the 4D reconstruction by conjugate gradient.
itk::Image< CovariantVectorForSpatialGradient, VolumeSeriesType::ImageDimension > SpatialGradientImageType
itk::Image< CovariantVectorForTemporalGradient, VolumeSeriesType::ImageDimension > TemporalGradientImageType
void SetInputProjectionStack(const ProjectionStackType *Projection)
DVFSequenceImageType::Pointer GetDisplacementField()
#define itkSetMacro(name, type)
Averages along the last dimension if the pixel is outside ROI.
itk::CovariantVector< typename VolumeSeriesType::ValueType, 1 > CovariantVectorForTemporalGradient
virtual void SetWeights(const itk::Array2D< float > _arg)
DVFSequenceImageType::Pointer GetInverseDisplacementField()
void SetMotionMask(const VolumeType *mask)