libtpcmodel
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Functions
simulate.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "include/integr.h"
#include "include/simulate.h"
Include dependency graph for simulate.c:

Go to the source code of this file.

Functions

int simC3s (double *t, double *ca, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double *ct, double *cta, double *ctb, double *ctc)
int simC3p (double *t, double *ca, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double *ct, double *cta, double *ctb, double *ctc)
int simC3vs (double *t, double *ca, double *cb, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double f, double vb, double fa, double *cpet, double *cta, double *ctb, double *ctc, double *ctab, double *ctvb)
int simC3vp (double *t, double *ca, double *cb, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double f, double vb, double fa, double *cpet, double *cta, double *ctb, double *ctc, double *ctab, double *ctvb)
int simC2l (double *t, double *ca, int nr, double k1, double k2, double k3, double kLoss, double *ct, double *cta, double *ctb)
int simC2vl (double *t, double *ca, double *cb, int nr, double k1, double k2, double k3, double kL, double f, double vb, double fa, double *cpet, double *cta, double *ctb, double *ctab, double *ctvb)
int simC3vpKLoss (double *t, double *ca, double *cb, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double kLoss, double f, double vb, double fa, double *cpet, double *cta, double *ctb, double *ctc, double *ctab, double *ctvb)
int simRTCM (double *t, double *cr, int nr, double R1, double k2, double k3, double k4, double *ct, double *cta, double *ctb)
int simSRTM (double *t, double *cr, int nr, double R1, double k2, double BP, double *ct)
int simTRTM (double *t, double *cr, int nr, double R1, double k2, double k3, double *ct)
int simHuangmet (double *t, double *ctot, int nr, double k01, double k12, double k21, double k03, double k34, double k43, double *c0, double *c1, double *c3)
int simTPCMOD0009c (double *t, double *ctot, int nr, double km, double k1m, double k2m, double k3m, double k4m, double *ca, double *cm)
int simMBF (double *t, double *ci, int nr, double k1, double k2, double Vfit, double *ct)
int simC1 (double *t, double *ca, int nr, double k1, double k2, double *ct)
int simC3DIvs (double *t, double *ca1, double *ca2, double *cb, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double k1b, double k2b, double f, double vb, double fa, double *scpet, double *sct1, double *sct2, double *sct3, double *sct1b, double *sctab, double *sctvb)
int simDispersion (double *x, double *y, int n, double tau1, double tau2, double *tmp)

Function Documentation

int simC1 ( double *  t,
double *  ca,
int  nr,
double  k1,
double  k2,
double *  ct 
)

Simulates tissue TAC using 1 tissue compartment model plasma TAC, at plasma TAC times.

Memory for ct must be allocated in the calling program.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
caArray of arterial activities
nrNumber of values in TACs
k1Rate constant of the model
k2Rate constant of the model
ctPointer for TAC array to be simulated; must be allocated

Definition at line 1368 of file simulate.c.

Referenced by simDispersion().

int simC2l ( double *  t,
double *  ca,
int  nr,
double  k1,
double  k2,
double  k3,
double  kLoss,
double *  ct,
double *  cta,
double *  ctb 
)

Simulates tissue TAC using 2 tissue compartment model (in series) and plasma TAC, at plasma TAC times. In contrary to the common model, kLoss represents a direct loss rate from the 2nd tissue compartment to venous plasma.

Memory for ct must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cta and ctb can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
caArray of arterial activities
nrNumber of values in TACs
k1Rate constant of the model
k2Rate constant of the model
k3Rate constant of the model
kLossRate constant of the model
ctPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL

Definition at line 562 of file simulate.c.

int simC2vl ( double *  t,
double *  ca,
double *  cb,
int  nr,
double  k1,
double  k2,
double  k3,
double  kL,
double  f,
double  vb,
double  fa,
double *  cpet,
double *  cta,
double *  ctb,
double *  ctab,
double *  ctvb 
)

Simulates tissue TAC using 2 tissue compartment model and plasma TAC, at plasma TAC times, considering also arterial and venous vasculature. The efflux from 2nd tissue compartment (at rate kL) goes directly to blood.

Memory for cpet must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cta, ctb, ctab and/or ctvb can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

If blood flow is set to 0, function assumes that f>>k1, and Cvb=Cab.,

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
caArray of arterial plasma activities
cbArray of arterial blood activities
nrNumber of values in TACs
k1Rate constant of the model
k2Rate constant of the model
k3Rate constant of the model
kLRate constant of the model
fBlood flow; if 0, function assumes that f>>k1, and Cvb=Cab.
vbVascular volume fraction
faArterial fraction of vascular volume
cpetPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL
ctabPointer for arterial TAC in tissue, or NULL
ctvbPointer for venous TAC in tissue, or NULL

Definition at line 652 of file simulate.c.

int simC3DIvs ( double *  t,
double *  ca1,
double *  ca2,
double *  cb,
int  nr,
double  k1,
double  k2,
double  k3,
double  k4,
double  k5,
double  k6,
double  k1b,
double  k2b,
double  f,
double  vb,
double  fa,
double *  scpet,
double *  sct1,
double *  sct2,
double *  sct3,
double *  sct1b,
double *  sctab,
double *  sctvb 
)

Simulates tissue TAC using dual-input tissue compartment model (1-3 compartments in series for tracer1, and 1 compartment for tracer2) at plasma TAC times, considering also contribution of arterial and venous vasculature. The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec. If blood flow is set to 0, function assumes that f>>k1, and Cvb=Cab.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
ca1Array of arterial plasma activities of tracer1
ca2Array of arterial plasma activities of tracer1
cbArray of arterial blood activities
nrNumber of values in TACs
k1Rate constant of the model for tracer1
k2Rate constant of the model for tracer1
k3Rate constant of the model for tracer1
k4Rate constant of the model for tracer1
k5Rate constant of the model for tracer1
k6Rate constant of the model for tracer1
k1bRate constant of the model for tracer2
k2bRate constant of the model for tracer2
fBlood flow; if 0, function assumes that f>>k1, and Cvb=Cab.
vbVascular volume fraction
faArterial fraction of vascular volume
scpetPointer for TAC array to be simulated; must be allocated
sct1Pointer for 1st tracer1 compartment TAC, or NULL if not needed
sct2Pointer for 2nd tracer1 compartment TAC, or NULL if not needed
sct3Pointer for 3rd tracer1 compartment TAC, or NULL if not needed
sct1bPointer for 1st tracer2 compartment TAC, or NULL if not needed
sctabPointer for arterial TAC in tissue, or NULL if not needed
sctvbPointer for venous TAC in tissue, or NULL if not needed

Definition at line 1436 of file simulate.c.

int simC3p ( double *  t,
double *  ca,
int  nr,
double  k1,
double  k2,
double  k3,
double  k4,
double  k5,
double  k6,
double *  ct,
double *  cta,
double *  ctb,
double *  ctc 
)

Simulates tissue TAC using 1-3 tissue compartment model (2nd and 3rd compartments in parallel) and plasma TAC, at plasma TAC times.

Memory for ct must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cta, ctb and/or ctc can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
caArray of arterial activities
nrNumber of values in TACs
k1Rate constant of the model
k2Rate constant of the model
k3Rate constant of the model
k4Rate constant of the model
k5Rate constant of the model
k6Rate constant of the model
ctPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL
ctcPointer for 3rd compartment TAC to be simulated, or NULL

Definition at line 203 of file simulate.c.

int simC3s ( double *  t,
double *  ca,
int  nr,
double  k1,
double  k2,
double  k3,
double  k4,
double  k5,
double  k6,
double *  ct,
double *  cta,
double *  ctb,
double *  ctc 
)

Simulates tissue TAC using 1-3 tissue compartment model (in series) and plasma TAC, at plasma TAC times.

Memory for ct must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cta, ctb and/or ctc can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
caArray of arterial activities
nrNumber of values in TACs
k1Rate constant of the model
k2Rate constant of the model
k3Rate constant of the model
k4Rate constant of the model
k5Rate constant of the model
k6Rate constant of the model
ctPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL
ctcPointer for 3rd compartment TAC to be simulated, or NULL

Definition at line 94 of file simulate.c.

References SIMULATE_TEST.

int simC3vp ( double *  t,
double *  ca,
double *  cb,
int  nr,
double  k1,
double  k2,
double  k3,
double  k4,
double  k5,
double  k6,
double  f,
double  vb,
double  fa,
double *  cpet,
double *  cta,
double *  ctb,
double *  ctc,
double *  ctab,
double *  ctvb 
)

Simulates tissue TAC using 1-3 tissue compartment model (2nd and 3rd compartments in parallel) and plasma TAC, at plasma TAC times, considering also arterial and venous vasculature.

Memory for cpet must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cta, ctb, ctc, ctab and/or ctvb can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

If blood flow is set to 0, function assumes that f>>k1, and Cvb=Cab.,

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
caArray of arterial plasma activities
cbArray of arterial blood activities
nrNumber of values in TACs
k1Rate constant of the model
k2Rate constant of the model
k3Rate constant of the model
k4Rate constant of the model
k5Rate constant of the model
k6Rate constant of the model
fBlood flow; if 0, function assumes that f>>k1, and Cvb=Cab.
vbVascular volume fraction
faArterial fraction of vascular volume
cpetPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL
ctcPointer for 3rd compartment TAC to be simulated, or NULL
ctabPointer for arterial TAC in tissue, or NULL
ctvbPointer for venous TAC in tissue, or NULL

Definition at line 437 of file simulate.c.

int simC3vpKLoss ( double *  t,
double *  ca,
double *  cb,
int  nr,
double  k1,
double  k2,
double  k3,
double  k4,
double  k5,
double  k6,
double  kLoss,
double  f,
double  vb,
double  fa,
double *  cpet,
double *  cta,
double *  ctb,
double *  ctc,
double *  ctab,
double *  ctvb 
)

Simulates tissue TAC using 3 tissue compartmental model with two parallel compartments, and plasma TAC, at plasma TAC sample times, considering also arterial and venous vasculature. The efflux from 3rd tissue compartment (C) goes directly to blood at rate kLoss.

Memory for cpet must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cta, ctb, ctab and/or ctvb can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

If blood flow is set to 0, function assumes that f>>k1, and Cvb=Cab.,

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of sample times
caArray of arterial plasma activities
cbArray of arterial blood activities
nrNumber of sample values in TACs
k1Rate constant of the model
k2Rate constant of the model
k3Rate constant of the model
k4Rate constant of the model
k5Rate constant of the model
k6Rate constant of the model
kLossRate constant of the model
fBlood flow; if 0, function assumes that f>>k1, and Cvb=Cab.
vbVascular volume fraction
faArterial fraction of vascular volume
cpetPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st tissue compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL
ctcPointer for 3rd compartment TAC to be simulated, or NULL
ctabPointer for arterial TAC in tissue, or NULL
ctvbPointer for venous TAC in tissue, or NULL

Definition at line 765 of file simulate.c.

int simC3vs ( double *  t,
double *  ca,
double *  cb,
int  nr,
double  k1,
double  k2,
double  k3,
double  k4,
double  k5,
double  k6,
double  f,
double  vb,
double  fa,
double *  cpet,
double *  cta,
double *  ctb,
double *  ctc,
double *  ctab,
double *  ctvb 
)

Simulates tissue TAC using 1-3 tissue compartment model (in series) and plasma TAC, at plasma TAC times, considering also arterial and venous vasculature.

Memory for cpet must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cta, ctb, ctc, ctab and/or ctvb can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

If blood flow is set to 0, function assumes that f>>k1, and Cvb=Cab.,

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
caArray of arterial plasma activities
cbArray of arterial blood activities
nrNumber of values in TACs
k1Rate constant of the model
k2Rate constant of the model
k3Rate constant of the model
k4Rate constant of the model
k5Rate constant of the model
k6Rate constant of the model
fBlood flow; if 0, function assumes that f>>k1, and Cvb=Cab.
vbVascular volume fraction
faArterial fraction of vascular volume
cpetPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL
ctcPointer for 3rd compartment TAC to be simulated, or NULL
ctabPointer for arterial TAC in tissue, or NULL
ctvbPointer for venous TAC in tissue, or NULL

Definition at line 309 of file simulate.c.

int simDispersion ( double *  x,
double *  y,
int  n,
double  tau1,
double  tau2,
double *  tmp 
)

Simulate the effect of dispersion on a time-activity curve.

Returns:
Returns 0 when successful, otherwise <>0.
Parameters:
xArray of sample times
yArray of sample values, which will be replaced here by dispersion added values
nNr of samples
tau1First dispersion time constant (zero if no dispersion); in same time unit as sample times
tau22nd dispersion time constant (zero if no dispersion); in same time unit as sample times
tmpArray for temporary data, for at least n samples

Definition at line 1569 of file simulate.c.

References simC1().

Here is the call graph for this function:

int simHuangmet ( double *  t,
double *  ctot,
int  nr,
double  k01,
double  k12,
double  k21,
double  k03,
double  k34,
double  k43,
double *  c0,
double *  c1,
double *  c3 
)

Simulation of TACs of parent tracer, and 1-2 of its metabolites in plasma using Huang's compartmental model.

The units of model parameters must be related to the sample time unit; 1/min and min, or 1/sec and sec.

Pointers to memory for output TACs must be specified, or NULL if TAC is not needed.

Returns:
Returns 0, if ok.
Parameters:
tInput: Sample times (preferably with short intervals)
ctotInput: Measured total plasma TAC
nrInput: Nr of samples
k01Input: Model parameters
k12Input: Model parameters
k21Input: Model parameters
k03Input: Model parameters
k34Input: Model parameters
k43Input: Model parameters
c0Output: unchanged (parent) tracer TAC
c1Output: TAC of the 1st metabolite
c3Output: TAC of the 2nd metabolite

Definition at line 1105 of file simulate.c.

References SIMULATE_TEST.

int simMBF ( double *  t,
double *  ci,
int  nr,
double  k1,
double  k2,
double  Vfit,
double *  ct 
)

Simulate myocardial tissue TAC using Iida's compartment model. Memory for ct must be allocated in the calling program. The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec. Function returns 0 when succesful, else a value >= 1.

Parameters:
tArray of time values
ciInput activities
nrNumber of values in TACs
k1Apparent k1
k2Apparent k2
VfitVfit
ctPointer for TAC array to be simulated; must be allocated

Definition at line 1305 of file simulate.c.

int simRTCM ( double *  t,
double *  cr,
int  nr,
double  R1,
double  k2,
double  k3,
double  k4,
double *  ct,
double *  cta,
double *  ctb 
)

Simulates tissue TAC using reference tissue compartment model (original) and reference region TAC, at reference region TAC times.

Memory for ct must be allocated in the calling program. To retrieve the separate tissue compartment TACs, pointer to allocated memory for cf and/or cb can be given; if compartmental TACs are not required, NULL pointer can be given instead.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
crReference region activities
nrNumber of values in TACs
R1Ratio K1/K1'
k2Rate constant of the model
k3Rate constant of the model
k4Rate constant of the model
ctPointer for TAC array to be simulated; must be allocated
ctaPointer for 1st compartment TAC to be simulated, or NULL
ctbPointer for 2nd compartment TAC to be simulated, or NULL

Definition at line 891 of file simulate.c.

int simSRTM ( double *  t,
double *  cr,
int  nr,
double  R1,
double  k2,
double  BP,
double *  ct 
)

Simulates tissue TAC using reference tissue compartment model (simplified) and reference region TAC, at reference region TAC times.

Memory for ct must be allocated in the calling program.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
crReference region activities
nrNumber of values in TACs
R1Ratio K1/K1'
k2Rate constant of the model
BPBinding potential
ctPointer for TAC array to be simulated; must be allocated

Definition at line 973 of file simulate.c.

int simTPCMOD0009c ( double *  t,
double *  ctot,
int  nr,
double  km,
double  k1m,
double  k2m,
double  k3m,
double  k4m,
double *  ca,
double *  cm 
)

Simulate parent tracer TAC using plasma metabolite model TPCMOD0009C, http://www.turkupetcentre.net/reports/tpcmod0009_app_c.pdf

Returns:
Returns 0 if successful.
Parameters:
tSample times
ctotTotal plasma TAC
nrSample number
kmkm
k1mk1m
k2mk2m
k3mk3m
k4mk4m
caPointer to array where parent tracer TAC will be written; NULL, if not needed.
cmPointer to array where metabolized tracer TAC will be written; NULL, if not needed.

Definition at line 1217 of file simulate.c.

int simTRTM ( double *  t,
double *  cr,
int  nr,
double  R1,
double  k2,
double  k3,
double *  ct 
)

Simulates tissue TAC using reference tissue compartment model (transport limited in ref region) and reference region TAC, at reference region TAC times.

Memory for ct must be allocated in the calling program.

The units of rate constants must be related to the time unit; 1/min and min, or 1/sec and sec.

Returns:
Function returns 0 when succesful, else a value >= 1.
Parameters:
tArray of time values
crReference region activities
nrNumber of values in TACs
R1Ratio K1/K1'
k2Rate constant of the model
k3Rate constant of the model
ctPointer for TAC array to be simulated; must be allocated

Definition at line 1039 of file simulate.c.