Commit 0c51deba authored by Stefan Philips's avatar Stefan Philips

[CHANGE] Adapt the HARDI2SphericalHarmonics module to the spherical harmonics...

[CHANGE] Adapt the HARDI2SphericalHarmonics module to the spherical harmonics class with Eigen vector
parent 341224bc
......@@ -167,11 +167,11 @@ void WMHARDIToSphericalHarmonics::moduleMain()
int order = m_order->get( true );
WMatrix< double > TransformMatrix(
WSymmetricSphericalHarmonic::getSHFittingMatrix( gradients,
order,
m_regularisationFactorLambda->get( true ),
m_doFunkRadonTransformation->get( true ) ) );
WMatrix_2 TransformMatrix(
WSymmetricSphericalHarmonic::getSHFittingMatrix( gradients,
order,
m_regularisationFactorLambda->get( true ),
m_doFunkRadonTransformation->get( true ) ) );
double overallError = 0.0;
boost::shared_ptr< WValueSet< int16_t > > valueSet = boost::shared_dynamic_cast< WValueSet< int16_t > >( m_dataSet->getValueSet() );
......@@ -202,7 +202,7 @@ void WMHARDIToSphericalHarmonics::moduleMain()
parameter.m_S0Indexes = S0Indexes;
parameter.m_data = data;
parameter.m_order = order;
parameter.m_TransformMatrix = boost::shared_ptr< WMatrix<double> >( new WMatrix<double>( TransformMatrix ) );
parameter.m_TransformMatrix = boost::shared_ptr< WMatrix_2 >( new WMatrix_2( TransformMatrix ) );
parameter.m_gradients = gradients;
parameter.m_progress = progress;
parameter.m_doFunkRadonTransformation = m_doFunkRadonTransformation->get( true );
......
......@@ -35,6 +35,8 @@
#include "HARDIToSphericalHarmonics.xpm"
#include "../../common/WLimits.h"
#include "../../common/WAssert.h"
#include "../../common/math/WVector3D.h"
#include "../../common/math/WMatrix.h"
#include "WSphericalHarmonicsCoefficientsThread.h"
......@@ -57,7 +59,7 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
WValue< int16_t > allMeasures( m_parameter.m_valueSet->getWValue( i ) );
// extract measures for gradients != 0
WValue< double > measures( m_parameter.m_validIndices.size() );
WVector_2 measures( m_parameter.m_validIndices.size() );
unsigned int idx = 0;
// find max S0 value
......@@ -68,18 +70,18 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
}
S0avg /= m_parameter.m_S0Indexes.size();
double minVal = 1e99;
double maxVal = -1e99;
for ( std::vector< size_t >::const_iterator it = m_parameter.m_validIndices.begin(); it != m_parameter.m_validIndices.end(); it++, idx++ )
{
double minVal = 1e99;
double maxVal = -1e99;
for ( std::vector< size_t >::const_iterator it = m_parameter.m_validIndices.begin(); it != m_parameter.m_validIndices.end(); it++, idx++ )
{
measures[ idx ] = S0avg <= 0.0 ? 0.0 :
static_cast<double>( allMeasures[ *it ] ) / S0avg;
static_cast<double>( allMeasures[ *it ] ) / S0avg;
if ( measures[ idx ] < minVal ) minVal = measures[ idx ];
if ( measures[ idx ] > maxVal ) maxVal = measures[ idx ];
}
}
WValue< double > coefficients( ( *m_parameter.m_TransformMatrix ) * measures );
WVector_2 coefficients( ( *m_parameter.m_TransformMatrix ) * measures );
if ( m_parameter.m_doResidualCalculation || m_parameter.m_doErrorCalculation )
{
......@@ -114,7 +116,10 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
scale *= std::sqrt( 4.0 * piDouble ) / coefficients[ 0 ];
}
for ( size_t j = 0; j < l; j++ ) m_parameter.m_data->operator[]( l*i + j ) = coefficients[ j ];
for ( size_t j = 0; j < l; j++ )
{
m_parameter.m_data->operator[]( l*i + j ) = coefficients[ j ];
}
}
}
......
......@@ -81,7 +81,7 @@ public:
* Transformation-Matrix for conversion from HARDI measurements to spherical harmonics coefficients
* (see Descoteaux dissertation)
*/
boost::shared_ptr< WMatrix< double > > m_TransformMatrix;
boost::shared_ptr< WMatrix_2 > m_TransformMatrix;
/**
* Gradients of all measurements (including )
......
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