ANIMA  4.0
animaGradientFileReader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vnl/vnl_vector_fixed.h>
4 #include <itkPoint.h>
5 #include <itkVector.h>
6 #include <vector>
7 #include <string>
8 
9 namespace anima
10 {
11 
12  template <class GradientType = std::vector <double>, class BValueScalarType = double>
14  {
15  public:
16 // typedef std::vector <GradientScalarType> GradientType;
17  typedef typename std::vector <GradientType> GradientVectorType;
18  typedef std::vector <BValueScalarType> BValueVectorType;
19 
22 
23  void SetGradientFileName(std::string fName) {m_GradientFileName = fName;this->SetModified();}
24  void SetBValueBaseString(std::string base) {m_BValueBaseString = base;this->SetModified();}
25  void SetSmallDelta(double val) {m_SmallDelta = val;this->SetModified();}
26  void SetBigDelta(double val) {m_BigDelta = val;this->SetModified();}
27  void SetB0ValueThreshold(double thr) {m_B0ValueThreshold = thr;this->SetModified();}
28  void SetGradientIndependentNormalization(bool normGrads) {m_GradientIndependentNormalization = normGrads;this->SetModified();}
29  void SetModified() {m_Modified = true;}
30 
31  std::vector <bool> GetB0Directions();
32  GradientVectorType &GetGradients();
33  BValueVectorType &GetBValues();
34  BValueVectorType &GetGradientStrengths();
35  unsigned int GetTotalNumberOfDirections();
36 
37  void Update();
38 
39  protected:
40  template <class T> void InitializeEmptyGradient(std::vector <T> &vec)
41  {
42  vec.resize(3);
43  std::fill(vec.begin(),vec.end(),0);
44  }
45 
46  template <class T> void InitializeEmptyGradient(itk::Point <T,3> &vec)
47  {
48  vec.Fill(0);
49  }
50 
51  template <class T> void InitializeEmptyGradient(vnl_vector_fixed <T,3> &vec)
52  {
53  vec.fill(0);
54  }
55 
56  template <class T> void InitializeEmptyGradient(itk::Vector <T,3> &vec)
57  {
58  vec.Fill(0);
59  }
60 
61  private:
62  void ReadGradientsFromBVecFile();
63  void ReadGradientsFromTextFile();
64  void ReadBValues();
65 
66  GradientVectorType m_Gradients;
67  BValueVectorType m_BValues;
68  BValueVectorType m_GradientStrengths;
69 
70  std::string m_GradientFileName;
71  std::string m_BValueBaseString;
72 
73  unsigned int m_TotalNumberOfDirections;
74 
75  double m_B0ValueThreshold;
76  // If set to true, gradients are normalized to 1 without changing b-values, otherwise yes
77  bool m_GradientIndependentNormalization;
78 
80  double m_SmallDelta, m_BigDelta;
81 
82  // Internal value to trigger update
83  bool m_Modified;
84  };
85 
86 } // end namespace anima
87 
void InitializeEmptyGradient(itk::Vector< T, 3 > &vec)
void SetGradientIndependentNormalization(bool normGrads)
void InitializeEmptyGradient(itk::Point< T, 3 > &vec)
void InitializeEmptyGradient(std::vector< T > &vec)
std::vector< BValueScalarType > BValueVectorType
std::vector< bool > GetB0Directions()
GradientVectorType & GetGradients()
std::vector< GradientType > GradientVectorType
BValueVectorType & GetGradientStrengths()
void SetGradientFileName(std::string fName)
void SetBValueBaseString(std::string base)
void InitializeEmptyGradient(vnl_vector_fixed< T, 3 > &vec)