|
TPCCLIB
|
Header file for libtpcli. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "tpcextensions.h"Go to the source code of this file.
Functions | |
| int | liInterpolate (double *x, double *y, const int nr, double *newx, double *newy, double *newyi, double *newyii, const int newnr, const int se, const int ee, const int verbose) |
| Linear interpolation and/or integration with trapezoidal method. | |
| int | liInterpolateForPET (double *x, double *y, const int nr, double *newx1, double *newx2, double *newy, double *newyi, double *newyii, const int newnr, const int se, const int ee, const int verbose) |
| Linear TAC interpolation and/or integration to PET frames. | |
| double | liFirstStepSize (double *x, const int nr) |
| Find the initial x step size. | |
| unsigned int | simSamples (double initStep, double maxStep, double endTime, int mode, double *x) |
| int | liIntegrate (double *x, double *y, const int nr, double *yi, const int se, const int verbose) |
| Linear integration of TAC with trapezoidal method. | |
| int | liIntegratePET (double *x1, double *x2, double *y, int nr, double *ie, double *iie, const int verbose) |
| Calculate PET TAC AUC from start to each time frame, as averages during each frame. | |
| int | liIntegrateFE (double *x1, double *x2, double *y, int nr, double *ie, double *iie, const int verbose) |
| Linear integration of PET TAC to frame end times. | |
| int | liIntegrateHalfFrame (double *x1, double *x2, double *y, const size_t nr, double *fhi, const int verbose) |
| Calculate the integrals (AUC) of the first halves of PET frames based on dot-to-dot linear interpolation, assuming that original y values represent the mean value during the frame, i.e. AUC(frame start - frame end time)/frame duration. | |
| int | liDerivate (double *x, double *y, const int nr, double *d, double *dd, const int verbose) |
| Simplistic derivation of TAC as Δy divided by Δx, in relation to the previous point. | |
| int | liDerivate3 (double *x, double *y, const int nr, double *d, double *dd, const int verbose) |
| Simplistic derivation of PET TAC using regression line over three points. | |
Header file for libtpcli.
Header file for library libtpcli.
Definition in file tpcli.h.
|
extern |
Simplistic derivation of TAC as Δy divided by Δx, in relation to the previous point.
The derivative for point i is calculated as d[i]=(y[i]-y[i-1])/(x[i]-x[i-1]). For the first point, i=0, it is assumed that d[0]=0 if y[0]=0; otherwise we assume an imaginary previous data point y[-1]=0 at x[-1]=x[0]-(x[1]-x[0]) and thus d[0]=y[0]/(x[1]-x[0]).
| x | Array of input data x (time) values; obligatory. Data must be sorted by ascending x, and consecutive points must not have the same x. Negative x is accepted. |
| y | Array of input data y (concentration) values; obligatory. |
| nr | Number of samples in input data; obligatory; must be >1. |
| d | Array for derivatives at each x; obligatory. |
| dd | Array for 2nd derivatives at each x; NULL if not needed. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 444 of file integrate.c.
Referenced by tacDelayCMFit().
|
extern |
Simplistic derivation of PET TAC using regression line over three points.
| x | Array of input data x values (sample times); obligatory. |
| y | Array of input data y (concentration) values; obligatory. |
| nr | Number of samples in input data; obligatory; must be >1. |
| d | Array for derivatives at each x; obligatory. |
| dd | Array for 2nd derivatives at each x; NULL if not needed. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 493 of file integrate.c.
Referenced by liDerivate3(), and tacDelayCMFit().
|
extern |
Find the initial x step size.
| x | Array of x (time) values; must be sorted by ascending x, but consecutive points may have the same x. Negative x is accepted. Array must not contain NaNs. |
| nr | Number of samples in data. |
Definition at line 25 of file interpolate.c.
Referenced by liInterpolate().
|
extern |
Linear integration of TAC with trapezoidal method.
Use this function for input data, or PET data when frame start and end times are not known. Data must be frequently sampled to get accurate results. AUC calculation is started from time 0 or first input sample time, whichever is smaller. Very simple data extrapolation can be optionally enabled. Results will be wrong if data contains NaNs. To get the same result as with integrate() in the libtpcmodel, set se=3.
| x | Array of input data x (time) values; obligatory. Data must be sorted by ascending x, but consecutive points may have the same x. Negative x is accepted, AUCs are then started from the first x, otherwise from 0. |
| y | Array of input data y (concentration) values; obligatory. |
| nr | Number of samples in input data; obligatory. |
| yi | Array for integrals (AUCs) at each x; obligatory. |
| se | Extrapolation setting for the start of data:
|
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 33 of file integrate.c.
Referenced by tacDelayCMFit(), and tacIntegrate().
|
extern |
Linear integration of PET TAC to frame end times.
Use this function for PET data when frame start and end times are known. AUC calculation is started from first frame start time, ignoring possible time gap before it. Any gaps between time frames are filled with an imaginary frame calculated as weighted average of previous and next frame. Frames must be in ascending time order and frame overlaps removed.
| x1 | Array of input data x1 (frame start time) values; obligatory. Negative frame times are accepted. |
| x2 | Array of input data x2 (frame end time) values; obligatory. Negative frame times are accepted, but it is required that for each frame x2>=x1. |
| y | Array of frame mean y (concentration) values; obligatory. |
| nr | Number of samples (frames); obligatory. |
| ie | Array for integrals (AUCs) at each x (frame middle time); enter NULL if not needed. |
| iie | Array for 2nd integrals (AUCs) at each x (frame middle time); enter NULL if not needed. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 219 of file integrate.c.
Referenced by tacDelayCMFit(), and tacIntegrateFE().
|
extern |
Calculate the integrals (AUC) of the first halves of PET frames based on dot-to-dot linear interpolation, assuming that original y values represent the mean value during the frame, i.e. AUC(frame start - frame end time)/frame duration.
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. Results will be wrong if data contains NaNs. The beginning and end of true TAC is assumed to follow a line drawn based on the two first/last TAC middle frame y values.
| x1 | Array of PET frame start times; obligatory. Data must be sorted by ascending x, but consecutive points may have the same x. Negative x is accepted. |
| x2 | Array of PET frame end times; obligatory. Data must be sorted by ascending x, but consecutive points may have the same x. Negative x is accepted, but frame duration (x2-x1) must be >=0. |
| y | Array of original TAC y (concentration) values, representing the average concentration during the PET frame; obligatory |
| nr | Number of samples in the data; obligatory |
| fhi | Array for first-half frame integrals of TAC y (concentration) values for each PET frame; obligatory |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout |
Definition at line 309 of file integrate.c.
|
extern |
Calculate PET TAC AUC from start to each time frame, as averages during each frame.
Use this function for PET data when frame start and end times are known. AUC at the end of frame i is calculated as AUCe[i]=AUCe[i-1]+y[i]*(x2[i]-x1[i]), and the integral for frame i is calculated as an average AUC[i]=(AUCe[i]+AUCe[i-1])/2. AUC calculation is started from first frame start time, ignoring possible time gap before it. Any gaps between time frames are filled with an imaginary frame calculated as weighted average of previous and next frame. Frames must be in ascending time order and frame overlaps removed; wrong order or large overlaps will lead to substantial errors in integrals without warning. Results will be wrong if data contains NaNs.
| x1 | Array of input data x1 (frame start time) values; obligatory. Negative frame times are accepted. |
| x2 | Array of input data x2 (frame end time) values; obligatory. Negative frame times are accepted, but it is required that for each frame x2>=x1. |
| y | Array of frame mean y (concentration) values; obligatory. |
| nr | Number of samples (frames); obligatory. |
| ie | Array for integrals (AUCs) at each x (frame middle time); enter NULL if not needed. |
| iie | Array for 2nd integrals (AUCs) at each x (frame middle time); enter NULL if not needed. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 120 of file integrate.c.
Referenced by bfm1TCM(), tacIntegrate(), tacInterpolate(), and tacInterpolateInto().
|
extern |
Linear interpolation and/or integration with trapezoidal method.
PET data must be frequently sampled to get accurate results. AUC calculation is started from time 0 or first input sample time, whichever is smaller. Very simple data extrapolation can be optionally enabled. Results will be wrong if data contains NaNs. To get the same result as with interpolate() in the libtpcmodel, set se=3 and ee=1.
| x | Array of input data x (time) values; obligatory. Data must be sorted by ascending x, but consecutive points may have the same x. Negative x is accepted, AUCs are then started from the first x, otherwise from 0. Array must not contain NaNs. |
| y | Array of input data y (concentration) values; obligatory. Array must not contain NaNs. |
| nr | Number of samples in input data; obligatory. |
| newx | Array of output data x values; obligatory. Must be in ascending order. Negative x is accepted. Array must not contain NaNs. |
| newy | Array for interpolated (extrapolated) y values; NULL can be given if not needed. |
| newyi | Array for integrals (AUCs); NULL can be given if not needed. |
| newyii | Arrays for 2nd integrals; NULL can be given if not needed. |
| newnr | Nr of samples in output data; obligatory. |
| se | Extrapolation setting for the start of data:
|
| ee | Extrapolation setting for the end of data:
|
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout |
Definition at line 139 of file interpolate.c.
Referenced by bfm1TCM(), liInterpolateForPET(), tacAUC(), tacDelay(), tacDelayCMFit(), tacInput2sim(), tacInterpolate(), and tacInterpolateInto().
|
extern |
Linear TAC interpolation and/or integration to PET frames.
PET data must be frequently sampled to get accurate results. AUC calculation is started from time 0 or first input sample time, whichever is smaller. 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. Results will be wrong if data contains NaNs. Very simple data extrapolation can be optionally enabled. To get the same result as with interpolate4pet() in the libtpcmodel, set se=3 and ee=1.
| x | Array of input data x (time) values; obligatory. Data must be sorted by ascending x, but consecutive points may have the same x. Negative x is accepted, AUCs are then started from the first x, otherwise from 0. |
| y | Array of input data y (concentration) values; obligatory. |
| nr | Number of samples in input data; obligatory. |
| newx1 | Array of PET frame start times for output data; obligatory. Must be in ascending order. Negative times are accepted. |
| newx2 | Array of PET frame end times for output data; obligatory. Must be in ascending order. Negative times are accepted, but frame duration (x2-x1) must be >=0. |
| newy | Array for mean concentration values for each PET frame; NULL can be given if not needed. |
| newyi | Array for integrals (AUCs) at frame middle times; NULL can be given if not needed. |
| newyii | Arrays for 2nd integrals at frame middle times; NULL can be given if not needed. |
| newnr | Nr of samples in output data; obligatory. |
| se | Extrapolation setting for the start of data:
|
| ee | Extrapolation setting for the end of data:
|
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 317 of file interpolate.c.
Referenced by bfm1TCM(), tacDelay(), tacDelayCMFit(), tacInterpolate(), tacInterpolateInto(), and tacInterpolateToEqualLengthFrames().
|
extern |
Create sample times with more frequent sampling in the beginning.
| initStep | Initial sampling frequency. |
| maxStep | Maximal sampling frequency which is never exceeded; enter 0 to set it automatically. |
| endTime | End time; last sample will usually be later. |
| mode | Sampling scheme:
|
| x | Allocated array for the samples; NULL if only computing the number of samples. |
Definition at line 50 of file interpolate.c.