TPCCLIB
Loading...
Searching...
No Matches
convttm.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 "tpccm.h"
20#include "tpctacmod.h"
21/*****************************************************************************/
22
23/*****************************************************************************/
24static char *info[] = {
25 "Convolution of PET time-activity curve (TAC) with response function h(t)",
26 "based on one-parameter n-compartmental transit-time (time-delay) model",
27 " h(t) = b^(n-1) / (b+t)^n",
28 "Function integral from 0 to infinity is 1/(n-1), when n>1 and b>0.",
29/*
30 "Definite integral from 0 to T is",
31 " beta^(n-1) * [ beta/((beta^n)*(n-1)) - ((t+beta)^(1-n))/(n-1) ], when n>1",
32 "or",
33 " ln(t+beta) - ln(beta), when n=1",
34 "Definite integral from t1 to t2 is",
35 " beta^(n-1) * [(t1+beta)^(1-n) - (t2+beta)^(1-n)] / (n-1), when n>0, t2>t1, t1+beta>0",
36 "or, specifically",
37 " ln(t2+beta) - ln(t1+beta), when n=1",
38*/
39
40 "Output TAC, Co(t), is calculated from input TAC, Ci(t), as",
41 "Co(T) = Ci(T) (x) h(T)",
42 ", where (x) denotes the operation of convolution.",
43 " ",
44 "Usage: @P [Options] tacfile n b outputfile ",
45 " ",
46 "Options:",
47 " -i=<Interval>",
48 " Sample time interval in convolution; by default the shortest interval",
49 " in the plasma data; too long interval as compared to b's leads to bias.",
50 " -si",
51 " Output is written with sample intervals used in convolution; by default",
52 " data is interpolated back to the sample times of the TAC data.",
53 " -auc=1",
54 " Scale response function to have integral from 0 to infinity to unity;",
55 " that will lead to similar AUC for the input and output TACs.",
56 " In practise, then h(t) = (n-1) * b^(n-1) / (b+t)^n",
57 " -h0=1",
58 " Scale response function to h(0)=1, i.e. use h(t) = b^n / (b+t)^n",
59/*
60 " -Euler",
61 " Use Euler integration and A-M instead of convolution.",
62*/
63 " -stdoptions", // List standard options like --help, -v, etc
64 " ",
65 "The units of b and the optional sample interval must be the same as",
66 "the time units of the TAC.",
67 "For accurate results, input TAC should have very short sample intervals.",
68 "Frame durations are not used, even if available in the TAC file.",
69 " ",
70 "Example:",
71 " @P plasma.tac 2 2.17 simulated.tac",
72 " ",
73 "See also: convexpf, simdisp, fit2dat, simframe, sim_av, tacunit",
74 " ",
75 "Keywords: TAC, simulation, modelling, convolution, transit-time",
76 0};
77/*****************************************************************************/
78
79/*****************************************************************************/
80/* Turn on the globbing of the command line, since it is disabled by default in
81 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
82 In Unix&Linux wildcard command line processing is enabled by default. */
83/*
84#undef _CRT_glob
85#define _CRT_glob -1
86*/
87int _dowildcard = -1;
88/*****************************************************************************/
89
90/*****************************************************************************/
91#if(0)
105int simTTM_i(
107 double *t,
109 double *c0i,
111 const int nr,
113 const double k,
115 const int n,
117 double *cout
118) {
119 /* Check for data */
120 if(nr<2 || n<1) return(1);
121 if(t==NULL || c0i==NULL || cout==NULL) return(2);
122 /* Check the rate constant */
123 if(!(k>=0.0)) return(3);
124
125 double c[n+1], ci[n+1]; // Compartmental concentrations for current sample
126 double c_last[n+1], ci_last[n+1]; // Compartmental concentrations for previous sample
127 for(int j=0; j<=n; j++) c[j]=c_last[j]=ci[j]=ci_last[j]=0.0;
128
129 /* Calculate curves */
130 double t_last=0.0; if(t[0]<t_last) t_last=t[0];
131 for(int i=0; i<nr; i++) { // loop through sample times
132 /* delta time / 2 */
133 double dt2=0.5*(t[i]-t_last); if(!(dt2>=0.0)) return(5);
134 /* k/(1+k*(dt/2)) */
135 double kdt=k/(1.0+dt2*k);
136 /* calculate compartmental concentrations */
137 ci[0]=c0i[i];
138 if(dt2>0.0) {
139 for(int j=1; j<=n; j++) {
140 c[j] = kdt * (ci[j-1] - ci_last[j] - dt2*c_last[j]);
141 ci[j] = ci_last[j] + dt2*(c_last[j]+c[j]);
142 }
143 } else { // sample time same as previously, thus concentration do not change either
144 for(int j=0; j<=n; j++) {
145 c[j]=c_last[j];
146 ci[j]=ci_last[j];
147 }
148 }
149 cout[i]=c[n];
150 /* prepare to the next loop */
151 t_last=t[i];
152 for(int j=0; j<=n; j++) {
153 c_last[j]=c[j];
154 ci_last[j]=ci[j];
155 }
156 }
157
158 return(0);
159}
160#endif
161/*****************************************************************************/
162
163/*****************************************************************************/
167int main(int argc, char **argv)
168{
169 int ai, help=0, version=0, verbose=1;
170 char tacfile[FILENAME_MAX], simfile[FILENAME_MAX];
171 double interval=nan(""), h0=nan(""), auc=nan("");
172 double beta=nan("");
173 unsigned int n=0;
174 int output_sampling=0; // 0=input, 1=convolution
175 int sol=0; // Solution: 0=convolution, 1=Euler
176
177
178 /*
179 * Get arguments
180 */
181 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
182 tacfile[0]=simfile[0]=(char)0;
183 /* Options */
184 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
185 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
186 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
187 if(strncasecmp(cptr, "I=", 2)==0) {
188 interval=atofVerified(cptr+2); if(interval>0.0) continue;
189 } else if(strcasecmp(cptr, "SI")==0) {
190 output_sampling=1; continue;
191 } else if(strcasecmp(cptr, "AUC=1")==0) {
192 auc=1.0; continue;
193 } else if(strncasecmp(cptr, "AUC=", 4)==0) {
194 auc=atofVerified(cptr+4); if(auc>0.0) continue;
195 } else if(strcasecmp(cptr, "h0=1")==0) {
196 h0=1.0; continue;
197 } else if(strncasecmp(cptr, "h0=", 3)==0) {
198 h0=atofVerified(cptr+3); if(h0>0.0) continue;
199 } else if(strncasecmp(cptr, "EULER", 3)==0) {
200 sol=1; continue;
201 }
202 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
203 return(1);
204 } else break; // tac name argument may start with '-'
205
206 TPCSTATUS status; statusInit(&status);
207 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
208 status.verbose=verbose-1;
209
210 /* Print help or version? */
211 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
212 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
213 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
214
215 /* Process other arguments, starting from the first non-option */
216 if(ai<argc) {strlcpy(tacfile, argv[ai++], FILENAME_MAX);}
217 if(ai<argc) {
218 int i;
219 if(atoiCheck(argv[ai], &i) || i<1) {
220 fprintf(stderr, "Error: invalid a1 '%s'.\n", argv[ai]); return(1);}
221 n=i; ai++;
222 }
223 if(ai<argc) {
224 beta=atofVerified(argv[ai]);
225 if(!(beta>0.0)) {fprintf(stderr, "Error: invalid beta '%s'.\n", argv[ai]); return(1);}
226 ai++;
227 }
228 if(ai<argc) {strlcpy(simfile, argv[ai++], FILENAME_MAX);}
229 if(ai<argc) {
230 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
231 return(1);
232 }
233
234 /* Is something missing? */
235 if(!simfile[0]) {
236 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
237 return(1);
238 }
239
240
241 /* In verbose mode print arguments and options */
242 if(verbose>1) {
243 printf("tacfile := %s\n", tacfile);
244 printf("simfile := %s\n", simfile);
245 printf("n := %u\n", n);
246 printf("beta := %g\n", beta);
247 if(!isnan(auc)) printf("auc := %g\n", auc);
248 if(!isnan(h0)) printf("h0 := %g\n", h0);
249 if(!isnan(interval)) printf("interval := %g\n", interval);
250 printf("output_sampling := %d\n", output_sampling);
251 if(sol>0) printf("solution := %d\n", sol);
252 fflush(stdout);
253 }
254
255
256 /*
257 * Read plasma TAC
258 */
259 if(verbose>1) fprintf(stdout, "reading %s\n", tacfile);
260 TAC tac; tacInit(&tac);
261 if(tacRead(&tac, tacfile, &status)!=TPCERROR_OK) {
262 fprintf(stderr, "Error: %s (%s)\n", errorMsg(status.error), tacfile);
263 tacFree(&tac); return(2);
264 }
265 if(verbose>2) {
266 printf("fileformat := %s\n", tacFormattxt(tac.format));
267 printf("tacNr := %d\n", tac.tacNr);
268 printf("sampleNr := %d\n", tac.sampleNr);
269 printf("xunit := %s\n", unitName(tac.tunit));
270 printf("yunit := %s\n", unitName(tac.cunit));
271 if(tacIsWeighted(&tac)) printf("weighting := yes\n");
272 }
273 /* Check for missing sample times */
274 if(tacXNaNs(&tac)>0) {
275 fprintf(stderr, "Error: missing frame times.\n");
276 tacFree(&tac); return(2);
277 }
278 /* Check for missing concentrations */
279 if(tacYNaNs(&tac, -1)>0) {
280 fprintf(stderr, "Error: missing concentrations.\n");
281 tacFree(&tac); return(2);
282 }
283 if(tac.sampleNr<3) {
284 fprintf(stderr, "Error: too few samples in plasma data.\n");
285 tacFree(&tac); return(2);
286 }
287 if(tac.tacNr>1) {
288 fprintf(stderr, "Warning: only first TAC in %s is used.\n", tacfile);
289 tac.tacNr=1;
290 }
291 if(tacSortByTime(&tac, &status)!=TPCERROR_OK) {
292 fprintf(stderr, "Error: invalid sample times.\n");
293 tacFree(&tac); return(2);
294 }
295 if(tac.isframe!=0 && verbose>0) {
296 if(tacSetX(&tac, &status)!=TPCERROR_OK) { // make sure that frame middle times are set
297 fprintf(stderr, "Error: invalid sample times.\n");
298 tacFree(&tac); return(2);
299 }
300 fprintf(stderr, "Warning: frame durations are ignored.\n");
301 }
302
303
304 /*
305 * If required, use Euler integration based solution instead of convolution
306 */
307 if(sol==1) {
308 int ret=0;
309 double ci[tac.sampleNr], cout[tac.sampleNr];
310 /* Integrate the input function */
311 if(tac.isframe==0) ret=liIntegrate(tac.x, tac.c[0].y, tac.sampleNr, ci, 3, verbose-10);
312 else ret=liIntegratePET(tac.x1, tac.x2, tac.c[0].y, tac.sampleNr, ci, NULL, verbose-10);
313 if(ret!=0) {
314 fprintf(stderr, "Error: cannot integrate input data.\n");
315 tacFree(&tac); return(3);
316 }
317 /* Simulate */
318 ret=simTTM_i(tac.x, ci, tac.sampleNr, 1.0/beta, n, cout);
319 if(ret!=0) {
320 fprintf(stderr, "Error: invalid data for simulation.\n");
321 tacFree(&tac); return(4);
322 }
323 /* Write the simulated data */
324 for(int i=0; i<tac.sampleNr; i++) tac.c[0].y[i]=cout[i];
325 if(verbose>1) printf("writing simulated data in %s\n", simfile);
326 FILE *fp; fp=fopen(simfile, "w");
327 if(fp==NULL) {
328 fprintf(stderr, "Error: cannot open file for writing (%s)\n", simfile);
329 tacFree(&tac); return(11);
330 }
331 ret=tacWrite(&tac, fp, TAC_FORMAT_UNKNOWN, 1, &status);
332 fclose(fp); tacFree(&tac);
333 if(ret!=TPCERROR_OK) {
334 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
335 return(12);
336 }
337 if(verbose>=0) printf("Simulated TAC saved in %s\n", simfile);
338 return(0);
339 }
340
341
342
343 /*
344 * Interpolate data with even sample intervals for convolution
345 */
346
347 /* Check user-defined interval time */
348 if(!isnan(interval) && interval>0.0) {
349 if(interval>0.01*tac.x[tac.sampleNr-1] || interval>0.2*beta) {
350 fprintf(stderr, "Error: too long interval time.\n");
351 printf("time_range: %g - %g\n", tac.x[0], tac.x[tac.sampleNr-1]);
352 printf("beta := %g\n", beta);
353 printf("interval := %g\n", interval);
354 fflush(stderr); fflush(stdout);
355 tacFree(&tac); return(2);
356 }
357 if(interval>0.001*tac.x[tac.sampleNr-1] || interval>0.05*beta) {
358 if(verbose>0) {
359 fprintf(stderr, "Warning: interval time may be too long.\n");
360 printf("time_range: %g - %g\n", tac.x[0], tac.x[tac.sampleNr-1]);
361 printf("beta := %g\n", beta);
362 printf("interval := %g\n", interval);
363 fflush(stderr); fflush(stdout);
364 }
365 }
366 }
367
368 TAC itac; tacInit(&itac);
369 {
370 int ret=0;
371 if(!isnan(interval)) {
372 /* user-defined interpolation sample frequency */
373 ret=tacInterpolateToEqualLengthFrames(&tac, interval, interval, &itac, &status);
374 } else {
375 /* automatic interpolation sample frequency */
376 ret=tacInterpolateToEqualLengthFrames(&tac, 0.0001*beta, 0.02*beta, &itac, &status);
377 }
378 if(ret!=TPCERROR_OK) {
379 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
380 fprintf(stderr, "Error: cannot interpolate data to even sample times.\n");
381 tacFree(&tac); tacFree(&itac); return(3);
382 }
383 }
384 /* Get the sample interval in interpolated data */
385 double freq=itac.x2[0]-itac.x1[0];
386 if(verbose>1) {
387 printf("sample_intervals_in_convolution := %g\n", freq);
388 printf("interpolated data range: %g - %g\n", itac.x1[0], itac.x2[itac.sampleNr-1]);
389 }
390
391
392 if(verbose>0) {fprintf(stdout, "allocate memory for kernel...\n"); fflush(stdout);}
393 double *kernel=(double*)malloc(2*itac.sampleNr*sizeof(double));
394 if(kernel==NULL) {
395 fprintf(stderr, "Error: out of memory.\n");
396 tacFree(&tac); tacFree(&itac); return(5);
397 }
398 double *cy=kernel+itac.sampleNr;
399
400
401 /*
402 * Calculate the response function for convolution
403 */
404 if(verbose>0) {fprintf(stdout, "computing the kernel...\n"); fflush(stdout);}
405 double ksum=0.0;
406 if(verbose>6) printf("\nData\tKernel:\n");
407 if(n==1) {
408 for(int i=0; i<itac.sampleNr; i++) {
409 kernel[i] = log(beta+itac.x2[i]) - log(beta+itac.x1[i]);
410 ksum+=kernel[i]; // sum of stepwise integrals
411 }
412 } else if(n==2) {
413 for(int i=0; i<itac.sampleNr; i++) {
414 kernel[i]=beta*freq/((beta+itac.x1[i])*(beta+itac.x2[i])); // integral, not mean
415 ksum+=kernel[i]; // sum of stepwise integrals
416 }
417 } else {
418 for(int i=0; i<itac.sampleNr; i++) {
419 double x1, x2; x1=beta+itac.x1[i]; x2=beta+itac.x2[i];
420 double y=-(double)(n-1); // required because n is unsigned integer
421 kernel[i] = pow(beta, (double)(n-1)) * (pow(x1, y) - pow(x2, y)) / (double)(n-1);
422 ksum+=kernel[i]; // sum of stepwise integrals
423
424 if(!isfinite(kernel[i])) {
425 printf("kernel[%d]=%g\n", i, kernel[i]);
426 printf("pow(%g, %d)=%g\n", beta, n-1, pow(beta, n-1));
427 printf("pow(10.0, -2.0)=%e\n", pow(10.0, -2.0));
428 double x,y;
429 x=beta+itac.x1[i]; y=-(double)(n-1);
430 printf("pow(%g, %g)=%g\n", x, y, pow(x, y));
431 x=beta+itac.x2[i]; y=-(double)(n-1);
432 printf("pow(%g, %g)=%g\n", x, y, pow(x, y));
433 break;
434 }
435
436 }
437 }
438 if(verbose>2) {printf("Sum of unscaled response function := %g\n", ksum); fflush(stdout);}
439 if(!isnormal(ksum)) {
440 fprintf(stderr, "Error: invalid kernel contents.\n");
441 tacFree(&tac); tacFree(&itac); free(kernel); return(6);
442 }
443 if(verbose>6) {
444 for(int i=0; i<itac.sampleNr; i++) printf("%g\t%g\n", itac.c[0].y[i], kernel[i]);
445 fflush(stdout);
446 }
447 /* If requested, scale the response function */
448 double sc=1.0;
449 if(auc>0.0) {
450 double hauc=1.0/(double)(n-1);
451 sc=auc/hauc;
452 } else if(h0>0.0) { // if both scalings are set then use only AUC because h(0) scaling would
453 // cancel out.
454 // h[0]=1/beta
455 sc*=h0*beta;
456 }
457 if(sc>0.0 && sc!=1.0) {
458 ksum=0.0;
459 if(verbose>7) printf("\nData\tKernel:\n");
460 for(int i=0; i<itac.sampleNr; i++) {
461 kernel[i]*=sc;
462 ksum+=kernel[i];
463 if(verbose>7) printf("%g\t%g\n", itac.c[0].y[i], kernel[i]);
464 }
465 if(verbose>2) printf("Sum of scaled response function := %g\n", ksum);
466 }
467
468
469 /*
470 * Convolution
471 */
472 if(verbose>1) fprintf(stdout, "convolution...\n");
473 if(convolve1D(itac.c[0].y, itac.sampleNr, kernel, itac.sampleNr, cy)!=0) {
474 fprintf(stderr, "Error: cannot convolve the data.\n");
475 tacFree(&tac); tacFree(&itac); free(kernel); return(7);
476 }
477 if(verbose>4) {
478 printf("\nData x\ty\tKernel\tConvolved\n");
479 for(int i=0; i<itac.sampleNr; i++)
480 printf("%g\t%g\t%g\t%g\n", itac.x[i], itac.c[0].y[i], kernel[i], cy[i]);
481 }
482
483 /* Copy convoluted curve over interpolated curve */
484 for(int i=0; i<itac.sampleNr; i++) itac.c[0].y[i]=cy[i];
485 /* No need for kernel or working space */
486 free(kernel);
487
488
489 /*
490 * If user wants to save data with sample intervals used in convolution, then do that and exit
491 */
492 if(output_sampling==1) {
493
494 /* No need for input data */
495 tacFree(&tac);
496
497 /* Change TAC name */
498 strcpy(itac.c[0].name, "MMT");
499
500 /* Save only mid sample time */
501 itac.isframe=0;
502
503 if(verbose>1) printf("writing convolved data in %s\n", simfile);
504 FILE *fp; fp=fopen(simfile, "w");
505 if(fp==NULL) {
506 fprintf(stderr, "Error: cannot open file for writing (%s)\n", simfile);
507 tacFree(&itac); return(11);
508 }
509 int ret=tacWrite(&itac, fp, TAC_FORMAT_UNKNOWN, 1, &status);
510 fclose(fp); tacFree(&itac);
511 if(ret!=TPCERROR_OK) {
512 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
513 return(12);
514 }
515 if(verbose>=0) printf("Convolved TAC saved in %s\n", simfile);
516 return(0);
517 }
518
519
520
521
522
523 /*
524 * Interpolate convolved data into original sample times
525 */
526 {
527 if(verbose>1) fprintf(stdout, "interpolating to original sample times...\n");
528 int ret=0;
529 if(tac.isframe==0)
530 ret=liInterpolate(itac.x, itac.c[0].y, itac.sampleNr, tac.x, tac.c[0].y, NULL, NULL,
531 tac.sampleNr, 4, 1, verbose-10);
532 else
533 ret=liInterpolateForPET(itac.x, itac.c[0].y, itac.sampleNr, tac.x1, tac.x2, tac.c[0].y,
534 NULL, NULL, tac.sampleNr, 4, 1, verbose-10);
535 tacFree(&itac);
536 if(ret!=0) {
537 fprintf(stderr, "Error: cannot interpolate back.\n");
538 tacFree(&tac); return(9);
539 }
540 }
541#if(0)
542 /* Interpolate to original times */
543 if(atac.isframe==0)
544 ret=liInterpolate(dtac.x, dtac.c[0].y, dtac.sampleNr, atac.x, atac.c[0].y, NULL, NULL,
545 atac.sampleNr, 0, 0, verbose-10);
546 else
547 ret=liInterpolateForPET(dtac.x, dtac.c[0].y, dtac.sampleNr, atac.x1, atac.x2, atac.c[0].y,
548 NULL, NULL, atac.sampleNr, 0, 1, verbose-10);
549#endif
550
551 /*
552 * Write the file
553 */
554 {
555 if(verbose>1) printf("writing convolved data in %s\n", simfile);
556 FILE *fp; fp=fopen(simfile, "w");
557 if(fp==NULL) {
558 fprintf(stderr, "Error: cannot open file for writing (%s)\n", simfile);
559 tacFree(&tac); return(11);
560 }
561 int ret=tacWrite(&tac, fp, TAC_FORMAT_UNKNOWN, 1, &status);
562 fclose(fp); tacFree(&tac);
563 if(ret!=TPCERROR_OK) {
564 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
565 return(12);
566 }
567 if(verbose>=0) printf("Convolved TAC saved in %s\n", simfile);
568 }
569
570 return(0);
571}
572/*****************************************************************************/
574/*****************************************************************************/
int convolve1D(double *data, const int n, double *kernel, const int m, double *out)
Calculates the convolution sum of a discrete real data set data[0..n-1] and a discretized response fu...
Definition convolut.c:27
double atofVerified(const char *s)
Definition decpoint.c:75
int liIntegrate(double *x, double *y, const int nr, double *yi, const int se, const int verbose)
Linear integration of TAC with trapezoidal method.
Definition integrate.c:33
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.
Definition integrate.c:120
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 atoiCheck(const char *s, int *v)
Definition intutil.c:25
int tacInterpolateToEqualLengthFrames(TAC *inp, double minfdur, double maxfdur, TAC *tac, TPCSTATUS *status)
Definition lisim.c:214
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
int simTTM_i(double *t, double *c0i, const int n, const double k, const int cn, double *cout)
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
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
unit tunit
Definition tpctac.h:109
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 tacYNaNs(TAC *tac, const int i)
Definition tacnan.c:47
int tacXNaNs(TAC *tac)
Definition tacnan.c:23
int tacSortByTime(TAC *d, TPCSTATUS *status)
Definition tacorder.c:74
int tacIsWeighted(TAC *tac)
Definition tacw.c:24
int tacSetX(TAC *d, TPCSTATUS *status)
Set TAC x values based on x1 and x2 values, or guess x1 and x2 values based on x values.
Definition tacx.c:653
Header file for libtpccm.
Header file for library libtpcextensions.
@ 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 library libtpctac.
@ TAC_FORMAT_UNKNOWN
Unknown format.
Definition tpctac.h:28
Header file for libtpctacmod.