DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkBasisMatrixGenerator.hxx
Go to the documentation of this file.
1 
18 #ifndef __itkBasisMatrixGenerator_hxx
19 #define __itkBasisMatrixGenerator_hxx
20 
22 
23 namespace itk
24 {
25 
26 template<typename TElement>
29  m_QBasisMatrixForDWI(new MatrixType()),
30  m_RBasisMatrixForEAP(new MatrixType()),
31  m_RBasisMatrixForODF(new MatrixType())
32 {
33  m_MD0 = 0.7e-3;
34  m_ODFOrder = 2;
35  m_OutputType = DWI;
36 
37  m_SamplingSchemeQSpace = SamplingSchemeQSpaceType::New();
38  m_SamplingSchemeRSpace = SamplingSchemeQSpaceType::New();
39 }
40 
41 template<typename TElement>
42 typename LightObject::Pointer
45 {
46  utlShowPosition(this->GetDebug());
47  typename LightObject::Pointer loPtr = Superclass::InternalClone();
48 
49  typename Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
50  if(rval.IsNull())
51  {
52  itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass()<< " failed.");
53  }
54  rval->m_MD0 = m_MD0;
55  rval->m_ODFOrder = m_ODFOrder;
56  rval->m_OutputType = m_OutputType;
57 
58  // NOTE: shared_ptr is thread safe, if the data is read only, thus do not need to copy the data block
59  rval->m_QBasisMatrixForDWI = m_QBasisMatrixForDWI;
60 
61  rval->m_RBasisMatrixForEAP = m_RBasisMatrixForEAP;
62  rval->m_RBasisMatrixForODF = m_RBasisMatrixForODF;
63 
64  rval->m_SamplingSchemeQSpace = m_SamplingSchemeQSpace;
65  rval->m_SamplingSchemeRSpace = m_SamplingSchemeRSpace;
66 
67  return loPtr;
68 }
69 
70 template<typename TElement>
71 void
73 ::PrintSelf(std::ostream& os, Indent indent) const
74 {
75  Superclass::PrintSelf(os, indent);
76  PrintVar2(true, m_MD0, m_ODFOrder, os<<indent);
77  PrintEnum3(true, m_OutputType, DWI, EAP, ODF, os <<indent);
78 
79  os << indent << "m_SamplingSchemeQSpace: " << m_SamplingSchemeQSpace << std::endl;
80  utl::PrintUtlMatrix(*m_QBasisMatrixForDWI, "m_QBasisMatrixForDWI", " ", os<<indent);
81 
82  os << indent << "m_SamplingSchemeRSpace: " << m_SamplingSchemeRSpace << std::endl;
83  utl::PrintUtlMatrix(*m_RBasisMatrixForEAP, "m_RBasisMatrixForEAP", " ", os<<indent);
84  utl::PrintUtlMatrix(*m_RBasisMatrixForODF, "m_RBasisMatrixForODF", " ", os<<indent);
85 }
86 
87 template<typename TElement>
88 void
91 {
92  if (m_OutputType==DWI)
93  {
94  MatrixPointer qOrientations = m_SamplingSchemeQSpace->GetOrientationsCartesian();
95  STDVectorPointer bVector = m_SamplingSchemeQSpace->GetBVector();
96  STDVectorPointer qVector = m_SamplingSchemeQSpace->GetRadiusVector();
97  utlGlobalException(bVector->size()==0 && qVector->size()==0, "no qVector nor bVector for DWI output");
98  utlGlobalException(qOrientations->Rows()==0, "no qOrientations for DWI output");
99  utlSAGlobalException(qVector->size()>0 && qVector->size()!=qOrientations->Rows())(qVector->size())(qOrientations->Rows()).msg("sizes are different");
100  utlSAGlobalException(bVector->size()>0 && bVector->size()!=qOrientations->Rows())(bVector->size())(qOrientations->Rows()).msg("sizes are different");
101  }
102  else
103  {
104  MatrixPointer rOrientations = m_SamplingSchemeRSpace->GetOrientationsCartesian();
105  STDVectorPointer rVector = m_SamplingSchemeRSpace->GetRadiusVector();
106  utlGlobalException(rOrientations->Rows()==0, "no rOrientations for ODF or EAP output");
107  utlGlobalException(m_OutputType==EAP && rVector->size()==0, "no m_RVector for EAP output");
108  utlSAGlobalException(rVector->size()>0 && rVector->size()!=rOrientations->Rows())(rVector->size())(rOrientations->Rows()).msg("sizes are different");
109  }
110 }
111 
112 }
113 
114 
115 #endif
116 
void PrintUtlMatrix(const NDArray< T, 2 > &mat, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout)
LightObject::Pointer InternalClone() const ITK_OVERRIDE
#define utlSAGlobalException(expr)
Definition: utlCoreMacro.h:362
utl_shared_ptr< STDVectorType > STDVectorPointer
utl_shared_ptr< MatrixType > MatrixPointer
#define utlGlobalException(cond, expout)
Definition: utlCoreMacro.h:372
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
virtual void VerifyInputParameters() const
#define utlShowPosition(cond)
Definition: utlCoreMacro.h:554
#define PrintEnum3(cond, var, val1, val2, val3, os)
Definition: utlCoreMacro.h:415
#define PrintVar2(cond, var1, var2, os)
Definition: utlCoreMacro.h:454