RTK  2.6.0
Reconstruction Toolkit
rtkSimplexSpectralProjectionsDecompositionImageFilter.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 rtkSimplexSpectralProjectionsDecompositionImageFilter_h
20 #define rtkSimplexSpectralProjectionsDecompositionImageFilter_h
21 
22 #include <itkImageToImageFilter.h>
23 #include <itkAmoebaOptimizer.h>
27 
29 
30 namespace rtk
31 {
43 template <typename DecomposedProjectionsType,
44  typename MeasuredProjectionsType,
45  typename IncidentSpectrumImageType = itk::Image<float, 3>,
46  typename DetectorResponseImageType = itk::Image<float, 2>,
47  typename MaterialAttenuationsImageType = itk::Image<float, 2>>
49  : public itk::ImageToImageFilter<DecomposedProjectionsType, DecomposedProjectionsType>
50 {
51 public:
52  ITK_DISALLOW_COPY_AND_MOVE(SimplexSpectralProjectionsDecompositionImageFilter);
53 
59 
61  using InputImageType = DecomposedProjectionsType;
62  using OutputImageType = DecomposedProjectionsType;
63 
67  using DetectorResponseType = vnl_matrix<double>;
68  using MaterialAttenuationsType = vnl_matrix<double>;
70  using DecomposedProjectionsDataType = typename DecomposedProjectionsType::PixelType::ValueType;
71  using MeasuredProjectionsDataType = typename MeasuredProjectionsType::PixelType::ValueType;
72 
73 #ifndef ITK_FUTURE_LEGACY_REMOVE
74 
75  using VectorSpectrumImageType = itk::VectorImage<float, 2>;
78 #endif
79 
81  itkNewMacro(Self);
82 
84  itkOverrideGetNameOfClassMacro(SimplexSpectralProjectionsDecompositionImageFilter);
85 
87  void
88  SetInputDecomposedProjections(
89  const typename itk::ImageBase<DecomposedProjectionsType::ImageDimension> * DecomposedProjections);
90  template <unsigned int VNumberOfMaterials>
91  void
92  SetInputFixedVectorLengthDecomposedProjections(
94  DecomposedProjectionsType::ImageDimension> * DecomposedProjections);
95  typename DecomposedProjectionsType::ConstPointer
96  GetInputDecomposedProjections();
98 
100  void
101  SetInputMeasuredProjections(
102  const typename itk::ImageBase<MeasuredProjectionsType::ImageDimension> * MeasuredProjections);
103  template <unsigned int VNumberOfSpectralBins>
104  void
105  SetInputFixedVectorLengthMeasuredProjections(
107  MeasuredProjectionsType::ImageDimension> * MeasuredProjections);
108  typename MeasuredProjectionsType::ConstPointer
109  GetInputMeasuredProjections();
111 
112 
114  void
115  SetDetectorResponse(const DetectorResponseImageType * DetectorResponse);
116  typename DetectorResponseImageType::ConstPointer
117  GetDetectorResponse();
119 
121  void
122  SetMaterialAttenuations(const MaterialAttenuationsImageType * MaterialAttenuations);
123  typename MaterialAttenuationsImageType::ConstPointer
124  GetMaterialAttenuations();
126 
128  void
129  SetInputIncidentSpectrum(const IncidentSpectrumImageType * IncidentSpectrum);
130  void
131  SetInputSecondIncidentSpectrum(const IncidentSpectrumImageType * SecondIncidentSpectrum);
132 #ifndef ITK_FUTURE_LEGACY_REMOVE
133  void
134  SetInputIncidentSpectrum(const VectorSpectrumImageType * IncidentSpectrum);
135  void
136  SetInputSecondIncidentSpectrum(const VectorSpectrumImageType * SecondIncidentSpectrum);
137 #endif
138  typename IncidentSpectrumImageType::ConstPointer
139  GetInputIncidentSpectrum();
140  typename IncidentSpectrumImageType::ConstPointer
141  GetInputSecondIncidentSpectrum();
143 
145  itkGetMacro(NumberOfIterations, unsigned int);
146  itkSetMacro(NumberOfIterations, unsigned int);
148 
149  itkSetMacro(NumberOfEnergies, unsigned int);
150  itkGetMacro(NumberOfEnergies, unsigned int);
151 
152  itkSetMacro(NumberOfMaterials, unsigned int);
153  itkGetMacro(NumberOfMaterials, unsigned int);
154 
155  itkSetMacro(OptimizeWithRestarts, bool);
156  itkGetMacro(OptimizeWithRestarts, bool);
157 
158  itkSetMacro(Thresholds, ThresholdsType);
159  itkGetMacro(Thresholds, ThresholdsType);
160 
161  itkSetMacro(NumberOfSpectralBins, unsigned int);
162  itkGetMacro(NumberOfSpectralBins, unsigned int);
163 
164  itkSetMacro(OutputInverseCramerRaoLowerBound, bool);
165  itkGetMacro(OutputInverseCramerRaoLowerBound, bool);
166 
167  itkSetMacro(OutputFischerMatrix, bool);
168  itkGetMacro(OutputFischerMatrix, bool);
169 
170  itkSetMacro(LogTransformEachBin, bool);
171  itkGetMacro(LogTransformEachBin, bool);
172 
173  itkSetMacro(GuessInitialization, bool);
174  itkGetMacro(GuessInitialization, bool);
175 
176  itkSetMacro(IsSpectralCT, bool);
177  itkGetMacro(IsSpectralCT, bool);
178 
179 protected:
182 
183  void
184  GenerateOutputInformation() override;
185 
186  void
187  GenerateInputRequestedRegion() override;
188 
189  void
190  BeforeThreadedGenerateData() override;
191  void
192  DynamicThreadedGenerateData(const typename DecomposedProjectionsType::RegionType & outputRegionForThread) override;
193 
196  using Superclass::MakeOutput;
198  MakeOutput(DataObjectPointerArraySizeType idx) override;
199 
202  void
203  VerifyInputInformation() const override
204  {}
205 
215  bool m_IsSpectralCT; // If not, it is dual energy CT
217  unsigned int m_NumberOfIterations;
218  unsigned int m_NumberOfMaterials;
219  unsigned int m_NumberOfEnergies;
221 
222 #ifndef ITK_FUTURE_LEGACY_REMOVE
223 
224  typename FlattenVectorFilterType::Pointer m_FlattenFilter;
225  typename FlattenVectorFilterType::Pointer m_FlattenSecondFilter;
226  typename PermuteFilterType::Pointer m_PermuteFilter;
227  typename PermuteFilterType::Pointer m_PermuteSecondFilter;
228 #endif
229 
230 }; // end of class
231 
232 } // end namespace rtk
233 
234 
235 #ifndef ITK_MANUAL_INSTANTIATION
236 # include "rtkSimplexSpectralProjectionsDecompositionImageFilter.hxx"
237 #endif
238 
239 #endif
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Decomposition of spectral projection images into material projections.
#define itkSetMacro(name, type)
Re-writes a vector image as an image.
typename DecomposedProjectionsType::PixelType::ValueType DecomposedProjectionsDataType