ANIMA  4.0
animaODFEstimatorImageFilter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <itkImageToImageFilter.h>
5 #include <itkVectorImage.h>
6 #include <itkImage.h>
7 #include <vector>
8 
9 namespace anima
10 {
11 
12 template <typename TInputPixelType, typename TOutputPixelType>
14  public itk::ImageToImageFilter< itk::Image<TInputPixelType, 3> , itk::VectorImage <TOutputPixelType, 3> >
15 {
16 public:
19  typedef itk::Image <TInputPixelType, 3> TInputImage;
20  typedef itk::Image<TInputPixelType,4> Image4DType;
21  typedef itk::VectorImage <TOutputPixelType, 3> TOutputImage;
22  typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass;
23  typedef itk::SmartPointer<Self> Pointer;
24  typedef itk::SmartPointer<const Self> ConstPointer;
25 
27  itkNewMacro(Self);
28 
30  itkTypeMacro(ODFEstimatorImageFilter, ImageToImageFilter);
31 
32  typedef typename TInputImage::Pointer InputImagePointer;
33  typedef typename TOutputImage::Pointer OutputImagePointer;
34 
36  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
37 
38  void AddGradientDirection(unsigned int i, std::vector <double> &grad);
39  void SetBValuesList(std::vector <double> bValuesList) {m_BValuesList = bValuesList;}
40  itkSetMacro(BValueShellSelected, int)
41 
42  itkSetMacro(Lambda,double);
43  itkSetMacro(LOrder,unsigned int);
44 
45  itkSetMacro(SharpnessRatio,double);
46  itkSetMacro(Sharpen,bool);
47 
48  itkSetMacro(Normalize,bool);
49  itkSetMacro(FileNameSphereTesselation,std::string);
50 
51  itkSetMacro(UseAganjEstimation,bool);
52  itkSetMacro(DeltaAganjRegularization, double);
53 
54  void SetReferenceB0Image(TInputImage *refB0) {m_ReferenceB0Image = refB0;}
55 
56 protected:
58  {
59  m_GradientDirections.clear();
60  m_PVector.clear();
61  m_ReferenceB0Image = nullptr;
62 
63  m_BValueShellSelected = -1;
64  m_BValueShellTolerance = 20;
65 
66  m_Lambda = 0.006;
67  m_DeltaAganjRegularization = 0.001;
68 
69  m_LOrder = 4;
70 
71  m_Sharpen = false;
72  m_SharpnessRatio = 0.255;
73 
74  m_Normalize = false;
75  m_SphereSHSampling.clear();
76 
77  m_UseAganjEstimation = false;
78  }
79 
81 
82  void GenerateOutputInformation() ITK_OVERRIDE;
83  void BeforeThreadedGenerateData() ITK_OVERRIDE;
84  void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE;
85 
86 private:
87  ITK_DISALLOW_COPY_AND_ASSIGN(ODFEstimatorImageFilter);
88 
89  bool isZero(std::vector <double> &testVal)
90  {
91  bool resVal = true;
92  for (unsigned int i = 0;i < testVal.size();++i)
93  {
94  if (testVal[i] != 0)
95  {
96  resVal = false;
97  break;
98  }
99  }
100 
101  return resVal;
102  }
103 
104  std::vector < std::vector <double> > m_GradientDirections;
105  std::vector <double> m_BValuesList;
106  InputImagePointer m_ReferenceB0Image;
107 
108  int m_BValueShellSelected;
109  double m_BValueShellTolerance;
110  std::vector <unsigned int> m_SelectedDWIIndexes;
111 
112  vnl_matrix <double> m_TMatrix; // evaluation matrix computed once and for all before threaded generate data
113  std::vector <double> m_DeconvolutionVector;
114  std::vector <double> m_PVector;
115 
116  std::vector <unsigned int> m_B0Indexes, m_GradientIndexes;
117 
118  bool m_Normalize;
119  std::string m_FileNameSphereTesselation;
120  std::vector < std::vector <double> > m_SphereSHSampling;
121 
122  double m_Lambda;
123  double m_SharpnessRatio; // See Descoteaux et al. TMI 2009, article plus appendix
124  bool m_Sharpen;
125  bool m_UseAganjEstimation;
126  double m_DeltaAganjRegularization;
127  unsigned int m_LOrder;
128 };
129 
130 } // end of namespace anima
131 
itk::VectorImage< TOutputPixelType, 3 > TOutputImage
itk::Image< TInputPixelType, 3 > TInputImage
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE
Superclass::OutputImageRegionType OutputImageRegionType
itk::Image< TInputPixelType, 4 > Image4DType
void AddGradientDirection(unsigned int i, std::vector< double > &grad)
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
void Normalize(const VectorType &v, const unsigned int NDimension, VectorType &resVec)
void SetReferenceB0Image(TInputImage *refB0)
itk::SmartPointer< const Self > ConstPointer
void SetBValuesList(std::vector< double > bValuesList)