Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
Split inputs into blocks of equidistant slices (for use in DICOMITKSeriesGDCMReader). More...
#include <mitkEquiDistantBlocksSorter.h>
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 DICOMDatasetList & | GetInput () const |
Input for sorting. More... | |
unsigned int | GetNumberOfOutputs () const |
Output of the sorting process. More... | |
const DICOMDatasetList & | GetOutput (unsigned int index) const |
Output of the sorting process. More... | |
DICOMDatasetList & | GetOutput (unsigned int index) |
Output of the sorting process. More... | |
Protected Types | |
typedef std::vector< SliceGroupingAnalysisResult > | ResultsList |
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) | |
EquiDistantBlocksSorter & | operator= (const EquiDistantBlocksSorter &other) |
Protected Member Functions inherited from mitk::DICOMDatasetSorter | |
DICOMDatasetSorter () | |
virtual | ~DICOMDatasetSorter () |
DICOMDatasetSorter (const DICOMDatasetSorter &other) | |
DICOMDatasetSorter & | operator= (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 |
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.
|
protected |
Definition at line 203 of file mitkEquiDistantBlocksSorter.h.
|
protected |
Definition at line 122 of file mitkEquiDistantBlocksSorter.cpp.
|
protectedvirtual |
Definition at line 142 of file mitkEquiDistantBlocksSorter.cpp.
|
protected |
Definition at line 132 of file mitkEquiDistantBlocksSorter.cpp.
|
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.
|
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.
|
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 | |||
) |
|
protected |
Definition at line 216 of file mitkEquiDistantBlocksSorter.cpp.
References m_AcceptTilt, m_AcceptTwoSlicesGroups, m_ToleratedOriginOffset, m_ToleratedOriginOffsetIsAbsolute, and mitk::DICOMDatasetSorter::operator=().
|
overridevirtual |
Implements mitk::DICOMDatasetSorter.
Definition at line 148 of file mitkEquiDistantBlocksSorter.cpp.
References mitk::eps.
|
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.
|
overridevirtual |
Delegates work to AnalyzeFileForITKImageSeriesReaderSpacingAssumption(). AnalyzeFileForITKImageSeriesReaderSpacingAssumption() is called until it does not create multiple blocks anymore.
Implements mitk::DICOMDatasetSorter.
Definition at line 243 of file mitkEquiDistantBlocksSorter.cpp.
References mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::GetBlockDatasets(), mitk::EquiDistantBlocksSorter::SliceGroupingAnalysisResult::GetUnsortedDatasets(), and MITK_DEBUG.
|
protected |
Definition at line 201 of file mitkEquiDistantBlocksSorter.h.
Referenced by operator=().
|
protected |
Definition at line 209 of file mitkEquiDistantBlocksSorter.h.
Referenced by operator=().
|
protected |
Definition at line 204 of file mitkEquiDistantBlocksSorter.h.
|
protected |
Definition at line 206 of file mitkEquiDistantBlocksSorter.h.
Referenced by operator=().
|
protected |
Definition at line 207 of file mitkEquiDistantBlocksSorter.h.
Referenced by operator=().