Medical Imaging Interaction Toolkit  2023.12.99-63768887
Medical Imaging Interaction Toolkit
mitk::EquiDistantBlocksSorter Class Reference

Split inputs into blocks of equidistant slices (for use in DICOMITKSeriesGDCMReader). More...

#include <mitkEquiDistantBlocksSorter.h>

Inheritance diagram for mitk::EquiDistantBlocksSorter:
Collaboration diagram for mitk::EquiDistantBlocksSorter:

Classes

class  SliceGroupingAnalysisResult
 Return type of AnalyzeFileForITKImageSeriesReaderSpacingAssumption(). More...
 

Public Member Functions

 mitkClassMacro (EquiDistantBlocksSorter, DICOMDatasetSorter)
 
DICOMTagList GetTagsOfInterest () override
 Return the tags of interest (to facilitate scanning) More...
 
void Sort () override
 Delegates work to AnalyzeFileForITKImageSeriesReaderSpacingAssumption(). AnalyzeFileForITKImageSeriesReaderSpacingAssumption() is called until it does not create multiple blocks anymore. More...
 
void SetAcceptTilt (bool accept)
 Whether or not to accept images from a tilted acquisition in a single output group. More...
 
bool GetAcceptTilt () const
 
void SetToleratedOriginOffsetToAdaptive (double fractionOfInterSliceDistanct=0.3)
 See class description and SetToleratedOriginOffset(). More...
 
void SetToleratedOriginOffset (double millimeters=0.005)
 See class description and SetToleratedOriginOffsetToAdaptive(). More...
 
double GetToleratedOriginOffset () const
 
bool IsToleratedOriginOffsetAbsolute () const
 
void SetAcceptTwoSlicesGroups (bool accept)
 
bool GetAcceptTwoSlicesGroups () const
 
void PrintConfiguration (std::ostream &os, const std::string &indent="") const override
 Print configuration details into 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 ()
 

Protected Types

typedef std::vector< SliceGroupingAnalysisResultResultsList
 

Protected Member Functions

SliceGroupingAnalysisResult AnalyzeFileForITKImageSeriesReaderSpacingAssumption (const DICOMDatasetList &files, bool groupsOfSimilarImages)
 Ensure an equal z-spacing for a group of files. More...
 
std::string ConstCharStarToString (const char *s)
 Safely convert const char* to std::string. More...
 
 EquiDistantBlocksSorter ()
 
 ~EquiDistantBlocksSorter () override
 
 EquiDistantBlocksSorter (const EquiDistantBlocksSorter &other)
 
EquiDistantBlocksSorteroperator= (const EquiDistantBlocksSorter &other)
 
- 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

bool m_AcceptTilt
 
ResultsList m_SliceGroupingResults
 
double m_ToleratedOriginOffset
 
bool m_ToleratedOriginOffsetIsAbsolute
 
bool m_AcceptTwoSlicesGroups
 

Detailed Description

Split inputs into blocks of equidistant slices (for use in DICOMITKSeriesGDCMReader).

Since inter-slice distance is not recorded in DICOM tags, we must ensure that blocks are made up of slices that have equal distances between neighboring slices. This is especially necessary because itk::ImageSeriesReader is later used for the actual loading, and this class expects (and does nocht verify) equal inter-slice distance (see Forced Configuration).

To achieve such grouping, the inter-slice distance is calculated from the first two different slice positions of a block. Following slices are added to a block as long as they can be added by adding the calculated inter-slice distance to the last slice of the block. Slices that do not fit into the expected distance pattern, are set aside for further analysis. This grouping is done until each file has been assigned to a group.

Slices that share a position in space are also sorted into separate blocks during this step. So the result of this step is a set of blocks that contain only slices with equal z spacing and unique slices at each position.

During sorting, the origins (documented in tag image position patient) are compared against expected origins (from former origin plus moving direction). As there will be minor differences in numbers (from both calculations and imprecise tag values), we must be a bit tolerant here. The default behavior is to expect that an origin is not further away from the expected position than 30% of the inter-slice distance. To support a legacy behavior of a former loader (DicomSeriesReader), this default can be restricted to a constant number of millimeters by calling SetToleratedOriginOffset(mm).

Detailed implementation in AnalyzeFileForITKImageSeriesReaderSpacingAssumption().

Definition at line 53 of file mitkEquiDistantBlocksSorter.h.

Member Typedef Documentation

◆ ResultsList

Constructor & Destructor Documentation

◆ EquiDistantBlocksSorter() [1/2]

mitk::EquiDistantBlocksSorter::EquiDistantBlocksSorter ( )
protected

◆ ~EquiDistantBlocksSorter()

mitk::EquiDistantBlocksSorter::~EquiDistantBlocksSorter ( )
overrideprotected

◆ EquiDistantBlocksSorter() [2/2]

mitk::EquiDistantBlocksSorter::EquiDistantBlocksSorter ( const EquiDistantBlocksSorter other)
protected

Member Function Documentation

◆ AnalyzeFileForITKImageSeriesReaderSpacingAssumption()

SliceGroupingAnalysisResult mitk::EquiDistantBlocksSorter::AnalyzeFileForITKImageSeriesReaderSpacingAssumption ( const DICOMDatasetList files,
bool  groupsOfSimilarImages 
)
protected

Ensure an equal z-spacing for a group of files.

Takes as input a number of images, which are all equally oriented and spatially sorted along their normal direction.

Internally used by GetSeries. Returns two lists: the first one contins slices of equal inter-slice spacing. The second list contains remaining files, which need to be run through AnalyzeFileForITKImageSeriesReaderSpacingAssumption again.

Relevant code that is matched here is in itkImageSeriesReader.txx (ImageSeriesReader<TOutputImage>::GenerateOutputInformation(void)), lines 176 to 245 (as of ITK 3.20)

◆ ConstCharStarToString()

std::string mitk::EquiDistantBlocksSorter::ConstCharStarToString ( const char *  s)
protected

Safely convert const char* to std::string.

◆ GetAcceptTilt()

bool mitk::EquiDistantBlocksSorter::GetAcceptTilt ( ) const

◆ GetAcceptTwoSlicesGroups()

bool mitk::EquiDistantBlocksSorter::GetAcceptTwoSlicesGroups ( ) const

◆ GetTagsOfInterest()

DICOMTagList mitk::EquiDistantBlocksSorter::GetTagsOfInterest ( )
overridevirtual

Return the tags of interest (to facilitate scanning)

Implements mitk::DICOMDatasetSorter.

◆ GetToleratedOriginOffset()

double mitk::EquiDistantBlocksSorter::GetToleratedOriginOffset ( ) const

◆ IsToleratedOriginOffsetAbsolute()

bool mitk::EquiDistantBlocksSorter::IsToleratedOriginOffsetAbsolute ( ) const

◆ mitkClassMacro()

mitk::EquiDistantBlocksSorter::mitkClassMacro ( EquiDistantBlocksSorter  ,
DICOMDatasetSorter   
)

◆ New()

static Pointer mitk::EquiDistantBlocksSorter::New ( )
static

◆ operator=()

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

◆ operator==()

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

◆ PrintConfiguration()

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

Print configuration details into stream.

Implements mitk::DICOMDatasetSorter.

◆ SetAcceptTilt()

void mitk::EquiDistantBlocksSorter::SetAcceptTilt ( bool  accept)

Whether or not to accept images from a tilted acquisition in a single output group.

◆ SetAcceptTwoSlicesGroups()

void mitk::EquiDistantBlocksSorter::SetAcceptTwoSlicesGroups ( bool  accept)

◆ SetToleratedOriginOffset()

void mitk::EquiDistantBlocksSorter::SetToleratedOriginOffset ( double  millimeters = 0.005)

See class description and SetToleratedOriginOffsetToAdaptive().

Default value of 0.005 is calculated so that we get a maximum of 1/10mm error when having a measurement crosses 20 slices in z direction (too strict? we don't know better..).

◆ SetToleratedOriginOffsetToAdaptive()

void mitk::EquiDistantBlocksSorter::SetToleratedOriginOffsetToAdaptive ( double  fractionOfInterSliceDistanct = 0.3)

See class description and SetToleratedOriginOffset().

◆ Sort()

void mitk::EquiDistantBlocksSorter::Sort ( )
overridevirtual

Delegates work to AnalyzeFileForITKImageSeriesReaderSpacingAssumption(). AnalyzeFileForITKImageSeriesReaderSpacingAssumption() is called until it does not create multiple blocks anymore.

Implements mitk::DICOMDatasetSorter.

Member Data Documentation

◆ m_AcceptTilt

bool mitk::EquiDistantBlocksSorter::m_AcceptTilt
protected

Definition at line 198 of file mitkEquiDistantBlocksSorter.h.

◆ m_AcceptTwoSlicesGroups

bool mitk::EquiDistantBlocksSorter::m_AcceptTwoSlicesGroups
protected

Definition at line 206 of file mitkEquiDistantBlocksSorter.h.

◆ m_SliceGroupingResults

ResultsList mitk::EquiDistantBlocksSorter::m_SliceGroupingResults
protected

Definition at line 201 of file mitkEquiDistantBlocksSorter.h.

◆ m_ToleratedOriginOffset

double mitk::EquiDistantBlocksSorter::m_ToleratedOriginOffset
protected

Definition at line 203 of file mitkEquiDistantBlocksSorter.h.

◆ m_ToleratedOriginOffsetIsAbsolute

bool mitk::EquiDistantBlocksSorter::m_ToleratedOriginOffsetIsAbsolute
protected

Definition at line 204 of file mitkEquiDistantBlocksSorter.h.


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