Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDCMTestingSanityTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkImage.h"
18 #include "mitkTestDCMLoading.h"
19 #include "mitkTestingMacros.h"
20 
21 int mitkDCMTestingSanityTest(int argc, char **const argv)
22 {
23  MITK_TEST_BEGIN("DCMTestingSanity")
24 
25  mitk::TestDCMLoading loader;
27 
28  // adapt expectations depending on configuration
29  std::string configuration = mitk::DicomSeriesReader::GetConfigurationString();
30  MITK_TEST_OUTPUT(<< "Configuration: " << configuration)
31  /*
32  MITK_TEST_CONDITION_REQUIRED( configuration.find( "GDCM_VERSION: 2." ) != std::string::npos,
33  "Expect at least GDCM version 2" )
34  */
35 
36  // load files from commandline
37  unsigned int numberOfExpectedImages = 0;
38  if (argc > 1)
39  numberOfExpectedImages = atoi(argv[1]);
40  for (int arg = 2; arg < argc; ++arg)
41  files.push_back(argv[arg]);
42 
43  // verify all files are DCM
44  for (mitk::TestDCMLoading::StringContainer::const_iterator fileIter = files.begin(); fileIter != files.end();
45  ++fileIter)
46  {
48  *fileIter << " is recognized as loadable DCM object")
49  }
50 
51  // compare with expected number of images from commandline
53  MITK_TEST_CONDITION_REQUIRED(images.size() == numberOfExpectedImages,
54  "Loading " << files.size() << " files from commandline results in "
55  << numberOfExpectedImages
56  << " images (see test invocation)")
57 
58  // check dump equality (dumping image information must always equal itself)
59  for (mitk::TestDCMLoading::ImageList::const_iterator imageIter = images.begin(); imageIter != images.end();
60  ++imageIter)
61  {
62  const mitk::Image *image = *imageIter;
64  loader.DumpImageInformation(image)) == true,
65  "Image information dumping is able to reproduce its result.")
66  }
67 
69 }
int mitkDCMTestingSanityTest(int argc, char **const argv)
std::string DumpImageInformation(const Image *image)
Dump relevant image information for later comparison.
static std::string GetConfigurationString()
Provide combination of preprocessor defines that was active during compilation.
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
DicomSeriesReader::StringContainer StringContainer
#define MITK_TEST_OUTPUT(x)
Output some text.
#define MITK_TEST_CONDITION(COND, MSG)
Image class for storing images.
Definition: mitkImage.h:76
static bool IsDicom(const std::string &filename)
Checks if a specific file contains DICOM data.
bool CompareImageInformationDumps(const std::string &reference, const std::string &test)
Compare two image information dumps.
std::list< itk::SmartPointer< Image > > ImageList
and MITK_TEST_END()
ImageList LoadFiles(const StringContainer &files, itk::SmartPointer< Image > preLoadedVolume=nullptr)
section MAP_FRAME_Mapper_Settings Mapper settings For the mapping of corrected images