RTK  2.1.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  * http://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_EXPORT ProjectionsReader : public itk::ImageSource<TOutputImage>
126 {
127 public:
128  ITK_DISALLOW_COPY_AND_ASSIGN(ProjectionsReader);
129 
134 
136  itkNewMacro(Self);
137 
139  itkTypeMacro(ProjectionsReader, itk::ImageSource);
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  itkStaticConstMacro(OutputImageDimension, unsigned int, 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 
265  itkGetMacro(ImageIO, itk::ImageIOBase::Pointer);
266 
269  void
270  GenerateOutputInformation() override;
271 
272 protected:
274  ~ProjectionsReader() override = default;
275  void
276  PrintSelf(std::ostream & os, itk::Indent indent) const override;
277 
279  void
280  GenerateData() override;
281 
284 
285 private:
289  template <class TInputImage>
290  void
291  PropagateParametersToMiniPipeline();
292  void
293  ConnectElektaRawFilter(itk::ImageBase<OutputImageDimension> ** nextInputBase);
294  void
295  PropagateI0(itk::ImageBase<OutputImageDimension> ** nextInputBase);
297 
302 
312 
316 
320 
324 
326  itk::ImageIOBase::Pointer m_ImageIO{ nullptr };
327 
338  double m_AirThreshold{ 32000 };
339  double m_ScatterToPrimaryRatio{ 0. };
340  double m_NonNegativityConstraintThreshold{ itk::NumericTraits<double>::NonpositiveMin() };
342  double m_IDark{ 0. };
343  double m_ConditionalMedianThresholdMultiplier{ 1. };
345  bool m_ComputeLineIntegral{ true };
346  unsigned int m_VectorComponent{ 0 };
347 };
349 
350 } // namespace rtk
351 
352 #ifndef ITK_MANUAL_INSTANTIATION
353 # include "rtkProjectionsReader.hxx"
354 #endif
355 
356 #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