Commit b6ee4c9e authored by reichenbach's avatar reichenbach
Browse files

[CHANGE] Berman Tracking now uses WDataSetScalar for GFA input

[CHANGE] restructured Berman Tracking's moduleMain
parent 511b4ff1
......@@ -85,7 +85,7 @@ void WMBermanTracking::connectors()
"inSH", "A spherical harmonics dataset." )
);
m_inputGFA = boost::shared_ptr< WModuleInputData< WDataSetSingle > >( new WModuleInputData< WDataSetSingle >( shared_from_this(),
m_inputGFA = boost::shared_ptr< WModuleInputData< WDataSetScalar > >( new WModuleInputData< WDataSetScalar >( shared_from_this(),
"inGFA", "GFA." )
);
......@@ -93,7 +93,7 @@ void WMBermanTracking::connectors()
"inResiduals", "The residual HARDI data." )
);
m_output = boost::shared_ptr< WModuleOutputData< WDataSetSingle > >( new WModuleOutputData< WDataSetSingle >( shared_from_this(),
m_output = boost::shared_ptr< WModuleOutputData< WDataSetScalar > >( new WModuleOutputData< WDataSetScalar >( shared_from_this(),
"outProb", "The probabilistic tracking result." )
);
......@@ -156,6 +156,7 @@ void WMBermanTracking::moduleMain()
m_moduleState.setResetable( true, true );
m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_inputResidual->getDataChangedCondition() );
m_moduleState.add( m_inputGFA->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
m_moduleState.add( m_exceptionCondition );
......@@ -176,10 +177,9 @@ void WMBermanTracking::moduleMain()
boost::shared_ptr< WDataSetSphericalHarmonics > inData = m_input->getData();
boost::shared_ptr< WDataSetRawHARDI > inData2 = m_inputResidual->getData();
bool dataChanged = ( m_dataSet != inData ) || ( m_dataSetResidual != inData2 );
boost::shared_ptr< WDataSetScalar > inData3 = m_inputGFA->getData();
bool dataChanged = ( m_dataSet != inData ) || ( m_dataSetResidual != inData2 ) || ( m_gfa != inData3 );
if( dataChanged || !m_dataSet || !m_dataSetResidual )
{
if( dataChanged )
{
if( m_trackingPool )
......@@ -191,17 +191,23 @@ void WMBermanTracking::moduleMain()
m_currentProgress->finish();
}
}
}
m_dataSet = inData;
m_dataSetResidual = inData2;
m_gfa = inData3;
}
if( !m_dataSet || !m_dataSetResidual )
if( m_startTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
continue;
}
else
m_startTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, false );
if( m_dataSet && m_dataSetResidual && m_gfa )
{
if( m_result )
{
WDataHandler::deregisterDataSet( m_result );
}
// calculate some matrices needed for the residuals
std::vector< wmath::WUnitSphereCoordinates > c;
for( std::size_t i = 0; i < m_dataSetResidual->getOrientations().size(); ++i )
......@@ -216,18 +222,6 @@ void WMBermanTracking::moduleMain()
m_HMat = m_BMat * wmath::WSymmetricSphericalHarmonic::getSHFittingMatrix( c, 4, 0.0, false );
WAssert( m_HMat.getNbCols() == m_HMat.getNbRows(), "" );
m_gfa = m_inputGFA->getData();
}
}
if( m_dataSet && m_dataSetResidual && m_gfa && ( dataChanged || m_startTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED ) )
{
m_startTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, false );
if( m_result )
{
WDataHandler::deregisterDataSet( m_result );
}
// get current properties
m_currentMinFA = m_minFA->get( true );
m_currentMinPoints = static_cast< std::size_t >( m_minPoints->get( true ) );
......@@ -242,6 +236,7 @@ void WMBermanTracking::moduleMain()
m_trackingPool->run();
debugLog() << "Running tracking function.";
}
}
else if( m_trackingPool && m_trackingPool->status() == W_THREADS_FINISHED )
{
// get result
......@@ -254,9 +249,9 @@ void WMBermanTracking::moduleMain()
m_outputFibers->updateData( m_fiberSet );
m_trackingPool = boost::shared_ptr< TrackingFuncType >();
boost::shared_ptr< WValueSet< float > > vs( new WValueSet< float >( 1, 1, *m_hits, DataType< float >::type ) );
boost::shared_ptr< WValueSet< float > > vs( new WValueSet< float >( 0, 1, *m_hits, DataType< float >::type ) );
m_result = boost::shared_ptr< WDataSetSingle >( new WDataSetSingle( vs, m_dataSet->getGrid() ) );
m_result = boost::shared_ptr< WDataSetScalar >( new WDataSetScalar( vs, m_dataSet->getGrid() ) );
m_result->setFileName( "Berman_prob_tracking_result" );
m_result->getTexture()->setThreshold( 0.05f );
m_result->getTexture()->setSelectedColormap( 2 );
......@@ -374,7 +369,7 @@ wmath::WVector3D WMBermanTracking::getDirFunc( boost::shared_ptr< WDataSetSingle
WAssert( v != -1, "" );
WAssert( m_gfa, "" );
if( m_gfa->getValueAt( v ) < m_currentMinFA )
if( boost::shared_dynamic_cast< WDataSetSingle >( m_gfa )->getValueAt( v ) < m_currentMinFA )
{
return wmath::WVector3D( 0.0, 0.0, 0.0 );
}
......
......@@ -37,6 +37,7 @@
#include "../../dataHandler/WDataSetSphericalHarmonics.h"
#include "../../dataHandler/WDataSetFibers.h"
#include "../../dataHandler/WDataSetRawHARDI.h"
#include "../../dataHandler/WDataSetScalar.h"
#include "../../dataHandler/WThreadedTrackingFunction.h"
#include "../../dataHandler/WFiberAccumulator.h"
......@@ -184,7 +185,7 @@ private:
wmath::WSymmetricSphericalHarmonic createRandomODF( std::size_t i );
//! Stores the gfa measure for the input data.
boost::shared_ptr< WDataSetSingle > m_gfa;
boost::shared_ptr< WDataSetScalar > m_gfa;
//! Stores a matrix representing the funk-radon-transform.
wmath::WMatrix< double > m_frtMat;
......@@ -214,7 +215,7 @@ private:
boost::shared_ptr< WDataSetRawHARDI > m_dataSetResidual;
//! The output dataset.
boost::shared_ptr< WDataSetSingle > m_result;
boost::shared_ptr< WDataSetScalar > m_result;
//! Stores the number of hits for a voxel.
boost::shared_ptr< std::vector< float > > m_hits;
......@@ -223,7 +224,7 @@ private:
boost::shared_ptr< WDataSetFibers > m_fiberSet;
//! The output Connector.
boost::shared_ptr< WModuleOutputData< WDataSetSingle > > m_output;
boost::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output;
//! The fiber output, used for testing.
boost::shared_ptr< WModuleOutputData< WDataSetFibers > > m_outputFibers;
......@@ -235,7 +236,7 @@ private:
boost::shared_ptr< WModuleInputData< WDataSetRawHARDI > > m_inputResidual;
//! The input for the gfa.
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_inputGFA;
boost::shared_ptr< WModuleInputData< WDataSetScalar > > m_inputGFA;
//! The threadpool for the tracking.
boost::shared_ptr< TrackingFuncType > m_trackingPool;
......
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