RTK  2.6.0
Reconstruction Toolkit
rtkSpectralForwardModelImageFilter.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 rtkSpectralForwardModelImageFilter_h
20 #define rtkSpectralForwardModelImageFilter_h
21 
24 
25 #include <itkInPlaceImageFilter.h>
26 
27 namespace rtk
28 {
42 template <typename DecomposedProjectionsType,
43  typename MeasuredProjectionsType,
44  typename IncidentSpectrumImageType = itk::VectorImage<float, 2>,
45  typename DetectorResponseImageType = itk::Image<float, 2>,
46  typename MaterialAttenuationsImageType = itk::Image<float, 2>>
47 class ITK_TEMPLATE_EXPORT SpectralForwardModelImageFilter
48  : public itk::InPlaceImageFilter<MeasuredProjectionsType, MeasuredProjectionsType>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_MOVE(SpectralForwardModelImageFilter);
52 
58 
60  using InputImageType = MeasuredProjectionsType;
61  using OutputImageType = MeasuredProjectionsType;
62 
65  using DetectorResponseType = vnl_matrix<double>;
66  using MaterialAttenuationsType = vnl_matrix<double>;
67 
69  itkNewMacro(Self);
70 
72 #ifdef itkOverrideGetNameOfClassMacro
73  itkOverrideGetNameOfClassMacro(SpectralForwardModelImageFilter);
74 #else
76 #endif
77 
78 
80  void
81  SetInputIncidentSpectrum(const IncidentSpectrumImageType * IncidentSpectrum);
82  void
83  SetInputSecondIncidentSpectrum(const IncidentSpectrumImageType * SecondIncidentSpectrum);
84  typename IncidentSpectrumImageType::ConstPointer
85  GetInputIncidentSpectrum();
86  typename IncidentSpectrumImageType::ConstPointer
87  GetInputSecondIncidentSpectrum();
89 
91  void
92  SetInputDecomposedProjections(const DecomposedProjectionsType * DecomposedProjections);
93  typename DecomposedProjectionsType::ConstPointer
94  GetInputDecomposedProjections();
96 
98  void
99  SetInputMeasuredProjections(const MeasuredProjectionsType * SpectralProjections);
100  typename MeasuredProjectionsType::ConstPointer
101  GetInputMeasuredProjections();
103 
105  void
106  SetDetectorResponse(const DetectorResponseImageType * DetectorResponse);
107  typename DetectorResponseImageType::ConstPointer
108  GetDetectorResponse();
110 
112  void
113  SetMaterialAttenuations(const MaterialAttenuationsImageType * MaterialAttenuations);
114  typename MaterialAttenuationsImageType::ConstPointer
115  GetMaterialAttenuations();
117 
118  typename DecomposedProjectionsType::ConstPointer
119  GetOutputCramerRaoLowerBound();
120 
121  typename MeasuredProjectionsType::ConstPointer
122  GetOutputVariances();
123 
124  itkSetMacro(Thresholds, ThresholdsType);
125  itkGetMacro(Thresholds, ThresholdsType);
126 
127  itkSetMacro(NumberOfSpectralBins, unsigned int);
128  itkGetMacro(NumberOfSpectralBins, unsigned int);
129 
130  itkSetMacro(NumberOfMaterials, unsigned int);
131  itkGetMacro(NumberOfMaterials, unsigned int);
132 
133  itkSetMacro(NumberOfEnergies, unsigned int);
134  itkGetMacro(NumberOfEnergies, unsigned int);
135 
136  itkSetMacro(IsSpectralCT, bool);
137  itkGetMacro(IsSpectralCT, bool);
138 
139  itkSetMacro(ComputeVariances, bool);
140  itkGetMacro(ComputeVariances, bool);
141 
142  itkSetMacro(ComputeCramerRaoLowerBound, bool);
143  itkGetMacro(ComputeCramerRaoLowerBound, bool);
144 
145 protected:
147  ~SpectralForwardModelImageFilter() override = default;
148 
151  using Superclass::MakeOutput;
153  MakeOutput(DataObjectPointerArraySizeType idx) override;
154 
155  void
156  GenerateOutputInformation() override;
157 
158  void
159  GenerateInputRequestedRegion() override;
160 
161  void
162  BeforeThreadedGenerateData() override;
163  void
164  DynamicThreadedGenerateData(const typename OutputImageType::RegionType & outputRegionForThread) override;
165 
168  void
169  VerifyInputInformation() const override
170  {}
171 
174 
177  unsigned int m_NumberOfEnergies;
178 
180  unsigned int m_NumberOfIterations;
181  unsigned int m_NumberOfMaterials;
183  bool m_IsSpectralCT; // If not, it is dual energy CT
184  bool m_ComputeVariances; // Only implemented for dual energy CT
185  bool m_ComputeCramerRaoLowerBound; // Only implemented for spectral CT
186 
187 }; // end of class
188 
189 // Function to bin a detector response matrix according to given energy thresholds
190 template <typename OutputElementType, typename DetectorResponseImageType, typename ThresholdsType>
191 vnl_matrix<OutputElementType>
192 SpectralBinDetectorResponse(const DetectorResponseImageType * drm,
193  const ThresholdsType & thresholds,
194  const unsigned int numberOfEnergies);
195 
196 } // end namespace rtk
197 
198 
199 #ifndef ITK_MANUAL_INSTANTIATION
200 # include "rtkSpectralForwardModelImageFilter.hxx"
201 #endif
202 
203 #endif
Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Forward model for the decomposition of spectral projection images into material projections.
TInputImage InputImageType
#define itkSetMacro(name, type)
TOutputImage OutputImageType
vnl_matrix< OutputElementType > SpectralBinDetectorResponse(const DetectorResponseImageType *drm, const ThresholdsType &thresholds, const unsigned int numberOfEnergies)