RTK  2.6.0
Reconstruction Toolkit
rtkProjectionsReader.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 rtkProjectionsReader_h
20 #define rtkProjectionsReader_h
21 
22 // ITK
23 #include <itkImageSource.h>
24 #include <itkImageIOFactory.h>
26 
27 // RTK
30 
31 // Standard lib
32 #include <vector>
33 #include <string>
34 
35 namespace rtk
36 {
37 
124 template <class TOutputImage>
125 class ITK_TEMPLATE_EXPORT ProjectionsReader : public itk::ImageSource<TOutputImage>
126 {
127 public:
128  ITK_DISALLOW_COPY_AND_MOVE(ProjectionsReader);
129 
134 
136  itkNewMacro(Self);
137 
139 #ifdef itkOverrideGetNameOfClassMacro
140  itkOverrideGetNameOfClassMacro(ProjectionsReader);
141 #else
142  itkTypeMacro(ProjectionsReader, itk::ImageSource);
143 #endif
144 
145 
147  using OutputImageType = TOutputImage;
148  using OutputImagePointer = typename OutputImageType::Pointer;
149  using OutputImageRegionType = typename OutputImageType::RegionType;
150  using OutputImagePixelType = typename OutputImageType::PixelType;
151  using OutputImageDirectionType = typename OutputImageType::DirectionType;
152  using OutputImageSpacingType = typename OutputImageType::SpacingType;
153  using OutputImagePointType = typename OutputImageType::PointType;
154  using OutputImageSizeType = typename OutputImageType::SizeType;
155 
156  using FileNamesContainer = std::vector<std::string>;
159  using WaterPrecorrectionVectorType = std::vector<double>;
160 
165 
167  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
168 
171  void
173  {
174  if (m_FileNames != name)
175  {
176  m_FileNames = name;
177  this->Modified();
178  }
179  }
180  const FileNamesContainer &
181  GetFileNames() const
182  {
183  return m_FileNames;
184  }
186 
188  itkSetMacro(Origin, OutputImagePointType);
189  itkGetConstMacro(Origin, OutputImagePointType);
191 
192  itkSetMacro(Spacing, OutputImageSpacingType);
193  itkGetConstMacro(Spacing, OutputImageSpacingType);
194 
195  itkSetMacro(Direction, OutputImageDirectionType);
196  itkGetConstMacro(Direction, OutputImageDirectionType);
197 
199  itkSetMacro(UpperBoundaryCropSize, OutputImageSizeType);
200  itkGetConstMacro(UpperBoundaryCropSize, OutputImageSizeType);
201  itkSetMacro(LowerBoundaryCropSize, OutputImageSizeType);
202  itkGetConstMacro(LowerBoundaryCropSize, OutputImageSizeType);
204 
206  itkSetMacro(ShrinkFactors, ShrinkFactorsType);
207  itkGetConstReferenceMacro(ShrinkFactors, ShrinkFactorsType);
209 
211  itkSetMacro(MedianRadius, MedianRadiusType);
212  itkGetConstReferenceMacro(MedianRadius, MedianRadiusType);
213  itkGetMacro(ConditionalMedianThresholdMultiplier, double);
214  itkSetMacro(ConditionalMedianThresholdMultiplier, double);
216 
218  itkGetMacro(AirThreshold, double);
219  itkSetMacro(AirThreshold, double);
221 
222  itkGetMacro(ScatterToPrimaryRatio, double);
223  itkSetMacro(ScatterToPrimaryRatio, double);
224 
225  itkGetMacro(NonNegativityConstraintThreshold, double);
226  itkSetMacro(NonNegativityConstraintThreshold, double);
227 
232  itkGetMacro(I0, double);
233  itkSetMacro(I0, double);
235 
239  itkGetMacro(IDark, double);
240  itkSetMacro(IDark, double);
242 
244  itkGetMacro(WaterPrecorrectionCoefficients, WaterPrecorrectionVectorType);
245  virtual void
247  {
248  if (this->m_WaterPrecorrectionCoefficients != _arg)
249  {
250  this->m_WaterPrecorrectionCoefficients = _arg;
251  this->Modified();
252  }
253  }
255 
258  itkSetMacro(ComputeLineIntegral, bool);
259  itkGetConstMacro(ComputeLineIntegral, bool);
260  itkBooleanMacro(ComputeLineIntegral);
262 
265  itkGetMacro(VectorComponent, unsigned int);
266  itkSetMacro(VectorComponent, unsigned int);
268 
275  itkSetObjectMacro(ImageIO, itk::ImageIOBase);
276  itkGetConstObjectMacro(ImageIO, itk::ImageIOBase);
278 
281  void
282  GenerateOutputInformation() override;
283 
284 protected:
286  ~ProjectionsReader() override = default;
287  void
288  PrintSelf(std::ostream & os, itk::Indent indent) const override;
289 
291  void
292  GenerateData() override;
293 
296 
297 private:
301  template <class TInputImage>
302  void
303  PropagateParametersToMiniPipeline();
304  void
305  ConnectElektaRawFilter(itk::ImageBase<OutputImageDimension> ** nextInputBase);
306  void
307  PropagateI0(itk::ImageBase<OutputImageDimension> ** nextInputBase);
309 
314 
324 
328 
332 
336 
338  itk::ImageIOBase::Pointer m_ImageIO{ nullptr };
339 
350  double m_AirThreshold{ 32000 };
351  double m_ScatterToPrimaryRatio{ 0. };
352  double m_NonNegativityConstraintThreshold{ itk::NumericTraits<double>::NonpositiveMin() };
354  double m_IDark{ 0. };
355  double m_ConditionalMedianThresholdMultiplier{ 1. };
357  bool m_ComputeLineIntegral{ true };
358  unsigned int m_VectorComponent{ 0 };
359 };
361 
362 } // namespace rtk
363 
364 #ifndef ITK_MANUAL_INSTANTIATION
365 # include "rtkProjectionsReader.hxx"
366 #endif
367 
368 #endif // rtkProjectionsReader_h
typename OutputImageType::SpacingType OutputImageSpacingType
typename OutputImageType::Pointer OutputImagePointer
OutputImageDirectionType m_Direction
const FileNamesContainer & GetFileNames() const
Performs the classical water precorrection for beam hardening (Kachelriess, Med. Phys. 2006)
OutputImagePointType m_Origin
itk::ProcessObject::Pointer m_VectorComponentSelectionFilter
itk::ProcessObject::Pointer m_ScatterFilter
static constexpr T NonpositiveMin()
OutputImageSpacingType m_Spacing
OutputImageSizeType m_UpperBoundaryCropSize
WaterPrecorrectionVectorType m_WaterPrecorrectionCoefficients
typename OutputImageType::SizeType OutputImageSizeType
typename OutputImageType::PointType OutputImagePointType
itk::ImageSource< TOutputImage >::Pointer m_RawCastFilter
typename OutputImageType::PixelType OutputImagePixelType
#define itkSetMacro(name, type)
FileNamesContainer m_FileNames
itk::ProcessObject::Pointer m_I0EstimationFilter
std::vector< double > WaterPrecorrectionVectorType
typename OutputImageType::RegionType OutputImageRegionType
itk::ProcessObject::Pointer m_BinningFilter
StreamingType::Pointer m_StreamingFilter
TOutputImage OutputImageType
MedianRadiusType m_MedianRadius
typename rtk::ConditionalMedianImageFilter< TOutputImage >::MedianRadiusType MedianRadiusType
itk::ProcessObject::Pointer m_ChangeInformationFilter
itk::ImageSource< TOutputImage >::Pointer m_RawToAttenuationFilter
OutputImageSizeType m_LowerBoundaryCropSize
typename OutputImageType::DirectionType OutputImageDirectionType
itk::ProcessObject::Pointer m_CropFilter
std::vector< std::string > FileNamesContainer
void SetFileNames(const FileNamesContainer &name)
itk::ProcessObject::Pointer m_ElektaRawFilter
typename itk::ConstNeighborhoodIterator< TInputImage >::RadiusType MedianRadiusType
WaterPrecorrectionType::Pointer m_WaterPrecorrectionFilter
itk::ProcessObject::Pointer m_RawDataReader
itk::ProcessObject::Pointer m_ConditionalMedianFilter
virtual void SetWaterPrecorrectionCoefficients(const WaterPrecorrectionVectorType _arg)
ShrinkFactorsType m_ShrinkFactors