Doxygen Source Code Documentation
model_gammavar.c
Go to the documentation of this file.00001 /***************************************************************************** 00002 Major portions of this software are copyrighted by the Medical College 00003 of Wisconsin, 1994-2000, and are released under the Gnu General Public 00004 License, Version 2. See the file README.Copyright for details. 00005 ******************************************************************************/ 00006 00007 /* 00008 This file contains routines to initialize and implement the 00009 gamma variate drug response signal model. 00010 00011 File: model_gammavar.c 00012 Author: B. Douglas Ward 00013 Date: 29 May 1997 00014 00015 Mod: Tests for illegal parameter values. Also, changed default 00016 constraint values. 00017 Date: 2 February 1998 00018 00019 */ 00020 00021 00022 /*---------------------------------------------------------------------------*/ 00023 00024 #include <math.h> 00025 #include "NLfit_model.h" 00026 00027 void signal_model 00028 ( 00029 float * gs, /* parameters for signal model */ 00030 int ts_length, /* length of time series data */ 00031 float ** x_array, /* independent variable matrix */ 00032 float * ts_array /* estimated signal model time series */ 00033 ); 00034 00035 00036 /*---------------------------------------------------------------------------*/ 00037 /* 00038 Routine to initialize the signal model by defining the number of parameters 00039 in the signal model, the name of the signal model, and the default values 00040 for the minimum and maximum parameter constraints. 00041 */ 00042 00043 DEFINE_MODEL_PROTOTYPE 00044 00045 MODEL_interface * initialize_model () 00046 { 00047 MODEL_interface * mi = NULL; 00048 00049 00050 /*----- allocate memory space for model interface -----*/ 00051 mi = (MODEL_interface *) XtMalloc (sizeof(MODEL_interface)); 00052 00053 00054 /*----- define interface for the gamma variate model -----*/ 00055 00056 /*----- name of this model -----*/ 00057 strcpy (mi->label, "GammaVar"); 00058 00059 /*----- this is a signal model -----*/ 00060 mi->model_type = MODEL_SIGNAL_TYPE; 00061 00062 /*----- number of parameters in the model -----*/ 00063 mi->params = 4; 00064 00065 /*----- parameter labels -----*/ 00066 strcpy (mi->plabel[0], "t0"); 00067 strcpy (mi->plabel[1], "k"); 00068 strcpy (mi->plabel[2], "r"); 00069 strcpy (mi->plabel[3], "b"); 00070 00071 /*----- minimum and maximum parameter constraints -----*/ 00072 mi->min_constr[0] = 45.0; mi->max_constr[0] = 75.0; 00073 mi->min_constr[1] = -200.0; mi->max_constr[1] = 200.0; 00074 mi->min_constr[2] = 0.0; mi->max_constr[2] = 1.0; 00075 mi->min_constr[3] = 1.0; mi->max_constr[3] = 100.0; 00076 00077 /*----- function which implements the model -----*/ 00078 mi->call_func = &signal_model; 00079 00080 00081 /*----- return pointer to the model interface -----*/ 00082 return (mi); 00083 } 00084 00085 00086 /*---------------------------------------------------------------------------*/ 00087 /* 00088 Routine to calculate the time series which results from using the 00089 gamma variate drug response signal model with the specified 00090 model parameters. 00091 00092 Definition of model parameters: 00093 00094 gs[0] = time delay of response (t0) 00095 gs[1] = multiplicative constant (k) 00096 gs[2] = rise rate exponent (r) 00097 gs[3] = decay rate constant (b) 00098 00099 */ 00100 00101 void signal_model 00102 ( 00103 float * gs, /* parameters for signal model */ 00104 int ts_length, /* length of time series data */ 00105 float ** x_array, /* independent variable matrix */ 00106 float * ts_array /* estimated signal model time series */ 00107 ) 00108 00109 { 00110 int it; /* time index */ 00111 float t; /* time */ 00112 float fval; /* time series value at time t */ 00113 00114 00115 for (it = 0; it < ts_length; it++) 00116 { 00117 t = x_array[it][1]; 00118 if ((t <= gs[0]) || (gs[3] <= 0.0)) 00119 fval = 0.0; 00120 else 00121 fval = gs[1] * exp( log(t-gs[0]) * gs[2] ) * exp(-(t-gs[0])/gs[3]); 00122 ts_array[it] = fval; 00123 } 00124 00125 } 00126 00127 00128 00129