Medical Imaging Interaction Toolkit  2025.12.02
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);
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 );
83 
87  void SetSortCriterion( DICOMSortCriterion::ConstPointer criterion );
88  DICOMSortCriterion::ConstPointer GetSortCriterion() const;
89 
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 
163 
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 
183 
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
#define MITKDICOM_EXPORT
Interface to datasets that is presented to sorting classes such as DICOMDatasetSorter.
The sorting/splitting building-block of DICOMITKSeriesGDCMReader.
Cuts a number after configured number of decimal places. An instance of this class can be used to avo...
std::string operator()(const std::string &) const override
Implements the "processing".
TagValueProcessor * Clone() const override
CutDecimalPlaces(const CutDecimalPlaces &other)
Processes tag values before they are compared. These classes could do some kind of normalization such...
virtual TagValueProcessor * Clone() const =0
virtual std::string operator()(const std::string &) const =0
Implements the "processing".
Sort DICOM datasets based on configurable tags.
void PrintConfiguration(std::ostream &os, const std::string &indent="") const override
Print configuration details into given stream.
bool GetExpectDistanceOne() const
void SetStrictSorting(bool strict)
Whether or not groups should be checked for consecutive tag values.
DICOMTagList GetTagsOfInterest() override
A list of all the tags needed for processing (facilitates scanning).
void SetExpectDistanceOne(bool strict)
Flag for a special case in "strict sorting". Please see documentation of SetStrictSorting().
std::string BuildGroupID(DICOMDatasetAccess *dataset)
Helper for SplitInputGroups().
GroupIDToListType & SortGroups(GroupIDToListType &groups, SplitReasonListType &splitReasons)
Implements the sorting step. Relatively simple implementation thanks to std::sort and a parameterizat...
void SetSortCriterion(DICOMSortCriterion::ConstPointer criterion)
Define the sorting criterion (which holds seconardy criteria)
std::map< std::string, IOVolumeSplitReason::Pointer > SplitReasonListType
DICOMTagBasedSorter & operator=(const DICOMTagBasedSorter &other)
mitkClassMacro(DICOMTagBasedSorter, DICOMDatasetSorter)
std::map< const DICOMTag, TagValueProcessor * > TagValueProcessorMap
bool operator==(const DICOMDatasetSorter &other) const override
TagValueProcessorMap m_TagValueProcessor
DICOMSortCriterion::ConstPointer GetSortCriterion() const
GroupIDToListType SplitInputGroups(SplitReasonListType &splitReasons)
Implements the "distiguishing tags". To sort datasets into different groups, a long string will be bu...
void Sort() override
Actually sort as described in the Detailed Description.
void AddDistinguishingTag(const DICOMTag &, TagValueProcessor *tagValueProcessor=nullptr)
Datasets that differ in given tag's value will be sorted into separate outputs.
const TagValueProcessor * GetTagValueProcessorForDistinguishingTag(const DICOMTag &) const
DICOMSortCriterion::ConstPointer m_SortCriterion
std::map< std::string, DICOMDatasetList > GroupIDToListType
DICOMTagList GetDistinguishingTags() const
bool GetStrictSorting() const
DICOMTagBasedSorter(const DICOMTagBasedSorter &other)
Representation of a DICOM tag.
Definition: mitkDICOMTag.h:33
Find image slices visible on a given plane.
std::vector< DICOMTag > DICOMTagList
Definition: mitkDICOMTag.h:59
Helper struct to feed into std::sort, configured via DICOMSortCriterion.
ParameterizedDatasetSort(DICOMSortCriterion::ConstPointer)