TPCCLIB
Loading...
Searching...
No Matches
interpol.c
Go to the documentation of this file.
1
7/*****************************************************************************/
8#include "tpcclibConfig.h"
9/*****************************************************************************/
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <math.h>
14/*****************************************************************************/
15#include "tpcextensions.h"
16#include "tpcift.h"
17#include "tpctac.h"
18#include "tpcli.h"
19#include "tpcstatist.h"
20/*****************************************************************************/
21
22/*****************************************************************************/
23static char *info[] = {
24 "Linear (dot-to-dot) interpolation and integration of PET time-activity data.",
25 " ",
26 "Usage: @P [options] tacfile [outputfile]",
27 " ",
28 "Options:",
29 " -y or -i or -ii",
30 " TACs are interpolated (-y, default), integrated (-i), or the 2nd",
31 " integral (-ii) is calculated.",
32 " -X=<x1,x2,...> or -C=<start,stop,step> or -F=<xfile>",
33 " The sample times for interpolated or integral TACs can be specified with",
34 " these options; if none of these is given, the sample times of the",
35 " original datafile are used. Definite sample times can be given after",
36 " -X; regular sample timing can be specified using option -C; with -F the",
37 " sample times can be read from given TAC file.",
38 " -A[=<t>]",
39 " Input TACs are interpolated and integrated with sample (0,0) or (t,0)",
40 " as their first measurement points.",
41 " -0=<y|F>",
42 " Input TACs are interpolated and integrated with sample (0,y) added",
43 " if TAC starts later than at zero time. With option -0=F the first",
44 " existing sample value is used as y value.",
45 " -header=<Yes|no>",
46 " Descriptive title lines (if header information is available) can be",
47 " included (default), or not included.",
48 " -stdoptions", // List standard options like --help, -v, etc
49 " ",
50 "Input TAC data is considered to be non-framed even if it contains frame",
51 "start and end times; if necessary, frame mid times are calculated and used.",
52 "The interpolated or integrated values are calculated exactly at the",
53 "specified sample times, except when the start and end times of PET frames",
54 "are given with -F=<xfile>; then the time frame average values or integrals",
55 "at the frame mid time are calculated.",
56 " ",
57 "If output filename is not specified, the results are written to stdout.",
58 " ",
59 "If result consists of only one value, output file is not given, and option",
60 "-header=no is given, then just the value is printed, without time, for",
61 "easier use in scripts. For example in bash:",
62 " ",
63 " auc=$(interpol -i -x=50 -header=no plasma.dat)",
64 " printf \"AUC=%s\\n\" $auc ",
65 " ",
66 "See also: taccalc, dftinteg, simframe, tacframe, ainterp, taccut, extrapol",
67 " ",
68 "Keywords: TAC, modelling, simulation, tool, AUC, interpolation",
69 0};
70/*****************************************************************************/
71
72/*****************************************************************************/
73/* Turn on the globbing of the command line, since it is disabled by default in
74 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
75 In Unix&Linux wildcard command line processing is enabled by default. */
76/*
77#undef _CRT_glob
78#define _CRT_glob -1
79*/
80int _dowildcard = -1;
81/*****************************************************************************/
82
83/*****************************************************************************/
87int main(int argc, char **argv)
88{
89 int ai, help=0, version=0, verbose=1;
90 int ret;
91 int mode=0; /* 0=interpolation; 1=integral; 2=2nd integral */
92 char *cptr, tacfile[FILENAME_MAX], outfile[FILENAME_MAX],
93 xfile[FILENAME_MAX];
94 static char *mode_str[] = {"concentration", "integral", "2nd_integral", 0};
95 TAC tac1, tac2;
96 double start0, startY;
97 int xnr; // length of xlist
98 double *xlist=NULL; // remember to free
99 int header=1; // save header (1) or do not save (0)
100
101
102 /*
103 * Get arguments
104 */
105 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
106 tacInit(&tac1); tacInit(&tac2);
107 tacfile[0]=outfile[0]=xfile[0]=(char)0;
108 xnr=0;
109 start0=startY=nan("");
110 /* Options */
111 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
112 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
113 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
114 if(strcasecmp(cptr, "Y")==0) {
115 mode=0; continue;
116 } else if(strcasecmp(cptr, "I")==0) {
117 mode=1; continue;
118 } else if(strcasecmp(cptr, "II")==0) {
119 mode=2; continue;
120 } else if(strncasecmp(cptr, "F=", 2)==0) {
121 if(xnr>0) {
122 fprintf(stderr,"Error: sample times specified with more than one way.\n");
123 free(xlist); return(1);
124 }
125 strcpy(xfile, cptr+2); if(strlen(xfile)>0) continue;
126 } else if(strncasecmp(cptr, "C=", 2)==0) {
127 if(xnr>0) {
128 fprintf(stderr,"Error: sample times specified with more than one way.\n");
129 free(xlist); return(1);
130 }
131 cptr+=2;
132 /* Read x start, end, and stepsize */
133 double v[4];
134 if(atofList(cptr, ";,_|: \t", v, 4) != 3) {
135 fprintf(stderr, "Error: invalid format with option -C.\n");
136 return(1);
137 }
138 if(v[0]>=v[1] || v[0]<0.0 || v[2]<=0.0) {
139 fprintf(stderr, "Error: invalid values with option -C.\n");
140 return(1);
141 }
142 int n;
143 n=1+(int)ceil(fabs(v[1]-v[0])/v[2]);
144 if(n<3 || n>10000) {
145 fprintf(stderr, "Error: invalid step size.\n");
146 return(1);
147 }
148 xlist=(double*)malloc(n*sizeof(double));
149 if(xlist==NULL) {
150 fprintf(stderr, "Error: out of memory.\n");
151 return(1);
152 }
153 /* Fill data from start to stop time */
154 double f;
155 for(xnr=0; xnr<n; xnr++) {
156 f=v[0]+(double)xnr*v[2]; if(f>v[1]) break; else xlist[xnr]=f;}
157 continue;
158 } else if(strncasecmp(cptr, "X=", 2)==0) {
159 if(xnr>0) {
160 fprintf(stderr,"Error: sample times specified with more than one way.\n");
161 free(xlist); return(1);
162 }
163 cptr+=2;
164 /* Read x values */
165 xnr=strTokenNr((char*)cptr, ";,_|: \t");
166 if(xnr<1 || xnr>100) {
167 fprintf(stderr, "Error: invalid format with option -X.\n");
168 return(1);
169 }
170 xlist=(double*)malloc(xnr*sizeof(double));
171 if(xlist==NULL) {
172 fprintf(stderr, "Error: out of memory.\n");
173 xnr=0; return(1);
174 }
175 xnr=atofList(cptr, ";,_|: \t", xlist, xnr);
176 if(xnr<1) {
177 fprintf(stderr, "Error: invalid format with option -X.\n");
178 free(xlist); xnr=0; return(1);
179 }
180 statSortDouble(xlist, xnr, 0); // make sure that values are ascending
181 continue;
182 } else if(strcasecmp(cptr, "A")==0) {
183 start0=0.0; continue;
184 } else if(strncasecmp(cptr, "A=", 2)==0) {
185 start0=atofVerified(cptr+2); if(isfinite(start0)) continue;
186 } else if(strncasecmp(cptr, "0=", 2)==0) {
187 cptr+=2;
188 if(strcasecmp(cptr, "F")==0) {startY=-1.0E+20; continue;}
189 startY=atofVerified(cptr); if(isfinite(startY)) continue;
190 } else if(strncasecmp(cptr, "HEADER=", 7)==0) {
191 cptr+=7;
192 if(strncasecmp(cptr, "YES", 1)==0) {
193 header=1; continue;
194 } else if(strncasecmp(cptr, "NO", 1)==0) {
195 header=0; continue;
196 }
197 } else if(strncasecmp(cptr, "HDR=", 4)==0) {
198 cptr+=4;
199 if(strncasecmp(cptr, "YES", 1)==0) {
200 header=1; continue;
201 } else if(strncasecmp(cptr, "NO", 1)==0) {
202 header=0; continue;
203 }
204 }
205 fprintf(stderr, "Error: invalid option '%s'\n", argv[ai]);
206 return(1);
207 } else break; // tac name argument may start with '-'
208
209 TPCSTATUS status; statusInit(&status);
210 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
211 status.verbose=verbose-1;
212
213 /* Print help or version? */
214 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
215 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
216 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
217
218 /* In verbose mode print options */
219 if(verbose>1) {
220 printf("mode := %s\n", mode_str[mode]);
221 if(xfile[0]) printf("xfile := %s\n", xfile);
222 if(!isnan(start0)) printf("start0 := %g\n", start0);
223 if(!isnan(startY)) printf("startY := %g\n", startY);
224 if(xnr>0) {
225 printf("xlist :=");
226 for(int i=0; i<xnr; i++) printf(" %g", xlist[i]);
227 printf("\n");
228 }
229 }
230
231 /* Process other arguments, starting from the first non-option */
232 if(ai<argc) strlcpy(tacfile, argv[ai++], FILENAME_MAX);
233 if(ai<argc) strlcpy(outfile, argv[ai++], FILENAME_MAX);
234 if(ai<argc) {
235 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
236 return(1);
237 }
238 /* Did we get all the information that we need? */
239 if(!tacfile[0]) {
240 fprintf(stderr, "Error: missing file name.\n");
241 return(1);
242 }
243
244 /* In verbose mode print arguments */
245 if(verbose>1) {
246 printf("tacfile := %s\n", tacfile);
247 if(outfile[0]) printf("outfile := %s\n", outfile);
248 }
249
250
251 /*
252 * Read the TAC file
253 */
254 if(verbose>1) printf("reading %s\n", tacfile);
255 ret=tacRead(&tac1, tacfile, &status);
256 if(ret!=TPCERROR_OK) {
257 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
258 tacFree(&tac1); free(xlist); return(2);
259 }
260 if(verbose>2) {
261 printf("fileformat := %s\n", tacFormattxt(tac1.format));
262 printf("tacNr := %d\n", tac1.tacNr);
263 printf("sampleNr := %d\n", tac1.sampleNr);
264 printf("xunit := %s\n", unitName(tac1.tunit));
265 printf("yunit := %s\n", unitName(tac1.cunit));
266 }
267 /* Sort data by sample times */
268 ret=tacSortByTime(&tac1, &status);
269 if(ret!=TPCERROR_OK) {
270 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
271 tacFree(&tac1); free(xlist); return(2);
272 }
273 /* Check for missing y values */
274 ret=tacNaNs(&tac1);
275 if(ret>0) {
276 if(verbose>1) printf("missing concentrations.\n");
277 /* Try to fix missing concentrations */
278 ret=tacFixNaNs(&tac1);
279 if(ret!=0) {
280 fprintf(stderr, "Error: missing concentrations in %s.\n", tacfile);
281 tacFree(&tac1); free(xlist); return(2);
282 }
283 }
284
285 /*
286 * Add an initial value, if required with option -A
287 */
288 if(isnormal(start0)) {
289 if(verbose>1) printf("adding initial point\n");
290 /* Make sure that sample is added, but keep the original first sample, too */
291 double x, x1, x2;
292 x=tac1.x[0]; x1=tac1.x1[0]; x2=tac1.x2[0];
293 tac1.x[0]=tac1.x1[0]=tac1.x2[0]=1.0;
294 ret=tacAddZeroSample(&tac1, &status);
295 if(ret!=TPCERROR_OK) {
296 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
297 if(verbose>=0) printf("Note: check the data and option -A\n");
298 tacFree(&tac1); free(xlist); return(3);
299 }
300 tac1.x[1]=x; tac1.x1[1]=x1; tac1.x2[1]=x2;
301 /* Set the new first sample to required values */
302 tac1.x[0]=tac1.x1[0]=tac1.x2[0]=start0;
303 for(int j=0; j<tac1.tacNr; j++) tac1.c[j].y[0]=0.0;
304 /* Remove samples with earlier time than the new first sample */
305 if(tac1.isframe)
306 for(int i=1; i<tac1.sampleNr; i++) tac1.x[i]=0.5*(tac1.x1[i]+tac1.x2[i]);
307 ret=TPCERROR_OK;
308 while(tac1.sampleNr>1 && tac1.x[1]<start0 && ret==TPCERROR_OK) {
309 if(verbose>4) printf("deleting sample x=%g\n", tac1.x[1]);
310 ret=tacDeleteSample(&tac1, 1);
311 }
312 if(ret!=TPCERROR_OK || tac1.sampleNr<2) {
313 fprintf(stderr, "Error: invalid data or option -A.\n");
314 tacFree(&tac1); free(xlist); return(3);
315 }
316 }
317
318
319 /*
320 * Add an initial value, if required with option -0
321 */
322 if(tac1.isframe) tac1.x[0]=0.5*(tac1.x1[0]+tac1.x2[0]);
323 if(isnormal(startY) && tac1.x[0]>0.0) {
324 if(verbose>1) printf("adding initial value at zero\n");
325 ret=tacAddZeroSample(&tac1, &status);
326 if(ret!=TPCERROR_OK) {
327 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
328 if(verbose>=0) printf("Note: check the data and option -0\n");
329 tacFree(&tac1); free(xlist); return(4);
330 }
331 /* Set first sample to zero time */
332 tac1.x[0]=tac1.x1[0]=tac1.x2[0]=0.0;
333 /* Set the value */
334 if(startY<-1.0E+10 && tac1.sampleNr>1)
335 for(int j=0; j<tac1.tacNr; j++) tac1.c[j].y[0]=tac1.c[j].y[1];
336 else
337 for(int j=0; j<tac1.tacNr; j++) tac1.c[j].y[0]=startY;
338 }
339
340
341 /*
342 * Set up space for output data and set output times
343 */
344 if(xfile[0]) {
345
346 /* If sample times are given in a file, then read it,
347 and use it as the basis of output data */
348 if(verbose>1) printf("reading %s\n", xfile);
349 ret=tacRead(&tac2, xfile, &status);
350 if(ret!=TPCERROR_OK) {
351 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
352 tacFree(&tac1); tacFree(&tac2); free(xlist); return(5);
353 }
354 if(verbose>2) {
355 printf("fileformat2 := %s\n", tacFormattxt(tac2.format));
356 printf("tacNr2 := %d\n", tac2.tacNr);
357 printf("sampleNr2 := %d\n", tac2.sampleNr);
358 printf("xunit2 := %s\n", unitName(tac2.tunit));
359 printf("yunit2 := %s\n", unitName(tac2.cunit));
360 }
361 /* Convert time units, if necessary/possible */
362 ret=tacXUnitConvert(&tac2, tac1.tunit, &status);
363 if(ret!=TPCERROR_OK && verbose>0) {
364 fprintf(stderr, "Warning: different or unknown time units.\n");
365 }
366 /* Allocate space for all TACs */
367 if(tac2.tacNr<tac1.tacNr) {
368 tac2.tacNr=0;
369 ret=tacAllocateMore(&tac2, tac1.tacNr);
370 if(ret!=TPCERROR_OK) {
371 fprintf(stderr, "Error: %s\n", errorMsg(ret));
372 tacFree(&tac1); tacFree(&tac2); free(xlist); return(5);
373 }
374 }
375 tac2.tacNr=tac1.tacNr;
376 /* Set header */
378 tac2.cunit=tac1.cunit;
379 tac2.format=tac1.format;
380 iftFree(&tac2.h); iftDuplicate(&tac1.h, &tac2.h);
381 for(int j=0; j<tac1.tacNr; j++) tacCopyTacchdr(&tac1.c[j], &tac2.c[j]);
382
383 } else if(xnr>0) {
384
385 /* x values were given with command-line options -X or -C */
386 if(verbose>1) printf("allocating memory for %d samples\n", xnr);
387 ret=tacAllocate(&tac2, xnr, tac1.tacNr);
388 if(ret!=TPCERROR_OK) {
389 fprintf(stderr, "Error: %s\n", errorMsg(ret));
390 tacFree(&tac1); tacFree(&tac2); free(xlist); return(5);
391 }
392 tac2.sampleNr=xnr; tac2.tacNr=tac1.tacNr;
394 tac2.cunit=tac1.cunit;
395 tac2.tunit=tac1.tunit;
396 tac2.format=tac1.format;
397 iftFree(&tac2.h); iftDuplicate(&tac1.h, &tac2.h);
398 for(int j=0; j<tac1.tacNr; j++) tacCopyTacchdr(&tac1.c[j], &tac2.c[j]);
399 tac2.isframe=0;
400 for(int j=0; j<xnr; j++) tac2.x[j]=xlist[j];
401
402 } else {
403
404 /* x values must be retrieved from the input data */
405 ret=tacDuplicate(&tac1, &tac2);
406 if(ret!=TPCERROR_OK) {
407 fprintf(stderr, "Error: %s\n", errorMsg(ret));
408 tacFree(&tac1); tacFree(&tac2); free(xlist); return(5);
409 }
410
411 }
412 /* list of x values is not needed later */
413 free(xlist);
414
415 if(verbose>3) {
416 printf("_tacNr2 := %d\n", tac2._tacNr);
417 printf("_sampleNr2 := %d\n", tac2._sampleNr);
418 printf("tacNr2 := %d\n", tac2.tacNr);
419 printf("sampleNr2 := %d\n", tac2.sampleNr);
420 }
421
422
423 /*
424 * Calculate
425 */
426 ret=0;
427 if(mode==0) {
428 if(verbose>1) printf("interpolating\n");
429 if(tac2.isframe) for(int j=0; j<tac1.tacNr && ret==0; j++) {
430 ret=liInterpolateForPET(tac1.x, tac1.c[j].y, tac1.sampleNr,
431 tac2.x1, tac2.x2, tac2.c[j].y, NULL, NULL, tac2.sampleNr,
432 3, 1, verbose-2);
433 } else for(int j=0; j<tac1.tacNr && ret==0; j++) {
434 ret=liInterpolate(tac1.x, tac1.c[j].y, tac1.sampleNr,
435 tac2.x, tac2.c[j].y, NULL, NULL, tac2.sampleNr,
436 3, 1, verbose-2);
437 }
438 } else if(mode==1) {
439 if(verbose>1) printf("integrating\n");
440 if(tac2.isframe) for(int j=0; j<tac1.tacNr && ret==0; j++) {
441 ret=liInterpolateForPET(tac1.x, tac1.c[j].y, tac1.sampleNr,
442 tac2.x1, tac2.x2, NULL, tac2.c[j].y, NULL, tac2.sampleNr,
443 3, 1, verbose-2);
444 } else for(int j=0; j<tac1.tacNr && ret==0; j++) {
445 ret=liInterpolate(tac1.x, tac1.c[j].y, tac1.sampleNr,
446 tac2.x, NULL, tac2.c[j].y, NULL, tac2.sampleNr,
447 3, 1, verbose-2);
448 }
449 } else if(mode==2) {
450 if(verbose>1) printf("computing 2nd integrals\n");
451 if(tac2.isframe) for(int j=0; j<tac1.tacNr && ret==0; j++) {
452 ret=liInterpolateForPET(tac1.x, tac1.c[j].y, tac1.sampleNr,
453 tac2.x1, tac2.x2, NULL, NULL, tac2.c[j].y, tac2.sampleNr,
454 3, 1, verbose-2);
455 } else for(int j=0; j<tac1.tacNr && ret==0; j++) {
456 ret=liInterpolate(tac1.x, tac1.c[j].y, tac1.sampleNr,
457 tac2.x, NULL, NULL, tac2.c[j].y, tac2.sampleNr,
458 3, 1, verbose-2);
459 }
460 }
461 if(ret) {
462 fprintf(stderr, "Error: cannot interpolate/integrate.\n");
463 if(verbose>1) printf("return_code := %d\n", ret);
464 tacFree(&tac1); tacFree(&tac2); return(8);
465 }
466
467
468 /*
469 * Save data
470 */
471 if(tac2.isframe && tac2.format==TAC_FORMAT_SIMPLE) {
472 /* make sure that frame start and end times are not replaced by middle
473 times because of file format */
475 }
476 FILE *fp;
477 if(outfile[0]) {
478 if(verbose>1) printf("writing %s\n", outfile);
479 fp=fopen(outfile, "w");
480 if(fp==NULL) {
481 fprintf(stderr, "Error: cannot open file for writing (%s)\n", outfile);
482 tacFree(&tac1); tacFree(&tac2); return(11);
483 }
484 } else if(header==0 && tac2.tacNr==1 && tac2.sampleNr==1) {
485 /* If user does not want headers, and we have just one value to print to
486 stdout, then do not print time(s) but only the value */
487 fprintf(stdout, "%g\n", tac2.c[0].y[0]);
488 tacFree(&tac1); tacFree(&tac2);
489 return(0);
490 } else {
491 fp=stdout;
492 }
493 ret=tacWrite(&tac2, fp, TAC_FORMAT_UNKNOWN, header, &status);
494 tacFree(&tac1); tacFree(&tac2);
495 if(outfile[0]) fclose(fp);
496 if(ret!=TPCERROR_OK) {
497 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
498 return(12);
499 }
500 if(verbose>=0 && outfile[0]) printf("%s saved.\n", outfile);
501
502 return(0);
503}
504/*****************************************************************************/
505
506/*****************************************************************************/
double atofVerified(const char *s)
Definition decpoint.c:75
int atofList(const char *s1, const char *s2, double *x, int maxn)
Definition decpoint.c:150
void iftFree(IFT *ift)
Definition ift.c:37
int iftDuplicate(IFT *ift1, IFT *ift2)
Definition ift.c:236
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 tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:47
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:169
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:339
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:114
void statSortDouble(double *data, unsigned int n, int order)
Definition sort.c:99
void statusInit(TPCSTATUS *s)
Definition statusmsg.c:104
char * errorMsg(tpcerror e)
Definition statusmsg.c:68
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition statusmsg.c:142
int strTokenNr(const char *s1, const char *s2)
Definition stringext.c:25
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition stringext.c:632
double * y
Definition tpctac.h:75
Definition tpctac.h:87
double * x
Definition tpctac.h:97
unit cunit
Definition tpctac.h:105
tacformat format
Definition tpctac.h:93
int _sampleNr
Definition tpctac.h:121
int sampleNr
Definition tpctac.h:89
IFT h
Optional (but often useful) header information.
Definition tpctac.h:141
int isframe
Definition tpctac.h:95
TACC * c
Definition tpctac.h:117
weights weighting
Definition tpctac.h:115
double * x2
Definition tpctac.h:101
unit tunit
Definition tpctac.h:109
int _tacNr
Definition tpctac.h:119
double * x1
Definition tpctac.h:99
int tacNr
Definition tpctac.h:91
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
void tacFree(TAC *tac)
Definition tac.c:106
int tacDuplicate(TAC *tac1, TAC *tac2)
Make a duplicate of TAC structure.
Definition tac.c:356
int tacAllocate(TAC *tac, int sampleNr, int tacNr)
Definition tac.c:130
void tacInit(TAC *tac)
Definition tac.c:24
int tacAllocateMore(TAC *tac, int tacNr)
Definition tac.c:178
int tacCopyTacchdr(TACC *d1, TACC *d2)
Definition tac.c:282
int tacRead(TAC *d, const char *fname, TPCSTATUS *status)
Definition tacio.c:413
char * tacFormattxt(tacformat c)
Definition tacio.c:98
int tacWrite(TAC *tac, FILE *fp, tacformat format, int extra, TPCSTATUS *status)
Definition tacio.c:332
int tacNaNs(TAC *tac)
Definition tacnan.c:71
int tacFixNaNs(TAC *tac)
Definition tacnan.c:121
int tacSortByTime(TAC *d, TPCSTATUS *status)
Definition tacorder.c:74
int tacXUnitConvert(TAC *tac, const int u, TPCSTATUS *status)
Definition tacunits.c:23
int tacAddZeroSample(TAC *d, TPCSTATUS *status)
Add an initial sample to TAC(s) with zero time and concentration.
Definition tacx.c:366
int tacDeleteSample(TAC *d, int i)
Delete a certain sample (time frame) from TAC structure.
Definition tacx.c:426
Header file for library libtpcextensions.
@ WEIGHTING_OFF
Not weighted or weights not available (weights for all included samples are 1.0).
@ TPCERROR_OK
No error.
char * unitName(int unit_code)
Definition units.c:143
Header file for library libtpcift.
Header file for libtpcli.
Header file for libtpcstatist.
Header file for library libtpctac.
@ TAC_FORMAT_UNKNOWN
Unknown format.
Definition tpctac.h:28
@ TAC_FORMAT_SIMPLE
x and y's with space delimiters
Definition tpctac.h:29
@ TAC_FORMAT_DFT
Data format of Turku PET Centre.
Definition tpctac.h:30