diff --git a/Modules/DICOMReader/TODOs.txt b/Modules/DICOMReader/TODOs.txt index a091613045..75370af496 100644 --- a/Modules/DICOMReader/TODOs.txt +++ b/Modules/DICOMReader/TODOs.txt @@ -1,36 +1,37 @@ Important [ ] ONLY load a pre-sorted list [ ] Either NRRD cache option or slice-by-slice loading [x] Performance of mitkdump / DICOMReaderSelector (TagCache?) - the note in GDCM..Reader::GetTagValue() is correct. This piece of code is taking lots of time. Approx. half of the time is tag scanning, the other half is construction of block describing properties, which accesses GetTagValue. [x] - maybe we can evaluate these properties in a lazy way (only when asked for). Solution: Yes, this helps, implemented. [x] Sorting by "Image Time" seems undeterministic (clarkson test data) [x] - Numeric conversion of "1.2.3.4" yields 1.2 on Windows, seems to fail on Linux(?) - need to verify that the whole string (except whitespace at the begin/end) was converted Solution: GetTagValue as String does a right-trim plus we check after conversion! Works. [x] Implement Configurator::GetBuiltIn3DReaders() (don't ignore "classic reader") [ ] Complete MITK properties of images: level/window and color type (MONOCHROME1/2) [ ] Check input images fo DICOMness and non-multi-frameness [ ] Use CanReadFile() in selection! -[ ] Check TODO in mitkDICOMTag.cpp +[x] Check TODO in mitkDICOMTag.cpp + - operator< for DICOMTag has been re-implemented in a readable and safer way. [ ] Configurable precision for tag value comparisons [x] Images are upside-down in some cases - error was hidden assumption somewhere: filenames for ImageSeriesReader need to be in an order that goes along the image normals, not in the opposite direction Questionable [ ] Fallback to filename instead of instance UID? Nice-to-have [ ] Multi-Frame images (DCMTK) [ ] ... diff --git a/Modules/DICOMReader/mitkDICOMTag.cpp b/Modules/DICOMReader/mitkDICOMTag.cpp index 4a54e4d58e..1fad5a5653 100644 --- a/Modules/DICOMReader/mitkDICOMTag.cpp +++ b/Modules/DICOMReader/mitkDICOMTag.cpp @@ -1,207 +1,211 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY { } without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDICOMTag.h" #include #include #include "mitkLogMacros.h" mitk::DICOMTag ::DICOMTag(unsigned int group, unsigned int element) :m_Group(group) ,m_Element(element) { } mitk::DICOMTag ::DICOMTag(const DICOMTag& other) :m_Group(other.m_Group) ,m_Element(other.m_Element) { } bool mitk::DICOMTag ::operator==(const DICOMTag& other) const { return m_Group == other.m_Group && m_Element == other.m_Element ; } mitk::DICOMTag& mitk::DICOMTag ::operator=(const DICOMTag& other) { if (this != &other) { m_Group = other.m_Group; m_Element = other.m_Element; } return *this; } unsigned int mitk::DICOMTag ::GetGroup() const { return m_Group; } unsigned int mitk::DICOMTag ::GetElement() const { return m_Element; } bool mitk::DICOMTag ::operator<(const DICOMTag& other) const { - // TODO check this comparison! - return this->m_Group * 0x3000 + this->m_Element < - other.m_Group * 0x3000 + other.m_Element; + return + ( this->m_Group < other.m_Group ) + || + ( ( this->m_Group == other.m_Group ) + && + ( this->m_Element < other.m_Element ) + ); } std::string mitk::DICOMTag ::GetName() const { gdcm::Tag t(m_Group, m_Element); const gdcm::Global& g = gdcm::Global::GetInstance(); // sum of all knowledge ! const gdcm::Dicts& dicts = g.GetDicts(); const gdcm::Dict& pub = dicts.GetPublicDict(); // Part 6 const gdcm::DictEntry& entry = pub.GetDictEntry(t); std::string name = entry.GetName(); if (name.empty()) { name = "Unknown Tag"; } return name; } std::string mitk::DICOMTag ::toHexString(unsigned int i) const { std::stringstream ss; ss << std::setfill ('0') << std::setw(4) << std::hex << i; return ss.str(); } void mitk::DICOMTag ::Print(std::ostream& os) const { os << "(" << toHexString(m_Group) << "," << toHexString(m_Element) << ") " << this->GetName(); } void mitk::DICOMStringToOrientationVectors(const std::string& s, Vector3D& right, Vector3D& up, bool& successful) { successful = true; std::istringstream orientationReader(s); std::string coordinate; unsigned int dim(0); while( std::getline( orientationReader, coordinate, '\\' ) && dim < 6 ) { if (dim<3) { right[dim++] = atof(coordinate.c_str()); } else { up[dim++ - 3] = atof(coordinate.c_str()); } } if (dim && dim != 6) { successful = false; } else if (dim == 0) { // fill with defaults right.Fill(0.0); right[0] = 1.0; up.Fill(0.0); up[1] = 1.0; successful = false; } } bool mitk::DICOMStringToSpacing(const std::string& s, ScalarType& spacingX, ScalarType& spacingY) { bool successful = false; std::istringstream spacingReader(s); std::string spacing; if ( std::getline( spacingReader, spacing, '\\' ) ) { spacingY = atof( spacing.c_str() ); if ( std::getline( spacingReader, spacing, '\\' ) ) { spacingX = atof( spacing.c_str() ); successful = true; } } return successful; } mitk::Point3D mitk::DICOMStringToPoint3D(const std::string& s, bool& successful) { Point3D p; successful = true; std::istringstream originReader(s); std::string coordinate; unsigned int dim(0); while( std::getline( originReader, coordinate, '\\' ) && dim < 3) { p[dim++]= atof(coordinate.c_str()); } if (dim && dim != 3) { successful = false; } else if (dim == 0) { successful = false; p.Fill(0.0); // assume default (0,0,0) } return p; }