Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
itkKurtosisFitFunctor.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_KurtosisFitFunctor_h_
18 #define _itk_KurtosisFitFunctor_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(KurtosisFitFunctor, 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(2 /*number of unknowns [ADC AKC]*/, 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 & D = x[0];
93  const double & K = x[1];
94  const vnl_vector<double> & b = bValueVector;
95 
96  for(int s=0; s<N; s++)
97  {
98  double approx = S0 * std::exp(- b[s] * D + 1./6. *b[s] * b[s] *D * D * K);
99  fx[s] = vnl_math_abs( measurements[s] - approx );
100  }
101 
102  }
103  };
104 
105 };
106 
107 }
108 
109 #endif
The DWIVoxelFunctor class Abstract basisclass for voxelprocessing of Diffusion Weighted Images...
SmartPointer< const Self > ConstPointer
#define MITKDIFFUSIONCORE_EXPORT
void set_measurements(const vnl_vector< double > &x)
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
SmartPointer< Self > Pointer
The lestSquaresFunction struct for Non-Linear-Least-Squres fit of Kurtosis.
vnl_vector< double > m_BValueList
lestSquaresFunction(unsigned int number_of_measurements)
void setListOfBValues(const vnl_vector< double > &BValueList)
void set_bvalues(const vnl_vector< double > &x)