Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

model_diffexp.c File Reference

#include <math.h>
#include "NLfit_model.h"

Go to the source code of this file.


Functions

void signal_model (float *gs, int ts_length, float **x_array, float *ts_array)
DEFINE_MODEL_PROTOTYPE MODEL_interfaceinitialize_model ()

Function Documentation

DEFINE_MODEL_PROTOTYPE MODEL_interface* initialize_model  
 

Definition at line 40 of file model_diffexp.c.

References MODEL_interface::call_func, MODEL_interface::label, MODEL_interface::max_constr, MODEL_interface::min_constr, MODEL_SIGNAL_TYPE, MODEL_interface::model_type, MODEL_interface::params, MODEL_interface::plabel, signal_model(), and XtMalloc.

00041 {
00042   MODEL_interface * mi = NULL;
00043 
00044 
00045   /*----- allocate memory space for model interface -----*/
00046   mi = (MODEL_interface *) XtMalloc (sizeof(MODEL_interface));
00047 
00048 
00049   /*----- define interface for the differential - exponential model -----*/   
00050 
00051   /*----- name of this model -----*/
00052   strcpy (mi->label, "DiffExp");
00053 
00054   /*----- this is a signal model -----*/
00055   mi->model_type = MODEL_SIGNAL_TYPE;
00056 
00057   /*----- number of parameters in the model -----*/
00058   mi->params = 4;
00059 
00060   /*----- parameter labels -----*/
00061   strcpy (mi->plabel[0], "t0");
00062   strcpy (mi->plabel[1], "k");
00063   strcpy (mi->plabel[2], "alpha1");
00064   strcpy (mi->plabel[3], "alpha2");
00065 
00066   /*----- minimum and maximum parameter constraints -----*/
00067   mi->min_constr[0] =    45.0;    mi->max_constr[0] =    75.0;
00068   mi->min_constr[1] =  -500.0;    mi->max_constr[1] =   500.0;
00069   mi->min_constr[2] =     0.00;   mi->max_constr[2] =     0.15;
00070   mi->min_constr[3] =     0.15;   mi->max_constr[3] =     0.50;
00071   
00072   /*----- function which implements the model -----*/
00073   mi->call_func = &signal_model;
00074 
00075 
00076   /*----- return pointer to the model interface -----*/
00077   return (mi);
00078 }

void signal_model float *    gs,
int    ts_length,
float **    x_array,
float *    ts_array
 

Definition at line 96 of file model_diffexp.c.

Referenced by initialize_model().

00103 {
00104   int it;                           /* time index */     
00105   float t;                          /* time */
00106   float fval;                       /* time series value at time t */  
00107 
00108 
00109   for (it = 0;  it < ts_length;  it++)
00110     {
00111       t = x_array[it][1];
00112       if (t < gs[0])
00113         fval = 0.0;
00114       else
00115         fval = gs[1] * (exp(-gs[2]*(t-gs[0])) - exp(-gs[3]*(t-gs[0])));
00116       ts_array[it] = fval;
00117     }
00118   
00119 }
 

Powered by Plone

This site conforms to the following standards: