Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
mitkDICOMTagBasedSorter.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 mitkDICOMTagBasedSorter_h
14 #define mitkDICOMTagBasedSorter_h
15 
16 #include "mitkDICOMDatasetSorter.h"
17 #include "mitkDICOMSortCriterion.h"
18 
19 namespace mitk
20 {
21 
41 {
42  public:
43 
49  {
50  public:
52  virtual std::string operator()(const std::string&) const = 0;
53  virtual TagValueProcessor* Clone() const = 0;
54  virtual ~TagValueProcessor() {}
55  };
56 
62  {
63  public:
64  CutDecimalPlaces(unsigned int precision);
65  CutDecimalPlaces(const CutDecimalPlaces& other);
66  unsigned int GetPrecision() const;
67  std::string operator()(const std::string&) const override;
68  TagValueProcessor* Clone() const override;
69  private:
70  unsigned int m_Precision;
71  };
72 
74 
75  itkNewMacro( DICOMTagBasedSorter );
76 
80  void AddDistinguishingTag( const DICOMTag&, TagValueProcessor* tagValueProcessor = nullptr );
81  DICOMTagList GetDistinguishingTags() const;
82  const TagValueProcessor* GetTagValueProcessorForDistinguishingTag(const DICOMTag&) const;
83 
87  void SetSortCriterion( DICOMSortCriterion::ConstPointer criterion );
88  DICOMSortCriterion::ConstPointer GetSortCriterion() const;
89 
93  DICOMTagList GetTagsOfInterest() override;
94 
114  void SetStrictSorting(bool strict);
115  bool GetStrictSorting() const;
116 
122  void SetExpectDistanceOne(bool strict);
123  bool GetExpectDistanceOne() const;
124 
125 
129  void Sort() override;
130 
134  void PrintConfiguration(std::ostream& os, const std::string& indent = "") const override;
135 
136  bool operator==(const DICOMDatasetSorter& other) const override;
137 
139  {
140  return m_DefaultStrictSorting;
141  }
142 
144  {
145  return m_DefaultExpectDistanceOne;
146  }
147 
148  protected:
149 
154  {
155  ParameterizedDatasetSort(DICOMSortCriterion::ConstPointer);
156  bool operator() (const mitk::DICOMDatasetAccess* left, const mitk::DICOMDatasetAccess* right);
157  DICOMSortCriterion::ConstPointer m_SortCriterion;
158  };
159 
160 
162  ~DICOMTagBasedSorter() override;
163 
165  DICOMTagBasedSorter& operator=(const DICOMTagBasedSorter& other);
166 
170  std::string BuildGroupID( DICOMDatasetAccess* dataset );
171 
172  using GroupIDToListType = std::map<std::string, DICOMDatasetList>;
173 
174  using SplitReasonListType = std::map<std::string, IOVolumeSplitReason::Pointer>;
175 
182  GroupIDToListType SplitInputGroups(SplitReasonListType& splitReasons);
183 
190  GroupIDToListType& SortGroups(GroupIDToListType& groups, SplitReasonListType& splitReasons);
191 
193  typedef std::map<const DICOMTag, TagValueProcessor*> TagValueProcessorMap;
195 
196  DICOMSortCriterion::ConstPointer m_SortCriterion;
197 
200 
201  const static bool m_DefaultStrictSorting = false;
202  const static bool m_DefaultExpectDistanceOne = false;
203 };
204 
205 }
206 
207 #endif
mitk::DICOMTagBasedSorter::GroupIDToListType
std::map< std::string, DICOMDatasetList > GroupIDToListType
Definition: mitkDICOMTagBasedSorter.h:172
mitk::DICOMDatasetAccess
Interface to datasets that is presented to sorting classes such as DICOMDatasetSorter.
Definition: mitkDICOMDatasetAccess.h:45
mitk::DICOMTagBasedSorter::m_TagValueProcessor
TagValueProcessorMap m_TagValueProcessor
Definition: mitkDICOMTagBasedSorter.h:194
mitk::DICOMTagBasedSorter::TagValueProcessor
Processes tag values before they are compared. These classes could do some kind of normalization such...
Definition: mitkDICOMTagBasedSorter.h:48
mitk::DICOMTagBasedSorter::CutDecimalPlaces
Cuts a number after configured number of decimal places. An instance of this class can be used to avo...
Definition: mitkDICOMTagBasedSorter.h:61
mitk::DICOMTagBasedSorter::m_SortCriterion
DICOMSortCriterion::ConstPointer m_SortCriterion
Definition: mitkDICOMTagBasedSorter.h:196
mitk::DICOMTagBasedSorter::GetDefaultStrictSorting
static bool GetDefaultStrictSorting()
Definition: mitkDICOMTagBasedSorter.h:138
mitk::DICOMTagBasedSorter::m_ExpectDistanceOne
bool m_ExpectDistanceOne
Definition: mitkDICOMTagBasedSorter.h:199
mitk::DICOMTag
Representation of a DICOM tag.
Definition: mitkDICOMTag.h:32
mitk::DICOMTagBasedSorter
Sort DICOM datasets based on configurable tags.
Definition: mitkDICOMTagBasedSorter.h:40
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::DICOMTagList
std::vector< DICOMTag > DICOMTagList
Definition: mitkDICOMTag.h:59
mitk::DICOMTagBasedSorter::m_DistinguishingTags
DICOMTagList m_DistinguishingTags
Definition: mitkDICOMTagBasedSorter.h:192
mitk::DICOMTagBasedSorter::m_StrictSorting
bool m_StrictSorting
Definition: mitkDICOMTagBasedSorter.h:198
mitk::operator==
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
mitk::DICOMTagBasedSorter::SplitReasonListType
std::map< std::string, IOVolumeSplitReason::Pointer > SplitReasonListType
Definition: mitkDICOMTagBasedSorter.h:174
mitk::DICOMTagBasedSorter::ParameterizedDatasetSort::m_SortCriterion
DICOMSortCriterion::ConstPointer m_SortCriterion
Definition: mitkDICOMTagBasedSorter.h:157
mitk::DICOMTagBasedSorter::GetDefaultExpectDistanceOne
static bool GetDefaultExpectDistanceOne()
Definition: mitkDICOMTagBasedSorter.h:143
mitkDICOMDatasetSorter.h
mitk::DICOMTagBasedSorter::ParameterizedDatasetSort
Helper struct to feed into std::sort, configured via DICOMSortCriterion.
Definition: mitkDICOMTagBasedSorter.h:153
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
MITKDICOM_EXPORT
#define MITKDICOM_EXPORT
Definition: MitkDICOMExports.h:15
mitkDICOMSortCriterion.h
mitk::DICOMDatasetSorter
The sorting/splitting building-block of DICOMITKSeriesGDCMReader.
Definition: mitkDICOMDatasetSorter.h:41
mitk::DICOMTagBasedSorter::TagValueProcessorMap
std::map< const DICOMTag, TagValueProcessor * > TagValueProcessorMap
Definition: mitkDICOMTagBasedSorter.h:193
mitk::DICOMTagBasedSorter::TagValueProcessor::~TagValueProcessor
virtual ~TagValueProcessor()
Definition: mitkDICOMTagBasedSorter.h:54