Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkRTDoseReaderTest.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 <mitkTestingMacros.h>
18 #include <mitkTestFixture.h>
19 
20 #include <vector>
21 
22 #include <mitkRTConstants.h>
23 #include <mitkGenericProperty.h>
24 #include <mitkIOUtil.h>
25 #include "mitkRTDoseReader.h"
26 
27 class mitkRTDoseReaderTestSuite : public mitk::TestFixture
28 {
29  CPPUNIT_TEST_SUITE(mitkRTDoseReaderTestSuite);
30  MITK_TEST(TestDoseImage);
31  CPPUNIT_TEST_SUITE_END();
32 
33 public:
34 
35  void setUp() override
36  {
37  }
38 
39  void TestDoseImage()
40  {
41  mitk::Image::Pointer refImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("RT/Dose/RT_Dose.nrrd"));
42 
43  auto doseReader = mitk::RTDoseReader();
44  doseReader.SetInput(GetTestDataFilePath("RT/Dose/RD.dcm"));
45  std::vector<itk::SmartPointer<mitk::BaseData> > readerOutput = doseReader.Read();
46  CPPUNIT_ASSERT_EQUAL_MESSAGE("reader output should have one entry.", static_cast<unsigned int>(1), static_cast<unsigned int>(readerOutput.size()));
47 
48  mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(readerOutput.at(0).GetPointer());
49 
50  CPPUNIT_ASSERT_EQUAL_MESSAGE("read image should not be null", image.IsNotNull(), true);
51  CPPUNIT_ASSERT_EQUAL_MESSAGE("reference image and image should be equal", true, mitk::Equal(*image, *refImage, mitk::eps, true));
52 
53  auto prescibedDoseProperty = image->GetProperty(mitk::RTConstants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str());
54  auto prescribedDoseGenericProperty = dynamic_cast<mitk::GenericProperty<double>*>(prescibedDoseProperty.GetPointer());
55  double actualPrescribedDose = prescribedDoseGenericProperty->GetValue();
56  double expectedPrescribedDose = 65535 * 0.0010494648*0.8;
57  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("prescribed dose property is not as expected", expectedPrescribedDose, actualPrescribedDose, 1e-5);
58 
59  }
60 
61 };
62 
63 MITK_TEST_SUITE_REGISTRATION(mitkRTDoseReader)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
RTDoseReader reads DICOM files of modality RTDOSE.
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static std::string GetTestDataFilePath(const std::string &testData)
Get the absolute path for test data.
Image class for storing images.
Definition: mitkImage.h:76
Test fixture for parameterized tests.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
static const std::string PRESCRIBED_DOSE_PROPERTY_NAME
MITKCORE_EXPORT const ScalarType eps
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
Definition: mitkIOUtil.cpp:597
virtual T GetValue() const