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_quadratic.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   quadratic noise model.
00010 
00011   File:     model_quadratic.c
00012   Author:   B. Douglas Ward
00013   Date:     29 May 1997
00014 
00015 */
00016 
00017 
00018 /*---------------------------------------------------------------------------*/
00019 
00020 #include <math.h>
00021 #include "NLfit_model.h"
00022 
00023 
00024 void noise_model 
00025 (
00026   float * gn,                /* parameters for noise model */
00027   int ts_length,             /* length of time series data */
00028   float ** x_array,          /* independent variable matrix */
00029   float * ts_array           /* estimated noise model time series */  
00030 );
00031 
00032 
00033 /*---------------------------------------------------------------------------*/
00034 /*
00035   Routine to initialize the noise model by defining the number of parameters
00036   in the noise model, the name of the noise model, and the default values
00037   for the minimum and maximum parameter constraints.
00038 */
00039 
00040 DEFINE_MODEL_PROTOTYPE
00041 
00042 MODEL_interface * initialize_model ()
00043 {
00044   MODEL_interface * mi = NULL;
00045 
00046 
00047   /*----- allocate memory space for model interface -----*/
00048   mi = (MODEL_interface *) XtMalloc (sizeof(MODEL_interface));
00049 
00050 
00051   /*----- define quadratic noise model -----*/   
00052 
00053   /*----- name of this model -----*/
00054   strcpy (mi->label, "Quadratic");
00055 
00056   /*----- this is a noise model -----*/
00057   mi->model_type = MODEL_NOISE_TYPE;
00058 
00059   /*----- number of parameters in the model -----*/
00060   mi->params = 3;
00061 
00062   /*----- parameter labels -----*/
00063   strcpy (mi->plabel[0], "constant");
00064   strcpy (mi->plabel[1], "linear");
00065   strcpy (mi->plabel[2], "quadratic");
00066 
00067   /*----- minimum and maximum parameter constraints -----*/
00068   mi->min_constr[0] = -100.0;   mi->max_constr[0] = 100.0;
00069   mi->min_constr[1] =   -1.0;   mi->max_constr[1] =   1.0;
00070   mi->min_constr[2] =   -0.1;   mi->max_constr[2] =   0.1;
00071   
00072   
00073   /*----- function which implements the model -----*/
00074   mi->call_func = noise_model;
00075 
00076 
00077   /*----- return pointer to the model interface -----*/
00078   return (mi);
00079 }
00080 
00081 
00082 /*---------------------------------------------------------------------------*/
00083 /*
00084   Routine to calculate the time series which results from the linear trend
00085   noise model and model parameters.
00086 
00087   Definition of model parameters:
00088 
00089      gn[0] = constant coefficient
00090      gn[1] = linear coefficient
00091      gn[2] = quadratic coefficient
00092 */
00093 
00094 void noise_model 
00095 (
00096   float * gn,                /* parameters for noise model */
00097   int ts_length,             /* length of time series data */
00098   float ** x_array,          /* independent variable matrix */
00099   float * ts_array           /* estimated noise model time series */  
00100 )
00101 
00102 {
00103   int it;                           /* time index */     
00104   float t;                          /* time */
00105   float fval;                       /* time series value at time t */  
00106 
00107 
00108   for (it = 0;  it < ts_length;  it++)
00109     {
00110       t = x_array[it][1];
00111       fval = gn[0] + gn[1]*t + gn[2]*t*t;
00112       ts_array[it] = fval;
00113     }
00114   
00115 }
00116 
 

Powered by Plone

This site conforms to the following standards: