RTK  2.6.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"
31 
32 #include <itkExtractImageFilter.h>
33 #include <itkAddImageFilter.h>
34 #include <itkMultiplyImageFilter.h>
35 
36 #ifdef RTK_USE_CUDA
38 #endif
39 
40 namespace rtk
41 {
152 template <typename TOutputImage, typename TPhotonCounts, typename TSpectrum>
154  : public rtk::IterativeConeBeamReconstructionFilter<TOutputImage, TOutputImage>
155 {
156 public:
157  ITK_DISALLOW_COPY_AND_MOVE(MechlemOneStepSpectralReconstructionFilter);
158 
163 
165  itkNewMacro(Self);
166 
168  itkOverrideGetNameOfClassMacro(MechlemOneStepSpectralReconstructionFilter);
169 
171  static constexpr unsigned int nBins = TPhotonCounts::PixelType::Dimension;
172  static constexpr unsigned int nMaterials = TOutputImage::PixelType::Dimension;
173  using dataType = typename TOutputImage::PixelType::ValueType;
174 
177 #ifdef RTK_USE_CUDA
178  typedef
179  typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
180  itk::Image<itk::Vector<dataType, nMaterials * nMaterials>, TOutputImage::ImageDimension>,
181  itk::CudaImage<itk::Vector<dataType, nMaterials * nMaterials>,
182  TOutputImage::ImageDimension>>::type HessiansImageType;
183  typedef
184  typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
186  itk::CudaImage<dataType, TOutputImage::ImageDimension>>::type SingleComponentImageType;
187 #else
188  using HessiansImageType =
189  typename itk::Image<itk::Vector<dataType, nMaterials * nMaterials>, TOutputImage::ImageDimension>;
191 #endif
192 
193 #if !defined(ITK_WRAPPING_PARSER)
194 # ifdef RTK_USE_CUDA
195  typedef typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
197  CudaWeidingerForwardModelImageFilter<TOutputImage, TPhotonCounts, TSpectrum>>::type
199  typedef
200  typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
202  CudaForwardProjectionImageFilter<SingleComponentImageType, SingleComponentImageType>>::
204  typedef typename std::conditional<std::is_same<TOutputImage, CPUOutputImageType>::value,
206  CudaBackProjectionImageFilter<HessiansImageType>>::type
208 # else
213 # endif
214  using GradientsImageType = TOutputImage;
215 #endif
216 
217  using ForwardProjectionType = typename Superclass::ForwardProjectionType;
218  using BackProjectionType = typename Superclass::BackProjectionType;
219 
220 #if !defined(ITK_WRAPPING_PARSER)
221 
223  using AddFilterType = itk::AddImageFilter<GradientsImageType>;
241 #endif
242 
244  itkSetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry);
245 
246  itkSetMacro(NumberOfIterations, int);
247  itkGetMacro(NumberOfIterations, int);
248 
250  itkSetMacro(NumberOfSubsets, int);
251  itkGetMacro(NumberOfSubsets, int);
253 
257  itkSetMacro(ResetNesterovEvery, int);
258  itkGetMacro(ResetNesterovEvery, int);
260 
262  void
263  SetInputMaterialVolumes(const TOutputImage * materialVolumes);
264  void
265  SetInputPhotonCounts(const TPhotonCounts * photonCounts);
266  void
267  SetInputSpectrum(const TSpectrum * spectrum);
268  void
269  SetSupportMask(const SingleComponentImageType * support);
270  void
271  SetSpatialRegularizationWeights(const SingleComponentImageType * regweights);
272  void
273  SetProjectionWeights(const SingleComponentImageType * weiprojections);
275 
277  itkSetMacro(RegularizationWeights, typename TOutputImage::PixelType);
278  itkGetMacro(RegularizationWeights, typename TOutputImage::PixelType);
280 
282  itkSetMacro(RegularizationRadius, typename TOutputImage::RegionType::SizeType);
283  itkGetMacro(RegularizationRadius, typename TOutputImage::RegionType::SizeType);
285 
288  using BinnedDetectorResponseType = vnl_matrix<dataType>;
289  using MaterialAttenuationsType = vnl_matrix<dataType>;
290  virtual void
291  SetBinnedDetectorResponse(const BinnedDetectorResponseType & detResp);
292  virtual void
293  SetMaterialAttenuations(const MaterialAttenuationsType & matAtt);
295 
296 protected:
298  ~MechlemOneStepSpectralReconstructionFilter() override = default;
299 
301  void
302  VerifyPreconditions() const override;
303 
305  void
306  GenerateData() override;
307 
308 #if !defined(ITK_WRAPPING_PARSER)
309 
311  typename AddFilterType::Pointer m_AddGradients;
332 #endif
333 
337  void
338  VerifyInputInformation() const override
339  {}
340 
343  void
344  GenerateInputRequestedRegion() override;
345  void
346  GenerateOutputInformation() override;
348 
350  typename TOutputImage::ConstPointer
351  GetInputMaterialVolumes();
352  typename TPhotonCounts::ConstPointer
353  GetInputPhotonCounts();
354  typename TSpectrum::ConstPointer
355  GetInputSpectrum();
356  typename SingleComponentImageType::ConstPointer
357  GetSupportMask();
358  typename SingleComponentImageType::ConstPointer
359  GetSpatialRegularizationWeights();
360  typename SingleComponentImageType::ConstPointer
361  GetProjectionWeights();
363 
364 #if !defined(ITK_WRAPPING_PARSER)
365 
367  typename SingleComponentForwardProjectionFilterType::Pointer
368  InstantiateSingleComponentForwardProjectionFilter(int fwtype);
369  typename HessiansBackProjectionFilterType::Pointer
370  InstantiateHessiansBackProjectionFilter(int bptype);
371 #endif
372 
373 
375 
382 
383  typename TOutputImage::PixelType m_RegularizationWeights;
384  typename TOutputImage::RegionType::SizeType m_RegularizationRadius;
385 };
386 } // namespace rtk
387 
388 
389 #ifndef ITK_MANUAL_INSTANTIATION
390 # include "rtkMechlemOneStepSpectralReconstructionFilter.hxx"
391 #endif
392 
393 #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.
ReorderProjectionsFilterProjectionsWeightsType::Pointer m_ReorderProjectionsWeightsFilter
typename itk::Image< itk::Vector< dataType, nMaterials *nMaterials >, TOutputImage::ImageDimension > HessiansImageType
ReorderProjectionsFilterPhotonCountsType::Pointer m_ReorderPhotonCountsFilter
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.
Sorts or shuffle projections and geometry inputs.
SingleComponentForwardProjectionFilterType::Pointer m_SingleComponentForwardProjectionFilter