ANIMA  4.0
animaGammaMixtureT2RelaxometryEstimationImageFilter.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <itkVectorImage.h>
5 #include <itkImage.h>
6 
7 namespace anima
8 {
9 
10 template <class TPixelScalarType>
12  public anima::MaskedImageToImageFilter<itk::Image <TPixelScalarType, 3>, itk::Image <TPixelScalarType, 3> >
13 {
14 public:
17  typedef itk::Image <TPixelScalarType, 3> TInputImage;
18  typedef itk::Image <TPixelScalarType, 3> TOutputImage;
20  typedef itk::SmartPointer<Self> Pointer;
21  typedef itk::SmartPointer<const Self> ConstPointer;
22 
24  itkNewMacro(Self)
25 
26 
28 
29 
30  typedef TInputImage InputImageType;
31  typedef typename InputImageType::IndexType IndexType;
32  typedef TOutputImage OutputImageType;
33  typedef itk::VectorImage <TPixelScalarType, 3> VectorOutputImageType;
34  typedef typename VectorOutputImageType::PixelType OutputVectorType;
35  typedef typename InputImageType::Pointer InputImagePointer;
36  typedef typename OutputImageType::Pointer OutputImagePointer;
37  typedef typename VectorOutputImageType::Pointer VectorOutputImagePointer;
38 
40  typedef typename Superclass::MaskImageType MaskImageType;
41  typedef typename Superclass::InputImageRegionType InputImageRegionType;
42  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
43 
44  itkSetMacro(EchoSpacing, double)
45 
46  void SetT1Map(InputImageType *map) {m_T1Map = map;}
47  InputImageType *GetT1Map() {return m_T1Map;}
48 
49  itkSetMacro(AverageSignalThreshold, double)
50 
51  InputImageType *GetM0OutputImage() {return this->GetOutput(0);}
52  InputImageType *GetMWFOutputImage() {return this->GetOutput(1);}
53  InputImageType *GetB1OutputImage() {return this->GetOutput(2);}
54  InputImageType *GetSigmaSquareOutputImage() {return this->GetOutput(3);}
55  VectorOutputImageType *GetWeightsImage() {return m_WeightsImage;}
56  VectorOutputImageType *GetMeanParamImage() {return m_MeanParamImage;}
57 
58  itkSetMacro(T2ExcitationFlipAngle, double)
59  itkSetMacro(GammaIntegralTolerance, double)
60  itkSetMacro(ConstrainedParameters, bool)
61 
62  void SetT2FlipAngles(std::vector <double> & flipAngles) {m_T2FlipAngles = flipAngles;}
63  void SetT2FlipAngles(double singleAngle, unsigned int numAngles) {m_T2FlipAngles = std::vector <double> (numAngles,singleAngle);}
64 
65 protected:
67  : Superclass()
68  {
69  // There are 4 outputs: M0, MWF, B1, sigma square
70  this->SetNumberOfRequiredOutputs(4);
71 
72  for (unsigned int i = 0;i < 4;++i)
73  this->SetNthOutput(i, this->MakeOutput(i));
74 
75  m_AverageSignalThreshold = 0;
76  m_EchoSpacing = 1;
77 
78  m_ConstrainedParameters = false;
79 
80  m_ShortT2Mean = 30.0;
81  m_ShortT2Var = 50.0;
82  m_MediumT2Var = 100.0;
83  m_HighT2Mean = 2000.0;
84  m_HighT2Var = 6400.0;
85 
86  m_LowerShortT2 = 15.0;
87  m_LowerMediumT2 = 100.0;
88  m_LowerHighT2 = 1900.0;
89  m_UpperShortT2 = 50.0;
90  m_UpperMediumT2 = 125.0;
91  m_UpperHighT2 = 2100.0;
92 
93  m_GammaIntegralTolerance = 1.0e-8;
94 
95  m_T2ExcitationFlipAngle = M_PI / 6;
96  }
97 
99 
100  void CheckComputationMask() ITK_OVERRIDE;
101 
102  void BeforeThreadedGenerateData() ITK_OVERRIDE;
103  void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE;
104 
105 private:
106  ITK_DISALLOW_COPY_AND_ASSIGN(GammaMixtureT2RelaxometryEstimationImageFilter);
107 
108  double m_AverageSignalThreshold;
109 
110  // Gamma PDF params for short and high T2
111  double m_ShortT2Mean;
112  double m_ShortT2Var;
113  double m_MediumT2Var;
114  double m_HighT2Mean;
115  double m_HighT2Var;
116 
117  // Gamma PDF Medium T2 upper and lower bounds of optimization
118  double m_LowerShortT2, m_LowerMediumT2, m_LowerHighT2;
119  double m_UpperShortT2, m_UpperMediumT2, m_UpperHighT2;
120 
121  // T1 relaxometry specific values
122  InputImagePointer m_T1Map;
123 
124  double m_GammaIntegralTolerance;
125  bool m_ConstrainedParameters;
126 
127  // Additional result images
128  VectorOutputImagePointer m_WeightsImage;
129  VectorOutputImagePointer m_MeanParamImage;
130 
131  // T2 relaxometry specific values
132  double m_EchoSpacing;
133  std::vector <double> m_T2FlipAngles;
134  double m_T2ExcitationFlipAngle;
135 };
136 
137 } // end namespace anima
138 
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE
STL namespace.
anima::MaskedImageToImageFilter< TInputImage, TOutputImage > Superclass