DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkDiffusionModelEstimationImageFilter.hxx
Go to the documentation of this file.
1 
19 #ifndef __itkDiffusionModelEstimationImageFilter_hxx
20 #define __itkDiffusionModelEstimationImageFilter_hxx
21 
23 
24 namespace itk
25 {
26 
27 template< class TInputImage, class TOutputImage >
30  m_BasisMatrix(new MatrixType()),
31  m_RegularizationWeight(new VectorType())
32 {
33  m_MD0 = 0.7e-3;
34  m_SamplingSchemeQSpace = SamplingSchemeQSpaceType::New();
35 }
36 
37 template< class TInputImage, class TOutputImage >
38 typename LightObject::Pointer
41 {
42  itkShowPositionThreadedLogger(this->GetDebug());
43  typename LightObject::Pointer loPtr = Superclass::InternalClone();
44 
45  typename Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
46  if(rval.IsNull())
47  {
48  itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass()<< " failed.");
49  }
50 
51  rval->m_SamplingSchemeQSpace = m_SamplingSchemeQSpace->Clone();
52 
53  // NOTE: shared_ptr is thread safe, if the data is read only, thus do not need to copy the data block.
54  rval->m_RegularizationWeight = m_RegularizationWeight;
55  rval->m_BasisMatrix = m_BasisMatrix;
56 
57  rval->m_MD0 = m_MD0;
58 
59  return loPtr;
60 }
61 
62 template< class TInputImage, class TOutputImage >
63 void
66 {
67  itkShowPositionThreadedLogger(this->GetDebug());
68  if (!IsImageEmpty(this->m_MaskImage))
69  this->VerifyMaskInformation();
70 
71  utlGlobalException(m_SamplingSchemeQSpace->GetBVector()->size()==0 && m_SamplingSchemeQSpace->GetRadiusVector()->size()==0, "no b values nor q values");
72  utlGlobalException(m_SamplingSchemeQSpace->size()==0, "no gradients in q-space");
73  InputImageConstPointer inputPtr = this->GetInput();
74  utlGlobalException(!inputPtr, "no input DWIs");
75  int dwiNumber = inputPtr->GetNumberOfComponentsPerPixel();
76  utlGlobalException(dwiNumber!=m_SamplingSchemeQSpace->GetNumberOfSamples(), "the size of gradients and the size of DWIs are not the same");
77  utlGlobalException(m_SamplingSchemeQSpace->GetRadiusVector()->size()!=m_SamplingSchemeQSpace->GetNumberOfSamples(), "the size of gradients and the size of b values are not the same");
78 }
79 
80 template< class TInputImage, class TOutputImage >
81 void
83 ::PrintSelf(std::ostream& os, Indent indent) const
84 {
85  Superclass::PrintSelf(os, indent);
86  PrintVar1(true, m_MD0, os<<indent);
87 
88  os << indent << "m_SamplingSchemeQSpace = " << m_SamplingSchemeQSpace << std::endl;
89  utl::PrintUtlMatrix(*m_BasisMatrix, "m_BasisMatrix", " ", os<<indent);
90  utl::PrintUtlVector(*m_RegularizationWeight, "m_RegularizationWeight", " ", os<<indent);
91 }
92 
93 }
94 
95 #endif
96 
97 
base filter for estimation of diffusion models
#define PrintVar1(cond, var, os)
Definition: utlCoreMacro.h:447
bool IsImageEmpty(const SmartPointer< ImageType > &image)
Definition: utlITK.h:435
void PrintUtlMatrix(const NDArray< T, 2 > &mat, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout)
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
LightObject::Pointer InternalClone() const ITK_OVERRIDE
#define utlGlobalException(cond, expout)
Definition: utlCoreMacro.h:372
#define itkShowPositionThreadedLogger(cond)
Definition: utlITKMacro.h:192
void PrintUtlVector(const NDArray< T, 1 > &vec, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout, bool showStats=true)