Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
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 <mutex>
17 #include <stack>
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  using SortingBlockListItemType = std::pair<DICOMDatasetAccessingImageFrameList, IOVolumeSplitReason::Pointer>;
314  using SortingBlockList = std::vector<SortingBlockListItemType> ;
319  virtual SortingBlockList Condense3DBlocks(SortingBlockList& resultOf3DGrouping);
320 
321  virtual DICOMTagCache::Pointer GetTagCache() const;
322  void SetTagCache( const DICOMTagCache::Pointer& ) override;
323 
325  static SortingBlockList InternalExecuteSortingStep(
326  unsigned int sortingStepIndex,
327  const DICOMDatasetSorter::Pointer& sorter,
328  const SortingBlockList& input);
329 
331  virtual bool LoadMitkImageForOutput(unsigned int o);
332 
333  virtual bool LoadMitkImageForImageBlockDescriptor(DICOMImageBlockDescriptor& block) const;
334 
336  static ReaderImplementationLevel GetReaderImplementationLevel(const std::string sopClassUID);
337  private:
338 
340  void EnsureMandatorySortersArePresent(unsigned int decimalPlacesForOrientation, bool simpleVolumeImport = false);
341 
342  protected:
343 
344  // NOT nice, made available to ThreeDnTDICOMSeriesReader due to lack of time
345  bool m_FixTiltByShearing; // could be removed by ITKDICOMSeriesReader NOT flagging tilt unless requested to fix it!
346 
348 
349  private:
350 
351  SortingBlockList m_SortingResultInProgress;
352 
353  typedef std::list<DICOMDatasetSorter::Pointer> SorterList;
354  SorterList m_Sorter;
355 
356  protected:
357 
358  // NOT nice, made available to ThreeDnTDICOMSeriesReader and ClassicDICOMSeriesReader due to lack of time
359  mitk::EquiDistantBlocksSorter::Pointer m_EquiDistantBlocksSorter;
360 
361  mitk::NormalDirectionConsistencySorter::Pointer m_NormalDirectionConsistencySorter;
362 
363  private:
364 
365  static std::mutex s_LocaleMutex;
366 
367  mutable std::stack<std::string> m_ReplacedCLocales;
368  mutable std::stack<std::locale> m_ReplacedCinLocales;
369 
370  double m_DecimalPlacesForOrientation;
371 
372  DICOMTagCache::Pointer m_TagCache;
373  bool m_ExternalCache;
374 };
375 
376 }
377 
378 #endif
mitk::DICOMITKSeriesGDCMReader::SetSimpleVolumeReading
void SetSimpleVolumeReading(bool read)
Ignore all dicom tags that are non-essential for simple 3D volume import.
Definition: mitkDICOMITKSeriesGDCMReader.h:249
mitk::DICOMITKSeriesGDCMReader::GetDefaultDecimalPlacesForOrientation
static int GetDefaultDecimalPlacesForOrientation()
Definition: mitkDICOMITKSeriesGDCMReader.h:271
mitk::DICOMTagPathList
std::vector< DICOMTagPath > DICOMTagPathList
Definition: mitkDICOMTagPath.h:155
mitk::DICOMImageBlockDescriptor
Output descriptor for DICOMFileReader.
Definition: mitkDICOMImageBlockDescriptor.h:78
mitkNewMacro2Param
#define mitkNewMacro2Param(classname, typea, typeb)
Definition: mitkCommon.h:81
mitkEquiDistantBlocksSorter.h
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::DICOMITKSeriesGDCMReader::SortingBlockList
std::vector< SortingBlockListItemType > SortingBlockList
Definition: mitkDICOMITKSeriesGDCMReader.h:314
mitk::DICOMITKSeriesGDCMReader::GetDefaultFixTiltByShearing
static bool GetDefaultFixTiltByShearing()
Definition: mitkDICOMITKSeriesGDCMReader.h:281
MitkDICOMExports.h
mitkDICOMFileReader.h
mitkDICOMGDCMImageFrameInfo.h
mitk::DICOMITKSeriesGDCMReader::m_FixTiltByShearing
bool m_FixTiltByShearing
Definition: mitkDICOMITKSeriesGDCMReader.h:345
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::DICOMITKSeriesGDCMReader::GetSimpleVolumeReading
bool GetSimpleVolumeReading()
Ignore all dicom tags that are non-essential for simple 3D volume import.
Definition: mitkDICOMITKSeriesGDCMReader.h:257
mitk::DICOMFileReader
Interface for DICOM readers that produce mitk::Images.
Definition: mitkDICOMFileReader.h:55
mitk::DICOMITKSeriesGDCMReader::m_NormalDirectionConsistencySorter
mitk::NormalDirectionConsistencySorter::Pointer m_NormalDirectionConsistencySorter
Definition: mitkDICOMITKSeriesGDCMReader.h:361
mitk::DICOMITKSeriesGDCMReader::m_EquiDistantBlocksSorter
mitk::EquiDistantBlocksSorter::Pointer m_EquiDistantBlocksSorter
Definition: mitkDICOMITKSeriesGDCMReader.h:359
mitkNormalDirectionConsistencySorter.h
mitk::operator==
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
mitk::ReaderImplementationLevel
ReaderImplementationLevel
Describes how well the reader is tested for a certain file type (see mitk::DICOMFileReader).
Definition: mitkDICOMEnums.h:48
mitk::DICOMITKSeriesGDCMReader
Flexible reader based on itk::ImageSeriesReader and GDCM, for single-slice modalities like CT,...
Definition: mitkDICOMITKSeriesGDCMReader.h:190
mitk::DICOMITKSeriesGDCMReader::SortingBlockListItemType
std::pair< DICOMDatasetAccessingImageFrameList, IOVolumeSplitReason::Pointer > SortingBlockListItemType
Definition: mitkDICOMITKSeriesGDCMReader.h:313
mitkDICOMDatasetSorter.h
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
mitkCloneMacro
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
mitk::DICOMITKSeriesGDCMReader::GetDefaultSimpleVolumeImport
static bool GetDefaultSimpleVolumeImport()
Definition: mitkDICOMITKSeriesGDCMReader.h:276
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
MITKDICOM_EXPORT
#define MITKDICOM_EXPORT
Definition: MitkDICOMExports.h:15
mitk::DICOMDatasetSorter
The sorting/splitting building-block of DICOMITKSeriesGDCMReader.
Definition: mitkDICOMDatasetSorter.h:41
mitk::DICOMITKSeriesGDCMReader::m_SimpleVolumeReading
bool m_SimpleVolumeReading
Definition: mitkDICOMITKSeriesGDCMReader.h:347
mitk::DICOMITKSeriesGDCMReader::ConstSorterList
const typedef std::list< DICOMDatasetSorter::ConstPointer > ConstSorterList
Definition: mitkDICOMITKSeriesGDCMReader.h:220