RTK  2.6.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  * https://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 {
206 template <typename VolumeSeriesType, typename ProjectionStackType>
208  : public rtk::IterativeConeBeamReconstructionFilter<VolumeSeriesType, ProjectionStackType>
209 {
210 public:
211  ITK_DISALLOW_COPY_AND_MOVE(FourDROOSTERConeBeamReconstructionFilter);
212 
217  using VolumeType = ProjectionStackType;
219  itk::CovariantVector<typename VolumeSeriesType::ValueType, VolumeSeriesType::ImageDimension - 1>;
222 
224  using CPUVolumeSeriesType =
226 #ifdef RTK_USE_CUDA
227  typedef
228  typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
230  itk::CudaImage<CovariantVectorForSpatialGradient, VolumeSeriesType::ImageDimension>>::type
232  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
234  itk::CudaImage<CovariantVectorForTemporalGradient,
235  VolumeSeriesType::ImageDimension>>::type TemporalGradientImageType;
236  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
238  itk::CudaImage<DVFVectorType, VolumeSeriesType::ImageDimension>>::type
240  typedef
241  typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
242  itk::Image<DVFVectorType, VolumeSeriesType::ImageDimension - 1>,
243  itk::CudaImage<DVFVectorType, VolumeSeriesType::ImageDimension - 1>>::type DVFImageType;
244  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
246  CudaAverageOutOfROIImageFilter>::type AverageOutOfROIFilterType;
247  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
249  CudaLastDimensionTVDenoisingImageFilter>::type TemporalTVDenoisingFilterType;
250 #else
254  using DVFImageType = itk::Image<DVFVectorType, VolumeSeriesType::ImageDimension - 1>;
258 #endif
259 
261  itkNewMacro(Self);
262 
264  itkOverrideGetNameOfClassMacro(FourDROOSTERConeBeamReconstructionFilter);
265 
267  void
268  SetInputVolumeSeries(const VolumeSeriesType * VolumeSeries);
269  typename VolumeSeriesType::ConstPointer
270  GetInputVolumeSeries();
272 
274  void
275  SetInputProjectionStack(const ProjectionStackType * Projection);
276  typename ProjectionStackType::Pointer
277  GetInputProjectionStack();
279 
281  void
282  SetMotionMask(const VolumeType * mask);
283  typename VolumeType::Pointer
284  GetMotionMask();
286 
288  void
289  SetDisplacementField(const DVFSequenceImageType * DVFs);
290  void
291  SetInverseDisplacementField(const DVFSequenceImageType * DVFs);
293  GetDisplacementField();
295  GetInverseDisplacementField();
297 
298  using FourDCGFilterType =
304  using WarpSequenceFilterType =
309  using AddFilterType = itk::AddImageFilter<VolumeSeriesType, VolumeSeriesType>;
311  using TNVDenoisingFilterType =
313 
314  using ForwardProjectionType = typename Superclass::ForwardProjectionType;
315  using BackProjectionType = typename Superclass::BackProjectionType;
316 
318  virtual void
319  SetWeights(const itk::Array2D<float> _arg);
320 
322  itkSetMacro(DisableDisplacedDetectorFilter, bool);
323  itkGetMacro(DisableDisplacedDetectorFilter, bool);
325 
326  // Regularization steps to perform
327  itkSetMacro(PerformPositivity, bool);
328  itkGetMacro(PerformPositivity, bool);
329  itkSetMacro(PerformMotionMask, bool);
330  itkGetMacro(PerformMotionMask, bool);
331  itkSetMacro(PerformTVSpatialDenoising, bool);
332  itkGetMacro(PerformTVSpatialDenoising, bool);
333  itkSetMacro(PerformWaveletsSpatialDenoising, bool);
334  itkGetMacro(PerformWaveletsSpatialDenoising, bool);
335  itkSetMacro(PerformWarping, bool);
336  itkGetMacro(PerformWarping, bool);
337  itkSetMacro(PerformTVTemporalDenoising, bool);
338  itkGetMacro(PerformTVTemporalDenoising, bool);
339  itkSetMacro(PerformL0TemporalDenoising, bool);
340  itkGetMacro(PerformL0TemporalDenoising, bool);
341  itkSetMacro(PerformTNVDenoising, bool);
342  itkGetMacro(PerformTNVDenoising, bool);
343  itkSetMacro(ComputeInverseWarpingByConjugateGradient, bool);
344  itkGetMacro(ComputeInverseWarpingByConjugateGradient, bool);
345  itkSetMacro(UseNearestNeighborInterpolationInWarping, bool);
346  itkGetMacro(UseNearestNeighborInterpolationInWarping, bool);
347  itkGetMacro(CudaConjugateGradient, bool);
348  itkSetMacro(CudaConjugateGradient, bool);
349 
351  itkSetMacro(UseCudaCyclicDeformation, bool);
352  itkGetMacro(UseCudaCyclicDeformation, bool);
354 
355  // Regularization parameters
356  itkSetMacro(GammaTVSpace, float);
357  itkGetMacro(GammaTVSpace, float);
358  itkSetMacro(GammaTVTime, float);
359  itkGetMacro(GammaTVTime, float);
360  itkSetMacro(GammaTNV, float);
361  itkGetMacro(GammaTNV, float);
362  itkSetMacro(LambdaL0Time, float);
363  itkGetMacro(LambdaL0Time, float);
364  itkSetMacro(SoftThresholdWavelets, float);
365  itkGetMacro(SoftThresholdWavelets, float);
366  itkSetMacro(PhaseShift, float);
367  itkGetMacro(PhaseShift, float);
368 
370  itkGetMacro(NumberOfLevels, unsigned int);
371  itkSetMacro(NumberOfLevels, unsigned int);
373 
375  itkGetMacro(Order, unsigned int);
376  itkSetMacro(Order, unsigned int);
378 
379  // Iterations
380  itkSetMacro(MainLoop_iterations, int);
381  itkGetMacro(MainLoop_iterations, int);
382  itkSetMacro(CG_iterations, int);
383  itkGetMacro(CG_iterations, int);
384  itkSetMacro(TV_iterations, int);
385  itkGetMacro(TV_iterations, int);
386  itkSetMacro(L0_iterations, int);
387  itkGetMacro(L0_iterations, int);
388 
389  // Geometry
390  itkSetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry);
391  itkGetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry);
392 
394  virtual void
395  SetSignal(const std::vector<double> signal);
396 
397 protected:
399  ~FourDROOSTERConeBeamReconstructionFilter() override = default;
400 
402  void
403  VerifyPreconditions() const override;
404 
406  void
407  GenerateData() override;
408 
409  void
410  GenerateOutputInformation() override;
411 
412  void
413  GenerateInputRequestedRegion() override;
414 
415  // Inputs are not supposed to occupy the same physical space,
416  // so there is nothing to verify
417  void
418  VerifyInputInformation() const override
419  {}
420 
433  typename AddFilterType::Pointer m_AddFilter;
436 
437  // Booleans :
438  // should warping be performed ?
439  // should conjugate gradient be performed on GPU ?
440  // should wavelets replace TV in spatial denoising ?
450  bool m_UseNearestNeighborInterpolationInWarping; // Default is false, linear interpolation is used instead
454 
455  // Regularization parameters
458  float m_GammaTNV;
462  bool m_DimensionsProcessedForTVSpace[VolumeSeriesType::ImageDimension];
463  bool m_DimensionsProcessedForTVTime[VolumeSeriesType::ImageDimension];
464 
466 
468  unsigned int m_Order;
469  unsigned int m_NumberOfLevels;
470 
471  // Iterations
476 
477  // Geometry
479 
480  // Signal
481  std::vector<double> m_Signal;
482 };
483 } // namespace rtk
484 
485 
486 #ifndef ITK_MANUAL_INSTANTIATION
487 # include "rtkFourDROOSTERConeBeamReconstructionFilter.hxx"
488 #endif
489 
490 #endif
rtk::ThreeDCircularProjectionGeometry::ConstPointer m_Geometry
Denoises along the last dimension, reducing the L0 norm of the gradient.
typename itk::Image< typename VolumeSeriesType::PixelType, VolumeSeriesType::ImageDimension > CPUVolumeSeriesType
Applies an N-D + time Motion Vector Field to an N-D + time sequence of images.
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...
Implements 4D RecOnstructiOn using Spatial and TEmporal Regularization (short 4D ROOSTER) ...
Projection geometry for a source and a 2-D flat panel.
itk::AddImageFilter< VolumeSeriesType, VolumeSeriesType > AddFilterType
#define itkSetMacro(name, type)
Applies 3D Daubechies wavelets denoising to a 3D + time sequence of images.
SpatialWaveletsDenoisingFilterType::Pointer m_WaveletsDenoisingSpace
Mother class for cone beam reconstruction filters which need runtime selection of their forward and b...
itk::ImageToImageFilter< VolumeSeriesType, VolumeSeriesType >::Pointer m_DownstreamFilter
Implements part of the 4D reconstruction by conjugate gradient.
Averages along the last dimension if the pixel is outside ROI.