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), 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. Meyer. Simultaneous correction for tracer arrival delay and dispersion",
65 " in CBF measurements by the H215O autoradiographic method and dynamic PET.",
66 " J Nucl Med 1989; 30:1069-1078.",
67 " 2. van den Hoff et al. Accurate local blood flow measurements with",
68 " dynamic PET: fast determination of input function delay and dispersion",
69 " by multilinear minimization. J Nucl Med 1993; 34:1770-1777.",
70 " ",
71 "See also: fitdelay, imgdelay, tacmove, tactime, simdisp, tacframe",
72 " ",
73 "Keywords: TAC, modelling, time delay",
74 0};
75/*****************************************************************************/
76
77/*****************************************************************************/
78/* Turn on the globbing of the command line, since it is disabled by default in
79 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
80 In Unix&Linux wildcard command line processing is enabled by default. */
81/*
82#undef _CRT_glob
83#define _CRT_glob -1
84*/
85int _dowildcard = -1;
86/*****************************************************************************/
87
88/*****************************************************************************/
92int main(int argc, char **argv)
93{
94 int ai, help=0, version=0, verbose=1;
95 char ttacfile[FILENAME_MAX], btacfile[FILENAME_MAX],
96 parfile[FILENAME_MAX], cttacfile[FILENAME_MAX];
97 double endtime=300.0; // fit end time in seconds
98 double endtimemin=90.0; // shortest fit end time allowed
99 double dtrange[2]={-10,+50}; // dT range
100 double dtstep=1.0; // dT step size
101 int mode=0; // Delay estimation mode
102 int model=0; // 0=R1TCM, 1=I2TCM, 2=R2TCM, 3=DMS
103
104
105 /*
106 * Get arguments
107 */
108 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
109 ttacfile[0]=btacfile[0]=parfile[0]=cttacfile[0]=(char)0;
110 /* Options */
111 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
112 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
113 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
114 if(strncasecmp(cptr, "END=", 4)==0) {
115 int ret=atofCheck(cptr+4, &endtime); if(!ret && endtime>=endtimemin) continue;
116 } else if(strncasecmp(cptr, "MIN=", 4)==0) {
117 if(atofCheck(cptr+4, &dtrange[0])==0) continue;
118 } else if(strncasecmp(cptr, "MAX=", 4)==0) {
119 if(atofCheck(cptr+4, &dtrange[1])==0) continue;
120 } else if(strncasecmp(cptr, "STEP=", 5)==0) {
121 int ret=atofCheck(cptr+5, &dtstep); if(!ret && dtstep>0.0) continue;
122 } else if(strncasecmp(cptr, "MODE=", 5)==0) {
123 if(atoiCheck(cptr+5, &mode)==0) continue;
124 } else if(strncasecmp(cptr, "MODEL=", 6)==0) {
125 if(strcasecmp(cptr+6, "R1TCM")==0) {model=0; continue;}
126 if(strcasecmp(cptr+6, "I2TCM")==0) {model=1; continue;}
127 if(strcasecmp(cptr+6, "R2TCM")==0) {model=2; continue;}
128 if(strcasecmp(cptr+6, "DMS")==0) {model=3; continue;}
129 }
130 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
131 return(1);
132 } else break; // tac name argument may start with '-'
133
134 TPCSTATUS status; statusInit(&status);
135 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
136 status.verbose=verbose-3;
137
138 /* Print help or version? */
139 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
140 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
141 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
142
143 /* The first argument (non-option) is the file name */
144 if(ai<argc) {strlcpy(btacfile, argv[ai], FILENAME_MAX); ai++;}
145 if(ai<argc) {strlcpy(ttacfile, argv[ai], FILENAME_MAX); ai++;}
146 if(ai<argc) {strlcpy(parfile, argv[ai], FILENAME_MAX); ai++;}
147 if(ai<argc) {strlcpy(cttacfile, argv[ai], FILENAME_MAX); ai++;}
148 /* check that there are no extra arguments */
149 if(ai<argc) {fprintf(stderr, "Error: extra command-line argument.\n"); return(1);}
150 /* Is something missing? */
151 if(!parfile[0]) {tpcPrintUsage(argv[0], info, stdout); return(1);}
152
153 /* In verbose mode print arguments and options */
154 if(verbose>1) {
155 printf("ttacfile := %s\n", ttacfile);
156 printf("btacfile := %s\n", btacfile);
157 printf("parfile := %s\n", parfile);
158 printf("cttacfile := %s\n", cttacfile);
159 printf("endtime := %g\n", endtime);
160 printf("dtrange := %g - %g s\n", dtrange[0], dtrange[1]);
161 printf("step := %g\n", dtstep);
162 printf("mode := %d\n", mode);
163 printf("model := %d\n", model);
164 fflush(stdout);
165 }
166
167 /* Check that TAC files do exist */
168 if(!fileExist(ttacfile)) {
169 fprintf(stderr, "Error: file '%s' does not exist.\n", ttacfile);
170 return(1);
171 }
172 if(!fileExist(btacfile)) {
173 fprintf(stderr, "Error: file '%s' does not exist.\n", btacfile);
174 return(1);
175 }
176
177 /* Check options */
178 if(dtrange[0]>dtrange[1]) {double f=dtrange[0]; dtrange[0]=dtrange[1]; dtrange[1]=f;}
179 int moveNr=1+(dtrange[1]-dtrange[0])/dtstep;
180 if(verbose>1) {
181 printf("step_number := %d\n", moveNr);
182 fflush(stdout);
183 }
184 if(moveNr<5 || moveNr>2000) {
185 fprintf(stderr, "Error: invalid dT range or step size.\n");
186 return(1);
187 }
188 if((moveNr<10 || moveNr>500) && verbose>0)
189 fprintf(stderr, "Warning: non-optimal dT range or step size.\n");
190
191
192
193 /*
194 * Read the data
195 */
196 if(verbose>1) printf("reading TACs\n");
197 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
198 TAC ttac, btac; tacInit(&ttac); tacInit(&btac);
199
200 if(tacRead(&ttac, ttacfile, &status)!=TPCERROR_OK) {
201 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
202 tacFree(&ttac); tacFree(&btac); return(2);
203 }
204 if(verbose>2) {
205 printf("ttac.fileformat := %s\n", tacFormattxt(ttac.format));
206 printf("ttacNr := %d\n", ttac.tacNr);
207 printf("ttac.sampleNr := %d\n", ttac.sampleNr);
208 fflush(stdout);
209 }
210
211 if(tacRead(&btac, btacfile, &status)!=TPCERROR_OK) {
212 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
213 tacFree(&ttac); tacFree(&btac); return(2);
214 }
215 if(verbose>2) {
216 printf("btac.fileformat := %s\n", tacFormattxt(btac.format));
217 printf("btacNr := %d\n", btac.tacNr);
218 printf("btac.sampleNr := %d\n", btac.sampleNr);
219 fflush(stdout);
220 }
221 if(btac.tacNr>1) {
222 if(verbose>0) fprintf(stderr, "Warning: BTAC file contains more than one TAC.\n");
223 btac.tacNr=1;
224 }
225
226 if(ttac.sampleNr<7 || btac.sampleNr<7) {
227 fprintf(stderr, "Error: too few samples.\n");
228 tacFree(&ttac); tacFree(&btac); return(2);
229 }
230 /* Check NaNs */
231 if(tacNaNs(&ttac)>0 || tacNaNs(&btac)>0) {
232 fprintf(stderr, "Error: data contains missing values.\n");
233 tacFree(&ttac); tacFree(&btac); return(2);
234 }
235 /* Sort data by sample time */
236 tacSortByTime(&ttac, &status);
237 tacSortByTime(&btac, &status);
238 /* Fix any gaps and overlap in data if possible and if not then quit with error */
240 fprintf(stderr, "Error: invalid curve data.\n");
241 tacFree(&ttac); tacFree(&btac); return(2);
242 }
243
244 /* Convert sample times into seconds */
245 if(tacXUnitConvert(&ttac, UNIT_SEC, &status)!=TPCERROR_OK ||
246 tacXUnitConvert(&btac, UNIT_SEC, &status)!=TPCERROR_OK)
247 {
248 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
249 tacFree(&ttac); tacFree(&ttac); return(2);
250 }
251 /* Convert BTAC concentrations into TTAC units */
252 if(tacYUnitConvert(&btac, ttac.cunit, &status)!=TPCERROR_OK) {
253 if(verbose>0) fprintf(stderr, "Warning: check and set the data units.\n");
254 }
255
256
257 /*
258 * Prepare the room for results
259 */
260 if(verbose>2) printf("allocate memory for PAR\n");
261 PAR par; parInit(&par);
262 if(parAllocate(&par, 1, ttac.tacNr)!=TPCERROR_OK) {
263 fprintf(stderr, "Error: cannot allocate memory for results.\n");
264 tacFree(&ttac); tacFree(&btac); return(3);
265 }
266 par.tacNr=ttac.tacNr;
267 par.parNr=1;
268 /* Copy TAC names */
269 for(int i=0; i<par.tacNr; i++) strcpy(par.r[i].name, ttac.c[i].name);
270 /* Set the parameter name and unit */
271 strcpy(par.n[0].name, "dT");
272 par.n[0].unit=UNIT_SEC;
273 /* Set titles & file names */
274 {
275 char buf[256];
276 time_t t=time(NULL);
277 tpcProgramName(argv[0], 1, 1, buf, 256);
278 iftPut(&par.h, "program", buf, 0, NULL);
279 iftPut(&par.h, "bloodfile", btacfile, 0, NULL);
280 iftPut(&par.h, "datafile", ttacfile, 0, NULL);
281 iftPut(&par.h, "analysis_time", ctime_r_int(&t, buf), 0, NULL);
282 for(int i=0; i<par.tacNr; i++) {
283 par.r[i].start=0.0;
284 par.r[i].end=endtime;
285 }
286 }
287
288
289 /*
290 * In case of function fits (instead of compartmental models), fit first the delay of BTAC
291 */
292 double btacDelaytime=0.0;
293 if(model>=3) {
294 if(verbose>1) {printf("BTAC delay fitting\n"); fflush(stdout);}
295 int ret=0, fitSampleNr=0;
296 for(fitSampleNr=0; fitSampleNr<btac.sampleNr; fitSampleNr++) if(btac.x[fitSampleNr]>endtime) break;
297 double *x1, *x2;
298 if(btac.isframe) {x1=btac.x1; x2=btac.x2;} else {x1=btac.x; x2=NULL;}
299 //printf("fitSampleNr=%d lastx=%g endtime=%g\n", fitSampleNr, btac.x[fitSampleNr-1], endtime);
300 ret=spectralDMSurge(x1, x2, btac.c[0].y, NULL, fitSampleNr, 1.0E-10, 1.0E+00, 1000,
301 dtrange[0], dtrange[1], dtstep, NULL, NULL, &btacDelaytime, NULL, &status);
302 if(ret!=TPCERROR_OK) {
303 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
304 tacFree(&ttac); tacFree(&btac); parFree(&par);
305 return(4);
306 }
307 if(verbose>3) printf("BTAC delay := %g\n", btacDelaytime);
308 }
309
310
311 /*
312 * Estimate the delay time
313 */
314 if(verbose>1) {printf("delay fitting\n"); fflush(stdout);}
315 if(model<3) { // CM fits
316 if(ttac.tacNr==1) { // just one tissue TAC, no need for temp data or median delay
317 double delaytime=nan("");
318 int ret=tacDelayFit(&btac, &ttac, 0, dtrange[0], dtrange[1], endtime, dtstep, &delaytime,
319 mode, model, NULL, &status);
320 if(ret!=TPCERROR_OK) {
321 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
322 tacFree(&ttac); tacFree(&btac); parFree(&par);
323 return(4);
324 }
325 if(verbose>3) printf("delay := %g\n", delaytime);
326 par.r[0].p[0]=delaytime;
327 } else { // more than one tissue TAC
328 DELAYFITDATA ddata;
329 initDelayFitData(&ddata);
330 int ret=0;
331 for(int ci=0; ci<ttac.tacNr; ci++) {
332 if(verbose>2) {printf("%s\n", ttac.c[ci].name); fflush(stdout);}
333 double delaytime=nan("");
334 if(ci==0)
335 ret=tacDelayFit(&btac, &ttac, ci, dtrange[0], dtrange[1], endtime, dtstep, &delaytime,
336 mode, model, &ddata, &status);
337 else
338 ret=tacDelayFit(NULL, &ttac, ci, 0.0, 0.0, 0.0, 0.0, &delaytime, mode, model, &ddata, &status);
339 if(ret!=TPCERROR_OK) {
340 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
341 freeDelayFitData(&ddata);
342 tacFree(&ttac); tacFree(&btac); parFree(&par);
343 return(4);
344 }
345 if(verbose>3) printf("delay := %g\n", delaytime);
346 par.r[ci].p[0]=delaytime;
347 }
348 freeDelayFitData(&ddata);
349 }
350 } else { // Function fits
351 int fitSampleNr=0;
352 for(fitSampleNr=0; fitSampleNr<ttac.sampleNr; fitSampleNr++) if(ttac.x[fitSampleNr]>endtime) break;
353 double *x1, *x2;
354 if(ttac.isframe) {x1=ttac.x1; x2=ttac.x2;} else {x1=ttac.x; x2=NULL;}
355 //printf("fitSampleNr=%d lastx=%g endtime=%g\n", fitSampleNr, ttac.x[fitSampleNr-1], endtime);
356 for(int ci=0; ci<ttac.tacNr; ci++) {
357 if(verbose>2) {printf("%s\n", ttac.c[ci].name); fflush(stdout);}
358 double delaytime=nan("");
359 int ret=spectralDMSurge(x1, x2, ttac.c[ci].y, NULL, fitSampleNr, 1.0E-10, 1.0E+00, 1000,
360 dtrange[0], dtrange[1], dtstep, NULL, NULL, &delaytime, NULL, &status);
361 if(ret!=TPCERROR_OK) {
362 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
363 tacFree(&ttac); tacFree(&btac); parFree(&par);
364 return(4);
365 }
366 if(verbose>3) printf("delay := %g (%g-%g)\n", delaytime-btacDelaytime, delaytime, btacDelaytime);
367 delaytime-=btacDelaytime;
368 par.r[ci].p[0]=delaytime;
369 }
370 }
371
372 /* Set median delay in results */
373 {
374 double delaytime=nan("");
375 double t[par.tacNr];
376 int n=0;
377 for(int i=0; i<par.tacNr; i++) if(isfinite(par.r[i].p[0])) t[n++]=par.r[i].p[0];
378 if(n==0) {
379 fprintf(stderr, "Error: delay estimation failed.\n");
380 tacFree(&ttac); tacFree(&btac); parFree(&par);
381 return(5);
382 } else {
383 delaytime=statMedian(t, n);
384 }
385 iftPutDouble(&par.h, "time_difference", delaytime, 1, NULL);
386 }
387
388
389 /* Print and save the parameters */
390 if(verbose>0) parWrite(&par, stdout, PAR_FORMAT_TSV_UK, 0, NULL);
391 if(parfile[0]) {
392 par.format=parFormatFromExtension(parfile);
393 if(verbose>2) printf("parameter file format := %s\n", parFormattxt(par.format));
395 /* Save file */
396 if(verbose>1) printf(" saving %s\n", parfile);
397 FILE *fp=fopen(parfile, "w");
398 if(fp==NULL) {
399 fprintf(stderr, "Error: cannot open file for writing.\n");
400 tacFree(&ttac); tacFree(&btac); parFree(&par); return(11);
401 }
402 int ret=parWrite(&par, fp, PAR_FORMAT_UNKNOWN, 1, &status);
403 fclose(fp);
404 if(ret!=TPCERROR_OK) {
405 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
406 tacFree(&ttac); tacFree(&btac); parFree(&par); return(12);
407 }
408 if(verbose>1) printf("parameters saved in %s\n", parfile);
409 }
410
411
412 /*
413 * Optionally, delay correction for the TTACs
414 */
415 if(cttacfile[0]) {
416 if(verbose>1) {printf("delay correcting TTACs\n"); fflush(stdout);}
417 int origframe=ttac.isframe; ttac.isframe=0; // simple interpolation
418 for(int i=0; i<ttac.tacNr; i++) {
419 if(tacDelay(&ttac, -par.r[i].p[0], i, &status)!=TPCERROR_OK) {
420 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
421 tacFree(&ttac); tacFree(&btac); parFree(&par); return(21);
422 }
423 }
424 ttac.isframe=origframe;
425 if(verbose>1) {printf("writing delay correcting TTACs\n"); fflush(stdout);}
426 FILE *fp=fopen(cttacfile, "w");
427 if(fp==NULL) {
428 fprintf(stderr, "Error: cannot open file for writing.\n");
429 tacFree(&ttac); tacFree(&btac); parFree(&par); return(22);
430 }
431 int ret=tacWrite(&ttac, fp, TAC_FORMAT_UNKNOWN, 0, &status);
432 fclose(fp);
433 if(ret!=TPCERROR_OK) {
434 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
435 tacFree(&ttac); tacFree(&btac); parFree(&par); return(23);
436 }
437 if(verbose>1) printf("delay corrected TTACs saved in %s\n", cttacfile);
438 }
439
440 tacFree(&ttac); tacFree(&btac); parFree(&par);
441 return(0);
442}
443/*****************************************************************************/
444
445/*****************************************************************************/
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
int tacDelayFit(TAC *btac, TAC *ttac, int ci, double dtmin, double dtmax, double fitend, double dtstep, double *dt, int mode, int model, DELAYFITDATA *tdata, TPCSTATUS *status)
Fit time delay between PET tissue and plasma or blood curve.
Definition delay.c:179
void initDelayFitData(DELAYFITDATA *d)
Before first use, initiate the data structure for delay time estimation.
Definition delay.c:131
void freeDelayFitData(DELAYFITDATA *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
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:406
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:632
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.