RTK  2.5.0
Reconstruction Toolkit
rtkMechlemOneStepSpectralReconstructionFilter.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 
19 #ifndef rtkMechlemOneStepSpectralReconstructionFilter_h
20 #define rtkMechlemOneStepSpectralReconstructionFilter_h
21 
26 #include "rtkConstantImageSource.h"
30 
31 #include <itkExtractImageFilter.h>
32 #include <itkAddImageFilter.h>
33 #include <itkMultiplyImageFilter.h>
34 
35 #ifdef RTK_USE_CUDA
37 #endif
38 
39 namespace rtk
40 {
145 template <typename TOutputImage, typename TPhotonCounts, typename TSpectrum>
147  : public rtk::IterativeConeBeamReconstructionFilter<TOutputImage, TOutputImage>
148 {
149 public:
150  ITK_DISALLOW_COPY_AND_MOVE(MechlemOneStepSpectralReconstructionFilter);
151 
156 
158  itkNewMacro(Self);
159 
161 #ifdef itkOverrideGetNameOfClassMacro
162  itkOverrideGetNameOfClassMacro(MechlemOneStepSpectralReconstructionFilter);
163 #else
165 #endif
166 
167 
169  static constexpr unsigned int nBins = TPhotonCounts::PixelType::Dimension;
170  static constexpr unsigned int nMaterials = TOutputImage::PixelType::Dimension;
171  using dataType = typename TOutputImage::PixelType::ValueType;
172 
175 #ifdef RTK_USE_CUDA
176  typedef
177  typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
178  itk::Image<itk::Vector<dataType, nMaterials * nMaterials>, TOutputImage::ImageDimension>,
179  itk::CudaImage<itk::Vector<dataType, nMaterials * nMaterials>,
180  TOutputImage::ImageDimension>>::type HessiansImageType;
181  typedef
182  typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
184  itk::CudaImage<dataType, TOutputImage::ImageDimension>>::type SingleComponentImageType;
185 #else
186  using HessiansImageType =
187  typename itk::Image<itk::Vector<dataType, nMaterials * nMaterials>, TOutputImage::ImageDimension>;
189 #endif
190 
191 #if !defined(ITK_WRAPPING_PARSER)
192 # ifdef RTK_USE_CUDA
193  typedef typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
195  CudaWeidingerForwardModelImageFilter<TOutputImage, TPhotonCounts, TSpectrum>>::type
197  typedef
198  typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
200  CudaForwardProjectionImageFilter<SingleComponentImageType, SingleComponentImageType>>::
202  typedef typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
204  CudaBackProjectionImageFilter<HessiansImageType>>::type
206 # else
211 # endif
212  using GradientsImageType = TOutputImage;
213 #endif
214 
215  using ForwardProjectionType = typename Superclass::ForwardProjectionType;
216  using BackProjectionType = typename Superclass::BackProjectionType;
217 
218 #if !defined(ITK_WRAPPING_PARSER)
219 
221  using AddFilterType = itk::AddImageFilter<GradientsImageType>;
237 #endif
238 
240  itkSetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry);
241 
242  itkSetMacro(NumberOfIterations, int);
243  itkGetMacro(NumberOfIterations, int);
244 
246  itkSetMacro(NumberOfSubsets, int);
247  itkGetMacro(NumberOfSubsets, int);
249 
253  itkSetMacro(ResetNesterovEvery, int);
254  itkGetMacro(ResetNesterovEvery, int);
256 
258  void
259  SetInputMaterialVolumes(const TOutputImage * materialVolumes);
260  void
261  SetInputPhotonCounts(const TPhotonCounts * photonCounts);
262  void
263  SetInputSpectrum(const TSpectrum * spectrum);
264  void
265  SetSupportMask(const SingleComponentImageType * support);
266  void
267  SetSpatialRegularizationWeights(const SingleComponentImageType * regweights);
268  void
269  SetProjectionWeights(const SingleComponentImageType * weiprojections);
271 
273  itkSetMacro(RegularizationWeights, typename TOutputImage::PixelType);
274  itkGetMacro(RegularizationWeights, typename TOutputImage::PixelType);
276 
278  itkSetMacro(RegularizationRadius, typename TOutputImage::RegionType::SizeType);
279  itkGetMacro(RegularizationRadius, typename TOutputImage::RegionType::SizeType);
281 
284  using BinnedDetectorResponseType = vnl_matrix<dataType>;
285  using MaterialAttenuationsType = vnl_matrix<dataType>;
286  virtual void
287  SetBinnedDetectorResponse(const BinnedDetectorResponseType & detResp);
288  virtual void
289  SetMaterialAttenuations(const MaterialAttenuationsType & matAtt);
291 
292 protected:
294  ~MechlemOneStepSpectralReconstructionFilter() override = default;
295 
297  void
298  VerifyPreconditions() ITKv5_CONST override;
299 
301  void
302  GenerateData() override;
303 
304 #if !defined(ITK_WRAPPING_PARSER)
305 
307  typename AddFilterType::Pointer m_AddGradients;
326 #endif
327 
331  void
332  VerifyInputInformation() const override
333  {}
334 
337  void
338  GenerateInputRequestedRegion() override;
339  void
340  GenerateOutputInformation() override;
342 
344  typename TOutputImage::ConstPointer
345  GetInputMaterialVolumes();
346  typename TPhotonCounts::ConstPointer
347  GetInputPhotonCounts();
348  typename TSpectrum::ConstPointer
349  GetInputSpectrum();
350  typename SingleComponentImageType::ConstPointer
351  GetSupportMask();
352  typename SingleComponentImageType::ConstPointer
353  GetSpatialRegularizationWeights();
354  typename SingleComponentImageType::ConstPointer
355  GetProjectionWeights();
357 
358 #if !defined(ITK_WRAPPING_PARSER)
359 
361  typename SingleComponentForwardProjectionFilterType::Pointer
362  InstantiateSingleComponentForwardProjectionFilter(int fwtype);
363  typename HessiansBackProjectionFilterType::Pointer
364  InstantiateHessiansBackProjectionFilter(int bptype);
365 #endif
366 
367 
369 
376 
377  typename TOutputImage::PixelType m_RegularizationWeights;
378  typename TOutputImage::RegionType::SizeType m_RegularizationRadius;
379 };
380 } // namespace rtk
381 
382 
383 #ifndef ITK_MANUAL_INSTANTIATION
384 # include "rtkMechlemOneStepSpectralReconstructionFilter.hxx"
385 #endif
386 
387 #endif
typename itk::Image< dataType, TOutputImage::ImageDimension > SingleComponentImageType
Base class for forward projection, i.e. accumulation along x-ray lines.
Applies Nesterov&#39;s momentum technique.
Generate an n-dimensional image with constant pixel values.
typename itk::Image< itk::Vector< dataType, nMaterials *nMaterials >, TOutputImage::ImageDimension > HessiansImageType
Projection geometry for a source and a 2-D flat panel.
#define itkSetMacro(name, type)
Computes update from gradient and Hessian in Newton&#39;s method.
Performs intermediate computations in Weidinger2016.
typename itk::Image< typename TOutputImage::PixelType, TOutputImage::ImageDimension > CPUOutputImageType
For each vector-valued pixel, adds a vector to the diagonal of a matrix.
For one-step inversion of spectral CT data by the method Mechlem2017, computes regularization term&#39;s ...
Mother class for cone beam reconstruction filters which need runtime selection of their forward and b...
Implements the one-step spectral CT inversion method described by Mechlem et al.
SingleComponentForwardProjectionFilterType::Pointer m_SingleComponentForwardProjectionFilter