5#include "tpcclibConfig.h"
47 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
48 if(verbose>0) printf(
"%s(itac, ttac, %d, %g, %g, %d, bf)\n", __func__, bfNr, k2min, k2max, distr);
49 if(input==NULL || tissue==NULL || bf==NULL) {
58 if(verbose>1) printf(
"invalid sample or BF number\n");
62 if(fabs(k2min)<1.0E-10 || fabs(k2min)>=k2max) {
63 if(verbose>1) printf(
"invalid k2 range\n");
79 if(verbose>1) printf(
"allocating memory for basis functions\n");
83 statusSet(status, __func__, __FILE__, __LINE__, ret);
91 for(
int bi=0; bi<bf->
tacNr; bi++) sprintf(bf->
c[bi].
name,
"B%5.5d", bi+1);
93 if(verbose>1) printf(
"computing k2 values\n");
94 int zero=0;
if(k2min<0.0) {zero=1; bf->
c[0].
size=0.0;}
97 a=log10(fabs(k2min)); b=log10(k2max); c=(b-a)/(
double)(bfNr-1-zero);
98 for(
int bi=zero; bi<bf->
tacNr; bi++) {
99 bf->
c[bi].
size=pow(10.0, (
double)(bi-zero)*c+a);
102 double c=(k2max-fabs(k2min))/(
double)(bfNr-1-zero);
103 for(
int bi=zero; bi<bf->
tacNr; bi++) {
104 bf->
c[bi].
size=fabs(k2min)+(double)(bi-zero)*c;
113 sim=(
double*)malloc(input->
sampleNr*
sizeof(
double));
124 if(verbose>1) printf(
"using BTAC integral as simulation input\n");
125 cbi=(
double*)malloc(input->
sampleNr*
sizeof(
double));
132 if(verbose>1) printf(
"liIntegratePET() = %d\n", ret);
137 if(verbose>1) printf(
"computing basis functions\n");
139 for(
int bi=0; bi<bf->
tacNr && !ret; bi++) {
147 printf(
"\nk2 := %g\n", bf->
c[bi].
size);
148 printf(
"simulated TAC:\n");
149 for(
int i=0; i<input->
sampleNr; i++) printf(
" %12.6f %12.3f\n", input->
x[i], sim[i]);
154 tissue->
x1, tissue->
x2, bf->
c[bi].
y, NULL, NULL, bf->
sampleNr, 4, 1, verbose-8);
157 bf->
c[bi].
y, NULL, NULL, bf->
sampleNr, 4, 1, verbose-8);
160 free(sim); free(cbi);
175 sim=(
double*)malloc(inp.
sampleNr*
sizeof(
double));
181 if(verbose>1) printf(
"computing basis functions\n");
183 for(
int bi=0; bi<bf->
tacNr && !ret; bi++) {
187 printf(
"\nk2 := %g\n", bf->
c[bi].
size);
188 printf(
"simulated TAC:\n");
189 for(
int i=0; i<inp.
sampleNr; i++) printf(
" %12.6f %12.3f\n", inp.
x[i], sim[i]);
194 tissue->
x1, tissue->
x2, bf->
c[bi].
y, NULL, NULL, bf->
sampleNr, 4, 1, verbose-8);
197 bf->
c[bi].
y, NULL, NULL, bf->
sampleNr, 4, 1, verbose-8);
int bfm1TCM(TAC *input, TAC *tissue, int bfNr, const double k2min, const double k2max, const int distr, TAC *bf, TPCSTATUS *status)
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 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.
int tacInput2sim(TAC *itac, TAC *ttac, TAC *stac, TPCSTATUS *status)
Modify input TAC based on tissue TAC, for use in simulations.
int simC1(double *t, double *ca, const int nr, const double k1, const double k2, double *ct)
int simC1_i(double *t, double *cai, const int nr, const double k1, const double k2, double *ct)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
char name[MAX_TACNAME_LEN+1]
int verbose
Verbose level, used by statusPrint() etc.
int forgiving
Force level, 0 for strict tests for data units etc.
int tacAllocate(TAC *tac, int sampleNr, int tacNr)
int tacXCopy(TAC *tac1, TAC *tac2, int i1, int i2)
Header file for libtpcbfm.
Header file for libtpccm.
Header file for library libtpcextensions.
@ TPCERROR_INVALID_VALUE
Invalid value.
@ TPCERROR_UNKNOWN_UNIT
Unknown data unit.
@ TPCERROR_FAIL
General error.
@ TPCERROR_OUT_OF_MEMORY
Cannot allocate memory.
@ TPCERROR_NO_DATA
File contains no data.
@ TPCERROR_TOO_FEW
File contains too few samples.
Header file for library libtpctac.
@ TAC_FORMAT_TSV_UK
UK TSV (point as decimal separator)
Header file for libtpctacmod.