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
itkADCFitFunctor.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_ADCFitFunctor_h_
18 #define _itk_ADCFitFunctor_h_
19 
20 #include "itkDWIVoxelFunctor.h"
21 #include "vnl/vnl_least_squares_function.h"
22 #include "vnl/vnl_math.h"
23 namespace itk
24 {
25 
27 {
28 public:
31 
37  itkFactorylessNewMacro(Self)
38  itkCloneMacro(Self)
40  itkTypeMacro(ADCFitFunctor, DWIVoxelFunctor)
41 
42  void operator()(vnl_matrix<double> & newSignal, const vnl_matrix<double> & SignalMatrix, const double & S0) override;
43 
44  void setTargetBValue(const double & targetBValue){m_TargetBvalue = targetBValue;}
45  void setListOfBValues(const vnl_vector<double> & BValueList){m_BValueList = BValueList;}
46 
47 protected:
49  vnl_vector<double> m_BValueList;
50 
54  struct lestSquaresFunction: public vnl_least_squares_function
55  {
56 
57  void set_measurements(const vnl_vector<double>& x)
58  {
59  measurements.set_size(x.size());
60  measurements.copy_in(x.data_block());
61  }
62 
63  void set_bvalues(const vnl_vector<double>& x)
64  {
65  bValueVector.set_size(x.size());
66  bValueVector.copy_in(x.data_block());
67  }
68 
69  void set_reference_measurement(const double & x)
70  {
71  S0 = x;
72  }
73 
74  vnl_vector<double> measurements;
75  vnl_vector<double> bValueVector;
76  double S0;
77  int N;
78 
79  lestSquaresFunction(unsigned int number_of_measurements) :
80  vnl_least_squares_function(1 /*number of unknowns [ ADC ]*/, number_of_measurements, no_gradient)
81  {
82  N = get_number_of_residuals();
83  }
84 
85  void f(const vnl_vector<double>& x, vnl_vector<double>& fx) override {
86 
87  const double & ADC = x[0];
88 
89  const vnl_vector<double> & b = bValueVector;
90 
91  for(int s=0; s<N; s++)
92  {
93  double approx = S0 * std::exp(-b[s] * ADC);
94  fx[s] = vnl_math_abs( measurements[s] - approx );
95  }
96 
97  }
98  };
99 };
100 }
101 
102 #endif
The DWIVoxelFunctor class Abstract basisclass for voxelprocessing of Diffusion Weighted Images...
vnl_vector< double > m_BValueList
SmartPointer< const Self > ConstPointer
#define MITKDIFFUSIONCORE_EXPORT
void setListOfBValues(const vnl_vector< double > &BValueList)
lestSquaresFunction(unsigned int number_of_measurements)
void set_reference_measurement(const double &x)
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
The lestSquaresFunction struct for Non-Linear-Least-Squres fit of monoexponential model...
void set_measurements(const vnl_vector< double > &x)
ADCFitFunctor Self
SmartPointer< Self > Pointer
DWIVoxelFunctor Superclass
void set_bvalues(const vnl_vector< double > &x)