OpenWalnut  1.5.0dev
WTalairachConverter_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 WTALAIRACHCONVERTER_TEST_H
26 #define WTALAIRACHCONVERTER_TEST_H
27 
28 #include <iostream>
29 #include <memory>
30 
31 #include <cxxtest/TestSuite.h>
32 
33 #include "../WTalairachConverter.h"
34 
35 /**
36  * Tests the Talairach converter class
37  */
38 class WTalairachConverterTest : public CxxTest::TestSuite
39 {
40 public:
41  /**
42  * Set up the special points of the Talairach coordinate system
43  * for testing the converter.
44  */
45  void setUp( void )
46  {
47  WVector3d ac( 150, 122, 90 );
48  WVector3d pc( 110, 124, 97 );
49  WVector3d ihp( 140, 119, 188 );
50  m_tc = std::shared_ptr<WTalairachConverter> ( new WTalairachConverter( ac, pc, ihp ) );
51 
52  m_tc->setAp( WVector3d( 80, 0, 0 ) );
53  m_tc->setPp( WVector3d( -97, 0, 0 ) );
54  m_tc->setSp( WVector3d( 0, 0, 81 ) );
55  m_tc->setIp( WVector3d( 0, 0, -41 ) );
56  m_tc->setRp( WVector3d( 0, -60, 0 ) );
57  m_tc->setLp( WVector3d( 0, 63, 0 ) );
58  }
59 
60  /**
61  * Release all data need for testing the converter
62  */
63  void tearDown( void )
64  {
65  m_tc.reset();
66  }
67 
68 
69  /**
70  * Test the conversion "to" ACPC coords.
71  */
72  void testCanonical2ACPC( void )
73  {
74  WVector3d testPoint( 200, 60, 130 );
75  WVector3d result = m_tc->Canonical2ACPC( testPoint );
76 
77  TS_ASSERT_DELTA( result[0], 45.35, 0.05 );
78  TS_ASSERT_DELTA( result[1], -57.6, 0.05 );
79  TS_ASSERT_DELTA( result[2], 50.69, 0.05 );
80  }
81 
82  /**
83  * Test the conversion "from" ACPC coords.
84  */
85  void testACPC2Canonical( void )
86  {
87  WVector3d testPoint( 45.35, -57.6, 50.69 );
88  WVector3d result = m_tc->ACPC2Canonical( testPoint );
89 
90  TS_ASSERT_DELTA( result[0], 200, 0.05 );
91  TS_ASSERT_DELTA( result[1], 60, 0.05 );
92  TS_ASSERT_DELTA( result[2], 130, 0.05 );
93  }
94 
95  /**
96  * Test conversion from ACPC to Talairach coords.
97  */
98  void testACPC2Talairach( void )
99  {
100  WVector3d testPoint( 12, 43, -12 );
101  WVector3d result = m_tc->ACPC2Talairach( testPoint );
102 
103  TS_ASSERT_DELTA( result[0], 12.0, 0.05 );
104  TS_ASSERT_DELTA( result[1], 49.6, 0.05 );
105  TS_ASSERT_DELTA( result[2], -3.8, 0.05 );
106  }
107 
108  /**
109  * Test conversion from Talairach to ACPC coords.
110  */
111  void testTalairach2ACPC( void )
112  {
113  WVector3d testPoint( 10.5, 46.41, -12.29 );
114  WVector3d result = m_tc->Talairach2ACPC( testPoint );
115 
116  TS_ASSERT_DELTA( result[0], 10.5, 0.05 );
117  TS_ASSERT_DELTA( result[1], 40.25, 0.05 );
118  TS_ASSERT_DELTA( result[2], -38.35, 0.05 );
119  }
120 
121 
122 private:
123  /**
124  * The Talairach converter object that is tested in the testing functions.
125  */
126  std::shared_ptr<WTalairachConverter> m_tc;
127 };
128 
129 #endif // WTALAIRACHCONVERTER_TEST_H
Tests the Talairach converter class.
void testCanonical2ACPC(void)
Test the conversion "to" ACPC coords.
void testACPC2Canonical(void)
Test the conversion "from" ACPC coords.
std::shared_ptr< WTalairachConverter > m_tc
The Talairach converter object that is tested in the testing functions.
void setUp(void)
Set up the special points of the Talairach coordinate system for testing the converter.
void testTalairach2ACPC(void)
Test conversion from Talairach to ACPC coords.
void testACPC2Talairach(void)
Test conversion from ACPC to Talairach coords.
void tearDown(void)
Release all data need for testing the converter.
class to provide conversions between world or voxel space coordinates und Talairach coordinates