Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkPropertyCalculatorTest.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 #include <mitkTestFixture.h>
13 #include <mitkTestingMacros.h>
14 
16 
17 class mitkPropertyCalculatorTestSuite : public mitk::TestFixture
18 {
19  CPPUNIT_TEST_SUITE(mitkPropertyCalculatorTestSuite);
20  MITK_TEST(testOutputIsNotEmpty);
21  CPPUNIT_TEST_SUITE_END();
22 
23 private:
24  mitk::pa::PropertyCalculator::Pointer m_PropertyCalculator;
25 
26 public:
27 
28  void setUp() override
29  {
30  m_PropertyCalculator = mitk::pa::PropertyCalculator::New();
31  }
32 
33  void assertProperties(mitk::pa::PropertyCalculator::Properties properties,
34  std::string type, int wavelength, int oxygenation)
35  {
36  CPPUNIT_ASSERT_MESSAGE("anisotropy " + std::to_string(properties.g) + " not bigger than 0 at type "
37  + type + " wv: " + std::to_string(wavelength) + " ox: " + std::to_string(oxygenation), properties.g > 0);
38  CPPUNIT_ASSERT_MESSAGE("absorption " + std::to_string(properties.mua) + " not bigger than 0 at type "
39  + type + " wv: " + std::to_string(wavelength) + " ox: " + std::to_string(oxygenation), properties.mua > 0);
40  CPPUNIT_ASSERT_MESSAGE("scattering " + std::to_string(properties.mus) + " not bigger than 0 at type "
41  + type + " wv: " + std::to_string(wavelength) + " ox: " + std::to_string(oxygenation), properties.mus > 0);
42  }
43 
44  void testOutputIsNotEmpty()
45  {
46  for (double oxygenation = 0; oxygenation <= 1; oxygenation += 0.05)
47  {
48  for (int wavelength = 700; wavelength <= 900; wavelength += 5)
49  {
50  auto properties = m_PropertyCalculator->CalculatePropertyForSpecificWavelength(
51  mitk::pa::PropertyCalculator::TissueType::AIR, wavelength, oxygenation);
52  assertProperties(properties, "AIR", wavelength, oxygenation);
53  properties = m_PropertyCalculator->CalculatePropertyForSpecificWavelength(
54  mitk::pa::PropertyCalculator::TissueType::BLOOD, wavelength, oxygenation);
55  assertProperties(properties, "BLOOD", wavelength, oxygenation);
56  properties = m_PropertyCalculator->CalculatePropertyForSpecificWavelength(
57  mitk::pa::PropertyCalculator::TissueType::EPIDERMIS, wavelength, oxygenation);
58  assertProperties(properties, "EPIDERMIS", wavelength, oxygenation);
59  properties = m_PropertyCalculator->CalculatePropertyForSpecificWavelength(
60  mitk::pa::PropertyCalculator::TissueType::FAT, wavelength, oxygenation);
61  assertProperties(properties, "FAT", wavelength, oxygenation);
62  properties = m_PropertyCalculator->CalculatePropertyForSpecificWavelength(
63  mitk::pa::PropertyCalculator::TissueType::STANDARD_TISSUE, wavelength, oxygenation);
64  assertProperties(properties, "STANDARD_TISSUE", wavelength, oxygenation);
65  }
66  }
67  }
68 
69  void tearDown() override
70  {
71  m_PropertyCalculator = nullptr;
72  }
73 };
74 
75 MITK_TEST_SUITE_REGISTRATION(mitkPropertyCalculator)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
Test fixture for parameterized tests.