ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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
32
33#include <itkAddImageFilter.h>
37
38#include <itkCastImageFilter.h>
39
40#ifdef RTK_USE_CUDA
42# include <itkCudaImageFromImageFilter.h>
43#endif
44
45namespace rtk
46{
156
157template <typename TOutputImage, typename TMeasuredProjections, typename TIncidentSpectrum>
159 : public rtk::IterativeConeBeamReconstructionFilter<TOutputImage, TOutputImage>
160{
161public:
162 ITK_DISALLOW_COPY_AND_MOVE(MechlemOneStepSpectralReconstructionFilter);
163
168
170 itkNewMacro(Self);
171
173 itkOverrideGetNameOfClassMacro(MechlemOneStepSpectralReconstructionFilter);
174
176 static constexpr unsigned int nBins = TMeasuredProjections::PixelType::Dimension;
177 static constexpr unsigned int nMaterials = TOutputImage::PixelType::Dimension;
178 using dataType = typename TOutputImage::PixelType::ValueType;
179
182
186 typename TOutputImage::template RebindImageType<itk::Vector<dataType, nMaterials * nMaterials>,
187 TOutputImage::ImageDimension>;
189 typename TOutputImage::template RebindImageType<dataType, TOutputImage::ImageDimension>;
190
191#ifndef ITK_FUTURE_LEGACY_REMOVE
192 // Vector incident spectra are flattened with CPU iterators first. When the reconstruction uses CUDA, the transfer to
193 // TIncidentSpectrum must happen after this CPU-only conversion step.
194 using IncidentSpectrumPixelType = typename TIncidentSpectrum::PixelType;
196 using VectorSpectrumImageType = itk::VectorImage<IncidentSpectrumPixelType, TIncidentSpectrum::ImageDimension - 1>;
197 using FlattenVectorSpectrumFilterType =
199 using PermuteSpectrumFilterType = itk::PermuteAxesImageFilter<CPUIncidentSpectrumType>;
200# ifdef RTK_USE_CUDA
201 // The VectorImage overload first converts the spectrum to a scalar CPU image. When the reconstruction uses CUDA, that
202 // CPU image must then be adapted to itk::CudaImage; a plain CastImageFilter would leave the CUDA data manager
203 // uninitialized and CudaWeidingerForwardModelImageFilter would read an invalid GPU buffer.
204 using CastIncidentSpectrumFilterType =
205 std::conditional_t<std::is_same_v<TIncidentSpectrum, CPUIncidentSpectrumType>,
207 itk::CudaImageFromImageFilter<CPUIncidentSpectrumType>>;
208# else
209 using CastIncidentSpectrumFilterType = itk::CastImageFilter<CPUIncidentSpectrumType, TIncidentSpectrum>;
210# endif
211#endif
212
213#if !defined(ITK_WRAPPING_PARSER)
214# ifdef RTK_USE_CUDA
215 using WeidingerForwardModelType = typename std::conditional_t<
216 std::is_same_v<TOutputImage, CPUOutputImageType>,
218 CudaWeidingerForwardModelImageFilter<TOutputImage, TMeasuredProjections, TIncidentSpectrum>>;
220 typename std::conditional_t<std::is_same_v<TOutputImage, CPUOutputImageType>,
222 CudaForwardProjectionImageFilter<SingleComponentImageType, SingleComponentImageType>>;
224 typename std::conditional_t<std::is_same_v<TOutputImage, CPUOutputImageType>,
226 CudaBackProjectionImageFilter<HessiansImageType>>;
227# else
233# endif
234 using GradientsImageType = TOutputImage;
235#endif
236
239
240#if !defined(ITK_WRAPPING_PARSER)
263#endif
264
266 itkSetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry);
267
268 itkSetMacro(NumberOfIterations, int);
269 itkGetMacro(NumberOfIterations, int);
270
272 itkSetMacro(NumberOfSubsets, int);
273 itkGetMacro(NumberOfSubsets, int);
274
278 itkSetClampMacro(ResetNesterovEvery, int, 1, itk::NumericTraits<int>::max());
279 itkGetMacro(ResetNesterovEvery, int);
280
282 void
283 SetInputMaterialVolumes(const TOutputImage * materialVolumes);
284 void
285 SetInputMaterialVolumes(const VectorImageType * materialVolumes);
286 void
287 SetInputMeasuredProjections(const TMeasuredProjections * measuredProjections);
288 void
289 SetInputMeasuredProjections(const VectorImageType * measuredProjections);
290 void
291 SetInputIncidentSpectrum(const TIncidentSpectrum * incidentSpectrum);
292#ifndef ITK_FUTURE_LEGACY_REMOVE
293 void
294 SetInputIncidentSpectrum(const VectorSpectrumImageType * incidentSpectrum);
295 void
296 SetInputPhotonCounts(const TMeasuredProjections * measuredProjections);
297 void
298 SetInputSpectrum(const TIncidentSpectrum * incidentSpectrum);
299#endif
300 void
302 void
304 void
306
308 itkSetMacro(RegularizationWeights, typename TOutputImage::PixelType);
309 itkGetMacro(RegularizationWeights, typename TOutputImage::PixelType);
310
312 itkSetMacro(RegularizationRadius, typename TOutputImage::RegionType::SizeType);
313 itkGetMacro(RegularizationRadius, typename TOutputImage::RegionType::SizeType);
314
317 using BinnedDetectorResponseType = vnl_matrix<dataType>;
318 using MaterialAttenuationsType = vnl_matrix<dataType>;
319 virtual void
321 virtual void
323
324protected:
327
329 void
330 VerifyPreconditions() const override;
331
333 void
334 GenerateData() override;
335
336#if !defined(ITK_WRAPPING_PARSER)
362# ifndef ITK_FUTURE_LEGACY_REMOVE
363 typename FlattenVectorSpectrumFilterType::Pointer m_FlattenVectorSpectrumFilter;
364 typename PermuteSpectrumFilterType::Pointer m_PermuteSpectrumFilter;
365 typename CastIncidentSpectrumFilterType::Pointer m_CastIncidentSpectrumFilter;
366# endif
367#endif
368
372 void
373 VerifyInputInformation() const override
374 {}
375
378 void
380 void
382
384 typename TOutputImage::ConstPointer
386 typename TMeasuredProjections::ConstPointer
388 typename TIncidentSpectrum::ConstPointer
390#ifndef ITK_FUTURE_LEGACY_REMOVE
391 typename TMeasuredProjections::ConstPointer
392 GetInputPhotonCounts();
393 typename TIncidentSpectrum::ConstPointer
394 GetInputSpectrum();
395#endif
396 typename SingleComponentImageType::ConstPointer
398 typename SingleComponentImageType::ConstPointer
400 typename SingleComponentImageType::ConstPointer
402
403#if !defined(ITK_WRAPPING_PARSER)
410#endif
411
413
420
421 typename TOutputImage::PixelType m_RegularizationWeights;
422 typename TOutputImage::RegionType::SizeType m_RegularizationRadius;
423};
424} // namespace rtk
425
426
427#ifndef ITK_MANUAL_INSTANTIATION
428# include "rtkMechlemOneStepSpectralReconstructionFilter.hxx"
429#endif
430
431#endif
Pixel-wise addition of two images.
Casts input pixels to output pixel type.
Decrease the image size by cropping the image to the selected region bounds.
Templated n-dimensional image class.
Definition itkImage.h:89
Pixel-wise multiplication of two images.
static constexpr T max(const T &)
Permutes the image axes according to a user specified order.
Implements transparent reference counting.
Templated n-dimensional vector image class.
For each vector-valued pixel, adds a vector to the diagonal of a matrix.
Generate an n-dimensional image with constant pixel values.
itk::SmartPointer< Self > Pointer
Base class for forward projection, i.e. accumulation along x-ray lines.
Computes update from gradient and Hessian in Newton's method.
Mother class for cone beam reconstruction filters which need runtime selection of their forward and b...
enum { FP_JOSEPH=0, FP_CUDARAYCAST=2, FP_JOSEPHATTENUATED=3, FP_ZENG=4, FP_CUDAWARP=5, FP_CUDAZENG=6 } ForwardProjectionType
enum { BP_VOXELBASED=0, BP_JOSEPH=1, BP_CUDAVOXELBASED=2, BP_CUDARAYCAST=4, BP_JOSEPHATTENUATED=5, BP_ZENG=6, BP_CUDAWARP=7, BP_CUDAZENG=8 } BackProjectionType
SingleComponentImageType::ConstPointer GetSpatialRegularizationWeights()
ReorderProjectionsWeightsFilterType::Pointer m_ReorderProjectionsWeightsFilter
void SetInputMaterialVolumes(const VectorImageType *materialVolumes)
IterativeConeBeamReconstructionFilter< TOutputImage, TOutputImage > Superclass
void SetProjectionWeights(const SingleComponentImageType *weiprojections)
itk::MultiplyImageFilter< TOutputImage, SingleComponentImageType > MultiplyFilterType
void SetSupportMask(const SingleComponentImageType *support)
WeidingerForwardModelImageFilter< TOutputImage, TMeasuredProjections, TIncidentSpectrum > WeidingerForwardModelType
rtk::ReorderProjectionsImageFilter< SingleComponentImageType > ReorderProjectionsWeightsFilterType
rtk::ConstantImageSource< SingleComponentImageType > SingleComponentImageSourceType
rtk::ForwardProjectionImageFilter< TOutputImage, TOutputImage > ForwardProjectionFilterType
HessiansBackProjectionFilterType::Pointer InstantiateHessiansBackProjectionFilter(int bptype)
itk::ExtractImageFilter< TMeasuredProjections, TMeasuredProjections > ExtractMeasuredProjectionsFilterType
TOutputImage::ConstPointer GetInputMaterialVolumes()
TIncidentSpectrum::ConstPointer GetInputIncidentSpectrum()
void SetInputMeasuredProjections(const VectorImageType *measuredProjections)
typename itk::VectorImage< dataType, TOutputImage::ImageDimension > VectorImageType
rtk::ReorderProjectionsImageFilter< TMeasuredProjections > ReorderMeasuredProjectionsFilterType
void SetInputIncidentSpectrum(const TIncidentSpectrum *incidentSpectrum)
void SetInputMeasuredProjections(const TMeasuredProjections *measuredProjections)
void SetInputMaterialVolumes(const TOutputImage *materialVolumes)
ExtractMeasuredProjectionsFilterType::Pointer m_ExtractMeasuredProjectionsFilter
ReorderMeasuredProjectionsFilterType::Pointer m_ReorderMeasuredProjectionsFilter
TMeasuredProjections::ConstPointer GetInputMeasuredProjections()
typename itk::Image< typename TOutputImage::PixelType, TOutputImage::ImageDimension > CPUOutputImageType
JosephForwardProjectionImageFilter< SingleComponentImageType, SingleComponentImageType > CudaSingleComponentForwardProjectionImageFilterType
SingleComponentImageType::ConstPointer GetProjectionWeights()
SingleComponentForwardProjectionFilterType::Pointer m_SingleComponentForwardProjectionFilter
SingleComponentImageType::ConstPointer GetSupportMask()
rtk::AddMatrixAndDiagonalImageFilter< GradientsImageType, HessiansImageType > AddMatrixAndDiagonalFilterType
itk::CastImageFilter< VectorImageType, TMeasuredProjections > CastMeasuredProjectionsFilterType
rtk::ForwardProjectionImageFilter< SingleComponentImageType, SingleComponentImageType > SingleComponentForwardProjectionFilterType
itk::CastImageFilter< VectorImageType, TOutputImage > CastMaterialVolumesFilterType
~MechlemOneStepSpectralReconstructionFilter() override=default
virtual void SetMaterialAttenuations(const MaterialAttenuationsType &matAtt)
void SetSpatialRegularizationWeights(const SingleComponentImageType *regweights)
typename TOutputImage::template RebindImageType< dataType, TOutputImage::ImageDimension > SingleComponentImageType
virtual void SetBinnedDetectorResponse(const BinnedDetectorResponseType &detResp)
itk::MultiplyImageFilter< GradientsImageType, SingleComponentImageType > MultiplyGradientFilterType
rtk::BackProjectionImageFilter< HessiansImageType, HessiansImageType > HessiansBackProjectionFilterType
typename TOutputImage::template RebindImageType< itk::Vector< dataType, nMaterials *nMaterials >, TOutputImage::ImageDimension > HessiansImageType
rtk::GetNewtonUpdateImageFilter< GradientsImageType, HessiansImageType > NewtonFilterType
rtk::SeparableQuadraticSurrogateRegularizationImageFilter< GradientsImageType > SQSRegularizationType
BackProjectionImageFilter< HessiansImageType, HessiansImageType > CudaHessiansBackProjectionImageFilterType
rtk::BackProjectionImageFilter< GradientsImageType, GradientsImageType > GradientsBackProjectionFilterType
SingleComponentForwardProjectionFilterType::Pointer InstantiateSingleComponentForwardProjectionFilter(int fwtype)
Applies Nesterov's momentum technique.
Sorts or shuffle projections and geometry inputs.
For one-step inversion of spectral CT data by the method Mechlem2017, computes regularization term's ...
Projection geometry for a source and a 2-D flat panel.
Re-writes a vector image as an image.
Performs intermediate computations in Weidinger2016.
#define itkSetMacro(name, type)