Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #include "mitkTestDICOMLoading.h"
15 
16 #include "mitkTestingMacros.h"
17 
18 int mitkDICOMTestingSanityTest(int argc, char** const argv)
19 {
20  MITK_TEST_BEGIN("DICOMTestingSanity")
21 
23  mitk::StringList files;
24 
25  // load files from commandline
26  unsigned int numberOfExpectedImages = 0;
27  if (argc > 1) numberOfExpectedImages = atoi(argv[1]);
28  for (int arg = 2; arg < argc; ++arg) files.push_back( argv[arg] );
29 
30  // verify all files are DICOM
31  for (mitk::StringList::const_iterator fileIter = files.begin();
32  fileIter != files.end();
33  ++fileIter)
34  {
35  MITK_TEST_CONDITION_REQUIRED( mitk::DICOMFileReader::IsDICOM(*fileIter) , *fileIter << " is recognized as loadable DICOM object" )
36  }
37 
38  // compare with expected number of images from commandline
40  MITK_TEST_CONDITION_REQUIRED( images.size() == numberOfExpectedImages, "Loading " << files.size()
41  << " files from commandline results in " << numberOfExpectedImages
42  << " images (see test invocation)" )
43 
44  // check dump equality (dumping image information must always equal itself)
45  for ( mitk::TestDICOMLoading::ImageList::const_iterator imageIter = images.begin();
46  imageIter != images.end();
47  ++imageIter )
48  {
49  const mitk::Image* image = *imageIter;
51  loader.DumpImageInformation(image) ) == true,
52  "Image information dumping is able to reproduce its result." )
53  }
54 
56 }
57 
ImageVectorType images
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:72
mitk::Image::Pointer image
std::vector< std::string > StringList
int mitkDICOMTestingSanityTest(int argc, char **const argv)
and MITK_TEST_END()
ImageList LoadFiles(const StringList &files)
bool CompareImageInformationDumps(const std::string &reference, const std::string &test)
Compare two image information dumps.