Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDICOMTestingSanityTest.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 
18 #include "mitkTestDICOMLoading.h"
19 
20 #include "mitkTestingMacros.h"
21 
22 int mitkDICOMTestingSanityTest(int argc, char** const argv)
23 {
24  MITK_TEST_BEGIN("DICOMTestingSanity")
25 
27  mitk::StringList files;
28 
29  // load files from commandline
30  unsigned int numberOfExpectedImages = 0;
31  if (argc > 1) numberOfExpectedImages = atoi(argv[1]);
32  for (int arg = 2; arg < argc; ++arg) files.push_back( argv[arg] );
33 
34  // verify all files are DICOM
35  for (mitk::StringList::const_iterator fileIter = files.begin();
36  fileIter != files.end();
37  ++fileIter)
38  {
39  MITK_TEST_CONDITION_REQUIRED( mitk::DICOMFileReader::IsDICOM(*fileIter) , *fileIter << " is recognized as loadable DICOM object" )
40  }
41 
42  // compare with expected number of images from commandline
44  MITK_TEST_CONDITION_REQUIRED( images.size() == numberOfExpectedImages, "Loading " << files.size()
45  << " files from commandline results in " << numberOfExpectedImages
46  << " images (see test invocation)" )
47 
48  // check dump equality (dumping image information must always equal itself)
49  for ( mitk::TestDICOMLoading::ImageList::const_iterator imageIter = images.begin();
50  imageIter != images.end();
51  ++imageIter )
52  {
53  const mitk::Image* image = *imageIter;
55  loader.DumpImageInformation(image) ) == true,
56  "Image information dumping is able to reproduce its result." )
57  }
58 
60 }
61 
static bool IsDICOM(const std::string &filename)
Test whether a file is DICOM at all.
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
std::string DumpImageInformation(const Image *image)
Dump relevant image information for later comparison.
std::list< Image::Pointer > ImageList
#define MITK_TEST_CONDITION(COND, MSG)
Image class for storing images.
Definition: mitkImage.h:76
std::vector< std::string > StringList
int mitkDICOMTestingSanityTest(int argc, char **const argv)
and MITK_TEST_END()
section MAP_FRAME_Mapper_Settings Mapper settings For the mapping of corrected images
ImageList LoadFiles(const StringList &files)
bool CompareImageInformationDumps(const std::string &reference, const std::string &test)
Compare two image information dumps.