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

Go to the source code of this file.

Functions

int interpolate (double *x, double *y, int nr, double *newx, double *newy, double *newyi, double *newyii, int newnr)
int finterpolate (float *x, float *y, int nr, float *newx, float *newy, float *newyi, float *newyii, int newnr)
int integrate (double *x, double *y, int nr, double *yi)
int fintegrate (float *x, float *y, int nr, float *yi)
int petintegrate (double *x1, double *x2, double *y, int nr, double *newyi, double *newyii)
int fpetintegrate (float *x1, float *x2, float *y, int nr, float *newyi, float *newyii)
int interpolate4pet (double *x, double *y, int nr, double *newx1, double *newx2, double *newy, double *newyi, double *newyii, int newnr)
int finterpolate4pet (float *x, float *y, int nr, float *newx1, float *newx2, float *newy, float *newyi, float *newyii, int newnr)
int petintegral (double *x1, double *x2, double *y, int nr, double *ie, double *iie)
int fpetintegral (float *x1, float *x2, float *y, int nr, float *ie, float *iie)
int petintegrate2fe (double *x1, double *x2, double *y, int nr, double *e, double *ie, double *iie)
int fpetintegrate2fe (float *x1, float *x2, float *y, int nr, float *e, float *ie, float *iie)

Function Documentation

int fintegrate ( float *  x,
float *  y,
int  nr,
float *  yi 
)

float version of integrate()

Parameters:
xOriginal x values; duplicates are not allowed, all must be >=0. Data must be sorted by ascending x
yOriginal y values
nrNr of values
yiArray for integrals

Definition at line 368 of file integr.c.

Referenced by test_integr().

int finterpolate ( float *  x,
float *  y,
int  nr,
float *  newx,
float *  newy,
float *  newyi,
float *  newyii,
int  newnr 
)

float version of interpolate()

Parameters:
xInput data x (time) values
yInput data y values
nrNumber of values in input data
newxOutput data x values
newyInterpolated (extrapolated) y values; NULL can be given if not needed
newyiIntegrals; NULL can be given if not needed
newyii2nd integrals; NULL can be given if not needed
newnrNr of values in output data

Definition at line 237 of file integr.c.

References INTEGR_TEST.

Referenced by finterpolate4pet(), and test_integr().

int finterpolate4pet ( float *  x,
float *  y,
int  nr,
float *  newx1,
float *  newx2,
float *  newy,
float *  newyi,
float *  newyii,
int  newnr 
)

float version of interpolate4pet()

Parameters:
xTimes of original data
yValues of original data
nrNumber of original data values
newx1PET frame start times; frames may overlap
newx2PET frame end times; frames may overlap
newyMean value during PET frame, or NULL if not needed; calculation may be faster if newyi is calculated too
newyiIntegral at frame mid time, or NULL if not needed
newyii2nd integral at frame mid time, or NULL if not needed
newnrNumber of PET frames

Definition at line 679 of file integr.c.

References finterpolate(), and INTEGR_TEST.

Here is the call graph for this function:

int fpetintegral ( float *  x1,
float *  x2,
float *  y,
int  nr,
float *  ie,
float *  iie 
)

float version of petintegral()

Parameters:
x1frame start times
x2frame end times
yavg value during frame
nrnumber of frames
ieintegrals at frame mid time
iie2nd integrals at frame mid time

Definition at line 855 of file integr.c.

References INTEGR_TEST.

int fpetintegrate ( float *  x1,
float *  x2,
float *  y,
int  nr,
float *  newyi,
float *  newyii 
)
Parameters:
x1Array of frame start times
x2Array of frame end times
yArray of y values (avg during each frame)
nrNr of frames
newyiOutput: integral values at frame end times, or NULL
newyiiOutput: 2nd integral values at frame end times, or NULL

Definition at line 476 of file integr.c.

References INTEGR_TEST.

Referenced by test_integr().

int fpetintegrate2fe ( float *  x1,
float *  x2,
float *  y,
int  nr,
float *  e,
float *  ie,
float *  iie 
)

float version of petintegrate2fe()

Parameters:
x1frame start times
x2frame end times
yavg value during frame
nrnumber of frames
evalues at frame end time
ieintegrals at frame end time
iie2nd integrals at frame end time

Definition at line 980 of file integr.c.

References INTEGR_TEST.

int integrate ( double *  x,
double *  y,
int  nr,
double *  yi 
)

Linear integration from time 0 to x[0..nr-1]. If x[0] is >0 and x[0]<=(x[1]-x[0]), then the beginning is interpolated from it to (0,0).

Returns:
Returns 0 if OK, or 1, if error.
Parameters:
xOriginal x values; duplicates are not allowed, all must be >=0. Data must be sorted by ascending x
yOriginal y values
nrNr of values
yiArray for integrals

Definition at line 346 of file integr.c.

Referenced by test_integr().

int interpolate ( double *  x,
double *  y,
int  nr,
double *  newx,
double *  newy,
double *  newyi,
double *  newyii,
int  newnr 
)

Linear interpolation and integration.

It is assumed, that both original and new interpolated data represent the actual values at specified time points (not from framed data). The integration is calculated dot-by-dot.

If NULL is spefied for newy[], newyi[] and/or newyii[], their values are not calculated.

Original data and new x values must be sorted by ascending x. Subsequent x values can have equal values, enabling the use of step functions. Negative x (time) values can be processed. If necessary, the data is extrapolated assuming that: 1) y[inf]=y[nr-1] and 2) if x[0]>0, y[0]>0 and x[0]<=x[1]-x[0], then an imaginary line is drawn from (0,0) to (x[0],y[0]).

Parameters:
xInput data x (time) values
yInput data y values
nrNumber of values in input data
newxOutput data x values
newyInterpolated (extrapolated) y values; NULL can be given if not needed
newyiIntegrals; NULL can be given if not needed
newyii2nd integrals; NULL can be given if not needed
newnrNr of values in output data

Definition at line 122 of file integr.c.

References INTEGR_TEST.

Referenced by interpolate4pet(), and test_integr().

int interpolate4pet ( double *  x,
double *  y,
int  nr,
double *  newx1,
double *  newx2,
double *  newy,
double *  newyi,
double *  newyii,
int  newnr 
)

Interpolate and integrate TAC to PET frames.

It is assumed, that original data is not from framed data, but that the values represent the actual value at specified time point, which allows the integration to be calculated dot-by-dot.

If NULL is specified for *newy, *newyi and/or *newyii, their values are not calculated.

Original data and new x values must be sorted by ascending x. Subsequent x values can have equal values, enabling the use of step functions. PET frames can overlap, but interpolation may then be slower. Negative x (time) values can be processed. If necessary, the data is extrapolated assuming that 1) y[inf]=y[nr-1] and 2) if x[0]>0 and y[0]>0 and x[0]>x[1]-x[0], then an imaginary line is drawn from (0,0) to (x[0],y[0]).

Parameters:
xTimes of original data
yValues of original data
nrNumber of original data values
newx1PET frame start times; frames may overlap
newx2PET frame end times; frames may overlap
newyMean value during PET frame, or NULL if not needed; calculation may be faster if newyi is calculated too
newyiIntegral at frame mid time, or NULL if not needed
newyii2nd integral at frame mid time, or NULL if not needed
newnrNumber of PET frames

Definition at line 569 of file integr.c.

References INTEGR_TEST, and interpolate().

Here is the call graph for this function:

int petintegral ( double *  x1,
double *  x2,
double *  y,
int  nr,
double *  ie,
double *  iie 
)

Integrate PET TAC data to frame mid times. Any of output arrays may be set to NULL if that is not needed. Frames must be in ascending time order. Gaps and small overlap are allowed. If x1[0]>0 and x1[0]<=x2[0]-x1[0], then an imaginary line is drawn from (0,0) to (x[0],y[0]).

Returns:
Returns 0 if ok.
Parameters:
x1frame start times
x2frame end times
yavg value during frame
nrnumber of frames
ieintegrals at frame mid time
iie2nd integrals at frame mid time

Definition at line 798 of file integr.c.

References INTEGR_TEST.

int petintegrate ( double *  x1,
double *  x2,
double *  y,
int  nr,
double *  newyi,
double *  newyii 
)

Calculates integrals of PET data at frame end times.

Data does not have to be continuous, but it must be increasing in time. For faster performance in repetitive calls, allocate memory for integral[] even if it is not needed. If x1[0] is >0 AND x1[0] is <=(x2[0]-x1[0]), then the beginning is interpolated from (0, 0) to (x1[0], y1[0]*x1[0]/x) where x is midtime of the first frame.

Returns:
Returns 0 if ok.
Parameters:
x1Array of frame start times
x2Array of frame end times
yArray of y values (avg during each frame)
nrNr of frames
newyiOutput: integral values at frame end times, or NULL
newyiiOutput: 2nd integral values at frame end times, or NULL

Definition at line 401 of file integr.c.

References INTEGR_TEST.

Referenced by test_integr().

int petintegrate2fe ( double *  x1,
double *  x2,
double *  y,
int  nr,
double *  e,
double *  ie,
double *  iie 
)

Integrate PET TAC data to frame end times. Any of output arrays may be set to NULL if that is not needed. Frames must be in ascending time order. Gaps and small overlap are allowed. If x1[0]>0 and x1[0]<=x2[0]-x1[0], then an imaginary line is drawn from (0,0) to (x[0],y[0]).

Returns:
Returns 0 if ok.
Parameters:
x1frame start times
x2frame end times
yavg value during frame
nrnumber of frames
evalues at frame end time
ieintegrals at frame end time
iie2nd integrals at frame end time

Definition at line 920 of file integr.c.

References INTEGR_TEST.