TPCCLIB
Loading...
Searching...
No Matches
fit_disp.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 "tpctac.h"
19#include "tpcpar.h"
20#include "tpcli.h"
21#include "tpccm.h"
22#include "tpctacmod.h"
23#include "tpclinopt.h"
24#include "tpcrand.h"
25#include "tpcmodels.h"
26#include "tpcnlopt.h"
27/*****************************************************************************/
28
29/*****************************************************************************/
30const int maxParNr=2;
31/* Local functions */
32double func_disp(int parNr, double *p, void*);
33/*****************************************************************************/
34typedef struct FITDATA {
36 unsigned int ni;
38 double *xi;
40 double *yi;
41
43 unsigned int no;
45 double *xo;
47 double *yo;
49 double *w;
51 double *ysim;
52
56 int verbose;
57} FITDATA;
58/*****************************************************************************/
59
60/*****************************************************************************/
61static char *info[] = {
62 "Non-linear fitting of dispersion and delay from system input and output",
63 "curves.",
64 " ",
65 "Usage: @P [Options] inputfile outputfile [parfile]",
66 " ",
67 "Options:",
68 " -min=<OLS|LAD>",
69 " Sum-of-squares (OLS) is minimized by default, but optionally",
70 " sum of absolute deviations (LAD) can be selected.",
71 " -w1",
72 " All weights are set to 1.0 (no weighting); by default, weights in",
73 " data file are used, if available.",
74 " -wf",
75 " Weight by sampling interval.",
76 " -svg=<Filename>",
77 " Fitted and measured TACs are plotted in specified SVG file.",
78 " -stdoptions", // List standard options like --help, -v, etc
79 " ",
80 "Data files must contain 2 columns, sample times and concentrations,",
81 "possibly also weights as last column.",
82 " ",
83 "Example:",
84 " @P -svg=delayfit.svg input.tac output.tac delayfit.par",
85 " ",
86 "See also: disp4dft, fit_sinf, fit_xexp, convexpf, fit_wrlv",
87 " ",
88 "Keywords: dispersion, curve fitting, input, blood",
89 0};
90/*****************************************************************************/
91
92/*****************************************************************************/
93/* Turn on the globbing of the command line, since it is disabled by default in
94 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
95 In Unix&Linux wildcard command line processing is enabled by default. */
96/*
97#undef _CRT_glob
98#define _CRT_glob -1
99*/
100int _dowildcard = -1;
101/*****************************************************************************/
102
103/*****************************************************************************/
106/*****************************************************************************/
107
108/*****************************************************************************/
112int main(int argc, char **argv)
113{
114 int ai, help=0, version=0, verbose=1;
115 char tacfile1[FILENAME_MAX], tacfile2[FILENAME_MAX],
116 parfile[FILENAME_MAX], svgfile[FILENAME_MAX];
117 int weights=0; // 0=default, 1=no weighting, 2=frequency
119
120
121
122 /*
123 * Get arguments
124 */
125 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
126 tacfile1[0]=tacfile2[0]=parfile[0]=svgfile[0]=(char)0;
127 /* Options */
128 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
129 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
130 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
131 if(strcasecmp(cptr, "W1")==0) {
132 weights=1; continue;
133 } else if(strcasecmp(cptr, "WF")==0) {
134 weights=2; continue;
135 } else if(strncasecmp(cptr, "MIN=", 4)==0 && strlen(cptr)>4) {
136 optcrit=optcritId(cptr+4); if(optcrit!=OPTCRIT_UNKNOWN) continue;
137 } else if(strncasecmp(cptr, "SVG=", 4)==0 && strlen(cptr)>4) {
138 strlcpy(svgfile, cptr+4, FILENAME_MAX); continue;
139 }
140 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
141 return(1);
142 } else break;
143
144 TPCSTATUS status; statusInit(&status);
145 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
146 status.verbose=verbose-3;
147
148 /* Print help or version? */
149 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
150 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
151 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
152
153 /* Process other arguments, starting from the first non-option */
154 if(ai<argc) strlcpy(tacfile1, argv[ai++], FILENAME_MAX);
155 if(ai<argc) strlcpy(tacfile2, argv[ai++], FILENAME_MAX);
156 if(ai<argc) strlcpy(parfile, argv[ai++], FILENAME_MAX);
157 if(ai<argc) {
158 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
159 return(1);
160 }
161 /* Did we get all the information that we need? */
162 if(!tacfile2[0]) { // note that parameter file is optional
163 fprintf(stderr, "Error: missing file name.\n");
164 return(1);
165 }
166
167 /* In verbose mode print arguments and options */
168 if(verbose>1) {
169 printf("tacfile1 := %s\n", tacfile1);
170 printf("tacfile2 := %s\n", tacfile2);
171 if(parfile[0]) printf("parfile := %s\n", parfile);
172 if(svgfile[0]) printf("svgfile := %s\n", svgfile);
173 printf("weights := %d\n", weights);
174 printf("optcrit := %s\n", optcritCode(optcrit));
175 fflush(stdout);
176 }
177
178
179 /*
180 * Read TAC data
181 */
182 if(verbose>1) printf("reading TAC data\n");
183 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
184 TAC tac1, tac2; tacInit(&tac1); tacInit(&tac2);
185 int fitSampleNr;
186 double fitdur=1.0E+12;
187 if(tacReadModelingData(tacfile2, tacfile1, NULL, NULL, &fitdur, 0,
188 &fitSampleNr, &tac2, &tac1, &status) != TPCERROR_OK)
189 {
190 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
191 tacFree(&tac1); tacFree(&tac2); return(2);
192 }
193 /* Convert sample times into seconds */
194 if(tacXUnitConvert(&tac1, UNIT_SEC, &status)!=TPCERROR_OK ||
195 tacXUnitConvert(&tac2, UNIT_SEC, &status)!=TPCERROR_OK)
196 {
197 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
198 tacFree(&tac1); tacFree(&tac2); return(2);
199 }
200 if(verbose>2) {
201 printf("fileformat := %s\n", tacFormattxt(tac1.format));
202 printf("tac1.sampleNr := %d\n", tac1.sampleNr);
203 printf("tac2.sampleNr := %d\n", tac2.sampleNr);
204 printf("fitSampleNr := %d\n", fitSampleNr);
205 printf("xunit := %s\n", unitName(tac1.tunit));
206 printf("yunit := %s\n", unitName(tac1.cunit));
207 printf("fitdur := %g s\n", fitdur);
208 }
209 if(fitSampleNr<8 || tac1.sampleNr<8 || tac2.sampleNr<8) {
210 fprintf(stderr, "Error: too few samples.\n");
211 tacFree(&tac1); tacFree(&tac2); return(2);
212 }
213
214
215 /* Check and set weights */
216 if(weights==0) {
217 if(!tacIsWeighted(&tac2)) {
219 for(int i=0; i<tac2.sampleNr; i++) tac2.w[i]=1.0;
220 }
221 } else if(weights==1) {
223 for(int i=0; i<tac2.sampleNr; i++) tac2.w[i]=1.0;
224 } else if(weights==2) {
225 if(tacWByFreq(&tac2, ISOTOPE_UNKNOWN, &status)!=TPCERROR_OK) {
226 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
227 tacFree(&tac1); tacFree(&tac2); return(2);
228 }
229 }
230
231
232 /*
233 * Copy function parameters into PAR struct for printing and saving
234 */
235 if(verbose>1) printf("preparing space for parameters\n");
236 PAR par; parInit(&par);
237 if(parAllocateWithTAC(&par, &tac2, maxParNr, &status)!=TPCERROR_OK) {
238 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
239 tacFree(&tac1); tacFree(&tac2); parFree(&par); return(3);
240 }
241 iftFree(&par.h); // remove stupid header info
242 /* set time and program name */
243 {
244 char buf[256];
245 time_t t=time(NULL);
246 iftPut(&par.h, "analysis_time", ctime_r_int(&t, buf), 0, NULL);
247 tpcProgramName(argv[0], 1, 1, buf, 256);
248 iftPut(&par.h, "program", buf, 0, NULL);
249 }
250 par.tacNr=1; par.parNr=2;
252 for(int i=0; i<par.tacNr; i++) {
253 par.r[i].model=modelCodeIndex("dispdelay");
254 par.r[i].dataNr=tacWSampleNr(&tac2);
255 par.r[i].start=tac2.x[0];
256 par.r[i].end=tac2.x[tac2.sampleNr-1];
257 }
258 /* Set parameter names */
259 strcpy(par.n[0].name, "tau"); par.n[0].unit=UNIT_SEC;
260 strcpy(par.n[1].name, "delay"); par.n[1].unit=UNIT_SEC;
261 /* set file names */
262 iftPut(&par.h, "inputfile", tacfile1, 0, NULL);
263 iftPut(&par.h, "datafile", tacfile2, 0, NULL);
264 /* set optimality criterion */
265 iftPut(&par.h, "optimality_criterion", optcritCode(optcrit), 0, NULL);
266
267
268 /*
269 * Fitting
270 */
271 if(verbose>1) printf("preparing for fitting\n");
272
273 drandSeed(1);
274
275 double yfit[tac2.sampleNr];
276 FITDATA fitdata;
277 {
278 /* Set data pointers for the fit */
279 fitdata.ni=tac1.sampleNr;
280 fitdata.xi=tac1.x;
281 fitdata.yi=tac1.c[0].y;
282 fitdata.no=tac2.sampleNr;
283 fitdata.xo=tac2.x;
284 fitdata.yo=tac2.c[0].y;
285 fitdata.ysim=yfit;
286 fitdata.w=tac2.w;
287 fitdata.optcrit=optcrit;
288 if(verbose>10) fitdata.verbose=verbose-10; else fitdata.verbose=0;
289 /* Set NLLS options */
290 NLOPT nlo; nloptInit(&nlo);
291 if(nloptAllocate(&nlo, par.parNr)!=TPCERROR_OK) {
292 fprintf(stderr, "Error: cannot initiate NLLS.\n");
293 tacFree(&tac1); tacFree(&tac2); parFree(&par); return(5);
294 }
295 nlo._fun=func_disp;
296 nlo.fundata=&fitdata;
297 nlo.totalNr=par.parNr;
298 /* Set initial values and limits */
299 nlo.xlower[0]=0.0; nlo.xupper[0]=60.0; nlo.xfull[0]=10.0; nlo.xdelta[0]=1.0; nlo.xtol[0]=0.02;
300 nlo.xlower[1]=0.0; nlo.xupper[1]=60.0; nlo.xfull[1]=10.0; nlo.xdelta[1]=1.0; nlo.xtol[1]=0.02;
301
302 if(verbose>2) printf("non-linear optimization\n");
303 if(nloptSimplex(&nlo, 0, &status)!=TPCERROR_OK) {
304 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
305 tacFree(&tac1); tacFree(&tac2); parFree(&par); nloptFree(&nlo); return(6);
306 }
307 if(verbose>3) {
308 nloptWrite(&nlo, stdout);
309 (void)func_disp(nlo.totalNr, nlo.xfull, nlo.fundata);
310 if(verbose>6) {
311 printf("measured and fitted TAC:\n");
312 for(unsigned int i=0; i<fitdata.no; i++)
313 printf("\t%g\t%g\t%g\t%g\n", fitdata.yi[i], fitdata.yo[i], fitdata.ysim[i], fitdata.w[i]);
314 }
315 double final_wss=0.0;
316 for(unsigned int i=0; i<fitdata.no; i++) {
317 double v=fitdata.ysim[i]-fitdata.yo[i];
318 final_wss+=fitdata.w[i]*v*v;
319 }
320 printf(" final_wss := %g\n", final_wss);
321 }
322
323 /* Simplex again, with new deltas */
324 for(unsigned int i=0; i<nlo.totalNr; i++) {
325 if(fabs(nlo.xdelta[i])<1.0E-100) continue;
326 if(nlo.xfull[i]>1.0E-06) nlo.xdelta[i]=0.0103*nlo.xfull[i];
327 else nlo.xdelta[i]*=0.0103;
328 nlo.xtol[i]*=0.5;
329 }
330 if(verbose>2) printf("non-linear optimization, 2nd time\n");
331 if(nloptSimplex(&nlo, 0, &status)!=TPCERROR_OK) {
332 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
333 tacFree(&tac1); tacFree(&tac2); parFree(&par); nloptFree(&nlo); return(6);
334 }
335 if(verbose>3) {
336 nloptWrite(&nlo, stdout);
337 (void)func_disp(nlo.totalNr, nlo.xfull, nlo.fundata);
338 if(verbose>6) {
339 printf("measured and fitted TAC:\n");
340 for(unsigned int i=0; i<fitdata.no; i++)
341 printf("\t%g\t%g\t%g\t%g\n", fitdata.yi[i], fitdata.yo[i], fitdata.ysim[i], fitdata.w[i]);
342 }
343 double final_wss=0.0;
344 for(unsigned int i=0; i<fitdata.no; i++) {
345 double v=fitdata.ysim[i]-fitdata.yo[i];
346 final_wss+=fitdata.w[i]*v*v;
347 }
348 printf(" final_wss := %g\n", final_wss);
349 }
350
351 /* and Simplex again, with new deltas */
352 for(unsigned int i=0; i<nlo.totalNr; i++) {
353 nlo.xdelta[i]=0.0093*nlo.xdelta[i];
354 nlo.xtol[i]*=0.001;
355 }
356 if(verbose>2) printf("non-linear optimization, 3rd time\n");
357 if(nloptSimplex(&nlo, 0, &status)!=TPCERROR_OK) {
358 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
359 tacFree(&tac1); tacFree(&tac2); parFree(&par); nloptFree(&nlo); return(6);
360 }
361
362 /* Call objective function again with the final parameters */
363 (void)func_disp(nlo.totalNr, nlo.xfull, nlo.fundata);
364 if(verbose>3) nloptWrite(&nlo, stdout);
365 if(verbose>6) {
366 printf("measured and fitted TAC:\n");
367 for(unsigned int i=0; i<fitdata.no; i++)
368 printf("\t%g\t%g\n", fitdata.yo[i], fitdata.ysim[i]);
369 }
370 double final_wss=0.0;
371 {
372 for(unsigned int i=0; i<fitdata.no; i++) {
373 double v=fitdata.ysim[i]-fitdata.yo[i];
374 final_wss+=fitdata.w[i]*v*v;
375 }
376 }
377 if(verbose>3) printf(" final_final_final_wss := %g\n", final_wss);
378 par.r[0].wss=final_wss; //nlo.funval;
379
380 /* Copy parameters */
381 for(int i=0; i<par.parNr; i++) par.r[0].p[i]=nlo.xfull[i];
382
383 nloptFree(&nlo);
384 }
385
386 /* Print and save parameters */
387 if(verbose>0 || !parfile[0]) parWrite(&par, stdout, PAR_FORMAT_TSV_UK, 1, NULL);
388 if(parfile[0]) {
389 par.format=parFormatFromExtension(parfile);
390 if(verbose>2) printf("parameter file format := %s\n", parFormattxt(par.format));
392 /* Save file */
393 if(verbose>1) printf(" saving %s\n", parfile);
394 FILE *fp=fopen(parfile, "w");
395 if(fp==NULL) {
396 fprintf(stderr, "Error: cannot open file for writing.\n");
397 tacFree(&tac1); tacFree(&tac2); parFree(&par); return(11);
398 }
399 int ret=parWrite(&par, fp, PAR_FORMAT_UNKNOWN, 1, &status);
400 fclose(fp);
401 if(ret!=TPCERROR_OK) {
402 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
403 tacFree(&tac1); tacFree(&tac2); parFree(&par); return(12);
404 }
405 if(verbose>0) printf("parameters saved in %s\n", parfile);
406 }
407
408
409
410 /*
411 * Plot measured and fitted data, if requested
412 */
413 if(svgfile[0]) {
414 if(verbose>1) printf("plotting measured and fitted data\n");
415 TAC fit; tacInit(&fit);
416 (void)tacDuplicate(&tac2, &fit);
417 for(int i=0; i<tac2.sampleNr; i++) fit.c[0].y[i]=fitdata.ysim[i];
418 /* Plot */
419 if(tacPlotFitSVG(&tac2, &fit, "", nan(""), nan(""), nan(""), nan(""), svgfile, &status)
420 != TPCERROR_OK)
421 {
422 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
423 tacFree(&tac1); tacFree(&tac2); parFree(&par); tacFree(&fit);
424 return(21);
425 }
426 if(verbose>0) printf("Measured and fitted data plotted in %s\n", svgfile);
427 tacFree(&fit);
428 }
429
430
431 tacFree(&tac1); tacFree(&tac2); parFree(&par);
432 return(0);
433}
434/*****************************************************************************/
435
436/*****************************************************************************
437 *
438 * Functions to be minimized
439 *
440 *****************************************************************************/
441double func_disp(int parNr, double *p, void *fdata)
442{
443 FITDATA *d=(FITDATA*)fdata;
444
445 if(d->verbose>0) {printf("%s()\n", __func__); fflush(stdout);}
446 if(parNr!=2) return(nan(""));
447 if(d->verbose>20) printf("p[]: %g %g\n", p[0], p[1]);
448
449 /* Add dispersion to the input TAC */
450 double dtac[2*d->ni];
451 double *buf=dtac+d->ni;
452 for(unsigned int i=0; i<d->ni; i++) dtac[i]=d->yi[i];
453 if(simDispersion(d->xi, dtac, d->ni, p[0], 0.0, buf)) return(nan(""));
454
455 /* Add delay and interpolate to output sample times */
456 for(unsigned int i=0; i<d->ni; i++) buf[i]=d->xi[i]+p[1];
457 if(liInterpolate(buf, dtac, d->ni, d->xo, d->ysim, NULL, NULL, d->no, 0, 1, 0)!=0) return(nan(""));
458
459 /* Calculate the weighted SS */
460 double wss=0.0;
461 for(unsigned int i=0; i<d->no; i++) {
462 if(isnan(d->ysim[i]) || isnan(d->xo[i]) || d->xo[i]<0.0) continue;
463 double v=d->ysim[i]-d->yo[i];
464 if(d->optcrit==OPTCRIT_LAD)
465 wss+=d->w[i]*fabs(v);
466 else
467 wss+=d->w[i]*v*v;
468 }
469
470 return(wss);
471}
472/*****************************************************************************/
473
474/*****************************************************************************/
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
unsigned int drandSeed(short int seed)
Make and optionally set the seed for rand(), drand, drandRange, and drandGaussian().
Definition gaussdev.c:27
void iftFree(IFT *ift)
Definition ift.c:37
int iftPut(IFT *ift, const char *key, const char *value, char comment, TPCSTATUS *status)
Definition ift.c:63
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.
unsigned int modelCodeIndex(const char *s)
Definition modell.c:237
void nloptInit(NLOPT *nlo)
Definition nlopt.c:25
int nloptAllocate(NLOPT *nlo, unsigned int parNr)
Definition nlopt.c:74
void nloptFree(NLOPT *nlo)
Definition nlopt.c:52
void nloptWrite(NLOPT *d, FILE *fp)
Definition nlopt.c:302
char * optcritCode(optimality_criterion id)
Definition optcrit.c:60
optimality_criterion optcritId(const char *s)
Definition optcrit.c:88
void parFree(PAR *par)
Definition par.c:75
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 parAllocateWithTAC(PAR *par, TAC *tac, int parNr, TPCSTATUS *status)
Allocate PAR based on data in TAC.
Definition partac.c:90
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
int simDispersion(double *x, double *y, const int n, const double tau1, const double tau2, double *tmp)
int nloptSimplex(NLOPT *nlo, unsigned int maxIter, TPCSTATUS *status)
Definition simplex.c:32
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
double(* _fun)(int, double *, void *)
Definition tpcnlopt.h:42
double * xupper
Definition tpcnlopt.h:33
double * xlower
Definition tpcnlopt.h:31
void * fundata
Definition tpcnlopt.h:44
double * xfull
Definition tpcnlopt.h:29
double * xdelta
Definition tpcnlopt.h:36
double * xtol
Definition tpcnlopt.h:39
unsigned int totalNr
Definition tpcnlopt.h:27
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
double wss
Definition tpcpar.h:72
int dataNr
Definition tpcpar.h:62
unsigned int model
Definition tpcpar.h:48
double * p
Definition tpcpar.h:64
double start
Definition tpcpar.h:52
double end
Definition tpcpar.h:54
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
double * w
Definition tpctac.h:111
TACC * c
Definition tpctac.h:117
weights weighting
Definition tpctac.h:115
unit tunit
Definition tpctac.h:109
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
void tacFree(TAC *tac)
Definition tac.c:106
int tacDuplicate(TAC *tac1, TAC *tac2)
Make a duplicate of TAC structure.
Definition tac.c:356
void tacInit(TAC *tac)
Definition tac.c:24
int tacPlotFitSVG(TAC *tac1, TAC *tac2, const char *main_title, const double x1, const double x2, const double y1, const double y2, const char *fname, TPCSTATUS *status)
Definition tacfitplot.c:27
char * tacFormattxt(tacformat c)
Definition tacio.c:98
int tacReadModelingData(const char *tissuefile, const char *inputfile1, const char *inputfile2, const char *inputfile3, double *fitdur, int cutInput, int *fitSampleNr, TAC *tis, TAC *inp, TPCSTATUS *status)
Read tissue and input data for modelling.
int tacXUnitConvert(TAC *tac, const int u, TPCSTATUS *status)
Definition tacunits.c:23
int tacIsWeighted(TAC *tac)
Definition tacw.c:24
unsigned int tacWSampleNr(TAC *tac)
Definition tacw.c:219
int tacWByFreq(TAC *tac, isotope isot, TPCSTATUS *status)
Definition tacw.c:134
Header file for libtpccm.
Header file for library libtpcextensions.
weights
Is data weighted, or are weight factors available with data?
@ WEIGHTING_OFF
Not weighted or weights not available (weights for all included samples are 1.0).
@ UNIT_SEC
seconds
@ TPCERROR_OK
No error.
char * unitName(int unit_code)
Definition units.c:143
Header file for libtpcfileutil.
Header file for library libtpcift.
@ ISOTOPE_UNKNOWN
Unknown.
Definition tpcisotope.h:51
Header file for libtpcli.
Header file for libtpclinopt.
Header file for libtpcmodels.
optimality_criterion
Optimality Criterion for statistical optimizations.
Definition tpcmodels.h:67
@ OPTCRIT_OLS
Ordinary Least Squares (sum-of-squares, SS).
Definition tpcmodels.h:69
@ OPTCRIT_LAD
Least Absolute Deviations (sum of absolute deviations, LAE, LAV, LAR).
Definition tpcmodels.h:71
@ OPTCRIT_UNKNOWN
Unknown optimality criterion.
Definition tpcmodels.h:68
Header file for library libtpcnlopt.
Header file for libtpcpar.
@ 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 libtpcrand.
Header file for library libtpctac.
Header file for libtpctacmod.