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_diffusion.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   Routine to initilize and calculate the diffusion model, fitting
00009   for So and D, where S is acquired as a function of b:
00010   S(b)  = So exp(-b/D) where b is given in mm^2/sec
00011 
00012   File:     model_diffusion.c
00013   Author:   K. Donahue (modification of Doug Ward's programs)
00014   Date:     04 March 1998
00015 */
00016 
00017 /*---------------------------------------------------------------------------*/
00018 
00019 #include <math.h>
00020 #include "NLfit_model.h"
00021 
00022 void signal_model 
00023 (
00024   float * gs,                /* parameters for signal model */
00025   int ts_length,             /* length of time series data */
00026   float ** x_array,          /* independent variable matrix */
00027   float * ts_array           /* estimated signal model time series */  
00028 );
00029 
00030 
00031 /*---------------------------------------------------------------------------*/
00032 /*
00033   Routine to initialize the signal model by defining the number of parameters
00034   in the signal model, the name of the signal model, and the default values
00035   for the minimum and maximum parameter constraints.
00036 */
00037 
00038 DEFINE_MODEL_PROTOTYPE
00039 
00040 MODEL_interface * initialize_model ()
00041 {
00042   MODEL_interface * mi = NULL;
00043  
00044   /*----- allocate memory space for model interface -----*/
00045   mi = (MODEL_interface *) XtMalloc (sizeof(MODEL_interface));
00046 
00047 
00048   /*----- define interface for the diffusion model -----*/   
00049 
00050   /*----- name of this model -----*/
00051   strcpy (mi->label, "ADC");
00052 
00053   /*----- this is a signal model -----*/
00054   mi->model_type = MODEL_SIGNAL_TYPE;
00055 
00056   /*----- number of parameters in the model -----*/
00057   mi->params = 2;
00058 
00059   /*----- parameter labels -----*/
00060   strcpy (mi->plabel[0], "So");
00061   strcpy (mi->plabel[1], "D");
00062 
00063   /*----- minimum and maximum parameter constraints -----*/
00064   mi->min_constr[0] =  0.0;    mi->max_constr[0] =   32256.0;
00065   mi->min_constr[1] =  0.00;    mi->max_constr[1] =   .004;
00066 
00067 
00068   /*----- function which implements the model -----*/
00069   mi->call_func = &signal_model;
00070 
00071 
00072   /*----- return pointer to the model interface -----*/
00073   return (mi);
00074 }
00075 
00076 
00077 /*---------------------------------------------------------------------------*/
00078 /*
00079   Routine to calculate the "time" (b-value) series which results from using the
00080   diffusion signal model with the specified
00081   model parameters.
00082 
00083   Definition of model parameters:
00084 
00085      gs[0] = So  
00086      gs[1] = ADC: Apparent diffusion coefficient
00087 */
00088 
00089 void signal_model 
00090 (
00091   float * gs,                /* parameters for signal model */
00092   int ts_length,             /* length of time series data */
00093   float ** x_array,          /* independent variable matrix */
00094   float * ts_array           /* estimated signal model time series */  
00095 )
00096 
00097 {
00098   int it;                           /* time index */     
00099   float t;                          /* time = in this case actually b factor */
00100   float fval;                       /* time series value at time t */  
00101 
00102 
00103   for (it = 0;  it < ts_length;  it++)
00104     {
00105       t = x_array[it][1];
00106       fval = gs[0] * exp(-t*gs[1]);
00107       ts_array[it] = fval;
00108     }
00109   
00110 }
00111 
00112 
00113 
00114 
 

Powered by Plone

This site conforms to the following standards: