1 /*****************************************************************************
2    Major portions of this software are copyrighted by the Medical College
3    of Wisconsin, 1994-2000, and are released under the Gnu General Public
4    License, Version 2.  See the file README.Copyright for details.
5 ******************************************************************************/
6 
7 /*
8   This file contains routines to initialize and implement the
9   differential exponential drug response signal model.
10 
11   File:     model_diffexp.c
12   Author:   B. Douglas Ward
13   Date:     6 June 1997
14 */
15 
16 
17 /*---------------------------------------------------------------------------*/
18 
19 #include <math.h>
20 #include "NLfit_model.h"
21 
22 void signal_model
23 (
24   float * gs,                /* parameters for signal model */
25   int ts_length,             /* length of time series data */
26   float ** x_array,          /* independent variable matrix */
27   float * ts_array           /* estimated signal model time series */
28 );
29 
30 
31 /*---------------------------------------------------------------------------*/
32 /*
33   Routine to initialize the signal model by defining the number of parameters
34   in the signal model, the name of the signal model, and the default values
35   for the minimum and maximum parameter constraints.
36 */
37 
38 DEFINE_MODEL_PROTOTYPE
39 
initialize_model()40 MODEL_interface * initialize_model ()
41 {
42   MODEL_interface * mi = NULL;
43 
44 
45   /*----- allocate memory space for model interface -----*/
46   mi = (MODEL_interface *) RwcMalloc (sizeof(MODEL_interface));
47 
48 
49   /*----- define interface for the differential - exponential model -----*/
50 
51   /*----- name of this model -----*/
52   strcpy (mi->label, "DiffExp");
53 
54   /*----- this is a signal model -----*/
55   mi->model_type = MODEL_SIGNAL_TYPE;
56 
57   /*----- number of parameters in the model -----*/
58   mi->params = 4;
59 
60   /*----- parameter labels -----*/
61   strcpy (mi->plabel[0], "t0");
62   strcpy (mi->plabel[1], "k");
63   strcpy (mi->plabel[2], "alpha1");
64   strcpy (mi->plabel[3], "alpha2");
65 
66   /*----- minimum and maximum parameter constraints -----*/
67   mi->min_constr[0] =    45.0;    mi->max_constr[0] =    75.0;
68   mi->min_constr[1] =  -500.0;    mi->max_constr[1] =   500.0;
69   mi->min_constr[2] =     0.00;   mi->max_constr[2] =     0.15;
70   mi->min_constr[3] =     0.15;   mi->max_constr[3] =     0.50;
71 
72   /*----- function which implements the model -----*/
73   mi->call_func = &signal_model;
74 
75 
76   /*----- return pointer to the model interface -----*/
77   return (mi);
78 }
79 
80 
81 /*---------------------------------------------------------------------------*/
82 /*
83   Routine to calculate the time series which results from using the
84   differential exponential drug response signal model with the specified
85   model parameters.
86 
87   Definition of model parameters:
88 
89      gs[0] = time delay of response (t0)
90      gs[1] = multiplicative constant (k)
91      gs[2] = elimination rate constant (alpha1)
92      gs[3] = absorption rate constant (alpha2)
93 */
94 
signal_model(float * gs,int ts_length,float ** x_array,float * ts_array)95 void signal_model
96 (
97   float * gs,                /* parameters for signal model */
98   int ts_length,             /* length of time series data */
99   float ** x_array,          /* independent variable matrix */
100   float * ts_array           /* estimated signal model time series */
101 )
102 
103 {
104   int it;                           /* time index */
105   float t;                          /* time */
106   float fval;                       /* time series value at time t */
107 
108 
109   for (it = 0;  it < ts_length;  it++)
110     {
111       t = x_array[it][1];
112       if (t < gs[0])
113 	fval = 0.0;
114       else
115 	fval = gs[1] * (exp(-gs[2]*(t-gs[0])) - exp(-gs[3]*(t-gs[0])));
116       ts_array[it] = fval;
117     }
118 
119 }
120 
121 
122 
123 
124