Medical Imaging Interaction Toolkit  2016.11.0
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) static Pointer New()
 
virtual DICOMTagList GetTagsOfInterest () override
 
virtual 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
 
virtual void PrintConfiguration (std::ostream &os, const std::string &indent="") const override
 Print configuration details into stream. More...
 
virtual bool operator== (const DICOMDatasetSorter &other) const override
 
- Public Member Functions inherited from mitk::DICOMDatasetSorter
 mitkClassMacroItkParent (DICOMDatasetSorter, itk::LightObject) virtual DICOMTagList GetTagsOfInterest()=0
 Return the tags of interest (to facilitate scanning) More...
 
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...
 

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 ()
 
virtual ~EquiDistantBlocksSorter ()
 
 EquiDistantBlocksSorter (const EquiDistantBlocksSorter &other)
 
EquiDistantBlocksSorteroperator= (const EquiDistantBlocksSorter &other)
 
- Protected Member Functions inherited from mitk::DICOMDatasetSorter
 DICOMDatasetSorter ()
 
virtual ~DICOMDatasetSorter ()
 
 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 57 of file mitkEquiDistantBlocksSorter.h.

Member Typedef Documentation

Constructor & Destructor Documentation

mitk::EquiDistantBlocksSorter::EquiDistantBlocksSorter ( )
protected

Definition at line 122 of file mitkEquiDistantBlocksSorter.cpp.

mitk::EquiDistantBlocksSorter::~EquiDistantBlocksSorter ( )
protectedvirtual

Definition at line 142 of file mitkEquiDistantBlocksSorter.cpp.

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

Definition at line 132 of file mitkEquiDistantBlocksSorter.cpp.

Member Function Documentation

mitk::EquiDistantBlocksSorter::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)

Definition at line 337 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(), mitk::GantryTiltInformation::MakeFromTagValues(), MITK_DEBUG, mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::SetFirstFilenameOfBlock(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::SetLastFilenameOfBlock(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::UndoPrematureGrouping(), and mitk::DICOMDatasetFinding::value.

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

Safely convert const char* to std::string.

Definition at line 330 of file mitkEquiDistantBlocksSorter.cpp.

bool mitk::EquiDistantBlocksSorter::GetAcceptTilt ( ) const

Definition at line 194 of file mitkEquiDistantBlocksSorter.cpp.

bool mitk::EquiDistantBlocksSorter::GetAcceptTwoSlicesGroups ( ) const

Definition at line 208 of file mitkEquiDistantBlocksSorter.cpp.

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

Definition at line 231 of file mitkEquiDistantBlocksSorter.cpp.

double mitk::EquiDistantBlocksSorter::GetToleratedOriginOffset ( ) const

Definition at line 315 of file mitkEquiDistantBlocksSorter.cpp.

bool mitk::EquiDistantBlocksSorter::IsToleratedOriginOffsetAbsolute ( ) const

Definition at line 322 of file mitkEquiDistantBlocksSorter.cpp.

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

Implements mitk::DICOMDatasetSorter.

Definition at line 148 of file mitkEquiDistantBlocksSorter.cpp.

References mitk::eps.

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

Print configuration details into stream.

Implements mitk::DICOMDatasetSorter.

Definition at line 165 of file mitkEquiDistantBlocksSorter.cpp.

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

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

Definition at line 186 of file mitkEquiDistantBlocksSorter.cpp.

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

Definition at line 201 of file mitkEquiDistantBlocksSorter.cpp.

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 303 of file mitkEquiDistantBlocksSorter.cpp.

References MITK_WARN.

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

See class description and SetToleratedOriginOffset().

Definition at line 285 of file mitkEquiDistantBlocksSorter.cpp.

References MITK_WARN.

Member Data Documentation

bool mitk::EquiDistantBlocksSorter::m_AcceptTilt
protected

Definition at line 201 of file mitkEquiDistantBlocksSorter.h.

Referenced by operator=().

bool mitk::EquiDistantBlocksSorter::m_AcceptTwoSlicesGroups
protected

Definition at line 209 of file mitkEquiDistantBlocksSorter.h.

Referenced by operator=().

ResultsList mitk::EquiDistantBlocksSorter::m_SliceGroupingResults
protected

Definition at line 204 of file mitkEquiDistantBlocksSorter.h.

double mitk::EquiDistantBlocksSorter::m_ToleratedOriginOffset
protected

Definition at line 206 of file mitkEquiDistantBlocksSorter.h.

Referenced by operator=().

bool mitk::EquiDistantBlocksSorter::m_ToleratedOriginOffsetIsAbsolute
protected

Definition at line 207 of file mitkEquiDistantBlocksSorter.h.

Referenced by operator=().


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