SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svk2SiteIMPyrCostFunction.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_PYR_COST_COST_FUNCTION_H
43 #define SVK_2_SITE_IM_PYR_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  *
59  * Only equation 1 of the above reference is implemented for initial fitting of Pyr signal to determine
60  * Rinj: the injection rate
61  * Kpyr: the pyruvate signal decay rate
62  * Tarrival: the arrival time
63  */
65 {
66 
67  public:
68 
70  itkNewMacro( Self );
71 
72 
77  {
78  this->InitNumberOfSignals();
79  this->TR = 0;
80  }
81 
82 
86  virtual void GetKineticModel( const ParametersType& parameters ) const
87  {
88 
89  float Rinj = parameters[0]; // injection rate
90  float Kpyr = parameters[1]; // Kpyr, signal decay from T1 and excitation
91  float Tarrival = parameters[2]; // arrival time in dimensionless time-point units
92 
93  float injectionDuration = 14/3; // X seconds normalized by TR into time point space
94 
95  //cout << "TR: " << this->TR << endl;
96  //cout << "ID: " << injectionDuration << endl;
97  int Tend = static_cast<int>( roundf(Tarrival + injectionDuration) );
98  Tarrival = static_cast<int>( roundf(Tarrival) );
99 
100 
101  // ==============================================================
102  // DEFINE COST FUNCTION
103  // ==============================================================
104  int PYR = 0;
105  //cout << "Tarrival: " << Tarrival << endl;
106  //cout << "TEND: " << Tend << endl;
107  //cout << "SIGTEND: " << this->GetSignalAtTime(PYR, Tend) << endl;
108  for ( int t = 0; t < this->numTimePoints; t++ ) {
109 
110  if ( t < Tarrival ) {
111  cout << "PRE T ARRIVAL" << endl;
112  this->GetModelSignal(PYR)[t] = 0.; //this->GetSignalAtTime(PYR, t);
113  }
114 
115  if ( Tarrival <= t < Tend) {
116  // PYRUVATE
117  this->GetModelSignal(PYR)[t] = (Rinj/Kpyr) * (1 - exp( -1 * Kpyr * (t - Tarrival)) ) ;
118  }
119 
120  if (t >= Tend) {
121  // PYRUVATE
122  this->GetModelSignal(PYR)[t] = this->GetSignalAtTime(PYR, Tend) * (exp( -1 * Kpyr * ( t - Tend) ) );
123  }
124 
125  }
126 
127  }
128 
129 
135  virtual unsigned int GetNumberOfParameters(void) const
136  {
137  int numParameters = 3;
138  return numParameters;
139  }
140 
141 
145  virtual void InitNumberOfSignals(void)
146  {
147  // pyruvate
148  this->SetNumberOfSignals(1);
149  }
150 
151 
155  virtual void InitOutputDescriptionVector(vector<string>* outputDescriptionVector ) const
156  {
157  outputDescriptionVector->resize( this->GetNumberOfOutputPorts() );
158  // Input Signal
159  (*outputDescriptionVector)[0] = "pyr";
160 
161  // These are the params from equation 1 of Zierhut:
162  (*outputDescriptionVector)[1] = "Rinj";
163  (*outputDescriptionVector)[2] = "Kpyr";
164  (*outputDescriptionVector)[3] = "Tarrival";
165  }
166 
167 
172  virtual void InitParamBounds( float* lowerBounds, float* upperBounds )
173  {
174  // These are the params from equation 1 of Zierhut:
175  upperBounds[0] = 100000000 * this->TR; // Rinj (arbitrary unit signal rise)
176  lowerBounds[0] = 10000 * this->TR; // Rinj
177 
178  upperBounds[1] = 0.20 * this->TR; // Kpyr
179  lowerBounds[1] = 0.0001 * this->TR; // Kpyr
180 
181  upperBounds[2] = 0 / this->TR; // Tarrival
182  lowerBounds[2] = -4.00 / this->TR; // Tarrival
183  }
184 
185 
189  virtual void InitParamInitialPosition( ParametersType* initialPosition )
190  {
191  if (this->TR == 0 ) {
192  cout << "ERROR: TR Must be set before initializing parameters" << endl;
193  exit(1);
194  }
195  // These are the params from equation 1 of Zierhut:
196  (*initialPosition)[0] = 50000 * this->TR; // Rinj (1/s)
197  (*initialPosition)[1] = 0.05 * this->TR; // Kpyr (1/s)
198  (*initialPosition)[2] = -3 / this->TR; // Tarrival (s)
199  }
200 
201 
205  virtual void GetParamFinalScaledPosition( ParametersType* finalPosition )
206  {
207  if (this->TR == 0 ) {
208  cout << "ERROR: TR Must be set before scaling final parameters" << endl;
209  exit(1);
210  }
211 
212  // These are the params from equation 1 of Zierhut:
213  (*finalPosition)[0] /= this->TR; // Rinj (1/s)
214  (*finalPosition)[1] /= this->TR; // Kpyr (1/s)
215  (*finalPosition)[2] *= this->TR; // Tarrival (s)
216 
217  }
218 
219 
220  private:
221 
222 };
223 
224 
225 #endif// SVK_2_SITE_IM_PYR_COST_COST_FUNCTION_H
Definition: svkKineticModelCostFunction.h:53
Definition: svk2SiteIMPyrCostFunction.h:64
virtual void GetParamFinalScaledPosition(ParametersType *finalPosition)
Definition: svk2SiteIMPyrCostFunction.h:205
virtual void InitParamInitialPosition(ParametersType *initialPosition)
Definition: svk2SiteIMPyrCostFunction.h:189
virtual void GetKineticModel(const ParametersType &parameters) const
Definition: svk2SiteIMPyrCostFunction.h:86
virtual void InitNumberOfSignals(void)
Definition: svk2SiteIMPyrCostFunction.h:145
svk2SiteIMPyrCostFunction()
Definition: svk2SiteIMPyrCostFunction.h:76
virtual void InitOutputDescriptionVector(vector< string > *outputDescriptionVector) const
Definition: svk2SiteIMPyrCostFunction.h:155
Superclass::ParametersType ParametersType
Definition: svkKineticModelCostFunction.h:64
virtual unsigned int GetNumberOfParameters(void) const
Definition: svk2SiteIMPyrCostFunction.h:135
virtual void InitParamBounds(float *lowerBounds, float *upperBounds)
Definition: svk2SiteIMPyrCostFunction.h:172
svk2SiteIMPyrCostFunction Self
Definition: svk2SiteIMPyrCostFunction.h:69