SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svk2SiteIMCostFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2016 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson,
40  */
41 
42 #ifndef SVK_2_SITE_IM_COST_COST_FUNCTION_H
43 #define SVK_2_SITE_IM_COST_COST_FUNCTION_H
44 
46 
47 
48 using namespace svk;
49 
50 
51 /*
52  * Cost function for ITK optimizer:
53  * This represents a 2 site exchange model for conversion of pyr->lactate
54  * Implementation of model from:
55  * Kinetic modeling of hyperpolarized 13C1-pyruvate metabolism in normal rats and TRAMP mice
56  * Zierhut, Matthew L, Yen, Yi-Fen, Chen, Albert P, Bok, Robert, Albers, Mark J, Zhang, Vickie
57  * Tropp, Jim, Park, Ilwoo, Vigneron, Daniel B, Kurhanewicz, John, Hurd, Ralph E, Nelson, Sarah J
58  */
60 {
61 
62  public:
63 
65  itkNewMacro( Self );
66 
67 
72  {
73  this->InitNumberOfSignals();
74  this->TR = 0;
75  }
76 
77 
81  virtual void GetKineticModel( const ParametersType& parameters ) const
82  {
83 
84  float Rinj = parameters[0]; // injection rate
85  float Kpyr = parameters[1]; // Kpyr, signal decay from T1 and excitation
86  float Tarrival = parameters[2]; // arrival time
87  float Kpl = parameters[3]; // Kpl conversion rate
88  float Klac = parameters[4]; // Klac, signal decay from T1 and excitation
89  float dc = parameters[5]; // dc baseline offset
90 
91  float injectionDuration = 14/3; // X seconds normalized by TR into time point space
92  int Tend = static_cast<int>( roundf(Tarrival + injectionDuration) );
93  Tarrival = static_cast<int>( roundf(Tarrival) );
94 
95  //cout << "Tarrival: " << Tarrival << endl;
96  //cout << "TEND: " << Tend << endl;
97 
98  // ==============================================================
99  // DEFINE COST FUNCTION
100  // ==============================================================
101  int PYR = 0;
102  int LAC = 1;
103  for ( int t = 0; t < this->numTimePoints; t++ ) {
104 
105  if ( t < Tarrival ) {
106  this->GetModelSignal(PYR)[t] = 0; //this->GetSignalAtTime(PYR, t);
107  this->GetModelSignal(LAC)[t] = 0; //this->GetSignalAtTime(LAC, t);
108  }
109 
110  if ( Tarrival <= t < Tend) {
111 
112  // PYRUVATE
113  this->GetModelSignal(PYR)[t] = (Rinj/Kpyr) * (1 - exp( -1 * Kpyr * (t - Tarrival)) ) + dc;
114 
115  // LACTATE
116  this->GetModelSignal(LAC)[t] = ( (Kpl * Rinj)/(Kpyr - Klac) )
117  * (
118  ( ( 1 - exp( -1 * Klac * ( t - Tarrival)) )/Klac )
119  - ( ( 1 - exp( -1 * Kpyr * ( t - Tarrival)) )/Kpyr )
120  ) + dc;
121  }
122 
123  if (t >= Tend) {
124 
125  // PYRUVATE
126  this->GetModelSignal(PYR)[t] = this->GetSignalAtTime(PYR, Tend) * (exp( -1 * Kpyr * ( t - Tend) ) ) + dc;
127 
128  // LACTATE
129  this->GetModelSignal(LAC)[t] = ( ( this->GetSignalAtTime(LAC, Tend) * Kpl ) / ( Kpyr - Klac ) )
130  * ( exp( -1 * Klac * (t-Tend)) - exp( -1 * Kpyr * (t-Tend)) )
131  + this->GetSignalAtTime(LAC, Tend) * exp ( -1 * Klac * ( t - Tend)) + dc;
132 
133  }
134 
135  }
136 
137  }
138 
139 
144  virtual unsigned int GetNumberOfParameters(void) const
145  {
146  int numParameters = 6;
147  return numParameters;
148  }
149 
150 
154  virtual void InitNumberOfSignals(void)
155  {
156  // pyruvate and lactate
157  this->SetNumberOfSignals(2);
158  }
159 
160 
164  virtual void InitOutputDescriptionVector(vector<string>* outputDescriptionVector ) const
165  {
166  outputDescriptionVector->resize( this->GetNumberOfOutputPorts() );
167  (*outputDescriptionVector)[0] = "pyr";
168  (*outputDescriptionVector)[1] = "lac";
169  // These are the params from equation 1 of Zierhut:
170  (*outputDescriptionVector)[2] = "Rinj";
171  (*outputDescriptionVector)[3] = "Kpyr";
172  (*outputDescriptionVector)[4] = "Tarrival";
173  // These are the params from equation 2 of Zierhut:
174  (*outputDescriptionVector)[5] = "Kpl";
175  (*outputDescriptionVector)[6] = "Klac";
176  (*outputDescriptionVector)[7] = "dcoffset";
177  }
178 
179 
184  virtual void InitParamBounds( float* lowerBounds, float* upperBounds )
185  {
186 
187  // These are the params from equation 1 of Zierhut:
188  upperBounds[0] = 100000000 * this->TR; // Rinj (arbitrary unit signal rise)
189  lowerBounds[0] = 1000 * this->TR; // Rinj
190 
191  upperBounds[1] = 0.20 * this->TR; // Kpyr
192  lowerBounds[1] = 0.0001 * this->TR; // Kpyr
193 
194  upperBounds[2] = 0 / this->TR; // Tarrival
195  lowerBounds[2] = -4.00 / this->TR; // Tarrival
196 
197  // These are the params from equation 2 of Zierhut:
198  upperBounds[3] = 0.08 * this->TR; // Kpl
199  lowerBounds[3] = 0.0001 * this->TR; // Kpl
200 
201  upperBounds[4] = 0.20 * this->TR; // Klac
202  lowerBounds[4] = 0.0001 * this->TR; // Klac
203 
204  // baseline
205  upperBounds[5] = 100000; // Baseline
206  lowerBounds[5] = -100000; // Baseline
207  }
208 
209 
213  virtual void InitParamInitialPosition( ParametersType* initialPosition )
214  {
215  if (this->TR == 0 ) {
216  cout << "ERROR: TR Must be set before initializing parameters" << endl;
217  exit(1);
218  }
219  // These are the params from equation 1 of Zierhut:
220  (*initialPosition)[0] = 50000 * this->TR; // Rinj (1/s)
221  (*initialPosition)[1] = 0.15 * this->TR; // Kpyr (1/s)
222  (*initialPosition)[2] = -3 / this->TR; // Tarrival (s)
223 
224  // These are the params from equation 2 of Zierhut:
225  (*initialPosition)[3] = 0.01 * this->TR; // Kpl (1/s)
226  (*initialPosition)[4] = 0.05 * this->TR; // Klac (1/s)
227  (*initialPosition)[5] = 70000; // Baseilne (a.u.)
228  }
229 
230 
234  virtual void GetParamFinalScaledPosition( ParametersType* finalPosition )
235  {
236  if (this->TR == 0 ) {
237  cout << "ERROR: TR Must be set before scaling final parameters" << endl;
238  exit(1);
239  }
240 
241  // These are the params from equation 1 of Zierhut:
242  (*finalPosition)[0] /= this->TR; // Rinj (1/s)
243  (*finalPosition)[1] /= this->TR; // Kpyr (1/s)
244  (*finalPosition)[2] *= this->TR; // Tarrival (s)
245 
246  // These are the params from equation 2 of Zierhut:
247  (*finalPosition)[3] /= this->TR; // Kpl (1/s)
248  (*finalPosition)[4] /= this->TR; // Klac (1/s)
249  }
250 
251 
252  private:
253 
254 };
255 
256 
257 #endif// SVK_2_SITE_IM_COST_COST_FUNCTION_H
Definition: svk2SiteIMCostFunction.h:59
Definition: svkKineticModelCostFunction.h:53
svk2SiteIMCostFunction()
Definition: svk2SiteIMCostFunction.h:71
virtual void InitNumberOfSignals(void)
Definition: svk2SiteIMCostFunction.h:154
virtual void InitOutputDescriptionVector(vector< string > *outputDescriptionVector) const
Definition: svk2SiteIMCostFunction.h:164
svk2SiteIMCostFunction Self
Definition: svk2SiteIMCostFunction.h:64
Superclass::ParametersType ParametersType
Definition: svkKineticModelCostFunction.h:64
virtual void GetParamFinalScaledPosition(ParametersType *finalPosition)
Definition: svk2SiteIMCostFunction.h:234
virtual void InitParamInitialPosition(ParametersType *initialPosition)
Definition: svk2SiteIMCostFunction.h:213
virtual void GetKineticModel(const ParametersType &parameters) const
Definition: svk2SiteIMCostFunction.h:81
virtual void InitParamBounds(float *lowerBounds, float *upperBounds)
Definition: svk2SiteIMCostFunction.h:184
virtual unsigned int GetNumberOfParameters(void) const
Definition: svk2SiteIMCostFunction.h:144