diff --git a/Modules/DCMTesting/CMakeLists.txt b/Modules/DCMTesting/CMakeLists.txt deleted file mode 100644 index 586ee6f18f..0000000000 --- a/Modules/DCMTesting/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# -# IMPORTANT NOTE: -# -# This module is a testing module for the DicomSeriesReader class, -# which is meant to be replaced by the Module DCMReader. -# To have the "old" code tested before it is removed, we still -# keep this DCMTesting module. -# -# Note that the DICOMTesting module is practically a copy of -# this DCMTesting module, doing the same kind of testing, just -# for the new readers instead of DicomSeriesReader. -# - -if(BUILD_TESTING) -if(GDCM_DIR) - -# clear variables from prior files.cmake -# Else CMake would use the content of these variables and would try to create tests (which are not present in DCMTesting). -#set(MODULE_TESTS) -#set(MODULE_IMAGE_TESTS) -#set(MODULE_SURFACE_TESTS) -#set(MODULE_TESTIMAGE) -#set(MODULE_TESTSURFACE) -#set(MODULE_CUSTOM_TESTS) -#set(H_FILES) -#set(CPP_FILES) - -# now create a new module only for testing purposes -MITK_CREATE_MODULE( - DEPENDS MitkCore # Mitk.so -) - -if(TARGET ${MODULE_NAME}) - # add helpful applications - include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - - # dumps out image information - add_executable(DumpDCMMitkImage src/DumpDCMMitkImage.cpp) - target_link_libraries(DumpDCMMitkImage ${MODULE_NAME}) - - # compares dumped out image information against reference dump - add_executable(VerifyDCMMitkImageDump src/VerifyDCMMitkImageDump.cpp) - target_link_libraries(VerifyDCMMitkImageDump ${MODULE_NAME}) - - add_subdirectory(test) -endif() - -endif() -endif() diff --git a/Modules/DCMTesting/files.cmake b/Modules/DCMTesting/files.cmake deleted file mode 100644 index bdf6f2947c..0000000000 --- a/Modules/DCMTesting/files.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(H_FILES - include/mitkTestDCMLoading.h -) - -set(CPP_FILES - mitkTestDCMLoading.cpp -) diff --git a/Modules/DCMTesting/include/mitkTestDCMLoading.h b/Modules/DCMTesting/include/mitkTestDCMLoading.h deleted file mode 100644 index c17abbadf8..0000000000 --- a/Modules/DCMTesting/include/mitkTestDCMLoading.h +++ /dev/null @@ -1,94 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ -#ifndef mitkTestDCMLoading_h -#define mitkTestDCMLoading_h - -#include "mitkDicomSeriesReader.h" - -#include "MitkDCMTestingExports.h" - -namespace mitk -{ - class Image; - - class MITKDCMTESTING_EXPORT TestDCMLoading - { - public: - typedef DicomSeriesReader::StringContainer StringContainer; - typedef std::list NodeList; - typedef std::list> ImageList; - - TestDCMLoading(); - - ImageList LoadFiles(const StringContainer &files, itk::SmartPointer preLoadedVolume = nullptr); - - /** - \brief Dump relevant image information for later comparison. - \sa CompareImageInformationDumps - */ - std::string DumpImageInformation(const Image *image); - - /** - \brief Compare two image information dumps. - \return true, if dumps are sufficiently equal (see parameters) - \sa DumpImageInformation - */ - bool CompareImageInformationDumps(const std::string &reference, const std::string &test); - - private: - typedef std::map KeyValueMap; - - void SetDefaultLocale(); - - void ResetUserLocale(); - - std::string ComponentTypeToString(int type); - - KeyValueMap ParseDump(const std::string &dump); - - bool CompareSpacedValueFields(const std::string &reference, const std::string &test, double eps = mitk::eps); - - /** - Compress whitespace in string - \param pString input string - \param pFill replacement whitespace (only whitespace in string after reduction) - \param pWhitespace characters handled as whitespace - */ - std::string reduce(const std::string &pString, - const std::string &pFill = " ", - const std::string &pWhitespace = " \t"); - - /** - Remove leading and trailing whitespace - \param pString input string - \param pWhitespace characters handled as whitespace - */ - std::string trim(const std::string &pString, const std::string &pWhitespace = " \t"); - - template - bool StringToNumber(const std::string &s, T &value) - { - std::stringstream stream(s); - stream >> value; - return (!stream.fail()) && (fabs(value) < std::numeric_limits::max()); - } - - const char *m_PreviousCLocale; - std::locale m_PreviousCppLocale; - }; -} - -#endif diff --git a/Modules/DCMTesting/src/DumpDCMMitkImage.cpp b/Modules/DCMTesting/src/DumpDCMMitkImage.cpp deleted file mode 100644 index 95d4956ab2..0000000000 --- a/Modules/DCMTesting/src/DumpDCMMitkImage.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*=================================================================== - -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 "mitkTestDCMLoading.h" - -#include "mitkImage.h" - -int main(int argc, char **argv) -{ - mitk::TestDCMLoading loader; - mitk::TestDCMLoading::StringContainer files; - - for (int arg = 1; arg < argc; ++arg) - files.push_back(argv[arg]); - - mitk::TestDCMLoading::ImageList images = loader.LoadFiles(files); - - // combine individual dumps in a way that VerifyDCMMitkImageDump is able to separate again. - // I.e.: when changing this piece of code, always change VerifyDCMMitkImageDump, too. - unsigned int imageCounter(0); - for (mitk::TestDCMLoading::ImageList::const_iterator imageIter = images.begin(); imageIter != images.end(); - ++imageIter) - { - std::cout << "-- Image " << ++imageCounter << "\n"; - std::cout << loader.DumpImageInformation(*imageIter) << "\n"; - } -} diff --git a/Modules/DCMTesting/src/VerifyDCMMitkImageDump.cpp b/Modules/DCMTesting/src/VerifyDCMMitkImageDump.cpp deleted file mode 100644 index f1b7b052c2..0000000000 --- a/Modules/DCMTesting/src/VerifyDCMMitkImageDump.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*=================================================================== - -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 "mitkTestDCMLoading.h" - -#include "mitkImage.h" - -std::vector LoadDumps(const std::string &fileName) -{ - std::vector separatedDumps; - - std::ifstream fileStream(fileName.c_str()); - - std::string buffer; - std::string line; - while (fileStream) - { - std::getline(fileStream, line); - - if (line.find("-- Image ") == 0) - { - // separator: starts a new image block - if (!buffer.empty()) - { - // unless this is the first block - separatedDumps.push_back(buffer); - buffer.clear(); - } - } - else - { - buffer += line + "\n"; - } - } - fileStream.close(); - - // eat last image dump - if (!buffer.empty()) - { - separatedDumps.push_back(buffer); - buffer.clear(); - } - - return separatedDumps; -} - -int main(int argc, char **argv) -{ - /** - Loads a list of DCM images, compares generated mitk::Images against stored references. - - first argument: file with reference dumps - following arguments: file names to load - */ - - if (argc < 2) - { - MITK_ERROR << "Usage:"; - MITK_ERROR << " " << argv[0] << " reference.dump file1 [file2 .. fileN]"; - MITK_ERROR << " "; - MITK_ERROR << " Loads all DCM images in file1 to fileN as MITK images "; - MITK_ERROR << " and compares loaded images against stored expectations (dumps)."; - MITK_ERROR << " See also DumpDCMMitkImage (generates dumps)"; - return EXIT_FAILURE; - } - - mitk::TestDCMLoading loader; - mitk::TestDCMLoading::StringContainer files; - - // TODO load reference dumps - - // load from argv[1] - // separate at "-- Image n" - // store in an array of dumps - - std::vector expectedDumps = LoadDumps(argv[1]); - - for (int arg = 2; arg < argc; ++arg) - files.push_back(argv[arg]); - - mitk::TestDCMLoading::ImageList images = loader.LoadFiles(files); - - unsigned int imageCounter(0); - for (mitk::TestDCMLoading::ImageList::const_iterator imageIter = images.begin(); imageIter != images.end(); - ++imageIter, ++imageCounter) - { - std::string imageDump = loader.DumpImageInformation(*imageIter); - - if (imageCounter >= expectedDumps.size()) - { - MITK_ERROR << "Loader produces more images than expected. Aborting after image " << (imageCounter - 1); - MITK_INFO << "Image " << imageCounter << " loaded as:\n" << imageDump; - return EXIT_FAILURE; - } - - bool loadedAsExpected = loader.CompareImageInformationDumps(expectedDumps[imageCounter], imageDump); - if (loadedAsExpected) - { - MITK_INFO << "Image " << imageCounter << " loads as expected."; - } - else - { - MITK_ERROR << "Image " << imageCounter << " did not load as expected."; - MITK_INFO << "Expected: \n" << expectedDumps[imageCounter] << "\nGot:\n" << imageDump; - return EXIT_FAILURE; - } - } - - return EXIT_SUCCESS; -} diff --git a/Modules/DCMTesting/src/mitkTestDCMLoading.cpp b/Modules/DCMTesting/src/mitkTestDCMLoading.cpp deleted file mode 100644 index bce7a7033c..0000000000 --- a/Modules/DCMTesting/src/mitkTestDCMLoading.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ -//#define MBILOG_ENABLE_DEBUG - -#include - -#include "mitkImage.h" -#include "mitkTestDCMLoading.h" -#include - -mitk::TestDCMLoading::TestDCMLoading() : m_PreviousCLocale(nullptr) -{ -} - -void mitk::TestDCMLoading::SetDefaultLocale() -{ - // remember old locale only once - if (m_PreviousCLocale == nullptr) - { - m_PreviousCLocale = setlocale(LC_NUMERIC, nullptr); - - // set to "C" - setlocale(LC_NUMERIC, "C"); - - m_PreviousCppLocale = std::cin.getloc(); - - std::locale l("C"); - std::cin.imbue(l); - std::cout.imbue(l); - } -} - -void mitk::TestDCMLoading::ResetUserLocale() -{ - if (m_PreviousCLocale) - { - setlocale(LC_NUMERIC, m_PreviousCLocale); - - std::cin.imbue(m_PreviousCppLocale); - std::cout.imbue(m_PreviousCppLocale); - - m_PreviousCLocale = nullptr; - } -} - -mitk::TestDCMLoading::ImageList mitk::TestDCMLoading::LoadFiles(const StringContainer &files, - itk::SmartPointer preLoadedVolume) -{ - for (auto iter = files.begin(); iter != files.end(); ++iter) - { - MITK_DEBUG << "File " << *iter; - } - - ImageList result; - - DicomSeriesReader::FileNamesGrouping seriesInFiles = DicomSeriesReader::GetSeries(files, true); - - // TODO sort series UIDs, implementation of map iterator might differ on different platforms (or verify this is a - // standard topic??) - for (DicomSeriesReader::FileNamesGrouping::const_iterator seriesIter = seriesInFiles.begin(); - seriesIter != seriesInFiles.end(); - ++seriesIter) - { - StringContainer files = seriesIter->second.GetFilenames(); - - DataNode::Pointer node = DicomSeriesReader::LoadDicomSeries( - files, true, true, true, nullptr, preLoadedVolume); // true, true, true ist just a copy of the default values - - if (node.IsNotNull()) - { - Image::Pointer image = dynamic_cast(node->GetData()); - - result.push_back(image); - } - else - { - } - } - - return result; -} - -std::string mitk::TestDCMLoading::ComponentTypeToString(int type) -{ - if (type == itk::ImageIOBase::UCHAR) - return "UCHAR"; - else if (type == itk::ImageIOBase::CHAR) - return "CHAR"; - else if (type == itk::ImageIOBase::USHORT) - return "USHORT"; - else if (type == itk::ImageIOBase::SHORT) - return "SHORT"; - else if (type == itk::ImageIOBase::UINT) - return "UINT"; - else if (type == itk::ImageIOBase::INT) - return "INT"; - else if (type == itk::ImageIOBase::ULONG) - return "ULONG"; - else if (type == itk::ImageIOBase::LONG) - return "LONG"; - else if (type == itk::ImageIOBase::FLOAT) - return "FLOAT"; - else if (type == itk::ImageIOBase::DOUBLE) - return "DOUBLE"; - else - return "UNKNOWN"; -} - -// add a line to stringstream result (see DumpImageInformation -#define DumpLine(field, data) DumpILine(0, field, data) - -// add an indented(!) line to stringstream result (see DumpImageInformation -#define DumpILine(indent, field, data) \ - \ -{ \ - std::string DumpLine_INDENT; \ - DumpLine_INDENT.resize(indent, ' '); \ - result << DumpLine_INDENT << field << ": " << data << "\n"; \ - \ -} - -std::string mitk::TestDCMLoading::DumpImageInformation(const Image *image) -{ - std::stringstream result; - - if (image == nullptr) - return result.str(); - - SetDefaultLocale(); - - // basic image data - DumpLine("Pixeltype", ComponentTypeToString(image->GetPixelType().GetComponentType())); - DumpLine("BitsPerPixel", image->GetPixelType().GetBpe()); - DumpLine("Dimension", image->GetDimension()); - - result << "Dimensions: "; - for (unsigned int dim = 0; dim < image->GetDimension(); ++dim) - result << image->GetDimension(dim) << " "; - result << "\n"; - - // geometry data - result << "Geometry: \n"; - BaseGeometry *geometry = image->GetGeometry(); - if (geometry) - { - AffineTransform3D *transform = geometry->GetIndexToWorldTransform(); - if (transform) - { - result << " " - << "Matrix: "; - const AffineTransform3D::MatrixType &matrix = transform->GetMatrix(); - for (unsigned int i = 0; i < 3; ++i) - for (unsigned int j = 0; j < 3; ++j) - result << matrix[i][j] << " "; - result << "\n"; - - result << " " - << "Offset: "; - const AffineTransform3D::OutputVectorType &offset = transform->GetOffset(); - for (unsigned int i = 0; i < 3; ++i) - result << offset[i] << " "; - result << "\n"; - - result << " " - << "Center: "; - const AffineTransform3D::InputPointType ¢er = transform->GetCenter(); - for (unsigned int i = 0; i < 3; ++i) - result << center[i] << " "; - result << "\n"; - - result << " " - << "Translation: "; - const AffineTransform3D::OutputVectorType &translation = transform->GetTranslation(); - for (unsigned int i = 0; i < 3; ++i) - result << translation[i] << " "; - result << "\n"; - - result << " " - << "Scale: "; - const double *scale = transform->GetScale(); - for (unsigned int i = 0; i < 3; ++i) - result << scale[i] << " "; - result << "\n"; - - result << " " - << "Origin: "; - const Point3D &origin = geometry->GetOrigin(); - for (unsigned int i = 0; i < 3; ++i) - result << origin[i] << " "; - result << "\n"; - - result << " " - << "Spacing: "; - const Vector3D &spacing = geometry->GetSpacing(); - for (unsigned int i = 0; i < 3; ++i) - result << spacing[i] << " "; - result << "\n"; - - result << " " - << "TimeBounds: "; - const TimeBounds timeBounds = image->GetTimeGeometry()->GetTimeBounds(); - for (unsigned int i = 0; i < 2; ++i) - result << timeBounds[i] << " "; - result << "\n"; - } - } - - ResetUserLocale(); - - return result.str(); -} - -std::string mitk::TestDCMLoading::trim(const std::string &pString, const std::string &pWhitespace) -{ - const size_t beginStr = pString.find_first_not_of(pWhitespace); - if (beginStr == std::string::npos) - { - // no content - return ""; - } - - const size_t endStr = pString.find_last_not_of(pWhitespace); - const size_t range = endStr - beginStr + 1; - - return pString.substr(beginStr, range); -} - -std::string mitk::TestDCMLoading::reduce(const std::string &pString, - const std::string &pFill, - const std::string &pWhitespace) -{ - // trim first - std::string result(trim(pString, pWhitespace)); - - // replace sub ranges - size_t beginSpace = result.find_first_of(pWhitespace); - while (beginSpace != std::string::npos) - { - const size_t endSpace = result.find_first_not_of(pWhitespace, beginSpace); - const size_t range = endSpace - beginSpace; - - result.replace(beginSpace, range, pFill); - - const size_t newStart = beginSpace + pFill.length(); - beginSpace = result.find_first_of(pWhitespace, newStart); - } - - return result; -} - -bool mitk::TestDCMLoading::CompareSpacedValueFields(const std::string &reference, - const std::string &test, - double /*eps*/) -{ - bool result(true); - - // tokenize string, compare each token, if possible by float comparison - std::stringstream referenceStream(reduce(reference)); - std::stringstream testStream(reduce(test)); - - std::string refToken; - std::string testToken; - while (std::getline(referenceStream, refToken, ' ') && std::getline(testStream, testToken, ' ')) - { - float refNumber; - float testNumber; - if (this->StringToNumber(refToken, refNumber)) - { - if (this->StringToNumber(testToken, testNumber)) - { - // print-out compared tokens if DEBUG output allowed - MITK_DEBUG << "Reference Token '" << refToken << "'" - << " value " << refNumber << ", test Token '" << testToken << "'" - << " value " << testNumber; - - bool old_result = result; - - result &= (fabs(refNumber - testNumber) < 0.0001 /*mitk::eps*/); - // log the token/number which causes the test to fail - if (old_result != result) - { - MITK_ERROR << std::setprecision(16) << "Reference Token '" << refToken << "'" - << " value " << refNumber << ", test Token '" << testToken << "'" - << " value " << testNumber; - - MITK_ERROR << "[FALSE] - difference: " << std::setprecision(16) << fabs(refNumber - testNumber) - << " EPS: " << 0.0001; // mitk::eps; - } - } - else - { - MITK_ERROR << refNumber << " cannot be compared to '" << testToken << "'"; - } - } - else - { - MITK_DEBUG << "Token '" << refToken << "'" - << " handled as string"; - result &= refToken == testToken; - } - } - - if (std::getline(referenceStream, refToken, ' ')) - { - MITK_ERROR << "Reference string still had values when test string was already parsed: ref '" << reference - << "', test '" << test << "'"; - result = false; - } - else if (std::getline(testStream, testToken, ' ')) - { - MITK_ERROR << "Test string still had values when reference string was already parsed: ref '" << reference - << "', test '" << test << "'"; - result = false; - } - - return result; -} - -bool mitk::TestDCMLoading::CompareImageInformationDumps(const std::string &referenceDump, const std::string &testDump) -{ - KeyValueMap reference = ParseDump(referenceDump); - KeyValueMap test = ParseDump(testDump); - - bool testResult(true); - - // verify all expected values - for (KeyValueMap::const_iterator refIter = reference.begin(); refIter != reference.end(); ++refIter) - { - const std::string &refKey = refIter->first; - const std::string &refValue = refIter->second; - - if (test.find(refKey) != test.end()) - { - const std::string &testValue = test[refKey]; - - bool thisTestResult = CompareSpacedValueFields(refValue, testValue); - testResult &= thisTestResult; - - MITK_DEBUG << refKey << ": '" << refValue << "' == '" << testValue << "' ? " << (thisTestResult ? "YES" : "NO"); - } - else - { - MITK_ERROR << "Reference dump contains a key'" << refKey << "' (value '" << refValue << "')."; - MITK_ERROR << "This key is expected to be generated for tests (but was not). Most probably you need to update " - "your test data."; - return false; - } - } - - // now check test dump does not contain any additional keys - for (KeyValueMap::const_iterator testIter = test.begin(); testIter != test.end(); ++testIter) - { - const std::string &key = testIter->first; - const std::string &value = testIter->second; - - if (reference.find(key) == reference.end()) - { - MITK_ERROR << "Test dump contains an unexpected key'" << key << "' (value '" << value << "')."; - MITK_ERROR << "This key is not expected. Most probably you need to update your test data."; - return false; - } - } - - return testResult; -} - -mitk::TestDCMLoading::KeyValueMap mitk::TestDCMLoading::ParseDump(const std::string &dump) -{ - KeyValueMap parsedResult; - - std::string shredder(dump); - - std::stack surroundingKeys; - - std::stack expectedIndents; - expectedIndents.push(0); - - while (true) - { - std::string::size_type newLinePos = shredder.find('\n'); - if (newLinePos == std::string::npos || newLinePos == 0) - break; - - std::string line = shredder.substr(0, newLinePos); - shredder = shredder.erase(0, newLinePos + 1); - - std::string::size_type keyPosition = line.find_first_not_of(' '); - std::string::size_type colonPosition = line.find(':'); - - std::string key = line.substr(keyPosition, colonPosition - keyPosition); - std::string::size_type firstSpacePosition = key.find_first_of(" "); - if (firstSpacePosition != std::string::npos) - { - key.erase(firstSpacePosition); - } - - if (keyPosition > expectedIndents.top()) - { - // more indent than before - expectedIndents.push(keyPosition); - } - else if (keyPosition == expectedIndents.top()) - { - if (!surroundingKeys.empty()) - { - surroundingKeys.pop(); // last of same length - } - } - else - { - // less indent than before - do - expectedIndents.pop(); - while (expectedIndents.top() != keyPosition); // unwind until current indent is found - } - - if (!surroundingKeys.empty()) - { - key = surroundingKeys.top() + "." + key; // construct current key name - } - - surroundingKeys.push(key); // this is the new embracing key - - std::string value = line.substr(colonPosition + 1); - - MITK_DEBUG << " Key: '" << key << "' value '" << value << "'"; - - parsedResult[key] = value; // store parsing result - } - - return parsedResult; -} diff --git a/Modules/DCMTesting/test/CMakeLists.txt b/Modules/DCMTesting/test/CMakeLists.txt deleted file mode 100644 index 06d357e7e0..0000000000 --- a/Modules/DCMTesting/test/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ - -MITK_CREATE_MODULE_TESTS(LABELS MITK-Core) - - -include(mitkFunctionAddTestLabel) - -# verify minimum expectations: -# files are recognized as DCM -# loading files results in a given number of images -mitkAddCustomModuleTest(mitkDCMTestingSanityTest_NoFiles mitkDCMTestingSanityTest 0) -mitkAddCustomModuleTest(mitkDCMTestingSanityTest_CTImage mitkDCMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-ct.dcm) -mitkAddCustomModuleTest(mitkDCMTestingSanityTest_MRImage mitkDCMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-mr.dcm) -mitkAddCustomModuleTest(mitkDCMTestingSanityTest_SCImage mitkDCMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-sc.dcm) -mitkAddCustomModuleTest(mitkDCMTestingSanityTest_NoImagePositionPatient mitkDCMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-sc-no2032.dcm) - -# verifies that the loader can also be used to just scan for tags and provide them in mitk::Properties (parameter preLoadedVolume) -mitkAddCustomModuleTest(mitkDCMPreloadedVolumeTest_Slice mitkDCMPreloadedVolumeTest ${MITK_DATA_DIR}/spacing-ok-ct.dcm) - -set(VERIFY_DUMP_CMD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/VerifyDCMMitkImageDump) - -set(CT_ABDOMEN_DIR ${MITK_DATA_DIR}/TinyCTAbdomen) -set(MR_HEART_DIR ${MITK_DATA_DIR}/3D+t-Heart_DCMTesting) -set(CT_TILT_HEAD_DIR ${MITK_DATA_DIR}/TiltHead) -set(CT_TILT_DIR ${MITK_DATA_DIR}/TiltedData) -set(SOP_CLASSES_DIR ${MITK_DATA_DIR}/DCMReader) - - -# these variables could be passed as parameters to a generic test creation function -set(TESTS_DIR Tests) -set(INPUT_LISTNAME input) -set(EXPECTED_DUMP expected.dump) - -function(AddDcmTestsFromDataRepository CURRENT_DATASET_DIR TESTS_DIR INPUT_LISTNAME EXPECTED_DUMP) - - # find all test input lists - file(GLOB_RECURSE allInputs ${CURRENT_DATASET_DIR}/${TESTS_DIR}/*/${INPUT_LISTNAME}) - - function(expectFileExists filename) - if(NOT EXISTS ${filename}) - message(SEND_ERROR "Test case expected file ${filename} which does not exist! Please fix your CMake code or file layout.") - endif(NOT EXISTS ${filename}) - endfunction(expectFileExists) - - foreach(input ${allInputs}) - - # extract only the name of the directory of this very test case - string(REGEX REPLACE ".*${TESTS_DIR}/([^/]+)/.*" "\\1" input ${input}) - set(inputfilelist "${CURRENT_DATASET_DIR}/${TESTS_DIR}/${input}/${INPUT_LISTNAME}") - set(expecteddump "${CURRENT_DATASET_DIR}/${TESTS_DIR}/${input}/${EXPECTED_DUMP}") - set(testname "DCM_Load_${input}") - - #message(STATUS "DCM loading test case '${input}'") - expectFileExists(${inputfilelist}) - expectFileExists(${expecteddump}) - - # TODO provide error messages if input not valid - - set(dicomFiles) # clear list - # read list of file names from file "input" - file(STRINGS ${inputfilelist} rawDcmFiles) - foreach(raw ${rawDcmFiles}) - # prepend each file with an abosolute path - set(fileWithFullPath ${CURRENT_DATASET_DIR}/${raw}) - list(APPEND dicomFiles ${fileWithFullPath}) - endforeach(raw ${rawDcmFiles}) - - #message(STATUS " Load ${dicomFiles}") - add_test(${testname} - ${VERIFY_DUMP_CMD} ${expecteddump} ${dicomFiles}) - mitkFunctionAddTestLabel(${testname}) - - endforeach(input allInputs) - -endfunction(AddDcmTestsFromDataRepository CURRENT_DATASET_DIR TESTS_DIR INPUT_LISTNAME EXPECTED_DUMP) - - -AddDcmTestsFromDataRepository(${CT_ABDOMEN_DIR} ${TESTS_DIR} ${INPUT_LISTNAME} ${EXPECTED_DUMP}) -AddDcmTestsFromDataRepository(${CT_TILT_HEAD_DIR} ${TESTS_DIR} ${INPUT_LISTNAME} ${EXPECTED_DUMP}) -AddDcmTestsFromDataRepository(${CT_TILT_DIR} ${TESTS_DIR} ${INPUT_LISTNAME} ${EXPECTED_DUMP}) -AddDcmTestsFromDataRepository(${MR_HEART_DIR} ${TESTS_DIR} ${INPUT_LISTNAME} ${EXPECTED_DUMP}) - -AddDcmTestsFromDataRepository(${SOP_CLASSES_DIR} ${TESTS_DIR} ${INPUT_LISTNAME} ${EXPECTED_DUMP}) - -# use one more realistic series for testing property lists -file(GLOB_RECURSE abdomenImages ${CT_ABDOMEN_DIR}/14?) # this is just one small volume -mitkAddCustomModuleTest(mitkDCMPreloadedVolumeTest_Abdomen mitkDCMPreloadedVolumeTest ${abdomenImages}) diff --git a/Modules/DCMTesting/test/files.cmake b/Modules/DCMTesting/test/files.cmake deleted file mode 100644 index 2d9380c11a..0000000000 --- a/Modules/DCMTesting/test/files.cmake +++ /dev/null @@ -1,6 +0,0 @@ - -# tests with no extra command line parameter -set(MODULE_CUSTOM_TESTS - mitkDCMTestingSanityTest.cpp - mitkDCMPreloadedVolumeTest.cpp -) diff --git a/Modules/DCMTesting/test/mitkDCMPreloadedVolumeTest.cpp b/Modules/DCMTesting/test/mitkDCMPreloadedVolumeTest.cpp deleted file mode 100644 index ea9f273521..0000000000 --- a/Modules/DCMTesting/test/mitkDCMPreloadedVolumeTest.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*=================================================================== - -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 "mitkImage.h" -#include "mitkTestDCMLoading.h" -#include "mitkTestingMacros.h" - -bool CheckAllPropertiesAreInOtherList(const mitk::PropertyList *list, const mitk::PropertyList *otherList) -{ - MITK_TEST_CONDITION_REQUIRED(list && otherList, "Comparison is passed two non-empty property lists") - - const mitk::PropertyList::PropertyMap *listM = list->GetMap(); - const mitk::PropertyList::PropertyMap *otherListM = otherList->GetMap(); - - bool equal = true; - for (auto iter = listM->begin(); iter != listM->end(); ++iter) - { - std::string key = iter->first; - mitk::BaseProperty *property = iter->second; - - auto otherEntry = otherListM->find(key); - MITK_TEST_CONDITION(otherEntry != otherListM->end(), " Property '" << key << "' is contained in other list") - - mitk::BaseProperty *otherProperty = otherEntry->second; - MITK_TEST_CONDITION(equal &= (*property == *otherProperty), " Property '" << key << "' is equal in both list") - } - - return equal; -} - -bool VerifyPropertyListsEquality(const mitk::PropertyList *testList, const mitk::PropertyList *referenceList) -{ - bool allTestPropsInReference = CheckAllPropertiesAreInOtherList(testList, referenceList); - MITK_TEST_CONDITION(allTestPropsInReference, "All test properties found in reference properties") - bool allReferencePropsInTest = CheckAllPropertiesAreInOtherList(referenceList, testList); - MITK_TEST_CONDITION(allReferencePropsInTest, "All reference properties found in test properties") - return allTestPropsInReference && allReferencePropsInTest; -} - -int mitkDCMPreloadedVolumeTest(int argc, char **const argv) -{ - MITK_TEST_BEGIN("DCMPreloadedVolume") - - mitk::TestDCMLoading loader; - mitk::TestDCMLoading::StringContainer files; - - // adapt expectations depending on configuration - std::string configuration = mitk::DicomSeriesReader::GetConfigurationString(); - MITK_TEST_OUTPUT(<< "Configuration: " << configuration) - - // load files from commandline - for (int arg = 1; arg < argc; ++arg) - { - MITK_TEST_OUTPUT(<< "Test file " << argv[arg]) - files.push_back(argv[arg]); - } - - // verify all files are DCM - for (mitk::TestDCMLoading::StringContainer::const_iterator fileIter = files.begin(); fileIter != files.end(); - ++fileIter) - { - MITK_TEST_CONDITION_REQUIRED(mitk::DicomSeriesReader::IsDicom(*fileIter), - *fileIter << " is recognized as loadable DCM object") - } - - // load for a first time - mitk::TestDCMLoading::ImageList images = loader.LoadFiles(files); - MITK_TEST_OUTPUT(<< "Loaded " << images.size() - << " images. Remembering properties of the first one for later comparison.") - mitk::Image::Pointer firstImage = images.front(); - - mitk::PropertyList::Pointer originalProperties = firstImage->GetPropertyList(); // save the original - firstImage->SetPropertyList(mitk::PropertyList::New()); // clear image properties - // what about DEFAULT properties? currently ONLY nodes get default properties - - // load for a second time, this time provide the image volume as a pointer - // expectation is that the reader will provide the same properties to this image (without actually loading a new - // mitk::Image) - mitk::TestDCMLoading::ImageList reloadedImages = loader.LoadFiles(files, firstImage); - MITK_TEST_OUTPUT(<< "Again loaded " << reloadedImages.size() << " images. Comparing to previously loaded version.") - mitk::Image::Pointer reloadedImage = reloadedImages.front(); - - mitk::PropertyList::Pointer regeneratedProperties = - reloadedImage->GetPropertyList(); // get the version of the second load attempt - - bool listsAreEqual = VerifyPropertyListsEquality(regeneratedProperties, originalProperties); - MITK_TEST_CONDITION(listsAreEqual, - "LoadDicomSeries generates a valid property list when provided a pre-loaded image"); - - MITK_TEST_END() -} diff --git a/Modules/DCMTesting/test/mitkDCMTestingSanityTest.cpp b/Modules/DCMTesting/test/mitkDCMTestingSanityTest.cpp deleted file mode 100644 index dca044edf1..0000000000 --- a/Modules/DCMTesting/test/mitkDCMTestingSanityTest.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/*=================================================================== - -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 "mitkImage.h" -#include "mitkTestDCMLoading.h" -#include "mitkTestingMacros.h" - -int mitkDCMTestingSanityTest(int argc, char **const argv) -{ - MITK_TEST_BEGIN("DCMTestingSanity") - - mitk::TestDCMLoading loader; - mitk::TestDCMLoading::StringContainer files; - - // adapt expectations depending on configuration - std::string configuration = mitk::DicomSeriesReader::GetConfigurationString(); - MITK_TEST_OUTPUT(<< "Configuration: " << configuration) - /* - MITK_TEST_CONDITION_REQUIRED( configuration.find( "GDCM_VERSION: 2." ) != std::string::npos, - "Expect at least GDCM version 2" ) - */ - - // load files from commandline - unsigned int numberOfExpectedImages = 0; - if (argc > 1) - numberOfExpectedImages = atoi(argv[1]); - for (int arg = 2; arg < argc; ++arg) - files.push_back(argv[arg]); - - // verify all files are DCM - for (mitk::TestDCMLoading::StringContainer::const_iterator fileIter = files.begin(); fileIter != files.end(); - ++fileIter) - { - MITK_TEST_CONDITION_REQUIRED(mitk::DicomSeriesReader::IsDicom(*fileIter), - *fileIter << " is recognized as loadable DCM object") - } - - // compare with expected number of images from commandline - mitk::TestDCMLoading::ImageList images = loader.LoadFiles(files); - MITK_TEST_CONDITION_REQUIRED(images.size() == numberOfExpectedImages, - "Loading " << files.size() << " files from commandline results in " - << numberOfExpectedImages - << " images (see test invocation)") - - // check dump equality (dumping image information must always equal itself) - for (mitk::TestDCMLoading::ImageList::const_iterator imageIter = images.begin(); imageIter != images.end(); - ++imageIter) - { - const mitk::Image *image = *imageIter; - MITK_TEST_CONDITION(loader.CompareImageInformationDumps(loader.DumpImageInformation(image), - loader.DumpImageInformation(image)) == true, - "Image information dumping is able to reproduce its result.") - } - - MITK_TEST_END() -} diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index 98b9304361..220afef5f0 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,78 +1,77 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(MITK_MODULES Core CommandLine AppUtil - DCMTesting RDF LegacyIO DataTypesExt Annotation LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction SceneSerialization Gizmo GraphAlgorithms Multilabel ImageStatistics ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation QtWidgets QtWidgetsExt Chart SegmentationUI Classification GPGPU OpenIGTLink IGTBase IGT CameraCalibration OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI PhotoacousticsHardware PhotoacousticsAlgorithms PhotoacousticsLib US USUI DicomUI Remeshing Python QtPython Persistence OpenIGTLinkUI IGTUI DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware MatchPointRegistration MatchPointRegistrationUI DiffusionImaging TumorInvasionAnalysis BoundingShape RenderWindowManager RenderWindowManagerUI CEST ) if(MITK_ENABLE_PIC_READER) list(APPEND MITK_MODULES IpPicSupportIO) endif()