7 #ifndef Tomato_OXModelT1TwoParam_HXX 8 #define Tomato_OXModelT1TwoParam_HXX 13 template<
typename MeasureType >
18 MeasureType A = parameters[0];
19 MeasureType T1 = parameters[1];
21 if (fabs(T1) < std::numeric_limits<MeasureType>::min())
24 return A * (1 - exp( -time / T1 ));
27 template<
typename MeasureType >
32 unsigned int nSamples = this->_nSamples;
34 for (
unsigned int i = 0; i < nSamples; i++) {
35 MeasureType invTime = this->_InvTimes[i];
36 MeasureType measured = this->_Signal[i];
37 MeasureType calculated = 0;
39 calculated = calcModelValue(parameters, invTime);
41 residuals[i] = calculated - measured;
45 template<
typename MeasureType >
50 int nSamples = this->_nSamples;
52 MeasureType A = parameters[0];
53 MeasureType T1 = parameters[1];
54 MeasureType invTime, myexp;
56 for (
int i = 0; i < nSamples; i++) {
57 invTime = this->_InvTimes[i];
58 myexp = exp(-invTime/T1);
61 jacobian[i*2+0] = 1.0 - myexp;
62 jacobian[i*2+1] = -( A * invTime * myexp )/ ( T1 * T1 );
66 template<
typename MeasureType >
71 int nSamples = this->_nSamples;
73 calcLSResiduals(parameters, this->_Residuals);
74 MeasureType result = 0;
76 for (
int i = 0; i < nSamples; ++i) {
77 result = result + this->_Residuals[i] * this->_Residuals[i];
83 template<
typename MeasureType >
88 int nSamples = this->_nSamples;
93 MeasureType measured, invTime, myexp;
95 MeasureType A = parameters[0];
96 MeasureType T1 = parameters[1];
99 for (
int i = 0; i < nSamples; ++i){
100 measured = this->getSignal()[i];
101 invTime = this->getInvTimes()[i];
102 myexp = exp(-invTime / T1);
104 derivative[0] = derivative[0] + 2 * (myexp - 1)*(measured + A*(myexp - 1));
105 derivative[1] = derivative[1] + ( 2 * A * invTime * myexp * ( measured + A * ( myexp - 1 ))) / ( T1 * T1 );
112 #endif //Tomato_OXModelT1TwoParam_HXX virtual MeasureType calcCostValue(const MeasureType *parameters)
Definition: OxModelT1TwoParam.hxx:69
virtual MeasureType calcModelValue(const MeasureType *parameters, MeasureType time)
Definition: OxModelT1TwoParam.hxx:16
virtual void calcCostDerivative(const MeasureType *parameters, MeasureType *derivative)
Definition: OxModelT1TwoParam.hxx:86
virtual void calcLSResiduals(const MeasureType *parameters, MeasureType *residuals)
Definition: OxModelT1TwoParam.hxx:30
Definition: OxCalculator.h:19
virtual void calcLSJacobian(const MeasureType *parameters, MeasureType *jacobian)
Definition: OxModelT1TwoParam.hxx:48