Commit b050a50a authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[DOC] added missing member docu

parent f73d3873
......@@ -42,6 +42,11 @@ class WDataHandler;
*/
class WLoaderNIfTI : public WLoader
{
/**
* Only UnitTests may be friends.
*/
friend class WLoaderNIfTITest;
public:
/**
* Constructs a loader to be executed in its own thread and ets the data needed
......
......@@ -28,18 +28,142 @@
#include <cxxtest/TestSuite.h>
#include "../WLoaderNIfTI.h"
#include "../../WDataHandler.h"
/**
* test class the nifti loader class
*/
class WLoaderNIfTITest : public CxxTest::TestSuite
{
private: // private normally comes behind public, but I would like to make it easily visible here.
/**
* Dummy DataHandler instance
*/
boost::shared_ptr< WDataHandler > m_dataHandler;
public:
/**
* this funtion tests something
* Create test environment.
*/
void setUp( void )
{
m_dataHandler = boost::shared_ptr< WDataHandler >( new WDataHandler() );
}
/**
* Test instantiation with non existing file
*/
void testInstantiationNonExisting( void )
{
TS_ASSERT_THROWS( WLoaderNIfTI( "no such file", m_dataHandler ), WDHIOFailure );
}
/**
* Test instantiation
*/
void testInstantiation( void )
{
TS_ASSERT_THROWS_NOTHING( WLoaderNIfTI( "../fixtures/scalar_signed_short.nii.gz", m_dataHandler ) );
TS_ASSERT_THROWS_NOTHING( WLoaderNIfTI( "../fixtures/scalar_unsigned_char.nii.gz", m_dataHandler ) );
TS_ASSERT_THROWS_NOTHING( WLoaderNIfTI( "../fixtures/scalar_float.nii.gz", m_dataHandler ) );
TS_ASSERT_THROWS_NOTHING( WLoaderNIfTI( "../fixtures/vector_float.nii.gz", m_dataHandler ) );
TS_ASSERT_THROWS_NOTHING( WLoaderNIfTI( "../fixtures/symmetric_2nd_order_tensor_float.nii.gz", m_dataHandler ) );
TS_ASSERT_THROWS_NOTHING( WLoaderNIfTI( "../fixtures/vector_unsigned_char.nii.gz", m_dataHandler ) );
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 0 );
}
/**
* Test if the loaded files are really in the dataHandler
*/
void testLoading( void )
{
WLoaderNIfTI loader1( "../fixtures/scalar_signed_short.nii.gz", m_dataHandler );
WLoaderNIfTI loader2( "../fixtures/scalar_unsigned_char.nii.gz", m_dataHandler );
WLoaderNIfTI loader3( "../fixtures/scalar_float.nii.gz", m_dataHandler );
WLoaderNIfTI loader4( "../fixtures/vector_float.nii.gz", m_dataHandler );
WLoaderNIfTI loader5( "../fixtures/symmetric_2nd_order_tensor_float.nii.gz", m_dataHandler );
WLoaderNIfTI loader6( "../fixtures/vector_unsigned_char.nii.gz", m_dataHandler );
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 0 );
loader1.load();
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 1 );
TS_ASSERT_EQUALS( m_dataHandler->getSubject( 0 )->getNumberOfDataSets(), 1 );
loader2.load();
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 1 );
TS_ASSERT_EQUALS( m_dataHandler->getSubject( 0 )->getNumberOfDataSets(), 2 );
loader3.load();
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 1 );
TS_ASSERT_EQUALS( m_dataHandler->getSubject( 0 )->getNumberOfDataSets(), 3 );
loader4.load();
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 1 );
TS_ASSERT_EQUALS( m_dataHandler->getSubject( 0 )->getNumberOfDataSets(), 4 );
loader5.load();
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 1 );
TS_ASSERT_EQUALS( m_dataHandler->getSubject( 0 )->getNumberOfDataSets(), 5 );
loader6.load();
TS_ASSERT_EQUALS( m_dataHandler->getNumberOfSubjects(), 1 );
TS_ASSERT_EQUALS( m_dataHandler->getSubject( 0 )->getNumberOfDataSets(), 6 );
}
/**
* Test conversion of nifti matrix to OW matrix.
*/
void testSomething( void )
void testMatrixConversion( void )
{
mat44 dummy;
dummy.m[0][0] = 1.1;
dummy.m[0][1] = 1.2;
dummy.m[0][2] = 1.3;
dummy.m[0][3] = 1.4;
dummy.m[1][0] = 1.5;
dummy.m[1][1] = 1.6;
dummy.m[1][2] = 1.7;
dummy.m[1][3] = 1.8;
dummy.m[2][0] = 1.9;
dummy.m[2][1] = 1.11;
dummy.m[2][2] = 1.12;
dummy.m[2][3] = 1.13;
dummy.m[3][0] = 1.14;
dummy.m[3][1] = 1.15;
dummy.m[3][2] = 1.16;
dummy.m[3][3] = 1.17;
WLoaderNIfTI loader1( "../fixtures/scalar_signed_short.nii.gz", m_dataHandler );
wmath::WMatrix< double > result = loader1.convertMatrix( dummy );
TS_ASSERT_EQUALS( result.getNbRows(), 4 );
TS_ASSERT_EQUALS( result.getNbCols(), 4 );
double delta = 1e-7;
TS_ASSERT_DELTA( result( 0, 0 ), 1.1, delta );
TS_ASSERT_DELTA( result( 0, 1 ), 1.2, delta );
TS_ASSERT_DELTA( result( 0, 2 ), 1.3, delta );
TS_ASSERT_DELTA( result( 0, 3 ), 1.4, delta );
TS_ASSERT_DELTA( result( 1, 0 ), 1.5, delta );
TS_ASSERT_DELTA( result( 1, 1 ), 1.6, delta );
TS_ASSERT_DELTA( result( 1, 2 ), 1.7, delta );
TS_ASSERT_DELTA( result( 1, 3 ), 1.8, delta );
TS_ASSERT_DELTA( result( 2, 0 ), 1.9, delta );
TS_ASSERT_DELTA( result( 2, 1 ), 1.11, delta );
TS_ASSERT_DELTA( result( 2, 2 ), 1.12, delta );
TS_ASSERT_DELTA( result( 2, 3 ), 1.13, delta );
TS_ASSERT_DELTA( result( 3, 0 ), 1.14, delta );
TS_ASSERT_DELTA( result( 3, 1 ), 1.15, delta );
TS_ASSERT_DELTA( result( 3, 2 ), 1.16, delta );
TS_ASSERT_DELTA( result( 3, 3 ), 1.17, delta );
}
};
......
......@@ -81,7 +81,15 @@ boost::program_options::variables_map parseOptions( int argc, char** argv )
int WQt4Gui::run()
{
m_optionsMap = parseOptions( argc, argv );
try
{
m_optionsMap = parseOptions( argc, argv );
}
catch( boost::program_options::unknown_option e )
{
std::cout << e.what() << std::endl;
return 1;
}
// exit as fast as possible if command line asks for help.
if( m_optionsMap.count( "help" ) )
......
......@@ -132,8 +132,9 @@ void WKernel::threadMain()
m_graphicsEngine->run();
// default modules
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Navigation Slice Module" ) ) , true );
// m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Navigation Slice Module" ) ) , true );
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Coordinate System Module" ) ) , true );
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Marching Cubes" ) ) , true );
// actually there is nothing more to do here
waitForStop();
......
......@@ -118,7 +118,7 @@ public:
protected:
private:
size_t m_nbCols;
size_t m_nbCols; //!< Number of columns of the matrix. The number of rows will be computed by (size/m_nbCols).
};
} // End of namespace
#endif // WMATRIX_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment