Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkBiExpFitFunctor.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _itk_BiExpFitFunctor_h_
18 #define _itk_BiExpFitFunctor_h_
19 
20 #include "itkDWIVoxelFunctor.h"
21 #include <math.h>
22 
23 // vnl include
24 #include "vnl/vnl_least_squares_function.h"
25 #include "vnl/algo/vnl_levenberg_marquardt.h"
26 #include "vnl/vnl_math.h"
27 
28 namespace itk
29 {
30 
32 {
33 public:
36 
42  itkFactorylessNewMacro(Self)
43  itkCloneMacro(Self)
45  itkTypeMacro(BiExpFitFunctor, DWIVoxelFunctor)
46 
47  void operator()(vnl_matrix<double> & newSignal,const vnl_matrix<double> & SignalMatrix, const double & S0) override;
48 
49  void setTargetBValue(const double & targetBValue){m_TargetBvalue = targetBValue;}
50  void setListOfBValues(const vnl_vector<double> & BValueList){m_BValueList = BValueList;}
51 
52 protected:
54  vnl_vector<double> m_BValueList;
55 
59  struct lestSquaresFunction: public vnl_least_squares_function
60  {
61 
62  void set_measurements(const vnl_vector<double>& x)
63  {
64  measurements.set_size(x.size());
65  measurements.copy_in(x.data_block());
66  }
67 
68  void set_bvalues(const vnl_vector<double>& x)
69  {
70  bValueVector.set_size(x.size());
71  bValueVector.copy_in(x.data_block());
72  }
73 
74  void set_reference_measurement(const double & x)
75  {
76  S0 = x;
77  }
78 
79  vnl_vector<double> measurements;
80  vnl_vector<double> bValueVector;
81  double S0;
82  int N;
83 
84  lestSquaresFunction(unsigned int number_of_measurements) :
85  vnl_least_squares_function(3 /*number of unknowns [ ADC_slow ADC_fast lambda]*/, number_of_measurements, no_gradient)
86  {
87  N = get_number_of_residuals();
88  }
89 
90  void f(const vnl_vector<double>& x, vnl_vector<double>& fx) override {
91 
92  const double & ADC_slow = x[0];
93  const double & ADC_fast = x[1];
94  const double & lambda = x[2];
95 
96  const vnl_vector<double> & b = bValueVector;
97 
98  for(int s=0; s<N; s++)
99  {
100  double approx = lambda * std::exp(-b[s] * ADC_slow) + (1-lambda) * std::exp(-b[s] * ADC_fast);
101  fx[s] = vnl_math_abs( measurements[s] - approx*S0 );
102  }
103 
104  }
105  };
106 
107 };
108 
109 }
110 
111 #endif
The DWIVoxelFunctor class Abstract basisclass for voxelprocessing of Diffusion Weighted Images...
lestSquaresFunction(unsigned int number_of_measurements)
The lestSquaresFunction struct for Non-Linear-Least-Squres fit of Biexponential model.
vnl_vector< double > m_BValueList
#define MITKDIFFUSIONCORE_EXPORT
void setListOfBValues(const vnl_vector< double > &BValueList)
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
void set_bvalues(const vnl_vector< double > &x)
SmartPointer< const Self > ConstPointer
DWIVoxelFunctor Superclass
SmartPointer< Self > Pointer
void set_measurements(const vnl_vector< double > &x)