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  itkOverrideGetNameOfClassMacro(ProjectionsReader);
140 
142  using OutputImageType = TOutputImage;
143  using OutputImagePointer = typename OutputImageType::Pointer;
144  using OutputImageRegionType = typename OutputImageType::RegionType;
145  using OutputImagePixelType = typename OutputImageType::PixelType;
146  using OutputImageDirectionType = typename OutputImageType::DirectionType;
147  using OutputImageSpacingType = typename OutputImageType::SpacingType;
148  using OutputImagePointType = typename OutputImageType::PointType;
149  using OutputImageSizeType = typename OutputImageType::SizeType;
150 
151  using FileNamesContainer = std::vector<std::string>;
154  using WaterPrecorrectionVectorType = std::vector<double>;
155 
160 
162  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
163 
166  void
168  {
169  if (m_FileNames != name)
170  {
171  m_FileNames = name;
172  this->Modified();
173  }
174  }
175  const FileNamesContainer &
176  GetFileNames() const
177  {
178  return m_FileNames;
179  }
181 
183  itkSetMacro(Origin, OutputImagePointType);
184  itkGetConstMacro(Origin, OutputImagePointType);
186 
187  itkSetMacro(Spacing, OutputImageSpacingType);
188  itkGetConstMacro(Spacing, OutputImageSpacingType);
189 
190  itkSetMacro(Direction, OutputImageDirectionType);
191  itkGetConstMacro(Direction, OutputImageDirectionType);
192 
194  itkSetMacro(UpperBoundaryCropSize, OutputImageSizeType);
195  itkGetConstMacro(UpperBoundaryCropSize, OutputImageSizeType);
196  itkSetMacro(LowerBoundaryCropSize, OutputImageSizeType);
197  itkGetConstMacro(LowerBoundaryCropSize, OutputImageSizeType);
199 
201  itkSetMacro(ShrinkFactors, ShrinkFactorsType);
202  itkGetConstReferenceMacro(ShrinkFactors, ShrinkFactorsType);
204 
206  itkSetMacro(MedianRadius, MedianRadiusType);
207  itkGetConstReferenceMacro(MedianRadius, MedianRadiusType);
208  itkGetMacro(ConditionalMedianThresholdMultiplier, double);
209  itkSetMacro(ConditionalMedianThresholdMultiplier, double);
211 
213  itkGetMacro(AirThreshold, double);
214  itkSetMacro(AirThreshold, double);
216 
217  itkGetMacro(ScatterToPrimaryRatio, double);
218  itkSetMacro(ScatterToPrimaryRatio, double);
219 
220  itkGetMacro(NonNegativityConstraintThreshold, double);
221  itkSetMacro(NonNegativityConstraintThreshold, double);
222 
227  itkGetMacro(I0, double);
228  itkSetMacro(I0, double);
230 
234  itkGetMacro(IDark, double);
235  itkSetMacro(IDark, double);
237 
239  itkGetMacro(WaterPrecorrectionCoefficients, WaterPrecorrectionVectorType);
240  virtual void
242  {
243  if (this->m_WaterPrecorrectionCoefficients != _arg)
244  {
245  this->m_WaterPrecorrectionCoefficients = _arg;
246  this->Modified();
247  }
248  }
250 
253  itkSetMacro(ComputeLineIntegral, bool);
254  itkGetConstMacro(ComputeLineIntegral, bool);
255  itkBooleanMacro(ComputeLineIntegral);
257 
260  itkGetMacro(VectorComponent, unsigned int);
261  itkSetMacro(VectorComponent, unsigned int);
263 
270  itkSetObjectMacro(ImageIO, itk::ImageIOBase);
271  itkGetConstObjectMacro(ImageIO, itk::ImageIOBase);
273 
276  void
277  GenerateOutputInformation() override;
278 
279 protected:
281  ~ProjectionsReader() override = default;
282  void
283  PrintSelf(std::ostream & os, itk::Indent indent) const override;
284 
286  void
287  GenerateData() override;
288 
291 
292 private:
296  template <class TInputImage>
297  void
298  PropagateParametersToMiniPipeline();
299  void
300  ConnectElektaRawFilter(itk::ImageBase<OutputImageDimension> ** nextInputBase);
301  void
302  PropagateI0(itk::ImageBase<OutputImageDimension> ** nextInputBase);
304 
309 
319 
323 
327 
331 
333  itk::ImageIOBase::Pointer m_ImageIO{ nullptr };
334 
345  double m_AirThreshold{ 32000 };
346  double m_ScatterToPrimaryRatio{ 0. };
347  double m_NonNegativityConstraintThreshold{ itk::NumericTraits<double>::NonpositiveMin() };
349  double m_IDark{ 0. };
350  double m_ConditionalMedianThresholdMultiplier{ 1. };
352  bool m_ComputeLineIntegral{ true };
353  unsigned int m_VectorComponent{ 0 };
354 };
356 
357 } // namespace rtk
358 
359 #ifndef ITK_MANUAL_INSTANTIATION
360 # include "rtkProjectionsReader.hxx"
361 #endif
362 
363 #endif // rtkProjectionsReader_h
typename OutputImageType::SpacingType OutputImageSpacingType
typename OutputImageType::RegionType OutputImageRegionType
OutputImageDirectionType m_Direction
const FileNamesContainer & GetFileNames() const
Performs the classical water precorrection for beam hardening (Kachelriess, Med. Phys. 2006)
OutputImagePointType m_Origin
typename OutputImageType::Pointer OutputImagePointer
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
#define itkSetMacro(name, type)
FileNamesContainer m_FileNames
itk::ProcessObject::Pointer m_I0EstimationFilter
std::vector< double > WaterPrecorrectionVectorType
itk::ProcessObject::Pointer m_BinningFilter
StreamingType::Pointer m_StreamingFilter
MedianRadiusType m_MedianRadius
typename rtk::ConditionalMedianImageFilter< TOutputImage >::MedianRadiusType MedianRadiusType
itk::ProcessObject::Pointer m_ChangeInformationFilter
itk::ImageSource< TOutputImage >::Pointer m_RawToAttenuationFilter
typename OutputImageType::PixelType OutputImagePixelType
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