TPCCLIB
Loading...
Searching...
No Matches
fit_exp.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 <math.h>
13#include <string.h>
14#include <time.h>
15/*****************************************************************************/
16#include "libtpcmisc.h"
17#include "libtpcmodel.h"
18#include "libtpccurveio.h"
19#include "libtpcsvg.h"
20#include "libtpcmodext.h"
21/*****************************************************************************/
22
23/*****************************************************************************/
24/* Local functions */
25double func_exp(int parNr, double *p, void*);
26/*****************************************************************************/
27double *x, *ymeas, *yfit, *w;
28int dataNr=0, parNr=0;
29double pmin[MAX_PARAMETERS], pmax[MAX_PARAMETERS];
30int start_index, end_index;
31/*****************************************************************************/
32
33/*****************************************************************************/
34static char *info[] = {
35 "Non-linear fitting of the sum of 1-3 exponential functions to PET plasma and",
36 "tissue time-activity curves (TACs).",
37 " ",
38 "Function:",
39 " ",
40 " f(x) = p1*exp(p2*x) + p3*exp(p4*x) + p5*exp(p6*x)",
41 " ",
42 "Usage: @P [Options] tacfile fitfile",
43 " ",
44 "Options:",
45 " -3[e] | -2[e] | -1[e]",
46 " Fit to sum of three (default), two, or single exponential function.",
47 " -nonneg",
48 " p1, p3 and p5 are constrained to values >= 0.",
49 " -expneg",
50 " p2, p4 and p6 are constrained to values <= 0.",
51 " -starttime=<<Time (min)>|Peak>",
52 " Set the sample time from where fitting is started (0 by default),",
53 " or 'peak' to start fitting from common peak time.",
54 " -endtime=<Time (min)>",
55 " Set the sample time where fitting is stopped (last sample by default).",
56 " -svg=<Filename>",
57 " Fitted and measured TACs are plotted in specified SVG file.",
58 " -autoname",
59 " Names for fit file and fitted TAC file are set automatically",
60 " -w1",
61 " All weights are set to 1.0 (no weighting); by default, weights in",
62 " data file are used, if available.",
63 " -wf",
64 " Weight by sampling interval.",
65 " -stdoptions", // List standard options like --help, -v, etc
66 " ",
67 "Function parameters are written in fit (2) or result (3) format,",
68 "depending on filename extension (.fit or .res).",
69 " ",
70 "References:",
71 "1. https://www.turkupetcentre.net/petanalysis/doc/format_tpc_dft.html",
72 "2. https://www.turkupetcentre.net/petanalysis/doc/format_tpc_fit.html",
73 "3. https://www.turkupetcentre.net/petanalysis/doc/format_tpc_res.html",
74 " ",
75 "See also: fit_fexp, fit_dexp, llsqe3, fit_ratf, fit2dat, extrapol, tacln",
76 " ",
77 "Keywords: TAC, curve fitting, input, simulation, extrapolation",
78 0};
79/*****************************************************************************/
80
81/*****************************************************************************/
82/* Turn on the globbing of the command line, since it is disabled by default in
83 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
84 In Unix&Linux wildcard command line processing is enabled by default. */
85/*
86#undef _CRT_glob
87#define _CRT_glob -1
88*/
89int _dowildcard = -1;
90/*****************************************************************************/
91
92/*****************************************************************************/
96int main(int argc, char **argv)
97{
98 int ai, help=0, version=0, verbose=1;
99 int n, fi, pi, ri, type=303, ret;
100 int is_nonneg=0, is_expneg=0;
101 // Weights: 0=left as it is in datafile, 1=set to 1, 2=sampling frequency
102 int weighting=0;
103 char datfile[FILENAME_MAX], outfile[FILENAME_MAX], svgfile[FILENAME_MAX],
104 *cptr, temp[512];
105 DFT dft;
106 FIT fit;
107 double a, b, c, tstart, tstop;
108 double starttime=-1.0, endtime=-1.0;
109 int peak_start=0; // 1=start fit from peak
110 int tgo_nr, neigh_nr, iter_nr;
111
112
113 /*
114 * Get arguments
115 */
116 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
117 datfile[0]=outfile[0]=svgfile[0]=(char)0;
118 dftInit(&dft); fitInit(&fit);
119 parNr=6;
120 /* Options */
121 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
122 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
123 cptr=argv[ai]+1;
124 if(strcasecmp(cptr, "3")==0 || strcasecmp(cptr, "3e")==0) {
125 type=303; parNr=6; continue;
126 } else if(strcasecmp(cptr, "2")==0 || strcasecmp(cptr, "2e")==0) {
127 type=302; parNr=4; continue;
128 } else if(strcasecmp(cptr, "1")==0 || strcasecmp(cptr, "1e")==0) {
129 type=301; parNr=2; continue;
130 } else if(strncasecmp(cptr, "NONNEG", 2)==0) {
131 is_nonneg=1; continue;
132 } else if(strncasecmp(cptr, "EXPNEG", 2)==0) {
133 is_expneg=1; continue;
134 } else if(strcasecmp(cptr, "W1")==0) {
135 weighting=1; continue;
136 } else if(strcasecmp(cptr, "WF")==0) {
137 weighting=2; continue;
138 } else if(strncasecmp(cptr, "STARTTIME=", 10)==0) {
139 if(strcasecmp(cptr+10, "PEAK")==0) {peak_start=1; continue;}
140 starttime=atof_dpi(cptr+10); if(starttime>=0.0) continue;
141 } else if(strncasecmp(cptr, "ENDTIME=", 8)==0) {
142 endtime=atof_dpi(cptr+8); if(endtime>0.0) continue;
143 } else if(strncasecmp(cptr, "SVG=", 4)==0 && strlen(cptr)>4) {
144 strcpy(svgfile, cptr+4); continue;
145 }
146 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
147 return(1);
148 } else break;
149
150 /* Print help or version? */
151 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
152 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
153 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
154
155 /* Process other arguments, starting from the first non-option */
156 for(; ai<argc; ai++) {
157 if(!datfile[0]) {strcpy(datfile, argv[ai]); continue;}
158 else if(!outfile[0]) {strcpy(outfile, argv[ai]); continue;}
159 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
160 return(1);
161 }
162 if(!outfile[0]) {
163 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
164 return(1);
165 }
166
167
168 /* In verbose mode print arguments and options */
169 if(verbose>1) {
170 printf("datfile := %s\n", datfile);
171 printf("outfile := %s\n", outfile);
172 printf("svgfile := %s\n", svgfile);
173 printf("type := %d\nparNr := %d\n", type, parNr);
174 printf("weighting := %d\n", weighting);
175 if(is_nonneg) printf("non-negativity constraint was set for p1, p3 and p5\n");
176 if(is_expneg) printf("negativity constraint was set for p2, p4 and p6\n");
177 if(peak_start==0)
178 printf("starttime := %g min\n", starttime);
179 else
180 printf("starttime := peak\n");
181 printf("endtime := %g min\n", endtime);
182 }
183 if(verbose>6) MATHFUNC_TEST=verbose-6; else MATHFUNC_TEST=0;
184
185
186 /*
187 * Set parameter constraints;
188 * note that these apply to the [0,1] scaled data!
189 */
190 pmin[0]=-2.0e2; pmax[0]=5.0e2; if(is_nonneg) {pmin[0]=0.0; pmax[0]*=5.0;}
191 pmin[1]=-5.0e2; pmax[1]=5.0e2; if(is_expneg) {pmax[1]=0.0; pmin[1]*=2.0;}
192 pmin[2]=-1.0e2; pmax[2]=5.0e1; if(is_nonneg) {pmin[2]=0.0; pmax[2]*=5.0;}
193 pmin[3]=-0.9; pmax[3]=+0.9; if(is_expneg) {pmin[3]=0.0;}
194 pmin[4]=-2.0e2; pmax[4]=5.0e1; if(is_nonneg) {pmin[4]=0.0; pmax[4]*=5.0;}
195 pmin[5]=-0.9; pmax[5]=+0.9; if(is_expneg) {pmin[5]=0.0;}
196
197
198 /*
199 * Read data
200 */
201 if(verbose>1) printf("reading %s\n", datfile);
202 if(dftRead(datfile, &dft)) {
203 fprintf(stderr, "Error in reading '%s': %s\n", datfile, dfterrmsg);
204 return(2);
205 }
206
207 /*
208 * Delete the TACs that have name 'SD' (produced at least by avgbolus)
209 * unless all TACs would be deleted.
210 */
211 for(ri=0, n=0; ri<dft.voiNr; ri++) {
212 dft.voi[ri].sw2=0;
213 if(strcasecmp(dft.voi[ri].voiname, "SD")==0) {
214 dft.voi[ri].sw2=1; n++; continue;}
215 if(strcasecmp(dft.voi[ri].hemisphere, "SD")==0) {
216 dft.voi[ri].sw2=1; n++; continue;}
217 }
218 if(n>0 && n<dft.voiNr) {
219 if(verbose>0) printf("%d TAC(s) with SDs are not used.\n", n);
220 ri=0;
221 while(ri<dft.voiNr) {
222 if(dft.voi[ri].sw2) dftDelete(&dft, ri); else ri++;
223 }
224 }
225
226 /* Check for NA's */
227 if(dft_nr_of_NA(&dft) > 0) {
228 fprintf(stderr, "Error: missing sample(s) in %s\n", datfile);
229 dftEmpty(&dft); return(2);
230 }
231
232 /* Sort the samples by time in case data is catenated from several curves */
233 dftSortByFrame(&dft);
234
235 /* If fit is to be started at peak time, then find the common peak time */
236 if(peak_start!=0) {
237 ret=dftRobustMinMaxTAC(&dft, -1, NULL, &starttime, NULL, NULL, NULL, NULL,
238 NULL, NULL, verbose-10);
239 if(ret!=0) {
240 fprintf(stderr, "Error: can not determine peak time.\n");
241 if(verbose>1) printf("ret := %d\n", ret);
242 dftEmpty(&dft); return(3);
243 }
244 /* Convert it to minutes, if sample times are in seconds */
245 if(dft.timeunit==TUNIT_SEC) starttime/=60.;
246 if(verbose>1) printf("peak_time := %g min\n", starttime);
247 }
248
249 /* Set the fit time */
250 if(endtime<=0.0) endtime=1.0E20;
251 dataNr=fittime_from_dft(&dft, &starttime, &endtime, &start_index, &end_index, verbose-10);
252 if(dataNr<0) {
253 fprintf(stderr, "Error: check the fit time range.\n");
254 if(verbose>1) printf("ret := %d\n", -dataNr);
255 dftEmpty(&dft); return(3);
256 }
257 if(verbose>2) {
258 printf("start_index := %d\n", start_index);
259 printf("end_index := %d\n", end_index);
260 }
261 if(dataNr<3) {
262 fprintf(stderr, "Error: too few samples in the fit range.\n");
263 dftEmpty(&dft); return(3);
264 }
265 /* Get start and end times in the same units as in the data */
266 if(dft.timetype==DFT_TIME_STARTEND) {
267 tstart=dft.x1[start_index]; tstop=dft.x2[end_index];
268 } else {
269 tstart=dft.x[start_index]; tstop=dft.x[end_index];
270 }
271 /* Check times */
272 if(dataNr<3 || tstop<=tstart) {
273 fprintf(stderr, "Error: bad time scale in %s\n", datfile);
274 dftEmpty(&dft); return(2);
275 }
276
277 /* Check and set weights */
278 if(weighting==0) {
279 if(dft.isweight==0) {
280 dft.isweight=1; for(fi=0; fi<dft.frameNr; fi++) dft.w[fi]=1.0;}
281 } else if(weighting==1) {
282 dft.isweight=1; for(fi=0; fi<dft.frameNr; fi++) dft.w[fi]=1.0;
283 } else if(weighting==2) {
284 dftWeightByFreq(&dft);
285 }
286 if(verbose>2) {
287 printf("data_weights := %g", dft.w[0]);
288 for(fi=1; fi<dft.frameNr; fi++) printf(", %g", dft.w[fi]);
289 printf("\n");
290 }
291
292
293 /*
294 * Allocate memory for fits
295 */
296 if(verbose>1) printf("allocating memory for fits.\n");
297 if((ret=fit_allocate_with_dft(&fit, &dft))!=0) {
298 fprintf(stderr, "Error: cannot prepare memory for fit parameters (%d)", ret);
299 dftEmpty(&dft); return(4);
300 }
301 strncpy(fit.datafile, datfile, FILENAME_MAX);
302 tpcProgramName(argv[0], 1, 1, fit.program, 1024);
303 strcpy(fit.unit, dft.unit);
304 fit.time=time(NULL);
305 for(ri=0; ri<dft.voiNr; ri++) {
306 fit.voi[ri].type=type; fit.voi[ri].parNr=parNr;
307 fit.voi[ri].start=tstart; fit.voi[ri].end=tstop;
308 fit.voi[ri].dataNr=dataNr;
309 }
310
311 /*
312 * Use scaled [0,1] data during the fitting
313 */
314 /* Set the scale factors */
315 double xscale, yscale[dft.voiNr];
316 xscale=1.0/tstop;
317 for(ri=0; ri<dft.voiNr; ri++) {
318 a=dft.voi[ri].y[0];
319 for(fi=1; fi<dft.frameNr; fi++)
320 if(dft.voi[ri].y[fi]>a) a=dft.voi[ri].y[fi];
321 yscale[ri]=1.0/a;
322 }
323 if(verbose>1) {
324 printf("xscale=%g yscale=", xscale);
325 for(ri=0; ri<dft.voiNr; ri++) printf("%g ", yscale[ri]);
326 printf("\n");
327 }
328 /* Allocate memory for scaled data for fitting */
329 double *scaled_data;
330 scaled_data=malloc(sizeof(double)*3*dft.frameNr);
331 if(scaled_data==NULL) {
332 fprintf(stderr, "Error: out of memory.\n");
333 dftEmpty(&dft); fitEmpty(&fit);
334 return(5);
335 }
336 /* Set pointers */
337 x=scaled_data; ymeas=scaled_data+dft.frameNr; yfit=ymeas+dft.frameNr;
338 w=dft.w;
339 /* Calculate scaled x values */
340 for(fi=0; fi<dft.frameNr; fi++) x[fi]=xscale*dft.x[fi];
341
342
343
344 /*
345 * Fit each TAC
346 */
347 if(verbose>1 || (verbose>0 && dft.voiNr>1)) printf("fitting TACs\n");
348 for(ri=0; ri<dft.voiNr; ri++) {
349 if(verbose>0 && dft.voiNr>1) printf("%s\n", dft.voi[ri].name);
350
351 /* Scale y values for this TAC */
352 for(fi=0; fi<dft.frameNr; fi++)
353 ymeas[fi]=yscale[ri]*dft.voi[ri].y[fi];
354
355 tgo_nr=100+200*parNr;
356 neigh_nr=2*parNr;
357 iter_nr=parNr;
360
361 /* Set the initial values for parameters */
362 fit.voi[ri].wss=3.402823e+38;
363
364 /* fit */
365 ret=tgo(pmin, pmax, func_exp, NULL, parNr, neigh_nr, &fit.voi[ri].wss,
366 fit.voi[ri].p, tgo_nr, iter_nr, verbose-8);
367 if(ret) {
368 fprintf(stderr, "Error %d in TGO.\n", ret);
369 dftEmpty(&dft); fitEmpty(&fit); free(scaled_data);
370 return(6);
371 }
372
373 /* Print measured and fitted curve (scaled down) */
374 if(verbose>6) {
375 printf(" Measured Fitted:\n");
376 for(fi=0; fi<dft.frameNr; fi++)
377 printf(" %2d: %8.2e %8.2e %8.2e\n", fi+1, x[fi], ymeas[fi], yfit[fi]);
378 printf("\n");
379 }
380 if(verbose>2) {
381 printf(" fitted parameters (scaled), with limits:\n");
382 for(pi=0; pi<parNr; pi++)
383 printf(" %g [%g, %g]\n", fit.voi[ri].p[pi], pmin[pi], pmax[pi]);
384 printf("\n"); fflush(stdout);
385 }
386
387 /* Correct fitted parameters to match constraints like inside the function */
388 /* No need to remove penalty from WSS because WSS is calculated later again */
389 (void)modelCheckParameters(parNr, pmin, pmax, fit.voi[ri].p, fit.voi[ri].p, NULL);
390 /* Warn user about parameters that collide with limits */
391 if(verbose>1) {
392 ret=modelCheckLimits(parNr, pmin, pmax, fit.voi[ri].p);
393 if(ret==0) {fprintf(stdout, "ok\n");}
394 else fprintf(stderr, "fit collided with the limits.\n");
395 }
396
397 /* Calculate the function values again in case parameters were changed */
398 func_exp(parNr, fit.voi[ri].p, NULL);
399
400 /* Scale the fitted y values back */
401 for(fi=0; fi<dft.frameNr; fi++) dft.voi[ri].y2[fi]=yfit[fi]/yscale[ri];
402
403 /* Calculate the WSS from data in original scale */
404 a=c=0.0;
405 for(fi=0; fi<dft.frameNr; fi++) {
406 b=dft.voi[ri].y2[fi]-dft.voi[ri].y[fi];
407 a+=w[fi]*b*b;
408 if(fi==0 || fabs(b)>c) c=fabs(b);
409 }
410 fit.voi[ri].wss=a;
411 if(verbose>1) printf(" max_dev := %g\n", c);
412 if(verbose>4) printf("\n last_y := %g\n\n", dft.voi[ri].y2[dft.frameNr-1]);
413
414 /* Scale back the parameters */
415 for(pi=1; pi<parNr; pi+=2) {
416 fit.voi[ri].p[pi-1]/=yscale[ri];
417 }
418 fit.voi[ri].p[1]*=xscale;
419 /* Convert exponentials to the original values from the relative values */
420 if(parNr>3) fit.voi[ri].p[3]*=fit.voi[ri].p[1];
421 if(parNr>5) fit.voi[ri].p[5]*=fit.voi[ri].p[3];
422
423 } /* next TAC */
424 free(scaled_data);
425
426
427 /*
428 * Print fit results on screen
429 */
430 if(verbose>1 || strcasecmp(outfile, "stdout")==0) {
431 printf("\n");
432 fitWrite(&fit, "stdout");
433 printf("\n");
434 }
435
436
437 /*
438 * Save fit results, if required
439 */
440 if(outfile[0] && strcasecmp(outfile, "stdout")!=0) {
441 if(verbose>1) printf("writing fit results in %s\n", outfile);
442 cptr=strrchr(outfile, '.'); if(cptr!=NULL) cptr++;
443 if(strcasecmp(cptr, "FIT")==0) { // Save in FIT format
444 if(fitWrite(&fit, outfile)) {
445 fprintf(stderr, "Error in writing '%s': %s\n", outfile, fiterrmsg);
446 dftEmpty(&dft); fitEmpty(&fit); return(11);
447 }
448 } else { // Save in RES format
449 RES res; resInit(&res);
450 ret=fitToResult(&fit, &res, temp);
451 if(ret!=0) {
452 fprintf(stderr, "Error in making results: %s\n", temp);
453 dftEmpty(&dft); fitEmpty(&fit); resEmpty(&res); return(11);
454 }
455 if(parNr==6) strcpy(res.titleline, "Func p1 p2 p3 p4 p5 p6 WSS");
456 else if(parNr==4) strcpy(res.titleline, "Func a1 c1 a2 c2 WSS");
457 else strcpy(res.titleline, "Func a1 c1 WSS");
458 strcpy(res.program, fit.program);
459 sprintf(res.datarange, "%g - %g", tstart, tstop);
460 res.isweight=dft.isweight;
461 if(resWrite(&res, outfile, verbose-3)) {
462 fprintf(stderr, "Error in writing '%s': %s\n", outfile, fiterrmsg);
463 dftEmpty(&dft); fitEmpty(&fit); resEmpty(&res); return(11);
464 }
465 resEmpty(&res);
466 }
467 }
468
469
470 /*
471 * Saving and/or plotting of fitted TACs
472 */
473 if(svgfile[0]) {
474 if(verbose>1) printf("saving SVG plot\n");
475
476 /* Create a DFT containing fitted TACs */
477 char tmp[128];
478 int fj;
479 DFT dft2; dftInit(&dft2);
480 ret=dftAllocateWithHeader(&dft2, 1+end_index-start_index, dft.voiNr, &dft);
481 if(ret) {
482 fprintf(stderr, "Error: cannot save fitted curves.\n");
483 dftEmpty(&dft); fitEmpty(&fit);
484 return(21);
485 }
486 for(fi=start_index, fj=0; fi<=end_index; fi++) {
487 dft2.x[fj]=dft.x[fi]; dft2.x1[fj]=dft.x1[fi]; dft2.x2[fj]=dft.x2[fi];
488 for(ri=0; ri<dft.voiNr; ri++) dft2.voi[ri].y[fj]=dft.voi[ri].y2[fi];
489 fj++;
490 }
491
492 /* Save SVG plot of fitted and original data */
493 if(svgfile[0]) {
494 tpcProgramName(argv[0], 0, 0, tmp, 64); strcat(tmp, " ");
495 if(strlen(dft.studynr)>0) strcat(tmp, dft.studynr);
496 ret=plot_fit_svg(&dft, &dft2, tmp, svgfile, verbose-10);
497 if(ret) {
498 fprintf(stderr, "Error (%d) in writing '%s'.\n", ret, svgfile);
499 dftEmpty(&dft2); dftEmpty(&dft); fitEmpty(&fit);
500 return(30+ret);
501 }
502 if(verbose>0) printf("Plots written in %s\n", svgfile);
503 }
504
505 dftEmpty(&dft2);
506 }
507
508
509 /* Free memory */
510 dftEmpty(&dft); fitEmpty(&fit);
511
512 return(0);
513}
514/*****************************************************************************/
515
516/*****************************************************************************
517 *
518 * Functions to be minimized
519 *
520 *****************************************************************************/
521double func_exp(int parNr, double *p, void *fdata)
522{
523 int i;
524 double v, wss;
525 double pa[MAX_PARAMETERS], penalty=1.0;
526
527 /* Check parameters against the constraints */
528 (void)modelCheckParameters(parNr, pmin, pmax, p, pa, &penalty);
529 if(fdata) {}
530
531 /* Calculate the curve values and weighted SS */
532 if(parNr==6) {
533 for(i=start_index, wss=0.0; i<=end_index; i++) {
534 if(isnan(ymeas[i]) || isnan(x[i])) continue;
535 yfit[i]=pa[0]*exp(pa[1]*x[i]) +
536 pa[2]*exp(pa[1]*pa[3]*x[i]) +
537 pa[4]*exp(pa[1]*pa[3]*pa[5]*x[i]);
538 v=yfit[i]-ymeas[i]; wss+=w[i]*v*v;
539 }
540 } else if(parNr==4) {
541 for(i=start_index, wss=0.0; i<=end_index; i++) {
542 if(isnan(ymeas[i]) || isnan(x[i])) continue;
543 yfit[i]=pa[0]*exp(pa[1]*x[i]) +
544 pa[2]*exp(pa[1]*pa[3]*x[i]);
545 v=yfit[i]-ymeas[i]; wss+=w[i]*v*v;
546 }
547 } else if(parNr==2) {
548 for(i=start_index, wss=0.0; i<=end_index; i++) {
549 if(isnan(ymeas[i]) || isnan(x[i])) continue;
550 yfit[i]=pa[0]*exp(pa[1]*x[i]);
551 v=yfit[i]-ymeas[i]; wss+=w[i]*v*v;
552 }
553 } else {printf("Program error: parNr=%d\n", parNr); exit(10);}
554 wss*=penalty;
555
556 return(wss);
557}
558/*****************************************************************************/
559
560/*****************************************************************************/
562
int modelCheckParameters(int par_nr, double *lower_p, double *upper_p, double *test_p, double *accept_p, double *penalty)
Definition constraints.c:15
int modelCheckLimits(int par_nr, double *lower_p, double *upper_p, double *test_p)
Definition constraints.c:59
double atof_dpi(char *str)
Definition decpoint.c:59
void dftInit(DFT *data)
Definition dft.c:38
char dfterrmsg[64]
Definition dft.c:6
int dftSortByFrame(DFT *dft)
Definition dft.c:1169
int dftDelete(DFT *dft, int voi)
Definition dft.c:538
void dftEmpty(DFT *data)
Definition dft.c:20
int dft_nr_of_NA(DFT *dft)
Definition dft.c:905
int dftAllocateWithHeader(DFT *dft, int frameNr, int voiNr, DFT *dft_from)
Definition dft.c:702
int dftRobustMinMaxTAC(DFT *dft, int tacindex, double *minx, double *maxx, double *miny, double *maxy, int *mini, int *maxi, int *mins, int *maxs, int verbose)
Definition dftinput.c:608
int dftRead(char *filename, DFT *data)
Definition dftio.c:22
int fitToResult(FIT *fit, RES *res, char *status)
Definition fitres.c:56
int fit_allocate_with_dft(FIT *fit, DFT *dft)
Definition fitres.c:14
int fittime_from_dft(DFT *dft, double *startTime, double *endTime, int *first, int *last, int verbose)
Definition fittime.c:16
Header file for libtpccurveio.
void resInit(RES *res)
Definition result.c:52
void fitEmpty(FIT *fit)
Definition mathfunc.c:18
int fitWrite(FIT *fit, char *filename)
Definition mathfunc.c:54
int resWrite(RES *res, char *filename, int verbose)
Definition result.c:565
int MATHFUNC_TEST
Definition mathfunc.c:5
char fiterrmsg[64]
Definition mathfunc.c:6
void fitInit(FIT *fit)
Definition mathfunc.c:38
#define DFT_TIME_STARTEND
void resEmpty(RES *res)
Definition result.c:22
Header file for libtpcmisc.
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:40
void tpcProgramName(const char *program, int version, int copyright, char *prname, int n)
Definition proginfo.c:101
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:213
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:383
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:158
Header file for libtpcmodel.
int tgo(double *lowlim, double *uplim, double(*objf)(int, double *, void *), void *objfData, int dim, int neighNr, double *fmin, double *gmin, int samNr, int tgoNr, int verbose)
Definition tgo.c:39
int TGO_LOCAL_INSIDE
Definition tgo.c:29
#define MAX_PARAMETERS
Definition libtpcmodel.h:31
int TGO_SQUARED_TRANSF
Definition tgo.c:27
Header file for libtpcmodext.
int plot_fit_svg(DFT *dft1, DFT *dft2, char *main_title, char *fname, int verbose)
Definition plotfit.c:216
int dftWeightByFreq(DFT *dft)
Header file for libtpcsvg.
int timetype
Voi * voi
int timeunit
char studynr[MAX_STUDYNR_LEN+1]
double * w
double * x1
int voiNr
double * x2
int frameNr
int isweight
double * x
char unit[MAX_UNITS_LEN+1]
char datafile[FILENAME_MAX]
char program[1024]
char unit[MAX_UNITS_LEN+1]
FitVOI * voi
time_t time
double wss
double end
double start
double p[MAX_FITPARAMS]
char titleline[1024]
char program[1024]
char datarange[128]
int isweight
double * y2
char voiname[MAX_REGIONSUBNAME_LEN+1]
double * y
char name[MAX_REGIONNAME_LEN+1]
char hemisphere[MAX_REGIONSUBNAME_LEN+1]
char sw2