TPCCLIB
Loading...
Searching...
No Matches
fitdt.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 "tpcfileutil.h"
17#include "tpcift.h"
18#include "tpccsv.h"
19#include "tpcisotope.h"
20#include "tpctac.h"
21#include "tpctacmod.h"
22#include "tpcbfm.h"
23#include "tpcstatist.h"
24/*****************************************************************************/
25
26/*****************************************************************************/
27static char *info[] = {
28 "Estimate the time delay (dT) between PET tissue and blood curves.",
29 "Initial part of tissue curve is fitted with a range of input curves moved",
30 "in time (1, 2, 3), using linearised one or two tissue compartment model",
31 "with blood volume term. The time that provides the best fit",
32 "(smallest sum-of-squares) is selected. Tissue heterogeneity, dispersion of",
33 "the blood curve, metabolites, and variable plasma-to-blood ratio may",
34 "only minimally impact the time delay estimate, if only the initial part",
35 "of the data is fitted with relatively complex model.",
36 " ",
37 "Usage: @P [options] btacfile ttacfile parfile [dcttacfile]",
38 " ",
39 "Options:",
40 " -min=<Time (sec)> and -max=<Time (sec)>",
41 " The range of time delays to be tested; by default -10 - +50 s.",
42 " -end=<Fit end time (sec)>",
43 " Use data from 0 to end time; by default, 300 s; at least 120 s.",
44 " In case of short PET scan, end time may need to be reduced so that",
45 " BTAC with negative delay extends to end time.",
46 " -step=<dT step size (sec)>",
47 " The step length for moving the input curve; by default 1 s.",
48//" -model=<R1TCM | I2TCM | R2TCM | DMS>", // -DMS currently does not work reliably.
49 " -model=<R1TCM | I2TCM | R2TCM>",
50 " Reversible one-tissue (R1TCM, default), irreversible 2-tissue model",
51 " (I2TCM), or reversible 2-tissue model (R2TCM) can be selected.",
52 " -stdoptions", // List standard options like --help, -v, etc
53 " ",
54 "Delay times for each tissue curve are reported in parameter file.",
55 "File may also contain a median time delay as 'time_difference := time',",
56 "depending on the file format.",
57 "Positive delay time means that tissue curve is delayed as compared to",
58 "the input curve, and vice versa. Thus, input curve needs to be moved",
59 "by the delay time to match the tissue curve.",
60 " ",
61 "Optionally, delay corrected TTACs can be written in specified file.",
62 " ",
63 "References:",
64 " 1. Iida H et al. Evaluation of regional differences of tracer appearance",
65 " time in cerebral tissues using [15O]water and dynamic positron emission",
66 " tomography. J Cereb Blood Flow Metab. 1988; 8:285-288.",
67 " 2. Meyer. Simultaneous correction for tracer arrival delay and dispersion",
68 " in CBF measurements by the H215O autoradiographic method and dynamic PET.",
69 " J Nucl Med 1989; 30:1069-1078.",
70 " 3. van den Hoff et al. Accurate local blood flow measurements with",
71 " dynamic PET: fast determination of input function delay and dispersion",
72 " by multilinear minimization. J Nucl Med 1993; 34:1770-1777.",
73 " ",
74 "See also: fitdelay, imgdelay, tacmove, tactime, simdisp, tacframe",
75 " ",
76 "Keywords: TAC, modelling, time delay",
77 0};
78/*****************************************************************************/
79
80/*****************************************************************************/
81/* Turn on the globbing of the command line, since it is disabled by default in
82 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
83 In Unix&Linux wildcard command line processing is enabled by default. */
84/*
85#undef _CRT_glob
86#define _CRT_glob -1
87*/
88int _dowildcard = -1;
89/*****************************************************************************/
90
91/*****************************************************************************/
95int main(int argc, char **argv)
96{
97 int ai, help=0, version=0, verbose=1;
98 char ttacfile[FILENAME_MAX], btacfile[FILENAME_MAX],
99 parfile[FILENAME_MAX], cttacfile[FILENAME_MAX];
100 double endtime=300.0; // fit end time in seconds
101 double endtimemin=90.0; // shortest fit end time allowed
102 double dtrange[2]={-10,+50}; // dT range
103 double dtstep=1.0; // dT step size
104 int mode=0; // Delay estimation mode
105 int model=0; // 0=R1TCM, 1=I2TCM, 2=R2TCM, 3=DMS
106
107
108 /*
109 * Get arguments
110 */
111 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
112 ttacfile[0]=btacfile[0]=parfile[0]=cttacfile[0]=(char)0;
113 /* Options */
114 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
115 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
116 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
117 if(strncasecmp(cptr, "END=", 4)==0) {
118 int ret=atofCheck(cptr+4, &endtime); if(!ret && endtime>=endtimemin) continue;
119 } else if(strncasecmp(cptr, "MIN=", 4)==0) {
120 if(atofCheck(cptr+4, &dtrange[0])==0) continue;
121 } else if(strncasecmp(cptr, "MAX=", 4)==0) {
122 if(atofCheck(cptr+4, &dtrange[1])==0) continue;
123 } else if(strncasecmp(cptr, "STEP=", 5)==0) {
124 int ret=atofCheck(cptr+5, &dtstep); if(!ret && dtstep>0.0) continue;
125 } else if(strncasecmp(cptr, "MODE=", 5)==0) {
126 if(atoiCheck(cptr+5, &mode)==0) continue;
127 } else if(strncasecmp(cptr, "MODEL=", 6)==0) {
128 if(strcasecmp(cptr+6, "R1TCM")==0) {model=0; continue;}
129 if(strcasecmp(cptr+6, "I2TCM")==0) {model=1; continue;}
130 if(strcasecmp(cptr+6, "R2TCM")==0) {model=2; continue;}
131 if(strcasecmp(cptr+6, "DMS")==0) {model=3; continue;}
132 }
133 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
134 return(1);
135 } else break; // tac name argument may start with '-'
136
137 TPCSTATUS status; statusInit(&status);
138 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
139 status.verbose=verbose-3;
140
141 /* Print help or version? */
142 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
143 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
144 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
145
146 /* The first argument (non-option) is the file name */
147 if(ai<argc) {strlcpy(btacfile, argv[ai], FILENAME_MAX); ai++;}
148 if(ai<argc) {strlcpy(ttacfile, argv[ai], FILENAME_MAX); ai++;}
149 if(ai<argc) {strlcpy(parfile, argv[ai], FILENAME_MAX); ai++;}
150 if(ai<argc) {strlcpy(cttacfile, argv[ai], FILENAME_MAX); ai++;}
151 /* check that there are no extra arguments */
152 if(ai<argc) {fprintf(stderr, "Error: extra command-line argument.\n"); return(1);}
153 /* Is something missing? */
154 if(!parfile[0]) {tpcPrintUsage(argv[0], info, stdout); return(1);}
155
156 /* In verbose mode print arguments and options */
157 if(verbose>1) {
158 printf("ttacfile := %s\n", ttacfile);
159 printf("btacfile := %s\n", btacfile);
160 printf("parfile := %s\n", parfile);
161 printf("cttacfile := %s\n", cttacfile);
162 printf("endtime := %g\n", endtime);
163 printf("dtrange := %g - %g s\n", dtrange[0], dtrange[1]);
164 printf("step := %g\n", dtstep);
165 printf("mode := %d\n", mode);
166 printf("model := %d\n", model);
167 fflush(stdout);
168 }
169
170 /* Check that TAC files do exist */
171 if(!fileExist(ttacfile)) {
172 fprintf(stderr, "Error: file '%s' does not exist.\n", ttacfile);
173 return(1);
174 }
175 if(!fileExist(btacfile)) {
176 fprintf(stderr, "Error: file '%s' does not exist.\n", btacfile);
177 return(1);
178 }
179
180 /* Check options */
181 if(dtrange[0]>dtrange[1]) {double f=dtrange[0]; dtrange[0]=dtrange[1]; dtrange[1]=f;}
182 int moveNr=1+(dtrange[1]-dtrange[0])/dtstep;
183 if(verbose>1) {
184 printf("step_number := %d\n", moveNr);
185 fflush(stdout);
186 }
187 if(moveNr<5 || moveNr>2000) {
188 fprintf(stderr, "Error: invalid dT range or step size.\n");
189 return(1);
190 }
191 if((moveNr<10 || moveNr>500) && verbose>0)
192 fprintf(stderr, "Warning: non-optimal dT range or step size.\n");
193
194
195
196 /*
197 * Read the data
198 */
199 if(verbose>1) printf("reading TACs\n");
200 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
201 TAC ttac, btac; tacInit(&ttac); tacInit(&btac);
202
203 if(tacRead(&ttac, ttacfile, &status)!=TPCERROR_OK) {
204 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
205 tacFree(&ttac); tacFree(&btac); return(2);
206 }
207 if(verbose>2) {
208 printf("ttac.fileformat := %s\n", tacFormattxt(ttac.format));
209 printf("ttacNr := %d\n", ttac.tacNr);
210 printf("ttac.sampleNr := %d\n", ttac.sampleNr);
211 fflush(stdout);
212 }
213
214 if(tacRead(&btac, btacfile, &status)!=TPCERROR_OK) {
215 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
216 tacFree(&ttac); tacFree(&btac); return(2);
217 }
218 if(verbose>2) {
219 printf("btac.fileformat := %s\n", tacFormattxt(btac.format));
220 printf("btacNr := %d\n", btac.tacNr);
221 printf("btac.sampleNr := %d\n", btac.sampleNr);
222 fflush(stdout);
223 }
224 if(btac.tacNr>1) {
225 if(verbose>0) fprintf(stderr, "Warning: BTAC file contains more than one TAC.\n");
226 btac.tacNr=1;
227 }
228
229 if(ttac.sampleNr<7 || btac.sampleNr<7) {
230 fprintf(stderr, "Error: too few samples.\n");
231 tacFree(&ttac); tacFree(&btac); return(2);
232 }
233 /* Check NaNs */
234 if(tacNaNs(&ttac)>0 || tacNaNs(&btac)>0) {
235 fprintf(stderr, "Error: data contains missing values.\n");
236 tacFree(&ttac); tacFree(&btac); return(2);
237 }
238 /* Sort data by sample time */
239 tacSortByTime(&ttac, &status);
240 tacSortByTime(&btac, &status);
241 /* Fix any gaps and overlap in data if possible and if not then quit with error */
243 fprintf(stderr, "Error: invalid curve data.\n");
244 tacFree(&ttac); tacFree(&btac); return(2);
245 }
246
247 /* Convert sample times into seconds */
248 if(tacXUnitConvert(&ttac, UNIT_SEC, &status)!=TPCERROR_OK ||
249 tacXUnitConvert(&btac, UNIT_SEC, &status)!=TPCERROR_OK)
250 {
251 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
252 tacFree(&ttac); tacFree(&ttac); return(2);
253 }
254 /* Convert BTAC concentrations into TTAC units */
255 if(tacYUnitConvert(&btac, ttac.cunit, &status)!=TPCERROR_OK) {
256 if(verbose>0) fprintf(stderr, "Warning: check and set the data units.\n");
257 }
258
259
260 /*
261 * Prepare the room for results
262 */
263 if(verbose>2) printf("allocate memory for PAR\n");
264 PAR par; parInit(&par);
265 if(parAllocate(&par, 1, ttac.tacNr)!=TPCERROR_OK) {
266 fprintf(stderr, "Error: cannot allocate memory for results.\n");
267 tacFree(&ttac); tacFree(&btac); return(3);
268 }
269 par.tacNr=ttac.tacNr;
270 par.parNr=1;
271 /* Copy TAC names */
272 for(int i=0; i<par.tacNr; i++) strcpy(par.r[i].name, ttac.c[i].name);
273 /* Set the parameter name and unit */
274 strcpy(par.n[0].name, "dT");
275 par.n[0].unit=UNIT_SEC;
276 /* Set titles & file names */
277 {
278 char buf[256];
279 time_t t=time(NULL);
280 tpcProgramName(argv[0], 1, 1, buf, 256);
281 iftPut(&par.h, "program", buf, 0, NULL);
282 iftPut(&par.h, "bloodfile", btacfile, 0, NULL);
283 iftPut(&par.h, "datafile", ttacfile, 0, NULL);
284 iftPut(&par.h, "analysis_time", ctime_r_int(&t, buf), 0, NULL);
285 for(int i=0; i<par.tacNr; i++) {
286 par.r[i].start=0.0;
287 par.r[i].end=endtime;
288 }
289 }
290
291
292 /*
293 * In case of function fits (instead of compartmental models), fit first the delay of BTAC
294 */
295 double btacDelaytime=0.0;
296 if(model>=3) {
297 if(verbose>1) {printf("BTAC delay fitting\n"); fflush(stdout);}
298 int ret=0, fitSampleNr=0;
299 for(fitSampleNr=0; fitSampleNr<btac.sampleNr; fitSampleNr++) if(btac.x[fitSampleNr]>endtime) break;
300 double *x1, *x2;
301 if(btac.isframe) {x1=btac.x1; x2=btac.x2;} else {x1=btac.x; x2=NULL;}
302 //printf("fitSampleNr=%d lastx=%g endtime=%g\n", fitSampleNr, btac.x[fitSampleNr-1], endtime);
303 ret=spectralDMSurge(x1, x2, btac.c[0].y, NULL, fitSampleNr, 1.0E-10, 1.0E+00, 1000,
304 dtrange[0], dtrange[1], dtstep, NULL, NULL, &btacDelaytime, NULL, &status);
305 if(ret!=TPCERROR_OK) {
306 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
307 tacFree(&ttac); tacFree(&btac); parFree(&par);
308 return(4);
309 }
310 if(verbose>3) printf("BTAC delay := %g\n", btacDelaytime);
311 }
312
313
314 /*
315 * Estimate the delay time
316 */
317 if(verbose>1) {printf("delay fitting\n"); fflush(stdout);}
318 if(model<3) { // CM fits
319 if(ttac.tacNr==1) { // just one tissue TAC, no need for temp data or median delay
320 double delaytime=nan("");
321 int ret=tacDelayCMFit(&btac, &ttac, 0, dtrange[0], dtrange[1], endtime, dtstep, &delaytime,
322 mode, model, NULL, &status);
323 if(ret!=TPCERROR_OK) {
324 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
325 tacFree(&ttac); tacFree(&btac); parFree(&par);
326 return(4);
327 }
328 if(verbose>3) printf("delay := %g\n", delaytime);
329 par.r[0].p[0]=delaytime;
330 } else { // more than one tissue TAC
331 DELAYCMFITDATA ddata;
332 initDelayCMFitData(&ddata);
333 int ret=0;
334 for(int ci=0; ci<ttac.tacNr; ci++) {
335 if(verbose>2) {printf("%s\n", ttac.c[ci].name); fflush(stdout);}
336 double delaytime=nan("");
337 if(ci==0)
338 ret=tacDelayCMFit(&btac, &ttac, ci, dtrange[0], dtrange[1], endtime, dtstep, &delaytime,
339 mode, model, &ddata, &status);
340 else
341 ret=tacDelayCMFit(NULL, &ttac, ci, 0.0, 0.0, 0.0, 0.0, &delaytime, mode, model, &ddata, &status);
342 if(ret!=TPCERROR_OK) {
343 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
344 freeDelayCMFitData(&ddata);
345 tacFree(&ttac); tacFree(&btac); parFree(&par);
346 return(4);
347 }
348 if(verbose>3) printf("delay := %g\n", delaytime);
349 par.r[ci].p[0]=delaytime;
350 }
351 freeDelayCMFitData(&ddata);
352 }
353 } else { // Function fits
354 int fitSampleNr=0;
355 for(fitSampleNr=0; fitSampleNr<ttac.sampleNr; fitSampleNr++) if(ttac.x[fitSampleNr]>endtime) break;
356 double *x1, *x2;
357 if(ttac.isframe) {x1=ttac.x1; x2=ttac.x2;} else {x1=ttac.x; x2=NULL;}
358 //printf("fitSampleNr=%d lastx=%g endtime=%g\n", fitSampleNr, ttac.x[fitSampleNr-1], endtime);
359 for(int ci=0; ci<ttac.tacNr; ci++) {
360 if(verbose>2) {printf("%s\n", ttac.c[ci].name); fflush(stdout);}
361 double delaytime=nan("");
362 int ret=spectralDMSurge(x1, x2, ttac.c[ci].y, NULL, fitSampleNr, 1.0E-10, 1.0E+00, 1000,
363 dtrange[0], dtrange[1], dtstep, NULL, NULL, &delaytime, NULL, &status);
364 if(ret!=TPCERROR_OK) {
365 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
366 tacFree(&ttac); tacFree(&btac); parFree(&par);
367 return(4);
368 }
369 if(verbose>3) printf("delay := %g (%g-%g)\n", delaytime-btacDelaytime, delaytime, btacDelaytime);
370 delaytime-=btacDelaytime;
371 par.r[ci].p[0]=delaytime;
372 }
373 }
374
375 /* Set median delay in results */
376 {
377 double delaytime=nan("");
378 double t[par.tacNr];
379 int n=0;
380 for(int i=0; i<par.tacNr; i++) if(isfinite(par.r[i].p[0])) t[n++]=par.r[i].p[0];
381 if(n==0) {
382 fprintf(stderr, "Error: delay estimation failed.\n");
383 tacFree(&ttac); tacFree(&btac); parFree(&par);
384 return(5);
385 } else {
386 delaytime=statMedian(t, n);
387 }
388 iftPutDouble(&par.h, "time_difference", delaytime, 1, NULL);
389 }
390
391
392 /* Print and save the parameters */
393 if(verbose>0) parWrite(&par, stdout, PAR_FORMAT_TSV_UK, 0, NULL);
394 if(parfile[0]) {
395 par.format=parFormatFromExtension(parfile);
396 if(verbose>2) printf("parameter file format := %s\n", parFormattxt(par.format));
398 /* Save file */
399 if(verbose>1) printf(" saving %s\n", parfile);
400 FILE *fp=fopen(parfile, "w");
401 if(fp==NULL) {
402 fprintf(stderr, "Error: cannot open file for writing.\n");
403 tacFree(&ttac); tacFree(&btac); parFree(&par); return(11);
404 }
405 int ret=parWrite(&par, fp, PAR_FORMAT_UNKNOWN, 1, &status);
406 fclose(fp);
407 if(ret!=TPCERROR_OK) {
408 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
409 tacFree(&ttac); tacFree(&btac); parFree(&par); return(12);
410 }
411 if(verbose>1) printf("parameters saved in %s\n", parfile);
412 }
413
414
415 /*
416 * Optionally, delay correction for the TTACs
417 */
418 if(cttacfile[0]) {
419 if(verbose>1) {printf("delay correcting TTACs\n"); fflush(stdout);}
420 int origframe=ttac.isframe; ttac.isframe=0; // simple interpolation
421 for(int i=0; i<ttac.tacNr; i++) {
422 if(tacDelay(&ttac, -par.r[i].p[0], i, &status)!=TPCERROR_OK) {
423 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
424 tacFree(&ttac); tacFree(&btac); parFree(&par); return(21);
425 }
426 }
427 ttac.isframe=origframe;
428 if(verbose>1) {printf("writing delay correcting TTACs\n"); fflush(stdout);}
429 FILE *fp=fopen(cttacfile, "w");
430 if(fp==NULL) {
431 fprintf(stderr, "Error: cannot open file for writing.\n");
432 tacFree(&ttac); tacFree(&btac); parFree(&par); return(22);
433 }
434 int ret=tacWrite(&ttac, fp, TAC_FORMAT_UNKNOWN, 0, &status);
435 fclose(fp);
436 if(ret!=TPCERROR_OK) {
437 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
438 tacFree(&ttac); tacFree(&btac); parFree(&par); return(23);
439 }
440 if(verbose>1) printf("delay corrected TTACs saved in %s\n", cttacfile);
441 }
442
443 tacFree(&ttac); tacFree(&btac); parFree(&par);
444 return(0);
445}
446/*****************************************************************************/
447
448/*****************************************************************************/
int spectralDMSurge(const double *x, const double *x2, const double *y, double *w, const int sNr, const double kMin, const double kMax, const int fNr, const double dtMin, const double dtMax, const double dtStep, double *k, double *a, double *dtEst, double *yfit, TPCSTATUS *status)
Definition bf_dms.c:27
char * ctime_r_int(const time_t *t, char *buf)
Convert calendar time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss,...
Definition datetime.c:119
int atofCheck(const char *s, double *v)
Definition decpoint.c:94
void freeDelayCMFitData(DELAYCMFITDATA *d)
After last use, free memory in the data structure for delay time estimation.
Definition delay.c:150
int tacDelay(TAC *tac, double dt, int ti, TPCSTATUS *status)
Move TAC y values (concentrations) in time, keeping sample times (x values) intact.
Definition delay.c:29
void initDelayCMFitData(DELAYCMFITDATA *d)
Before first use, initiate the data structure for delay time estimation.
Definition delay.c:131
int tacDelayCMFit(TAC *btac, TAC *ttac, int ci, double dtmin, double dtmax, double fitend, double dtstep, double *dt, int mode, int model, DELAYCMFITDATA *tdata, TPCSTATUS *status)
Fit time delay between PET tissue and plasma or blood curve.
Definition delay.c:179
int fileExist(const char *filename)
Definition filexist.c:17
int iftPut(IFT *ift, const char *key, const char *value, char comment, TPCSTATUS *status)
Definition ift.c:63
int iftPutDouble(IFT *ift, const char *key, const double value, char comment, TPCSTATUS *status)
Definition ift.c:128
int atoiCheck(const char *s, int *v)
Definition intutil.c:25
double statMedian(double *a, const int n)
Definition median.c:25
void parFree(PAR *par)
Definition par.c:75
int parAllocate(PAR *par, int parNr, int tacNr)
Definition par.c:108
void parInit(PAR *par)
Definition par.c:25
char * parFormattxt(parformat c)
Definition pario.c:59
int parWrite(PAR *par, FILE *fp, parformat format, int extra, TPCSTATUS *status)
Definition pario.c:148
int parFormatFromExtension(const char *s)
Definition pario.c:102
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:47
void tpcProgramName(const char *program, int version, int copyright, char *prname, int n)
Definition proginfo.c:408
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 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
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition stringext.c:630
Definition tpcpar.h:100
int format
Definition tpcpar.h:102
IFT h
Optional (but often useful) header information.
Definition tpcpar.h:147
int parNr
Definition tpcpar.h:108
int tacNr
Definition tpcpar.h:104
PARR * r
Definition tpcpar.h:114
PARN * n
Definition tpcpar.h:112
int unit
Definition tpcpar.h:86
char name[MAX_PARNAME_LEN+1]
Definition tpcpar.h:82
char name[MAX_TACNAME_LEN+1]
Definition tpcpar.h:50
double * p
Definition tpcpar.h:64
double start
Definition tpcpar.h:52
double end
Definition tpcpar.h:54
char name[MAX_TACNAME_LEN+1]
Definition tpctac.h:81
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:89
int isframe
Definition tpctac.h:95
TACC * c
Definition tpctac.h:117
double * x2
Definition tpctac.h:101
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
void tacInit(TAC *tac)
Definition tac.c:24
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 tacSortByTime(TAC *d, TPCSTATUS *status)
Definition tacorder.c:74
int tacYUnitConvert(TAC *tac, const int u, TPCSTATUS *status)
Definition tacunits.c:72
int tacXUnitConvert(TAC *tac, const int u, TPCSTATUS *status)
Definition tacunits.c:23
int tacSetXContiguous(TAC *d)
Set PET TAC frame times contiguous, without even tiny overlap or gaps in between.
Definition tacx.c:1166
Header file for libtpcbfm.
Header file for library libtpccsv.
Header file for library libtpcextensions.
@ UNIT_SEC
seconds
@ TPCERROR_OK
No error.
Header file for libtpcfileutil.
Header file for library libtpcift.
Header file for library libtpcisotope.
@ PAR_FORMAT_UNKNOWN
Unknown format.
Definition tpcpar.h:28
@ PAR_FORMAT_TSV_UK
UK TSV (point as decimal separator).
Definition tpcpar.h:35
Header file for libtpcstatist.
Header file for library libtpctac.
@ TAC_FORMAT_UNKNOWN
Unknown format.
Definition tpctac.h:28
Header file for libtpctacmod.