DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkMeshFromDiscreteFiberODFImageFilter.h
Go to the documentation of this file.
1 
18 #ifndef __itkMeshFromDiscreteFiberODFImageFilter_h
19 #define __itkMeshFromDiscreteFiberODFImageFilter_h
20 
21 
24 
25 namespace itk
26 {
27 
35 template < class TInputImage, class TOutputMesh=vtkPolyData>
37  : public MeshFromContinuousSphericalFunctionImageFilter<TInputImage, TOutputMesh>
38 {
39 public:
43  typedef SmartPointer<Self> Pointer;
44  typedef SmartPointer<const Self> ConstPointer;
45 
47  itkNewMacro(Self);
48 
51 
52  //** Convenient typedefs */
53  typedef TInputImage InputImageType;
54  typedef typename InputImageType::Pointer InputImagePointer;
55  typedef typename InputImageType::ConstPointer InputImageConstPointer;
56  typedef typename InputImageType::IndexType InputImageIndexType;
57  typedef typename InputImageType::SizeType InputImageSizeType;
58  typedef typename InputImageType::SizeValueType InputImageSizeValueType;
59  typedef typename InputImageType::SpacingType InputImageSpacingType;
60  typedef typename InputImageType::PixelType InputImagePixelType;
61  typedef typename InputImageType::RegionType InputImageRegionType;
62  typedef typename InputImageType::PointType InputImagePointType;
63 
64  typedef TOutputMesh OutputMeshPolyDataType;
65 
71 
72 
77 
78 
86 
88 
91 
92  itkSetObjectMacro(BasisMatrixGenerator, BasisMatrixGeneratorType);
93  itkGetObjectMacro(BasisMatrixGenerator, BasisMatrixGeneratorType);
94 
95  itkSetMacro(Radius, double);
96  itkGetMacro(Radius, double);
97 
99  {
100  utlShowPosition(this->GetDebug());
101  InputImageConstPointer inputPtr = this->GetInput();
102  unsigned int inputPixelDimension = inputPtr->GetNumberOfComponentsPerPixel();
103 
104  utlGlobalException(!m_BasisMatrixGenerator, "no m_BasisMatrixGenerator");
105  utlSAGlobalException(m_BasisMatrixGenerator->GetNumberOfBasis()!=inputPixelDimension)
106  (m_BasisMatrixGenerator->GetNumberOfBasis())(inputPixelDimension)
107  .msg("no m_BasisMatrixGenerator");
108 
109  // this->Print(std::cout<<"this");
110  utlGlobalException(this->m_Orientations->Rows()==0, "no m_Orientations");
111  if (m_BasisMatrixGenerator->GetOutputType()==BasisMatrixGeneratorType::DWI)
112  {
113  m_BasisMatrixGenerator->GetSamplingSchemeQSpace()->SetOrientationsCartesian(this->m_Orientations);
114  STDVectorPointer bVec = m_BasisMatrixGenerator->GetSamplingSchemeQSpace()->GetBVector();
115  utlGlobalException(bVec->size()==0 && m_Radius<0, "need to set m_Radius (b value) for DWI");
116  if (bVec->size()==0 && m_Radius>=0)
117  utl::MatchBVectorAndGradientMatrix(m_Radius, *bVec, *this->m_Orientations);
118  }
119  else if (m_BasisMatrixGenerator->GetOutputType()==BasisMatrixGeneratorType::EAP)
120  {
121  m_BasisMatrixGenerator->GetSamplingSchemeRSpace()->SetOrientationsCartesian(this->m_Orientations);
122  STDVectorPointer rVec = m_BasisMatrixGenerator->GetSamplingSchemeRSpace()->GetRadiusVector();
123  utlGlobalException(rVec->size()==0 && m_Radius<0, "need to set m_Radius (r value) for EAP");
124  if (rVec->size()==0 && m_Radius>=0)
125  utl::MatchBVectorAndGradientMatrix(m_Radius, *rVec, *this->m_Orientations);
126  }
127  else if (m_BasisMatrixGenerator->GetOutputType()==BasisMatrixGeneratorType::ODF)
128  {
129  m_BasisMatrixGenerator->GetSamplingSchemeRSpace()->SetOrientationsCartesian(this->m_Orientations);
130  }
131 
132  // m_BasisMatrixGenerator->Print(std::cout<<"m_BasisMatrixGenerator");
133  m_BasisMatrixGenerator->Flip(this->m_Flip[0], this->m_Flip[1], this->m_Flip[2]);
134  m_BasisMatrixGenerator->ComputeBasisMatrix();
135  this->m_BasisMatrix = m_BasisMatrixGenerator->GetBasisMatrix();
136  return this->m_BasisMatrix;
137  }
138 
139 protected:
141  {
142  m_BasisMatrixGenerator = NULL;
143  m_Radius = -1.0;
144  }
146  {};
147 
148  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE
149  {
150  Superclass::PrintSelf(os, indent);
151  if (m_BasisMatrixGenerator)
152  m_BasisMatrixGenerator->Print(std::cout<<"m_BasisMatrixGenerator");
153  }
154 
155  double m_Radius;
156  // virtual void GenerateData();
157  // void ThreadedGenerateData(const typename TInputImage::RegionType& regionForThread,ThreadIdType threadId );
158  // void BeforeThreadedGenerateData();
159 
160 
161  BasisMatrixGeneratorPointer m_BasisMatrixGenerator;
162 
163 private:
164  MeshFromDiscreteFiberODFImageFilter(const Self&); //purposely not implemented
165  void operator=(const Self&);//purposely not implemented
166 
167 
168 };
169 
170 } // end namespace itk
171 
172 
173 #endif
Compute mesh from discrete fiber ODF represented by a set of basis functions.
Superclass::OutputMeshPolyDataPointer OutputMeshPolyDataPointer
void MatchBVectorAndGradientMatrix(const T &br, std::vector< T > &vec, const NDArray< T, 2 > &grad)
Definition: utlDMRI.h:480
#define utlSAGlobalException(expr)
Definition: utlCoreMacro.h:362
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
MeshFromContinuousSphericalFunctionImageFilter< TInputImage, TOutputMesh > Superclass
#define utlGlobalException(cond, expout)
Definition: utlCoreMacro.h:372
Superclass::OutputMeshPolyDataPointer OutputMeshPolyDataPointer
Compute mesh from continuous spherical function linearly represented by a set of bases.
#define utlShowPosition(cond)
Definition: utlCoreMacro.h:554
SmartPointer< Self > Pointer
Tesselates a sphere via subdivision of tetrahedron, octahedron, or icosahedron.
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE