TPCCLIB
Loading...
Searching...
No Matches
fit_bpr.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#define MAX_FUNC_NR 4
25enum {MODEL_UNKNOWN, MODEL_IGV, MODEL_HILLB, MODEL_IHILLB};
26int model=MODEL_UNKNOWN;
27int func_par_nr[MAX_FUNC_NR]={0,5,5,5};
28static char *model_name[] = {"Unknown", "IGV", "HILLB", "IHILLB", 0};
29/*****************************************************************************/
30#define MAX_MINMEAS_NR 3
31enum {MINMEAS_UNKNOWN, MINMEAS_SS, MINMEAS_ABS};
32int min_meas=MINMEAS_UNKNOWN;
33/*****************************************************************************/
34double *x, *ymeas, *yfit, *w; /* Local */
35int dataNr=0, parNr=0;
36double pmin[MAX_PARAMETERS], pmax[MAX_PARAMETERS];
37double lastWSS;
38/*****************************************************************************/
39/* Local functions */
40double (*func)(int, double*, void*);
41double func_igv(int parNr, double *p, void*);
42double func_hillb(int parNr, double *p, void*);
43/*****************************************************************************/
44
45/*****************************************************************************/
46static char *info[] = {
47 "Non-linear fitting of a function to sampled blood-to-plasma ratio data.",
48 " ",
49 "Usage: @P [Options] datafile fitfile",
50 " ",
51 "Options:",
52 " -model=<igv|hillb|ihillb>",
53 " Select the function; default is IGV.",
54 " -delay[=<time>]",
55 " Fit also delay time, or, set delay time (0 by default).",
56 " -bl=<baseline>",
57 " Constrain baseline level to specified value; fitted by default.",
58 " -w1 All weights are set to 1.0 (no weighting); by default, weights in",
59 " data file are used, if available.",
60 " -wf",
61 " Weight by sampling interval.",
62 " -fast or -safe",
63 " Speed up the fitting but increase the chance of failure, or",
64 " increase the reliability at the cost of computing time.",
65 " -min=<ss|abs>",
66 " Sum-of-squares (SS) is minimized by default, but optionally",
67 " sum of absolute deviations can be selected.",
68 " -svg=<Filename>",
69 " Fitted and measured TACs are plotted in specified SVG file.",
70 " -stdoptions", // List standard options like --help, -v, etc
71 " ",
72 "Datafile must contain at least 2 columns, sample times and ratios;",
73 "DFT file (1) can include also weights.",
74 "Program writes the fit start and end times, nr of points, WSS/n,",
75 "and parameters of the fitted function to the FIT file (2).",
76 " ",
77 "Example:",
78 " @P -model=igv -svg=ia765bprat.svg ia765bp.rat ia765bprat.fit",
79 " ",
80 "References:",
81 "1. https://www.turkupetcentre.net/petanalysis/format_tpc_dft.html",
82 "2. https://www.turkupetcentre.net/petanalysis/format_tpc_fit.html",
83 " ",
84 "See also: fit2dat, avgfract, b2plasma, bpr2cpr, tacinv, taccat, tacblend",
85 " ",
86 "Keywords: curve fitting, input, blood, plasma, modelling, simulation",
87 0};
88/*****************************************************************************/
89
90/*****************************************************************************/
91/* Turn on the globbing of the command line, since it is disabled by default in
92 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
93 In Unix&Linux wildcard command line processing is enabled by default. */
94/*
95#undef _CRT_glob
96#define _CRT_glob -1
97*/
98int _dowildcard = -1;
99/*****************************************************************************/
100
101/*****************************************************************************/
105int main(int argc, char **argv)
106{
107 int ai, help=0, version=0, verbose=1;
108 int fi, ri, pi, type, ret;
109 int weights=0; // 0=default, 1=no weighting, 2=frequency
110 double fixedDelay=0.0; // Fitted, if <0
111 double fixedBaseline=-1.0; // Fitted, if <0
112 char dftfile[FILENAME_MAX], fitfile[FILENAME_MAX], svgfile[FILENAME_MAX];
113 char *cptr;
114 double tstart, tstop, miny, maxy, par_tmp[MAX_PARAMETERS];
115 int tgo_nr, neighNr=0, reliability_level=2; /* 1=fast, 2=normal, 3=slow */
116 DFT dft;
117 FIT fit;
118
119
120 /*
121 * Get arguments
122 */
123 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
124 dftInit(&dft); fitInit(&fit);
125 dftfile[0]=fitfile[0]=svgfile[0]=(char)0;
126 /* Options */
127 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
128 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(cptr==NULL) continue;
129 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
130 if(strcasecmp(cptr, "SAFE")==0) {
131 reliability_level=3; continue;
132 } else if(strcasecmp(cptr, "NORMAL")==0) {
133 reliability_level=2; continue;
134 } else if(strcasecmp(cptr, "FAST")==0) {
135 reliability_level=1; continue;
136 } else if(strcasecmp(cptr, "W1")==0) {
137 weights=1; continue;
138 } else if(strcasecmp(cptr, "WF")==0) {
139 weights=2; continue;
140 } else if(strncasecmp(cptr, "SVG=", 4)==0 && strlen(cptr)>4) {
141 strcpy(svgfile, cptr+4); continue;
142 } else if(strncasecmp(cptr, "MODEL=", 6)==0) {
143 cptr+=6;
144 if(strncasecmp(cptr, "IGV", 3)==0) {model=MODEL_IGV; continue;}
145 if(strncasecmp(cptr, "HILLB", 3)==0) {model=MODEL_HILLB; continue;}
146 if(strncasecmp(cptr, "IHILLB", 3)==0) {model=MODEL_IHILLB; continue;}
147 fprintf(stderr, "Error: invalid ratio model.\n"); return(1);
148 } else if(strncasecmp(cptr, "MIN=", 4)==0) {
149 cptr+=4;
150 if(strcasecmp(cptr, "SS")==0 || strcasecmp(cptr, "WSS")==0) {
151 min_meas=MINMEAS_SS; continue;}
152 if(strcasecmp(cptr, "ABS")==0 || strcasecmp(cptr, "WABS")==0) {
153 min_meas=MINMEAS_ABS; continue;}
154 fprintf(stderr, "Error: invalid minimization measure.\n"); return(1);
155 } else if(strncasecmp(cptr, "DELAY=", 6)==0) {
156 fixedDelay=atof_dpi(cptr+6); if(fixedDelay>=0.0) continue;
157 } else if(strcasecmp(cptr, "DELAY")==0) {
158 fixedDelay=-1.0; continue;
159 } else if(strncasecmp(cptr, "BL=", 3)==0) {
160 fixedBaseline=atof_dpi(cptr+3); if(fixedBaseline>=0.0) continue;
161 }
162 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
163 return(1);
164 } else break;
165
166 /* Print help or version? */
167 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
168 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
169 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
170
171 /* Process other arguments, starting from the first non-option */
172 for(; ai<argc; ai++) {
173 if(!dftfile[0]) {strcpy(dftfile, argv[ai]); continue;}
174 if(!fitfile[0]) {strcpy(fitfile, argv[ai]); continue;}
175 fprintf(stderr, "Error: too many arguments: '%s'.\n", argv[ai]);
176 return(1);
177 }
178
179 /* Is something missing? */
180 if(!fitfile[0]) {
181 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
182 return(1);
183 }
184 if(model==MODEL_UNKNOWN) model=MODEL_IGV;
185 if(min_meas==MINMEAS_UNKNOWN) min_meas=MINMEAS_SS;
186
187
188 /* In verbose mode print arguments and options */
189 if(verbose>1) {
190 printf("dftfile := %s\n", dftfile);
191 printf("fitfile := %s\n", fitfile);
192 printf("svgfile := %s\n", svgfile);
193 printf("model := %d\n", model);
194 printf("min_meas := %d\n", min_meas);
195 printf("reliability_level := %d\n", reliability_level);
196 printf("weights := %d\n", weights);
197 if(fixedDelay>=0) printf("fixedDelay := %g\n", fixedDelay);
198 if(fixedBaseline>=0) printf("fixedBaseline := %g\n", fixedBaseline);
199 }
200 if(verbose>4) MATHFUNC_TEST=verbose-4; else MATHFUNC_TEST=0;
201
202
203 /*
204 * Read data
205 */
206 if(verbose>1) printf("reading '%s'\n", dftfile);
207 if(dftRead(dftfile, &dft)) {
208 fprintf(stderr, "Error in reading '%s': %s\n", dftfile, dfterrmsg);
209 return(2);
210 }
211 if(dft.frameNr<3) {
212 fprintf(stderr, "Error: not enough samples for decent fitting.\n");
213 dftEmpty(&dft); return(3);
214 }
215 dataNr=dft.frameNr;
216
217 /* Sort the samples by time in case data is catenated from several curves */
218 (void)dftSortByFrame(&dft);
219 if(verbose>30) dftPrint(&dft);
220
221 /* Check for NA's */
222 if(dft_nr_of_NA(&dft) > 0) {
223 fprintf(stderr, "Error: missing sample(s) in %s\n", dftfile);
224 dftEmpty(&dft); return(2);
225 }
226
227 /* Get min and max X and Y */
228 ret=dftMinMax(&dft, &tstart, &tstop, &miny, &maxy);
229 if(ret!=0) {
230 fprintf(stderr, "Error: invalid contents in %s\n", dftfile);
231 dftEmpty(&dft); return(2);
232 }
233 if(tstop<=0.0 || maxy<=0.0) {
234 fprintf(stderr, "Error: invalid contents in %s\n", dftfile);
235 dftEmpty(&dft); return(2);
236 }
237 if(tstart<0.0) fprintf(stderr, "Warning: negative x value(s).\n");
238 if(miny<0.0) fprintf(stderr, "Warning: negative y value(s).\n");
239
240 /* Check and set weights */
241 if(weights==0) {
242 if(dft.isweight==0) {
243 dft.isweight=1; for(fi=0; fi<dft.frameNr; fi++) dft.w[fi]=1.0;}
244 } else if(weights==1) {
245 dft.isweight=1; for(fi=0; fi<dft.frameNr; fi++) dft.w[fi]=1.0;
246 } else if(weights==2) {
247 dftWeightByFreq(&dft);
248 }
249 if(verbose==10) dftPrint(&dft);
250
251
252 /*
253 * Allocate memory for fits
254 */
255 if(verbose>1) printf("allocating memory for fits.\n");
256 ret=fit_allocate_with_dft(&fit, &dft); if(ret) {
257 fprintf(stderr, "Error: cannot allocate space for fit results (%d).\n", ret);
258 dftEmpty(&dft); fitEmpty(&fit); return(4);
259 }
260 /* Set necessary information in fit data structure */
261 fit.voiNr=dft.voiNr;
262 strncpy(fit.datafile, dftfile, FILENAME_MAX);
263 tpcProgramName(argv[0], 1, 1, fit.program, 256);
264 fit.time=time(NULL);
265 parNr=func_par_nr[model];
266 if(model==MODEL_IGV) type=1402;
267 else if(model==MODEL_HILLB) type=844;
268 else if(model==MODEL_IHILLB) type=844;
269 else type=0;
270 for(ri=0; ri<fit.voiNr; ri++) {
271 fit.voi[ri].type=type;
272 fit.voi[ri].parNr=parNr;
273 fit.voi[ri].start=tstart; fit.voi[ri].end=tstop;
274 fit.voi[ri].dataNr=dataNr;
275 }
276 if(verbose>8) fitPrint(&fit);
277
278 /*
279 * Set fitting parameters
280 */
281 switch(reliability_level) {
282 case 1: tgo_nr=150; neighNr=4; break;
283 case 3: tgo_nr=1200; neighNr=6; break;
284 case 2:
285 default: tgo_nr=300; neighNr=5; break;
286 }
287 /* Set constraints and function */
288 if(fixedDelay>=0.0) pmin[0]=pmax[0]=fixedDelay;
289 else {pmin[0]=0.0; pmax[0]=0.10*tstop;}
290 switch(model) {
291 case MODEL_IGV:
292 func=func_igv;
293 /* baseline, BL/PL water contents ratio */
294 if(fixedBaseline>=0.0) {pmin[1]=pmax[1]=fixedBaseline;}
295 else {pmin[1]=0.80; pmax[1]=1.20;}
296 /* scale */
297 pmin[2]=0.001; pmax[2]=1.0;
298 /* exponent */
299 pmin[3]=0.0; pmax[3]=1.0;
300 /* exp div */
301 pmin[4]=1.0e-05; pmax[4]=1.0e+03;
302 break;
303 case MODEL_HILLB:
304 func=func_hillb;
305 /* scale */
306 pmin[1]=0.0; pmax[1]=5.0;
307 /* exponent */
308 pmin[2]=1.0; pmax[2]=20.0;
309 /* steepness */
310 pmin[3]=1.0E-6; pmax[3]=1.0E+8;
311 /* backround */
312 if(fixedBaseline>=0.0) {pmin[4]=pmax[4]=fixedBaseline;}
313 else {pmin[4]=0.5; pmax[4]=1.0;}
314 break;
315 case MODEL_IHILLB:
316 func=func_hillb;
317 /* scale */
318 pmin[1]=-5.0; pmax[1]=0.0;
319 /* exponent */
320 pmin[2]=1.0; pmax[2]=20.0;
321 /* steepness */
322 pmin[3]=1.0E-6; pmax[3]=1.0E+8;
323 /* backround */
324 if(fixedBaseline>=0.0) {pmin[4]=pmax[4]=fixedBaseline;}
325 else {pmin[4]=0.5; pmax[4]=5.0;}
326 break;
327 }
328
329 /*
330 * Fit each TAC
331 */
332 if(verbose>0) {printf("fitting\n"); fflush(stdout);}
333 for(ri=0; ri<dft.voiNr; ri++) {
334
335 if(verbose>2) {
336 fprintf(stdout, " fitting %s: ", dft.voi[ri].name);
337 fflush(stdout);
338 } else if(dft.voiNr>1 && verbose>0) {
339 fprintf(stdout, "."); fflush(stdout);
340 }
341
342 /* Set data pointers */
343 x=dft.x; ymeas=dft.voi[ri].y; yfit=dft.voi[ri].y2;
344 w=dft.voi[ri].y3; for(fi=0; fi<dataNr; fi++) w[fi]=dft.w[fi];
345
346 /* Set the initial values for parameters */
347 fit.voi[ri].wss=3.402823e+38;
348
349 /* Fit */
350 ret=tgo(pmin, pmax, func, NULL, parNr, neighNr,
351 &fit.voi[ri].wss, fit.voi[ri].p, tgo_nr, 0, verbose-5);
352 if(ret) {
353 fprintf(stderr, "Error %d in TGO.\n", ret);
354 dftEmpty(&dft); fitEmpty(&fit); return(5);
355 }
356 fit.voi[ri].wss=lastWSS; // non-penalized WSS
357 /* Correct fitted parameters to match constraints like inside the function */
358 (void)modelCheckParameters(parNr, pmin, pmax, fit.voi[ri].p, fit.voi[ri].p,
359 NULL);
360
361 /* Warn user about parameters that collide with limits */
362 if(verbose>1) {
363 ret=modelCheckLimits(parNr, pmin, pmax, fit.voi[ri].p);
364 if(ret==0) {if(verbose>2) fprintf(stdout, "ok\n");}
365 else fprintf(stderr, "warning, fit collided with the limits.\n");
366 }
367 /*
368 * Print additional information in verbose mode
369 */
370 if(verbose>1) {
371 double wss, a, aic;
372 int n, k;
373 char tmp[64];
374 if(dft.voiNr==1) strcpy(tmp, ""); else sprintf(tmp, "[%d]", ri+1);
375 /* Calculate WSS */
376 wss=0.0;
377 for(fi=0; fi<dataNr; fi++) {
378 a=ymeas[fi]-yfit[fi];
379 wss+=w[fi]*a*a;
380 }
381 printf("WSS%s := %g\n", tmp, wss);
382 /* Nr of fitted parameters */
383 for(pi=k=0; pi<parNr; pi++) if(pmax[pi]>pmin[pi]) k++;
384 printf("Nr_of_fitted_parameters%s := %d\n", tmp, k);
385 /* Nr of data points */
386 for(fi=n=0; fi<dataNr; fi++) if(w[fi]>0.0) n++;
387 printf("Nr_of_fitted_samples%s := %d\n", tmp, n);
388 /* Calculate AIC */
389 aic=aicSS(wss, n, k); printf("AIC%s := %g\n", tmp, aic);
390 }
391
392 /* Print measured and fitted curve */
393 if(verbose>5) {
394 printf("\n Frame Time Value Fitted Weight \n");
395 for(fi=0; fi<dataNr; fi++)
396 printf(" %02d %8.3f %12.4f %12.4f %8.4f\n",
397 fi+1, x[fi], ymeas[fi], yfit[fi], w[fi]);
398 }
399 if(verbose>3) {
400 printf(" fitted parameters:\n");
401 for(pi=0; pi<fit.voi[ri].parNr; pi++)
402 printf(" p[%d] := %g [%g, %g]\n",
403 pi+1, fit.voi[ri].p[pi], pmin[pi], pmax[pi]);
404 }
405 } /* next TAC */
406 if(verbose>0) fprintf(stdout, "\n");
407
408
409 /*
410 * Set fitted parameters as required by FIT format
411 */
412 for(ri=0; ri<dft.voiNr; ri++) {
413 for(pi=0; pi<parNr; pi++) par_tmp[pi]=fit.voi[ri].p[pi];
414 switch(model) {
415 case MODEL_IGV:
416 fit.voi[ri].p[0]=-par_tmp[2];
417 fit.voi[ri].p[1]= par_tmp[3];
418 fit.voi[ri].p[2]= par_tmp[4];
419 fit.voi[ri].p[3]= par_tmp[0];
420 fit.voi[ri].p[4]= par_tmp[1];
421 break;
422 case MODEL_HILLB:
423 case MODEL_IHILLB:
424 fit.voi[ri].p[0]=par_tmp[1];
425 fit.voi[ri].p[1]=par_tmp[2];
426 fit.voi[ri].p[2]=par_tmp[3];
427 fit.voi[ri].p[3]=par_tmp[4];
428 fit.voi[ri].p[4]=par_tmp[0];
429 break;
430 }
431 }
432
433
434 /*
435 * Print fit results on screen
436 */
437 if(verbose>0 && fit.voiNr<=50) fitWrite(&fit, "stdout");
438
439 /*
440 * Save fit results
441 */
442 if(verbose>1) printf("saving results in %s\n", fitfile);
443 if(fitWrite(&fit, fitfile)) {
444 fprintf(stderr, "Error in writing '%s': %s\n", fitfile, fiterrmsg);
445 dftEmpty(&dft); fitEmpty(&fit); return(11);
446 }
447
448 /*
449 * Saving and/or plotting of fitted TACs
450 */
451 if(svgfile[0]) {
452 if(verbose>1) printf("saving SVG plot\n");
453
454 /* Create a DFT containing fitted TACs */
455 char tmp[128];
456 DFT dft2;
457 dftInit(&dft2); ret=dftdup(&dft, &dft2);
458 if(ret) {
459 fprintf(stderr, "Error: cannot save fitted curves.\n");
460 dftEmpty(&dft); fitEmpty(&fit);
461 return(21);
462 }
463 for(ri=0; ri<dft.voiNr; ri++) for(fi=0; fi<dft.frameNr; fi++)
464 dft2.voi[ri].y[fi]=dft2.voi[ri].y2[fi];
465
466 /* Save SVG plot of fitted and original data */
467 tpcProgramName(argv[0], 0, 0, tmp, 64); strcat(tmp, " ");
468 strcat(tmp, model_name[model]); strcat(tmp, " ");
469 if(strlen(dft2.studynr)>1) strcat(tmp, dft.studynr);
470 ret=plot_fit_svg(&dft, &dft2, tmp, svgfile, verbose-8);
471 if(ret) {
472 fprintf(stderr, "Error (%d) in writing '%s'.\n", ret, svgfile);
473 dftEmpty(&dft2); dftEmpty(&dft); fitEmpty(&fit);
474 return(30+ret);
475 }
476 if(verbose>0) printf("Plots written in %s\n", svgfile);
477
478 dftEmpty(&dft2);
479 }
480
481 /* Free memory */
482 dftEmpty(&dft); fitEmpty(&fit);
483
484 return(0);
485}
486/*****************************************************************************/
487
488/*****************************************************************************
489 *
490 * Functions to be minimized
491 *
492 *****************************************************************************/
493double func_igv(int parNr, double *p, void *fdata)
494{
495 int i;
496 double xt, v, wss;
497 double pa[MAX_PARAMETERS], penalty=1.0;
498
499
500 /* Check parameters against the constraints */
501 (void)modelCheckParameters(parNr, pmin, pmax, p, pa, &penalty);
502 if(fdata) {}
503 if(0) {
504 for(i=0; i<parNr; i++) printf(" p[%d]=%g", i, p[i]);
505 printf("\n");
506 }
507
508 /* Calculate the curve and WSS */
509 for(i=0, wss=0.0; i<dataNr; i++) {
510 xt=x[i]-pa[0];
511 if(xt<0.0) {
512 yfit[i]=0.0;
513 } else {
514 yfit[i]=pa[2]*pow(xt, pa[3])*exp(-xt/pa[4]);
515 }
516 yfit[i]=pa[1]-yfit[i];
517 /* Calculate weighted SS or ABS */
518 v=yfit[i]-ymeas[i];
519 if(min_meas==MINMEAS_SS) v*=v; else v=fabs(v);
520 wss+=w[i]*v;
521 }
522 lastWSS=wss;
523 wss*=penalty;
524 return(wss);
525}
526double func_hillb(int parNr, double *p, void *fdata)
527{
528 int i;
529 double xt, v, wss;
530 double pa[MAX_PARAMETERS], penalty=1.0;
531
532
533 /* Check parameters against the constraints */
534 (void)modelCheckParameters(parNr, pmin, pmax, p, pa, &penalty);
535 if(fdata) {}
536 if(0) {
537 for(i=0; i<parNr; i++) printf(" p[%d]=%g", i, p[i]);
538 printf("\n");
539 }
540
541 /* Calculate the curve and WSS */
542 for(i=0, wss=0.0; i<dataNr; i++) {
543 xt=x[i]-pa[0];
544 if(xt<=0.0) {
545 yfit[i]=0.0;
546 } else {
547 v=pow(xt, pa[2]);
548 yfit[i]=pa[1]*v/(v+pa[3]);
549 }
550 yfit[i]+=pa[4];
551 /* Calculate weighted SS or ABS */
552 v=yfit[i]-ymeas[i];
553 if(min_meas==MINMEAS_SS) v*=v; else v=fabs(v);
554 wss+=w[i]*v;
555 }
556 lastWSS=wss;
557 wss*=penalty;
558 return(wss);
559}
560/*****************************************************************************/
561
562/*****************************************************************************/
double aicSS(double ss, const int n, const int k)
Definition aic.c:20
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
int dftdup(DFT *dft1, DFT *dft2)
Definition dft.c:655
char dfterrmsg[64]
Definition dft.c:6
int dftSortByFrame(DFT *dft)
Definition dft.c:1169
int dftMinMax(DFT *dft, double *minx, double *maxx, double *miny, double *maxy)
Definition dft.c:974
void dftEmpty(DFT *data)
Definition dft.c:20
int dft_nr_of_NA(DFT *dft)
Definition dft.c:905
int dftRead(char *filename, DFT *data)
Definition dftio.c:22
void dftPrint(DFT *data)
Definition dftio.c:538
int fit_allocate_with_dft(FIT *fit, DFT *dft)
Definition fitres.c:14
Header file for libtpccurveio.
void fitEmpty(FIT *fit)
Definition mathfunc.c:18
int fitWrite(FIT *fit, char *filename)
Definition mathfunc.c:54
int MATHFUNC_TEST
Definition mathfunc.c:5
char fiterrmsg[64]
Definition mathfunc.c:6
void fitInit(FIT *fit)
Definition mathfunc.c:38
void fitPrint(FIT *fit)
Definition mathfunc.c:180
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
#define MAX_PARAMETERS
Definition libtpcmodel.h:31
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.
Voi * voi
char studynr[MAX_STUDYNR_LEN+1]
double * w
int voiNr
int frameNr
int isweight
double * x
int voiNr
char datafile[FILENAME_MAX]
char program[1024]
FitVOI * voi
time_t time
double wss
double end
double start
double p[MAX_FITPARAMS]
double * y2
double * y
char name[MAX_REGIONNAME_LEN+1]
double * y3