RTK  2.4.1
Reconstruction Toolkit
rtkMotionCompensatedFourDReconstructionConjugateGradientOperator.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 rtkMotionCompensatedFourDReconstructionConjugateGradientOperator_h
19 #define rtkMotionCompensatedFourDReconstructionConjugateGradientOperator_h
20 
24 
25 #ifdef RTK_USE_CUDA
29 #endif
30 
31 namespace rtk
32 {
99 template <typename VolumeSeriesType, typename ProjectionStackType>
101  : public FourDReconstructionConjugateGradientOperator<VolumeSeriesType, ProjectionStackType>
102 {
103 public:
105 
110 
112  using VolumeType = ProjectionStackType;
113  using VectorForDVF = itk::CovariantVector<typename VolumeSeriesType::ValueType, VolumeSeriesType::ImageDimension - 1>;
114 
116  using CPUVolumeSeriesType =
118 #ifdef RTK_USE_CUDA
119  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
121  itk::CudaImage<VectorForDVF, VolumeSeriesType::ImageDimension>>::type
123  typedef
124  typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
125  itk::Image<VectorForDVF, VolumeSeriesType::ImageDimension - 1>,
126  itk::CudaImage<VectorForDVF, VolumeSeriesType::ImageDimension - 1>>::type DVFImageType;
127  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
129  CudaWarpForwardProjectionImageFilter>::type WarpForwardProjectionImageFilterType;
130  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
132  CudaWarpBackProjectionImageFilter>::type WarpBackProjectionImageFilterType;
133 #else
135  using DVFImageType = itk::Image<VectorForDVF, VolumeSeriesType::ImageDimension - 1>;
139 #endif
141 #ifdef RTK_USE_CUDA
142  typedef typename std::conditional<std::is_same<VolumeSeriesType, CPUVolumeSeriesType>::value,
144  CudaCyclicDeformationImageFilter>::type CudaCyclicDeformationImageFilterType;
145 #else
147 #endif
148 
150  itkNewMacro(Self);
151 
155 
157  void
159  {
160  itkExceptionMacro(<< "ForwardProjection cannot be changed");
161  }
162  void
164  {
165  itkExceptionMacro(<< "BackProjection cannot be changed");
166  }
168 
170  void
171  SetDisplacementField(const DVFSequenceImageType * DisplacementField);
172  void
173  SetInverseDisplacementField(const DVFSequenceImageType * InverseDisplacementField);
174  typename DVFSequenceImageType::ConstPointer
175  GetInverseDisplacementField();
176  typename DVFSequenceImageType::ConstPointer
177  GetDisplacementField();
179 
181  void
182  SetSignal(const std::vector<double> signal) override;
183 
185  itkSetMacro(UseCudaCyclicDeformation, bool);
186  itkGetMacro(UseCudaCyclicDeformation, bool);
188 
189 protected:
192 
194  void
195  GenerateOutputInformation() override;
196 
198  void
199  VerifyInputInformation() const override
200  {}
201 
203  void
204  GenerateData() override;
205 
209  std::vector<double> m_Signal;
211 };
212 } // namespace rtk
213 
214 
215 #ifndef ITK_MANUAL_INSTANTIATION
216 # include "rtkMotionCompensatedFourDReconstructionConjugateGradientOperator.hxx"
217 #endif
218 
219 #endif
Return 3D deformation vector field according to input 4D vector field, phase signal and frame number...
typename itk::Image< typename VolumeSeriesType::PixelType, VolumeSeriesType::ImageDimension > CPUVolumeSeriesType
#define itkSetMacro(name, type)
Implements part of the 4D reconstruction by conjugate gradient.