OpenWalnut  1.3.1
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
WSymmetricSphericalHarmonic Class Reference

Class for symmetric spherical harmonics The index scheme of the coefficients/basis values is like in the Descoteaux paper "Regularized, Fast, and Robust Analytical Q-Ball Imaging". More...

#include <WSymmetricSphericalHarmonic.h>

Public Member Functions

 WSymmetricSphericalHarmonic ()
 Default constructor.
 WSymmetricSphericalHarmonic (const WValue< double > &SHCoefficients)
 Constructor.
virtual ~WSymmetricSphericalHarmonic ()
 Destructor.
double getValue (double theta, double phi) const
 Return the value on the sphere.
double getValue (const WUnitSphereCoordinates &coordinates) const
 Return the value on the sphere.
const WValue< double > & getCoefficients () const
 Returns the used coefficients (stored like in the mentioned 2007 Descoteaux paper).
WValue< double > getCoefficientsSchultz () const
 Returns the coefficients for Schultz' SH base.
WValue< std::complex< double > > getCoefficientsComplex () const
 Returns the coefficients for the complex base.
void applyFunkRadonTransformation (WMatrix< double > const &frtMat)
 Applies the Funk-Radon-Transformation.
size_t getOrder () const
 Return the order of the spherical harmonic.
double calcGFA (std::vector< WUnitSphereCoordinates > const &orientations) const
 Calculate the generalized fractional anisotropy for this ODF.
double calcGFA (WMatrix< double > const &B) const
 Calculate the generalized fractional anisotropy for this ODF.
void normalize ()
 Normalize this SH in place.

Static Public Member Functions

static WMatrix< double > getSHFittingMatrix (const std::vector< WVector3d > &orientations, int order, double lambda, bool withFRT)
 This calculates the transformation/fitting matrix T like in the 2007 Descoteaux paper.
static WMatrix< double > getSHFittingMatrix (const std::vector< WUnitSphereCoordinates > &orientations, int order, double lambda, bool withFRT)
 This calculates the transformation/fitting matrix T like in the 2007 Descoteaux paper.
static WMatrix< double > getSHFittingMatrixForConstantSolidAngle (const std::vector< WVector3d > &orientations, int order, double lambda)
 This calculates the transformation/fitting matrix T like in the 2010 Aganj paper.
static WMatrix< double > getSHFittingMatrixForConstantSolidAngle (const std::vector< WUnitSphereCoordinates > &orientations, int order, double lambda)
 This calculates the transformation/fitting matrix T like in the 2010 Aganj paper.
static WMatrix< double > calcBaseMatrix (const std::vector< WUnitSphereCoordinates > &orientations, int order)
 Calculates the base matrix B like in the dissertation of Descoteaux.
static WMatrix< std::complex
< double > > 
calcComplexBaseMatrix (std::vector< WUnitSphereCoordinates > const &orientations, int order)
 Calculates the base matrix B for the complex spherical harmonics.
static WValue< double > calcEigenvalues (size_t order)
 Calc eigenvalues for SH elements.
static WMatrix< double > calcMatrixWithEigenvalues (size_t order)
 Calc matrix with the eigenvalues of the SH elements on its diagonal.
static WMatrix< double > calcSmoothingMatrix (size_t order)
 This calcs the smoothing matrix L from the 2007 Descoteaux Paper "Regularized, Fast, and Robust Analytical Q-Ball Imaging".
static WMatrix< double > calcFRTMatrix (size_t order)
 Calculates the Funk-Radon-Transformation-Matrix P from the 2007 Descoteaux Paper "Regularized, Fast, and Robust Analytical Q-Ball Imaging".
static WMatrix< double > calcSHToTensorSymMatrix (std::size_t order, const std::vector< WUnitSphereCoordinates > &orientations)
 Calculates a matrix that converts spherical harmonics to symmetric tensors of equal or lower order.

Private Attributes

size_t m_order
 order of the spherical harmonic
WValue< double > m_SHCoefficients
 coefficients of the spherical harmonic

Detailed Description

Class for symmetric spherical harmonics The index scheme of the coefficients/basis values is like in the Descoteaux paper "Regularized, Fast, and Robust Analytical Q-Ball Imaging".

Definition at line 41 of file WSymmetricSphericalHarmonic.h.

Constructor & Destructor Documentation

WSymmetricSphericalHarmonic::WSymmetricSphericalHarmonic ( )

Default constructor.

Definition at line 41 of file WSymmetricSphericalHarmonic.cpp.

WSymmetricSphericalHarmonic::WSymmetricSphericalHarmonic ( const WValue< double > &  SHCoefficients)
explicit

Constructor.

Parameters
SHCoefficientsthe initial coefficients (stored like in the mentioned Descoteaux paper).

Definition at line 47 of file WSymmetricSphericalHarmonic.cpp.

References m_order, m_SHCoefficients, and WValue< T >::size().

WSymmetricSphericalHarmonic::~WSymmetricSphericalHarmonic ( )
virtual

Destructor.

Definition at line 56 of file WSymmetricSphericalHarmonic.cpp.

Member Function Documentation

void WSymmetricSphericalHarmonic::applyFunkRadonTransformation ( WMatrix< double > const &  frtMat)

Applies the Funk-Radon-Transformation.

This is faster than matrix multiplication. ( O(n) instead of O(n²) )

Parameters
frtMatthe frt matrix as calculated by calcFRTMatrix()

Definition at line 243 of file WSymmetricSphericalHarmonic.cpp.

References WMatrix< T >::getNbCols(), WMatrix< T >::getNbRows(), m_SHCoefficients, and WValue< T >::size().

WMatrix< double > WSymmetricSphericalHarmonic::calcBaseMatrix ( const std::vector< WUnitSphereCoordinates > &  orientations,
int  order 
)
static

Calculates the base matrix B like in the dissertation of Descoteaux.

Parameters
orientationsThe vector with the used orientation on the unit sphere (usually the gradients of the HARDI)
orderThe order of the spherical harmonics intended to create
Returns
The base Matrix B

Definition at line 347 of file WSymmetricSphericalHarmonic.cpp.

Referenced by calcSHToTensorSymMatrix(), getSHFittingMatrix(), and getSHFittingMatrixForConstantSolidAngle().

WMatrix< std::complex< double > > WSymmetricSphericalHarmonic::calcComplexBaseMatrix ( std::vector< WUnitSphereCoordinates > const &  orientations,
int  order 
)
static

Calculates the base matrix B for the complex spherical harmonics.

Parameters
orientationsThe vector with the used orientation on the unit sphere (usually the gradients of the HARDI)
orderThe order of the spherical harmonics intended to create
Returns
The base Matrix B

Definition at line 382 of file WSymmetricSphericalHarmonic.cpp.

WValue< double > WSymmetricSphericalHarmonic::calcEigenvalues ( size_t  order)
static

Calc eigenvalues for SH elements.

Parameters
orderThe order of the spherical harmonic
Returns
The eigenvalues of the coefficients

Definition at line 411 of file WSymmetricSphericalHarmonic.cpp.

Referenced by calcMatrixWithEigenvalues(), and calcSmoothingMatrix().

WMatrix< double > WSymmetricSphericalHarmonic::calcFRTMatrix ( size_t  order)
static

Calculates the Funk-Radon-Transformation-Matrix P from the 2007 Descoteaux Paper "Regularized, Fast, and Robust Analytical Q-Ball Imaging".

Parameters
orderThe order of the spherical harmonic
Returns
The Funk-Radon-Matrix P

Definition at line 449 of file WSymmetricSphericalHarmonic.cpp.

Referenced by getSHFittingMatrix(), getSHFittingMatrixForConstantSolidAngle(), and WSymmetricSphericalHarmonicTest::testCalcFRTMatrix().

double WSymmetricSphericalHarmonic::calcGFA ( std::vector< WUnitSphereCoordinates > const &  orientations) const

Calculate the generalized fractional anisotropy for this ODF.

See: David S. Tuch, "Q-Ball Imaging", Magn. Reson. Med. 52, 2004, 1358-1372

Notes:
this only makes sense if this is an ODF, meaning funk-radon-transform was applied etc.
Parameters
orientationsA vector of unit sphere coordinates.
Returns
The generalized fractional anisotropy.

Definition at line 149 of file WSymmetricSphericalHarmonic.cpp.

References getValue().

double WSymmetricSphericalHarmonic::calcGFA ( WMatrix< double > const &  B) const

Calculate the generalized fractional anisotropy for this ODF.

This version of the function uses precomputed base functions (because calculating the base function values is rather expensive). Use this version if you want to compute the GFA for multiple ODFs with the same base functions. The base function Matrix can be computed using

See Also
calcBMatrix().

See: David S. Tuch, "Q-Ball Imaging", Magn. Reson. Med. 52, 2004, 1358-1372

Notes:
this only makes sense if this is an ODF, meaning funk-radon-transform was applied etc.
Parameters
BThe matrix of SH base functions.
Returns
The generalized fractional anisotropy.

Definition at line 192 of file WSymmetricSphericalHarmonic.cpp.

References WMatrix< T >::getNbCols(), WMatrix< T >::getNbRows(), m_SHCoefficients, and WValue< T >::size().

WMatrix< double > WSymmetricSphericalHarmonic::calcMatrixWithEigenvalues ( size_t  order)
static

Calc matrix with the eigenvalues of the SH elements on its diagonal.

Parameters
orderThe order of the spherical harmonic
Returns
The matrix with the eigenvalues of the coefficients

Definition at line 427 of file WSymmetricSphericalHarmonic.cpp.

References calcEigenvalues(), and WValue< T >::size().

Referenced by getSHFittingMatrixForConstantSolidAngle().

WMatrix< double > WSymmetricSphericalHarmonic::calcSHToTensorSymMatrix ( std::size_t  order,
const std::vector< WUnitSphereCoordinates > &  orientations 
)
static

Calculates a matrix that converts spherical harmonics to symmetric tensors of equal or lower order.

Parameters
orderThe order of the symmetric tensor.
orientationsA vector of at least (orderTensor+1) * (orderTensor+2) / 2 orientations.
Returns
the conversion matrix

Definition at line 467 of file WSymmetricSphericalHarmonic.cpp.

References calcBaseMatrix().

WMatrix< double > WSymmetricSphericalHarmonic::calcSmoothingMatrix ( size_t  order)
static

This calcs the smoothing matrix L from the 2007 Descoteaux Paper "Regularized, Fast, and Robust Analytical Q-Ball Imaging".

Parameters
orderThe order of the spherical harmonic
Returns
The smoothing matrix L

Definition at line 438 of file WSymmetricSphericalHarmonic.cpp.

References calcEigenvalues(), and WValue< T >::size().

Referenced by getSHFittingMatrix(), getSHFittingMatrixForConstantSolidAngle(), and WSymmetricSphericalHarmonicTest::testCalcSmoothingMatrix().

const WValue< double > & WSymmetricSphericalHarmonic::getCoefficients ( ) const

Returns the used coefficients (stored like in the mentioned 2007 Descoteaux paper).

Returns
coefficient list

Definition at line 91 of file WSymmetricSphericalHarmonic.cpp.

References m_SHCoefficients.

WValue< std::complex< double > > WSymmetricSphericalHarmonic::getCoefficientsComplex ( ) const

Returns the coefficients for the complex base.

Returns
coefficiend list

Definition at line 119 of file WSymmetricSphericalHarmonic.cpp.

References m_order, m_SHCoefficients, and WValue< T >::size().

WValue< double > WSymmetricSphericalHarmonic::getCoefficientsSchultz ( ) const

Returns the coefficients for Schultz' SH base.

Returns
coefficient list

Definition at line 96 of file WSymmetricSphericalHarmonic.cpp.

References m_order, m_SHCoefficients, and WValue< T >::size().

size_t WSymmetricSphericalHarmonic::getOrder ( ) const

Return the order of the spherical harmonic.

Returns
order of SH

Definition at line 254 of file WSymmetricSphericalHarmonic.cpp.

References m_order.

WMatrix< double > WSymmetricSphericalHarmonic::getSHFittingMatrix ( const std::vector< WVector3d > &  orientations,
int  order,
double  lambda,
bool  withFRT 
)
static

This calculates the transformation/fitting matrix T like in the 2007 Descoteaux paper.

The orientations are given as WVector3d.

Parameters
orientationsThe vector with the used orientation on the unit sphere (usually the gradients of the HARDI)
orderThe order of the spherical harmonics intended to create
lambdaRegularization parameter for smoothing matrix
withFRTinclude the Funk-Radon-Transformation?
Returns
Transformation matrix

Definition at line 259 of file WSymmetricSphericalHarmonic.cpp.

WMatrix< double > WSymmetricSphericalHarmonic::getSHFittingMatrix ( const std::vector< WUnitSphereCoordinates > &  orientations,
int  order,
double  lambda,
bool  withFRT 
)
static

This calculates the transformation/fitting matrix T like in the 2007 Descoteaux paper.

The orientations are given as WUnitSphereCoordinates .

Parameters
orientationsThe vector with the used orientation on the unit sphere (usually the gradients of the HARDI)
orderThe order of the spherical harmonics intended to create
lambdaRegularization parameter for smoothing matrix
withFRTinclude the Funk-Radon-Transformation?
Returns
Transformation matrix

Definition at line 273 of file WSymmetricSphericalHarmonic.cpp.

References calcBaseMatrix(), calcFRTMatrix(), calcSmoothingMatrix(), and WMatrix< T >::transposed().

WMatrix< double > WSymmetricSphericalHarmonic::getSHFittingMatrixForConstantSolidAngle ( const std::vector< WVector3d > &  orientations,
int  order,
double  lambda 
)
static

This calculates the transformation/fitting matrix T like in the 2010 Aganj paper.

The orientations are given as WUnitSphereCoordinates .

Parameters
orientationsThe vector with the used orientation on the unit sphere (usually the gradients of the HARDI)
orderThe order of the spherical harmonics intended to create
lambdaRegularization parameter for smoothing matrix
Returns
Transformation matrix

Definition at line 296 of file WSymmetricSphericalHarmonic.cpp.

WMatrix< double > WSymmetricSphericalHarmonic::getSHFittingMatrixForConstantSolidAngle ( const std::vector< WUnitSphereCoordinates > &  orientations,
int  order,
double  lambda 
)
static

This calculates the transformation/fitting matrix T like in the 2010 Aganj paper.

The orientations are given as WUnitSphereCoordinates .

Parameters
orientationsThe vector with the used orientation on the unit sphere (usually the gradients of the HARDI)
orderThe order of the spherical harmonics intended to create
lambdaRegularization parameter for smoothing matrix
Returns
Transformation matrix

Definition at line 309 of file WSymmetricSphericalHarmonic.cpp.

References calcBaseMatrix(), calcFRTMatrix(), calcMatrixWithEigenvalues(), calcSmoothingMatrix(), wlog::debug(), and WMatrix< T >::transposed().

double WSymmetricSphericalHarmonic::getValue ( double  theta,
double  phi 
) const

Return the value on the sphere.

Parameters
thetaangle for the position on the unit sphere
phiangle for the position on the unit sphere
Returns
value on sphere

Definition at line 60 of file WSymmetricSphericalHarmonic.cpp.

References m_order, and m_SHCoefficients.

Referenced by calcGFA(), and getValue().

double WSymmetricSphericalHarmonic::getValue ( const WUnitSphereCoordinates coordinates) const

Return the value on the sphere.

Parameters
coordinatesfor the position on the unit sphere
Returns
value on sphere

Definition at line 86 of file WSymmetricSphericalHarmonic.cpp.

References WUnitSphereCoordinates::getPhi(), WUnitSphereCoordinates::getTheta(), and getValue().

void WSymmetricSphericalHarmonic::normalize ( )

Normalize this SH in place.

Definition at line 519 of file WSymmetricSphericalHarmonic.cpp.

References m_SHCoefficients, and WValue< T >::size().

Member Data Documentation

size_t WSymmetricSphericalHarmonic::m_order
private

order of the spherical harmonic

Definition at line 253 of file WSymmetricSphericalHarmonic.h.

Referenced by getCoefficientsComplex(), getCoefficientsSchultz(), getOrder(), getValue(), and WSymmetricSphericalHarmonic().

WValue<double> WSymmetricSphericalHarmonic::m_SHCoefficients
private

The documentation for this class was generated from the following files: