Medical Imaging Interaction Toolkit  2018.4.99-68f53314
Medical Imaging Interaction Toolkit
mitkDICOMITKSeriesGDCMReader.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkDICOMITKSeriesGDCMReader_h
14 #define mitkDICOMITKSeriesGDCMReader_h
15 
16 #include <stack>
17 #include "itkMutexLock.h"
18 #include "mitkDICOMFileReader.h"
19 #include "mitkDICOMDatasetSorter.h"
23 #include "MitkDICOMExports.h"
24 
25 
26 namespace itk
27 {
28  class TimeProbesCollectorBase;
29 }
30 
31 namespace mitk
32 {
33 
191 {
192  public:
193 
196  itkFactorylessNewMacro( DICOMITKSeriesGDCMReader );
198  mitkNewMacro2Param( DICOMITKSeriesGDCMReader, unsigned int, bool );
199 
204  void AnalyzeInputFiles() override;
205 
206  // void AllocateOutputImages();
210  bool LoadImages() override;
211 
212  // re-implemented from super-class
213  bool CanHandleFile(const std::string& filename) override;
214 
218  virtual void AddSortingElement(DICOMDatasetSorter* sorter, bool atFront = false);
219 
220  typedef const std::list<DICOMDatasetSorter::ConstPointer> ConstSorterList;
221  ConstSorterList GetFreelyConfiguredSortingElements() const;
222 
226  void SetFixTiltByShearing(bool on);
227 
228  bool GetFixTiltByShearing() const;
229 
233  void SetAcceptTwoSlicesGroups(bool accept) const;
234  bool GetAcceptTwoSlicesGroups() const;
235 
239  void SetToleratedOriginOffsetToAdaptive(double fractionOfInterSliceDistanct = 0.3) const;
240 
244  void SetToleratedOriginOffset(double millimeters = 0.005) const;
245 
249  void SetSimpleVolumeReading(bool read)
250  {
251  m_SimpleVolumeReading = read;
252  };
253 
258  {
259  return m_SimpleVolumeReading;
260  };
261 
262  double GetToleratedOriginError() const;
263  bool IsToleratedOriginOffsetAbsolute() const;
264 
265  double GetDecimalPlacesForOrientation() const;
266 
267  bool operator==(const DICOMFileReader& other) const override;
268 
269  DICOMTagPathList GetTagsOfInterest() const override;
270 
272  {
273  return m_DefaultDecimalPlacesForOrientation;
274  }
275 
277  {
278  return m_DefaultSimpleVolumeImport;
279  }
280 
282  {
283  return m_DefaultFixTiltByShearing;
284  }
285 
286  protected:
287 
288  void InternalPrintConfiguration(std::ostream& os) const override;
289 
291  static std::string GetActiveLocale();
296  void PushLocale() const;
301  void PopLocale() const;
302 
303  const static int m_DefaultDecimalPlacesForOrientation = 5;
304  const static bool m_DefaultSimpleVolumeImport = false;
305  const static bool m_DefaultFixTiltByShearing = true;
306 
307  DICOMITKSeriesGDCMReader(unsigned int decimalPlacesForOrientation = m_DefaultDecimalPlacesForOrientation, bool simpleVolumeImport = m_DefaultSimpleVolumeImport);
308  ~DICOMITKSeriesGDCMReader() override;
309 
311  DICOMITKSeriesGDCMReader& operator=(const DICOMITKSeriesGDCMReader& other);
312 
313  typedef std::vector<DICOMDatasetAccessingImageFrameList> SortingBlockList;
318  virtual SortingBlockList Condense3DBlocks(SortingBlockList& resultOf3DGrouping);
319 
320  virtual DICOMTagCache::Pointer GetTagCache() const;
321  void SetTagCache( const DICOMTagCache::Pointer& ) override;
322 
324  static SortingBlockList InternalExecuteSortingStep(
325  unsigned int sortingStepIndex,
326  const DICOMDatasetSorter::Pointer& sorter,
327  const SortingBlockList& input);
328 
330  virtual bool LoadMitkImageForOutput(unsigned int o);
331 
332  virtual bool LoadMitkImageForImageBlockDescriptor(DICOMImageBlockDescriptor& block) const;
333 
335  static ReaderImplementationLevel GetReaderImplementationLevel(const std::string sopClassUID);
336  private:
337 
339  void EnsureMandatorySortersArePresent(unsigned int decimalPlacesForOrientation, bool simpleVolumeImport = false);
340 
341  protected:
342 
343  // NOT nice, made available to ThreeDnTDICOMSeriesReader due to lack of time
344  bool m_FixTiltByShearing; // could be removed by ITKDICOMSeriesReader NOT flagging tilt unless requested to fix it!
345 
347 
348  private:
349 
350  SortingBlockList m_SortingResultInProgress;
351 
352  typedef std::list<DICOMDatasetSorter::Pointer> SorterList;
353  SorterList m_Sorter;
354 
355  protected:
356 
357  // NOT nice, made available to ThreeDnTDICOMSeriesReader and ClassicDICOMSeriesReader due to lack of time
358  mitk::EquiDistantBlocksSorter::Pointer m_EquiDistantBlocksSorter;
359 
360  mitk::NormalDirectionConsistencySorter::Pointer m_NormalDirectionConsistencySorter;
361 
362  private:
363 
364  static itk::MutexLock::Pointer s_LocaleMutex;
365 
366  mutable std::stack<std::string> m_ReplacedCLocales;
367  mutable std::stack<std::locale> m_ReplacedCinLocales;
368 
369  double m_DecimalPlacesForOrientation;
370 
371  DICOMTagCache::Pointer m_TagCache;
372  bool m_ExternalCache;
373 };
374 
375 }
376 
377 #endif
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
The sorting/splitting building-block of DICOMITKSeriesGDCMReader.
Flexible reader based on itk::ImageSeriesReader and GDCM, for single-slice modalities like CT...
mitk::EquiDistantBlocksSorter::Pointer m_EquiDistantBlocksSorter
DataCollection - Class to facilitate loading/accessing structured data.
#define mitkNewMacro2Param(classname, typea, typeb)
Definition: mitkCommon.h:85
void SetSimpleVolumeReading(bool read)
Ignore all dicom tags that are non-essential for simple 3D volume import.
const std::list< DICOMDatasetSorter::ConstPointer > ConstSorterList
bool GetSimpleVolumeReading()
Ignore all dicom tags that are non-essential for simple 3D volume import.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Output descriptor for DICOMFileReader.
ReaderImplementationLevel
Describes how well the reader is tested for a certain file type (see mitk::DICOMFileReader).
#define MITKDICOM_EXPORT
std::vector< DICOMTagPath > DICOMTagPathList
std::vector< DICOMDatasetAccessingImageFrameList > SortingBlockList
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:158
Interface for DICOM readers that produce mitk::Images.
mitk::NormalDirectionConsistencySorter::Pointer m_NormalDirectionConsistencySorter