DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkDiffusionModelEstimationInSphericalCoordinateImageFilter.hxx
Go to the documentation of this file.
1 
18 #ifndef __itkDiffusionModelEstimationInSphericalCoordinateImageFilter_hxx
19 #define __itkDiffusionModelEstimationInSphericalCoordinateImageFilter_hxx
20 
22 
23 namespace itk
24 {
25 
26 template< class TInputImage, class TOutputImage >
29  m_BasisSHMatrix(new MatrixType()),
30  m_BasisRadialMatrix(new MatrixType())
31 {
32  m_SHRank = 4;
33  m_RadialRank = 0;
34 }
35 
36 template< class TInputImage, class TOutputImage >
37 typename LightObject::Pointer
40 {
41  itkShowPositionThreadedLogger(this->GetDebug());
42  typename LightObject::Pointer loPtr = Superclass::InternalClone();
43 
44  typename Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
45  if(rval.IsNull())
46  {
47  itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass()<< " failed.");
48  }
49 
50  rval->m_SHRank = m_SHRank;
51  rval->m_RadialRank = m_RadialRank;
52  rval->m_BasisSHMatrix = m_BasisSHMatrix;
53  rval->m_BasisRadialMatrix = m_BasisRadialMatrix;
54  return loPtr;
55 }
56 
57 template< class TInputImage, class TOutputImage >
58 void
61 {
62  itkShowPositionThreadedLogger(this->GetDebug());
63 
64  MatrixPointer qOrientations = this->m_SamplingSchemeQSpace->GetOrientationsSpherical();
65  this->m_BasisSHMatrix= utl::ComputeSHMatrix(m_SHRank, *qOrientations, SPHERICAL_TO_SPHERICAL);
66 
67  if(this->GetDebug())
68  {
69  int n_s = qOrientations->Rows();
70  int n_b = (m_SHRank + 1)*(m_SHRank + 2)/2;
71  std::ostringstream msg;
72  msg << this->ThreadIDToString() << "Generated the "<< n_s << "x" << n_b << " Bmatrix...\n";
73  utl::PrintUtlMatrix(*this->m_BasisSHMatrix,"SHMatrix", " ", msg << this->ThreadIDToString());
74  this->WriteLogger(msg.str());
75  }
76 }
77 
78 template< class TInputImage, class TOutputImage >
79 void
82 {
83  itkShowPositionThreadedLogger(this->GetDebug());
84  Superclass::VerifyInputParameters();
85 
86  utlGlobalException(this->m_SHRank<0 || this->m_RadialRank<0, "negative rank");
87  utlGlobalException(!utl::IsEven(this->m_SHRank), "sh rank should be even");
88 }
89 
90 template< class TInputImage, class TOutputImage >
91 void
93 ::PrintSelf(std::ostream& os, Indent indent) const
94 {
95  Superclass::PrintSelf(os, indent);
96 
97  PrintVar2(true, m_SHRank, m_RadialRank, os<<indent);
98  utl::PrintUtlMatrix(*m_BasisSHMatrix, "m_BasisSHMatrix", " ", os<<indent);
99  utl::PrintUtlMatrix(*m_BasisRadialMatrix, "m_BasisRadialMatrix", " ", os<<indent);
100 }
101 
102 }
103 
104 
105 #endif
106 
107 
108 
base filter for estimation of diffusion models
bool IsEven(const int value)
Definition: utlCore.h:819
void PrintUtlMatrix(const NDArray< T, 2 > &mat, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout)
std::shared_ptr< NDArray< T, 2 > > ComputeSHMatrix(const unsigned int rank, const NDArray< T, 2 > &grad, const int mode)
Definition: utl.h:171
#define utlGlobalException(cond, expout)
Definition: utlCoreMacro.h:372
#define itkShowPositionThreadedLogger(cond)
Definition: utlITKMacro.h:192
#define PrintVar2(cond, var1, var2, os)
Definition: utlCoreMacro.h:454