Medical Imaging Interaction Toolkit  2018.4.99-6a3ea89d
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:


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 uniqe 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 unprecise 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 ( )

◆ ~EquiDistantBlocksSorter()

mitk::EquiDistantBlocksSorter::~EquiDistantBlocksSorter ( )

Definition at line 140 of file mitkEquiDistantBlocksSorter.cpp.

References operator==().

Referenced by EquiDistantBlocksSorter().

◆ EquiDistantBlocksSorter() [2/2]

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

Definition at line 130 of file mitkEquiDistantBlocksSorter.cpp.

References ~EquiDistantBlocksSorter().

Member Function Documentation

◆ AnalyzeFileForITKImageSeriesReaderSpacingAssumption()

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

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)

Definition at line 335 of file mitkEquiDistantBlocksSorter.cpp.

References mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::AddFilesToUnsortedBlock(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::AddFileToSortedBlock(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::AddFileToUnsortedBlock(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::ContainsGantryTilt(), mitk::DICOMStringToOrientationVectors(), mitk::DICOMStringToPoint3D(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::FlagGantryTilt(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::GetBlockDatasets(), mitk::DICOMDatasetAccess::GetTagValueAsString(), mitk::GantryTiltInformation::IsRegularGantryTilt(), mitk::GantryTiltInformation::IsSheared(), m_AcceptTwoSlicesGroups, m_ToleratedOriginOffset, m_ToleratedOriginOffsetIsAbsolute, mitk::GantryTiltInformation::MakeFromTagValues(), MITK_DEBUG, mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::SetFirstFilenameOfBlock(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::SetLastFilenameOfBlock(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::UndoPrematureGrouping(), and mitk::DICOMDatasetFinding::value.

Referenced by ConstCharStarToString(), and Sort().

◆ ConstCharStarToString()

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

Safely convert const char* to std::string.

Definition at line 328 of file mitkEquiDistantBlocksSorter.cpp.

References AnalyzeFileForITKImageSeriesReaderSpacingAssumption().

Referenced by IsToleratedOriginOffsetAbsolute().

◆ GetAcceptTilt()

bool mitk::EquiDistantBlocksSorter::GetAcceptTilt ( ) const

Definition at line 192 of file mitkEquiDistantBlocksSorter.cpp.

References m_AcceptTilt, and SetAcceptTwoSlicesGroups().

Referenced by SetAcceptTilt().

◆ GetAcceptTwoSlicesGroups()

bool mitk::EquiDistantBlocksSorter::GetAcceptTwoSlicesGroups ( ) const

Definition at line 206 of file mitkEquiDistantBlocksSorter.cpp.

References m_AcceptTwoSlicesGroups, and operator=().

Referenced by SetAcceptTwoSlicesGroups().

◆ GetTagsOfInterest()

mitk::DICOMTagList mitk::EquiDistantBlocksSorter::GetTagsOfInterest ( )

Return the tags of interest (to facilitate scanning)

Implements mitk::DICOMDatasetSorter.

Definition at line 229 of file mitkEquiDistantBlocksSorter.cpp.

References Sort().

Referenced by operator=().

◆ GetToleratedOriginOffset()

double mitk::EquiDistantBlocksSorter::GetToleratedOriginOffset ( ) const

◆ IsToleratedOriginOffsetAbsolute()

bool mitk::EquiDistantBlocksSorter::IsToleratedOriginOffsetAbsolute ( ) const

◆ mitkClassMacro()

mitk::EquiDistantBlocksSorter::mitkClassMacro ( EquiDistantBlocksSorter  ,

◆ New()

static Pointer mitk::EquiDistantBlocksSorter::New ( )

◆ operator=()

◆ operator==()

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

◆ PrintConfiguration()

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

Print configuration details into stream.

Implements mitk::DICOMDatasetSorter.

Definition at line 163 of file mitkEquiDistantBlocksSorter.cpp.

References m_AcceptTilt, m_ToleratedOriginOffset, m_ToleratedOriginOffsetIsAbsolute, and SetAcceptTilt().

Referenced by operator==().

◆ SetAcceptTilt()

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

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

Definition at line 184 of file mitkEquiDistantBlocksSorter.cpp.

References GetAcceptTilt(), and m_AcceptTilt.

Referenced by PrintConfiguration().

◆ SetAcceptTwoSlicesGroups()

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

Definition at line 199 of file mitkEquiDistantBlocksSorter.cpp.

References GetAcceptTwoSlicesGroups(), and m_AcceptTwoSlicesGroups.

Referenced by GetAcceptTilt().

◆ 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..).

Definition at line 301 of file mitkEquiDistantBlocksSorter.cpp.

References GetToleratedOriginOffset(), m_ToleratedOriginOffset, m_ToleratedOriginOffsetIsAbsolute, and MITK_WARN.

Referenced by SetToleratedOriginOffsetToAdaptive().

◆ SetToleratedOriginOffsetToAdaptive()

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

◆ Sort()

Member Data Documentation

◆ m_AcceptTilt

bool mitk::EquiDistantBlocksSorter::m_AcceptTilt

◆ m_AcceptTwoSlicesGroups

bool mitk::EquiDistantBlocksSorter::m_AcceptTwoSlicesGroups

◆ m_SliceGroupingResults

ResultsList mitk::EquiDistantBlocksSorter::m_SliceGroupingResults

Definition at line 201 of file mitkEquiDistantBlocksSorter.h.

Referenced by Sort().

◆ m_ToleratedOriginOffset

◆ m_ToleratedOriginOffsetIsAbsolute

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