OpenWalnut  1.5.0dev
WDataSetDTI_test.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WDATASETDTI_TEST_H
26 #define WDATASETDTI_TEST_H
27 
28 #include <memory>
29 #include <vector>
30 
31 #include <cxxtest/TestSuite.h>
32 
33 #include "../../common/WLogger.h"
34 #include "../../common/math/test/WTensorTraits.h"
35 #include "../WDataSetDTI.h"
36 #include "../WGridRegular3D.h"
37 
38 /**
39  * Testsuite for unit tests of the WDataSetDTI class.
40  */
41 class WDataSetDTITest : public CxxTest::TestSuite
42 {
43 public:
44  /**
45  * Setup logger and other stuff for each test.
46  */
47  void setUp()
48  {
50  }
51 
52  /**
53  * Only values sets of order 1, dim 6 should be used to construct DTI datasets.
54  */
55  void testInstanziation( void )
56  {
57  float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; // NOLINT array init list
58  std::shared_ptr< std::vector< float > > data =
59  std::shared_ptr< std::vector< float > >(
60  new std::vector< float >( &dataArray[0], &dataArray[0] + sizeof( dataArray ) / sizeof( float ) ) );
61  std::shared_ptr< WValueSetBase > newValueSet( new WValueSet< float >( 1, 6, data, W_DT_FLOAT ) );
62  std::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1 ) );
63  TS_ASSERT_THROWS_NOTHING( WDataSetDTI( newValueSet, newGrid ) );
64  }
65 
66  /**
67  * Accessing the i'th tensor is: getting the WValue at that position and
68  * transform it to a WTensorSym< 2, 3 >.
69  */
70  void testTensorAccess( void )
71  {
72  float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; // NOLINT array init list
73  std::shared_ptr< std::vector< float > > data =
74  std::shared_ptr< std::vector< float > >(
75  new std::vector< float >( &dataArray[0], &dataArray[0] + sizeof( dataArray ) / sizeof( float ) ) );
76  std::shared_ptr< WValueSetBase > newValueSet( new WValueSet< float >( 1, 6, data, W_DT_FLOAT ) );
77  std::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1 ) );
78  WDataSetDTI dataset( newValueSet, newGrid );
80  expected( 0, 0 ) = 0.0;
81  expected( 0, 1 ) = 1.0;
82  expected( 0, 2 ) = 2.0;
83  expected( 1, 1 ) = 3.0;
84  expected( 1, 2 ) = 4.0;
85  expected( 2, 2 ) = 5.0;
86  TS_ASSERT_EQUALS( dataset.getTensor( 0 ), expected );
87  }
88 };
89 
90 #endif // WDATASETDTI_TEST_H
Testsuite for unit tests of the WDataSetDTI class.
void setUp()
Setup logger and other stuff for each test.
void testInstanziation(void)
Only values sets of order 1, dim 6 should be used to construct DTI datasets.
void testTensorAccess(void)
Accessing the i'th tensor is: getting the WValue at that position and transform it to a WTensorSym< 2...
Represents a Diffusion-Tensor-Image dataset.
Definition: WDataSetDTI.h:40
WTensorSym< 2, 3, float > getTensor(size_t index) const
Retrieves the i'th tensor.
Definition: WDataSetDTI.cpp:73
A grid that has parallelepiped cells which all have the same proportion.
static void startup(std::ostream &output=std::cout, LogLevel level=LL_DEBUG)
Create the first and only instance of the logger as it is a singleton.
Definition: WLogger.cpp:41
Implements a symmetric tensor that has the same number of components in every direction.
Definition: WTensorSym.h:73
Base Class for all value set types.
Definition: WValueSet.h:47