18 #ifndef __itkTensorBasisMatrixGenerator_hxx 19 #define __itkTensorBasisMatrixGenerator_hxx 27 template<
typename TElement>
37 template<
typename TElement>
38 typename LightObject::Pointer
43 typename LightObject::Pointer loPtr = Superclass::InternalClone();
48 itkExceptionMacro(<<
"downcast to type " << this->GetNameOfClass()<<
" failed.");
50 rval->m_EigenValue1 = m_EigenValue1;
51 rval->m_EigenValue2 = m_EigenValue2;
52 rval->m_EigenValue3 = m_EigenValue3;
53 rval->m_EigenValueISO = m_EigenValueISO;
57 template<
typename TElement>
62 Superclass::PrintSelf(os, indent);
63 PrintVar3(
true, m_EigenValue1, m_EigenValue2, m_EigenValue3, os<<indent);
64 PrintVar1(
true, m_EigenValueISO, os<<indent);
67 template<
typename TElement>
72 Superclass::VerifyInputParameters();
74 utlSAGlobalException(m_EigenValue1<0 || m_EigenValue2<0 || m_EigenValue3<0)(m_EigenValue1)(m_EigenValue2)(m_EigenValue3).msg(
"need to set m_EigenValue1, m_EigenValue2, m_EigenValue3");
75 utlSAGlobalException(this->m_UseIsotropicTerm && m_EigenValueISO<0)(m_EigenValueISO).msg(
"need to set m_EigenValueISO");
77 utlGlobalException(this->m_OutputType==Superclass::DWI && this->m_SamplingSchemeQSpace->GetBVector()->size()==0,
"no bVector");
81 template<
typename TElement>
87 VerifyInputParameters();
89 MatrixPointer qOrientations = this->m_SamplingSchemeQSpace->GetOrientationsCartesian();
91 MatrixPointer rOrientations = this->m_SamplingSchemeRSpace->GetOrientationsCartesian();
93 double tau = this->m_SamplingSchemeQSpace->GetTau();
95 int numberOfBasis = this->GetNumberOfBasis();
96 int numberOfSamples = -1;
101 numberOfSamples = this->GetNumberOfSamples();
105 std::vector<double> vec(3,1);
106 vec[0]=m_EigenValue1, vec[1]=m_EigenValue2, vec[2]=m_EigenValue3;
108 Vector<double, 3> principalDirection(0.0);
109 Vector<double, 3> e1;
110 e1[0]=1.0, e1[1]=0.0, e1[2]=0.0;
111 Matrix<double,3,3> rotation;
114 for (
int i = 0; i < this->m_BasisOrientations->Rows(); i += 1 )
119 principalDirection[0] = (*this->m_BasisOrientations)(i,0);
120 principalDirection[1] = (*this->m_BasisOrientations)(i,1);
121 principalDirection[2] = (*this->m_BasisOrientations)(i,2);
122 utl::RotationMatrixFromVectors<Vector<double,3>, Matrix<double,3> >(e1, principalDirection, rotation);
126 if (this->m_OutputType==Superclass::DWI)
128 else if (this->m_OutputType==Superclass::EAP)
130 else if (this->m_OutputType==Superclass::ODF)
131 tensor.
GetODFSamples(out, *rOrientations, this->m_ODFOrder,
false);
134 if (this->m_UseIsotropicTerm)
135 mat->SetColumn(i+1, out);
137 mat->SetColumn(i, out);
140 if (this->m_UseIsotropicTerm)
142 vec[0]=m_EigenValueISO, vec[1]=m_EigenValueISO, vec[2]=m_EigenValueISO;
146 if (this->m_OutputType==Superclass::DWI)
148 else if (this->m_OutputType==Superclass::EAP)
150 else if (this->m_OutputType==Superclass::ODF)
151 tensor.
GetODFSamples(out, *rOrientations, this->m_ODFOrder,
false);
153 mat->SetColumn(0, out);
156 if (this->m_OutputType==Superclass::DWI)
157 this->m_QBasisMatrixForDWI = mat;
158 else if (this->m_OutputType==Superclass::EAP)
159 this->m_RBasisMatrixForEAP = mat;
160 else if (this->m_OutputType==Superclass::ODF)
161 this->m_RBasisMatrixForODF = mat;
void GetEAPSamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const std::vector< TPrecision > &rValues, const TPrecision &tau) const
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
#define PrintVar1(cond, var, os)
LightObject::Pointer InternalClone() const ITK_OVERRIDE
void GetDWISamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const std::vector< TPrecision > &bValues) const
#define utlSAGlobalException(expr)
utl_shared_ptr< STDVectorType > STDVectorPointer
Self & Rotate(const typename Self::MatrixType &mat)
void ComputeBasisMatrix() ITK_OVERRIDE
utl_shared_ptr< MatrixType > MatrixPointer
#define utlGlobalException(cond, expout)
void SetEigenValues(const TArrayType &array)
SmartPointer< Self > Pointer
#define PrintVar3(cond, var1, var2, var3, os)
TensorBasisMatrixGenerator()
#define utlShowPosition(cond)
virtual void VerifyInputParameters() const ITK_OVERRIDE
void GetODFSamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const int &odfOrder=2, const bool &isNormalize=false) const
tensor with some useful functions