Medical Imaging Interaction Toolkit  2023.12.99-ed252ae7
Medical Imaging Interaction Toolkit
mitk::DICOMTagBasedSorter Class Reference

Sort DICOM datasets based on configurable tags. More...

#include <mitkDICOMTagBasedSorter.h>

Inheritance diagram for mitk::DICOMTagBasedSorter:
Collaboration diagram for mitk::DICOMTagBasedSorter:

Classes

class  CutDecimalPlaces
 Cuts a number after configured number of decimal places. An instance of this class can be used to avoid errors when comparing minimally different image orientations. More...
 
struct  ParameterizedDatasetSort
 Helper struct to feed into std::sort, configured via DICOMSortCriterion. More...
 
class  TagValueProcessor
 Processes tag values before they are compared. These classes could do some kind of normalization such as rounding, lower case formatting, etc. More...
 

Public Member Functions

 mitkClassMacro (DICOMTagBasedSorter, DICOMDatasetSorter)
 
void AddDistinguishingTag (const DICOMTag &, TagValueProcessor *tagValueProcessor=nullptr)
 Datasets that differ in given tag's value will be sorted into separate outputs. More...
 
DICOMTagList GetDistinguishingTags () const
 
const TagValueProcessorGetTagValueProcessorForDistinguishingTag (const DICOMTag &) const
 
void SetSortCriterion (DICOMSortCriterion::ConstPointer criterion)
 Define the sorting criterion (which holds seconardy criteria) More...
 
DICOMSortCriterion::ConstPointer GetSortCriterion () const
 
DICOMTagList GetTagsOfInterest () override
 A list of all the tags needed for processing (facilitates scanning). More...
 
void SetStrictSorting (bool strict)
 Whether or not groups should be checked for consecutive tag values. More...
 
bool GetStrictSorting () const
 
void SetExpectDistanceOne (bool strict)
 Flag for a special case in "strict sorting". Please see documentation of SetStrictSorting(). More...
 
bool GetExpectDistanceOne () const
 
void Sort () override
 Actually sort as described in the Detailed Description. More...
 
void PrintConfiguration (std::ostream &os, const std::string &indent="") const override
 Print configuration details into given stream. More...
 
bool operator== (const DICOMDatasetSorter &other) const override
 
- Public Member Functions inherited from mitk::DICOMDatasetSorter
 mitkClassMacroItkParent (DICOMDatasetSorter, itk::LightObject)
 
void SetInput (DICOMDatasetList filenames)
 Input for sorting. More...
 
const DICOMDatasetListGetInput () const
 Input for sorting. More...
 
unsigned int GetNumberOfOutputs () const
 Output of the sorting process. More...
 
const DICOMDatasetListGetOutput (unsigned int index) const
 Output of the sorting process. More...
 
DICOMDatasetListGetOutput (unsigned int index)
 Output of the sorting process. More...
 

Static Public Member Functions

static Pointer New ()
 
static bool GetDefaultStrictSorting ()
 
static bool GetDefaultExpectDistanceOne ()
 

Protected Types

typedef std::map< std::string, DICOMDatasetListGroupIDToListType
 
typedef std::map< const DICOMTag, TagValueProcessor * > TagValueProcessorMap
 

Protected Member Functions

 DICOMTagBasedSorter ()
 
 ~DICOMTagBasedSorter () override
 
 DICOMTagBasedSorter (const DICOMTagBasedSorter &other)
 
DICOMTagBasedSorteroperator= (const DICOMTagBasedSorter &other)
 
std::string BuildGroupID (DICOMDatasetAccess *dataset)
 Helper for SplitInputGroups(). More...
 
GroupIDToListType SplitInputGroups ()
 Implements the "distiguishing tags". To sort datasets into different groups, a long string will be built for each dataset. The string concatenates all tags and their respective values. Datasets that match in all values will end up with the same string. More...
 
GroupIDToListTypeSortGroups (GroupIDToListType &groups)
 Implements the sorting step. Relatively simple implementation thanks to std::sort and a parameterization via DICOMSortCriterion. More...
 
- Protected Member Functions inherited from mitk::DICOMDatasetSorter
 DICOMDatasetSorter ()
 
 ~DICOMDatasetSorter () override
 
 DICOMDatasetSorter (const DICOMDatasetSorter &other)
 
DICOMDatasetSorteroperator= (const DICOMDatasetSorter &other)
 
void ClearOutputs ()
 
void SetNumberOfOutputs (unsigned int numberOfOutputs)
 
void SetOutput (unsigned int index, const DICOMDatasetList &output)
 

Protected Attributes

DICOMTagList m_DistinguishingTags
 
TagValueProcessorMap m_TagValueProcessor
 
DICOMSortCriterion::ConstPointer m_SortCriterion
 
bool m_StrictSorting
 
bool m_ExpectDistanceOne
 

Static Protected Attributes

const static bool m_DefaultStrictSorting
 
const static bool m_DefaultExpectDistanceOne
 

Detailed Description

Sort DICOM datasets based on configurable tags.

This class implements sorting of input DICOM datasets into multiple outputs as described in Loading strategy.

The logic of sorting and splitting is most simple and most generic:

  1. Datasets will be put into different groups, if they differ in their value of specific tags (defined by AddDistinguishingTag())
    • there might be multiple distinguishing tags defined
    • tag values might be processed before comparison by means of TagValueProcessor (e.g. round to a number of decimal places)
  2. Each of the groups will be sorted by comparing their tag values using multiple DICOMSortCriterion

Definition at line 40 of file mitkDICOMTagBasedSorter.h.

Member Typedef Documentation

◆ GroupIDToListType

typedef std::map<std::string, DICOMDatasetList> mitk::DICOMTagBasedSorter::GroupIDToListType
protected

Definition at line 172 of file mitkDICOMTagBasedSorter.h.

◆ TagValueProcessorMap

Definition at line 188 of file mitkDICOMTagBasedSorter.h.

Constructor & Destructor Documentation

◆ DICOMTagBasedSorter() [1/2]

mitk::DICOMTagBasedSorter::DICOMTagBasedSorter ( )
protected

◆ ~DICOMTagBasedSorter()

mitk::DICOMTagBasedSorter::~DICOMTagBasedSorter ( )
overrideprotected

◆ DICOMTagBasedSorter() [2/2]

mitk::DICOMTagBasedSorter::DICOMTagBasedSorter ( const DICOMTagBasedSorter other)
protected

Member Function Documentation

◆ AddDistinguishingTag()

void mitk::DICOMTagBasedSorter::AddDistinguishingTag ( const DICOMTag ,
TagValueProcessor tagValueProcessor = nullptr 
)

Datasets that differ in given tag's value will be sorted into separate outputs.

◆ BuildGroupID()

std::string mitk::DICOMTagBasedSorter::BuildGroupID ( DICOMDatasetAccess dataset)
protected

Helper for SplitInputGroups().

◆ GetDefaultExpectDistanceOne()

static bool mitk::DICOMTagBasedSorter::GetDefaultExpectDistanceOne ( )
inlinestatic

Definition at line 143 of file mitkDICOMTagBasedSorter.h.

◆ GetDefaultStrictSorting()

static bool mitk::DICOMTagBasedSorter::GetDefaultStrictSorting ( )
inlinestatic

Definition at line 138 of file mitkDICOMTagBasedSorter.h.

◆ GetDistinguishingTags()

DICOMTagList mitk::DICOMTagBasedSorter::GetDistinguishingTags ( ) const

◆ GetExpectDistanceOne()

bool mitk::DICOMTagBasedSorter::GetExpectDistanceOne ( ) const

◆ GetSortCriterion()

DICOMSortCriterion::ConstPointer mitk::DICOMTagBasedSorter::GetSortCriterion ( ) const

◆ GetStrictSorting()

bool mitk::DICOMTagBasedSorter::GetStrictSorting ( ) const

◆ GetTagsOfInterest()

DICOMTagList mitk::DICOMTagBasedSorter::GetTagsOfInterest ( )
overridevirtual

A list of all the tags needed for processing (facilitates scanning).

Implements mitk::DICOMDatasetSorter.

◆ GetTagValueProcessorForDistinguishingTag()

const TagValueProcessor* mitk::DICOMTagBasedSorter::GetTagValueProcessorForDistinguishingTag ( const DICOMTag ) const

◆ mitkClassMacro()

mitk::DICOMTagBasedSorter::mitkClassMacro ( DICOMTagBasedSorter  ,
DICOMDatasetSorter   
)

◆ New()

static Pointer mitk::DICOMTagBasedSorter::New ( )
static

◆ operator=()

DICOMTagBasedSorter& mitk::DICOMTagBasedSorter::operator= ( const DICOMTagBasedSorter other)
protected

◆ operator==()

bool mitk::DICOMTagBasedSorter::operator== ( const DICOMDatasetSorter other) const
overridevirtual

◆ PrintConfiguration()

void mitk::DICOMTagBasedSorter::PrintConfiguration ( std::ostream &  os,
const std::string &  indent = "" 
) const
overridevirtual

Print configuration details into given stream.

Implements mitk::DICOMDatasetSorter.

◆ SetExpectDistanceOne()

void mitk::DICOMTagBasedSorter::SetExpectDistanceOne ( bool  strict)

Flag for a special case in "strict sorting". Please see documentation of SetStrictSorting().

See also
SetStrictSorting

◆ SetSortCriterion()

void mitk::DICOMTagBasedSorter::SetSortCriterion ( DICOMSortCriterion::ConstPointer  criterion)

Define the sorting criterion (which holds seconardy criteria)

◆ SetStrictSorting()

void mitk::DICOMTagBasedSorter::SetStrictSorting ( bool  strict)

Whether or not groups should be checked for consecutive tag values.

When this flag is set (default in constructor=off), the sorter will not only sort in a way that the values of a configured tag are ascending BUT in addition the sorter will enforce a constant numerical distance between values.

Having this flag is useful for handling of series with missing slices, e.g. Instance Numbers 1 2 3 5 6 7 8. With the flag set to true, the sorter would split this group into two, because the initial distance of 1 is not kept between Instance Numbers 3 and 5.

A special case of this behavior can be configured by SetExpectDistanceOne(). When this additional flag is set to true, the sorter will expect distance 1 exactly. This can help if the second slice is missing already. Without this additional flag, we would "learn" about a wrong distance of 2 (or similar) and then sort completely wrong.

◆ Sort()

void mitk::DICOMTagBasedSorter::Sort ( )
overridevirtual

Actually sort as described in the Detailed Description.

Implements mitk::DICOMDatasetSorter.

◆ SortGroups()

GroupIDToListType& mitk::DICOMTagBasedSorter::SortGroups ( GroupIDToListType groups)
protected

Implements the sorting step. Relatively simple implementation thanks to std::sort and a parameterization via DICOMSortCriterion.

◆ SplitInputGroups()

GroupIDToListType mitk::DICOMTagBasedSorter::SplitInputGroups ( )
protected

Implements the "distiguishing tags". To sort datasets into different groups, a long string will be built for each dataset. The string concatenates all tags and their respective values. Datasets that match in all values will end up with the same string.

Member Data Documentation

◆ m_DefaultExpectDistanceOne

const static bool mitk::DICOMTagBasedSorter::m_DefaultExpectDistanceOne
staticprotected

Definition at line 197 of file mitkDICOMTagBasedSorter.h.

◆ m_DefaultStrictSorting

const static bool mitk::DICOMTagBasedSorter::m_DefaultStrictSorting
staticprotected

Definition at line 196 of file mitkDICOMTagBasedSorter.h.

◆ m_DistinguishingTags

DICOMTagList mitk::DICOMTagBasedSorter::m_DistinguishingTags
protected

Definition at line 187 of file mitkDICOMTagBasedSorter.h.

◆ m_ExpectDistanceOne

bool mitk::DICOMTagBasedSorter::m_ExpectDistanceOne
protected

Definition at line 194 of file mitkDICOMTagBasedSorter.h.

◆ m_SortCriterion

DICOMSortCriterion::ConstPointer mitk::DICOMTagBasedSorter::m_SortCriterion
protected

Definition at line 191 of file mitkDICOMTagBasedSorter.h.

◆ m_StrictSorting

bool mitk::DICOMTagBasedSorter::m_StrictSorting
protected

Definition at line 193 of file mitkDICOMTagBasedSorter.h.

◆ m_TagValueProcessor

TagValueProcessorMap mitk::DICOMTagBasedSorter::m_TagValueProcessor
protected

Definition at line 189 of file mitkDICOMTagBasedSorter.h.


The documentation for this class was generated from the following file: