TPCCLIB
Loading...
Searching...
No Matches
fit_o2bl.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#include <unistd.h>
16/*****************************************************************************/
17#include "libtpcmisc.h"
18#include "libtpcmodel.h"
19#include "libtpccurveio.h"
20#include "libtpcsvg.h"
21#include "libtpcmodext.h"
22/*****************************************************************************/
23DFT blood, water;
24int fitframeNr=0, parNr=0;
25double pmin[MAX_PARAMETERS], pmax[MAX_PARAMETERS];
26double wss_wo_penalty;
27/* Local functions */
28double func(int parNr, double *p, void*);
29/*****************************************************************************/
30
31/*****************************************************************************/
32static char *info[] = {
33 "Non-linear fitting of compartmental model for whole body production of",
34 "labelled water during [O-15]O2 bolus PET studies.",
35 "Co(t) and Cw(t) represent the concentrations of [O-15]O2 and [O-15]H2O in",
36 "arterial blood, respectively, and Ct(t) represents the whole body tissue",
37 "compartment for [O-15]H2O.",
38 " ",
39 "The model is based on the following articles:",
40 "1. Huang S-C et al. Modelling approach for separating blood time-activity",
41 " curves in positron emission tomographic studies.",
42 " Phys Med Biol. 1991;36(6):749-761.",
43 "2. Iida H et al. Modelling approach to eliminate the need to separate",
44 " arterial plasma in oxygen-15 inhalation positron emission tomography.",
45 " J Nucl Med. 1993;34:1333-1340.",
46 "3. Kudomi N et al. A physiologic model for recirculation water correction",
47 " in CMRO2 assessment with 15O2 inhalation PET.",
48 " J Cereb Blood Flow Metab. 2009;29(2):355-364.",
49 " ______ ______ ______ ",
50 " | | k1 | | k3 | | ",
51 " | Co | ---> | Cw | ---> | Ct | ",
52 " | | | | <--- | | ",
53 " |______| |______| k4 |______| ",
54 " ",
55 "The corresponding differential equations are: ",
56 " dCw(t)/dt = k1*Cb(t-delay) - (k1+k3)*Cw(t) + k4*Ct(t) ",
57 " dCt(t)/dt = k3*Cw(t) - k4*Ct(t) ",
58 ", where Cb(t)=Co(t)+Cw(t) ",
59 "If k4 is assumed to zero, then:",
60 " dCw(t)/dt = k1*Cb(t-delay) - (k1+k3)*Cw(t)",
61 " ",
62 "Total arterial blood curve Cb(t), and Cw(t) are required for the fitting.",
63 "TAC files must be corrected for physical decay.",
64 "Cw(t) can be calculated from measured arterial plasma curve Ca(t), because",
65 "oxygen concentration in plasma is negligible, by multiplying it with",
66 "[O-15]H2O blood-to-plasma ratio, for example using program o2_p2w.",
67 " ",
68 "The estimated model parameters, or population averages, can then be used to",
69 "calculate the [O-15]O2 and [O-15]H2O blood curves using program o2metab.",
70 " ",
71 "Usage: @P [Options] cbtacfile cwtacfile resultfile",
72 " ",
73 "Options:",
74 " -model=<k3|k4>",
75 " Select the model: with k4 the full model is fitted (default);",
76 " with k3 it is assumed that k4=0.",
77 " Time delay is fitted in both models by default.",
78 " -delay=<time>",
79 " Constrain delay time to specified value (sec); fitted by default.",
80 " -k3=<value>",
81 " Constrain k3 to specified value (1/sec); fitted by default.",
82 " -k3k4=<value>",
83 " Constrain k3/k4 to specified value (unitless); fitted by default.",
84 " -w1 All weights are set to 1.0 (no weighting); by default, weights in",
85 " data file are used, if available.",
86 " -wf",
87 " Weight by sampling interval.",
88 " -svg=<Filename>",
89 " Fitted and measured TACs are plotted in specified SVG file.",
90 " -fit=<Filename>",
91 " Fitted Cw(t) TAC is written in specified TAC file.",
92 " -stdoptions", // List standard options like --help, -v, etc
93 " ",
94 "Results can be saved in RES, IFT, or HTML format.",
95 "File will contain the parameters k1, k1+k3, and delay (model k3), or, ",
96 "k1, k3, k3/k4, and delay (model k4).",
97 " ",
98 "See also: o2metab, o2_p2w, sim_o2bl, fit_mo2, b2t_mo2",
99 " ",
100 "Keywords: input, oxygen, blood, metabolite correction",
101 0};
102/*****************************************************************************/
103
104/*****************************************************************************/
105/* Turn on the globbing of the command line, since it is disabled by default in
106 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
107 In Unix&Linux wildcard command line processing is enabled by default. */
108/*
109#undef _CRT_glob
110#define _CRT_glob -1
111*/
112int _dowildcard = -1;
113/*****************************************************************************/
114
115/*****************************************************************************/
119int main(int argc, char **argv)
120{
121 int ai, help=0, version=0, verbose=1;
122 char *cptr,
123 btacfile[FILENAME_MAX], wtacfile[FILENAME_MAX],
124 parfile[FILENAME_MAX], ftacfile[FILENAME_MAX],
125 svgfile[FILENAME_MAX];
126 int model=2; // 1=k3; 2=k4
127 int weights=0; // 0=default, 1=no weighting, 2=frequency
128 double fixedDelay; // Fitted, if NaN
129 double fixedk3; // Fitted, if NaN
130 double fixedk3k4; // Fitted, if NaN
131 int fitparNr=0;
132 int ret, times_changed=0;
133 RES res;
134
135
136 /*
137 * Get arguments
138 */
139 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
140 dftInit(&blood); dftInit(&water); resInit(&res);
141 btacfile[0]=wtacfile[0]=parfile[0]=ftacfile[0]=svgfile[0]=(char)0;
142 fixedDelay=fixedk3=fixedk3k4=nan("");
143 /* Options */
144 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
145 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
146 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(cptr==NULL) continue;
147 if(strncasecmp(cptr, "MODEL=", 6)==0) {
148 cptr+=6;
149 if(strncasecmp(cptr, "K3", 2)==0) {model=1; continue;}
150 if(strncasecmp(cptr, "K4", 2)==0) {model=2; continue;}
151 fprintf(stderr, "Error: invalid model setting.\n"); return(1);
152 } else if(strncasecmp(cptr, "SVG=", 4)==0) {
153 strlcpy(svgfile, cptr+4, FILENAME_MAX);
154 if(strlen(svgfile)>0) continue;
155 } else if(strncasecmp(cptr, "FIT=", 4)==0) {
156 strlcpy(ftacfile, cptr+4, FILENAME_MAX);
157 if(strlen(ftacfile)>0) continue;
158 } else if(strcasecmp(cptr, "W1")==0) {
159 weights=1; continue;
160 } else if(strcasecmp(cptr, "WF")==0) {
161 weights=2; continue;
162 } else if(strncasecmp(cptr, "DELAY=", 6)==0) {
163 fixedDelay=atof_dpi(cptr+6); if(!isnan(fixedDelay)) continue;
164 } else if(strncasecmp(cptr, "K3=", 3)==0) {
165 fixedk3=atof_dpi(cptr+3); if(!isnan(fixedk3)) continue;
166 } else if(strncasecmp(cptr, "K3K4=", 5)==0) {
167 fixedk3k4=atof_dpi(cptr+5); if(!isnan(fixedk3k4)) continue;
168 }
169 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
170 return(1);
171 } else break;
172
173 /* Print help or version? */
174 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
175 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
176 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
177
178 /* Process other arguments, starting from the first non-option */
179 for(; ai<argc; ai++) {
180 if(!btacfile[0]) {strlcpy(btacfile, argv[ai], FILENAME_MAX); continue;}
181 if(!wtacfile[0]) {strlcpy(wtacfile, argv[ai], FILENAME_MAX); continue;}
182 if(!parfile[0]) {strlcpy(parfile, argv[ai], FILENAME_MAX); continue;}
183 fprintf(stderr, "Error: too many arguments: '%s'.\n", argv[ai]);
184 return(1);
185 }
186
187 /* Is something missing? */
188 if(!parfile[0]) {
189 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
190 return(1);
191 }
192 fitparNr=parNr=model+2;
193 if(!isnan(fixedDelay)) fitparNr--;
194 if(!isnan(fixedk3)) fitparNr--;
195 if(!isnan(fixedk3k4)) fitparNr--;
196
197 /* In verbose mode print arguments and options */
198 if(verbose>1) {
199 printf("btacfile := %s\n", btacfile);
200 printf("wtacfile := %s\n", wtacfile);
201 printf("parfile := %s\n", parfile);
202 if(ftacfile[0]) printf("ftacfile := %s\n", ftacfile);
203 if(svgfile[0]) printf("svgfile := %s\n", svgfile);
204 printf("model := %d\n", model);
205 printf("parNr := %d\n", parNr);
206 if(!isnan(fixedDelay)) printf("fixedDelay := %g\n", fixedDelay);
207 if(!isnan(fixedk3)) printf("fixedk3 := %g\n", fixedk3);
208 if(!isnan(fixedk3k4)) printf("fixedk3k4 := %g\n", fixedk3k4);
209 printf("weights := %d\n", weights);
210 }
211
212 /*
213 * Read total BTAC
214 */
215 if(verbose>1) printf("reading '%s'\n", btacfile);
216 if(dftRead(btacfile, &blood)) {
217 fprintf(stderr, "Error in reading '%s': %s\n", btacfile, dfterrmsg);
218 return(2);
219 }
220 if(blood.frameNr<5) {
221 fprintf(stderr, "Error: not enough input samples for decent fitting.\n");
222 dftEmpty(&blood); return(2);
223 }
224 /* Sort the samples by time in case data is catenated from several curves */
225 (void)dftSortByFrame(&blood);
226 /* Check for NA's */
227 if(dft_nr_of_NA(&blood) > 0) {
228 fprintf(stderr, "Error: missing sample(s) in %s\n", btacfile);
229 dftEmpty(&blood); return(2);
230 }
231 if(blood.voiNr>1) {
232 fprintf(stderr, "Warning: BTAC file may not be valid.\n");
233 blood.voiNr=1;
234 }
235 /* If sample times are minutes, change them to sec */
236 if(blood.timeunit==TUNIT_UNKNOWN && blood.x[blood.frameNr-1]<20.) {
237 blood.timeunit=TUNIT_MIN;
238 }
239 if(blood.timeunit==TUNIT_MIN) {
240 if(verbose>0) fprintf(stderr, "Note: BTAC sample times are converted to sec.\n");
241 dftMin2sec(&blood);
242 }
243
244
245 /*
246 * Read H2O BTAC
247 */
248 if(verbose>1) printf("reading '%s'\n", wtacfile);
249 if(dftRead(wtacfile, &water)) {
250 fprintf(stderr, "Error in reading '%s': %s\n", wtacfile, dfterrmsg);
251 dftEmpty(&blood); return(3);
252 }
253 if(water.frameNr<fitparNr) {
254 fprintf(stderr, "Error: not enough samples for decent fitting.\n");
255 dftEmpty(&blood); dftEmpty(&water); return(3);
256 }
257 /* Sort the samples by time in case data is catenated from several curves */
258 (void)dftSortByFrame(&water);
259 if(water.voiNr>1) {
260 fprintf(stderr, "Warning: [O-15]H2O BTAC file may not be valid.\n");
261 water.voiNr=1;
262 }
263 /* If sample times are minutes, change them to sec */
264 if(water.timeunit==TUNIT_UNKNOWN && water.x[water.frameNr-1]<20.) {
265 water.timeunit=TUNIT_MIN;
266 }
267 if(water.timeunit==TUNIT_MIN) {
268 if(verbose>0) fprintf(stderr, "Note: [O-15]H2O BTAC sample times are converted to sec.\n");
269 dftMin2sec(&water);
270 times_changed=1;
271 }
272 /* Get min and max X and Y */
273 double tstart, tstop, miny, maxy;
274 ret=dftMinMax(&water, &tstart, &tstop, &miny, &maxy);
275 if(ret!=0 || tstop<=0.0 || maxy<=0.0) {
276 fprintf(stderr, "Error: invalid contents in %s\n", wtacfile);
277 dftEmpty(&blood); dftEmpty(&water); return(3);
278 }
279 if(tstart<0.0) fprintf(stderr, "Warning: negative x value(s).\n");
280 if(miny<0.0) fprintf(stderr, "Warning: negative y value(s).\n");
281 /* Set fit duration */
282 fitframeNr=water.frameNr;
283 if(verbose>1) {
284 printf("fitframeNr := %d\n", fitframeNr);
285 printf("tstart := %g\n", tstart);
286 printf("tstop := %g\n", tstop);
287 printf("miny := %g\n", miny);
288 printf("maxy := %g\n", maxy);
289 }
290
291 /* Check and set weights */
292 if(weights==0) {
293 if(water.isweight==0) {
294 water.isweight=1; for(int i=0; i<water.frameNr; i++) water.w[i]=1.0;}
295 } else if(weights==1) {
296 water.isweight=1; for(int i=0; i<water.frameNr; i++) water.w[i]=1.0;
297 } else if(weights==2) {
298 dftWeightByFreq(&water);
299 }
300 /* Set weight to 0 for missing values */
301 {
302 int i, n=0;
303 for(i=0; i<water.frameNr; i++) if(isnan(water.voi[0].y[i])) water.w[i]=0.0; else n++;
304 if(n<=fitparNr+1) {
305 fprintf(stderr, "Error: not enough good samples for decent fitting.\n");
306 dftEmpty(&blood); dftEmpty(&water); return(3);
307 }
308 }
309
310
311 /*
312 * Prepare the room for the results
313 */
314 if(verbose>1) printf("initializing result data\n");
315 ret=res_allocate_with_dft(&res, &water); if(ret!=0) {
316 fprintf(stderr, "Error: cannot setup memory for results.\n");
317 dftEmpty(&blood); dftEmpty(&water); return(5);
318 }
319 /* Copy titles & filenames */
320 tpcProgramName(argv[0], 1, 1, res.program, 256);
321 strcpy(res.datafile, wtacfile);
322 strcpy(res.bloodfile, btacfile);
323 strcpy(res.fitmethod, "TGO");
324 /* Constants */
325 res.isweight=water.isweight;
326 /* Set data range */
327 sprintf(res.datarange, "%g - %g %s", tstart, tstop, dftTimeunit(water.timeunit));
328 res.datanr=fitframeNr;
329 /* Set current time to results */
330 res.time=time(NULL);
331 /* Set parameter number, including also the extra "parameters"
332 and the parameter names and units */
333 res.parNr=parNr+1;
334 {
335 int i;
336 i=0; strcpy(res.parname[i], "k1"); strcpy(res.parunit[i], "1/sec");
337 if(model==1) {
338 i++; strcpy(res.parname[i], "k1+k3"); strcpy(res.parunit[i], "1/sec");
339 } else {
340 i++; strcpy(res.parname[i], "k3"); strcpy(res.parunit[i], "1/sec");
341 }
342 if(model==2) {
343 i++; strcpy(res.parname[i], "k3/k4"); strcpy(res.parunit[i], "");
344 }
345 i++; strcpy(res.parname[i], "delay"); strcpy(res.parunit[i], "sec");
346 i++; strcpy(res.parname[i], "WSS"); strcpy(res.parunit[i], "");
347 }
348
349
350 /*
351 * Fitting
352 */
353 if(verbose>2) printf("preparing for fitting\n");
354 double p[MAX_PARAMETERS], wss;
355 /* Set parameter range */
356 pmin[0]=-0.2*tstop; pmax[0]=0.2*tstop; /* delay */
357 pmin[1]=0.000; pmax[1]=0.005; /* k1 */
358 pmin[2]=0.000; pmax[2]=0.010; /* k3 */
359 pmin[3]=0.500; pmax[3]=100.0; /* k3/k4; must be >0 */
360 if(!isnan(fixedDelay)) pmin[0]=pmax[0]=fixedDelay;
361 if(!isnan(fixedk3)) pmin[2]=pmax[2]=fixedk3;
362 if(!isnan(fixedk3k4)) pmin[3]=pmax[3]=fixedk3k4;
363 /* Fit data */
366 ret=tgo(
367 pmin, pmax, func, NULL, parNr, 6,
368 &wss, p, 1000, 0, verbose-8);
369 if(ret>0) {
370 fprintf(stderr, "Error in optimization (%d).\n", ret);
371 dftEmpty(&blood); dftEmpty(&water); resEmpty(&res); return(6);
372 }
373 if(verbose>1) {
374 printf("fitted parameters:");
375 for(int i=0; i<parNr; i++) printf(" %g", p[i]);
376 printf("\nwss := %g\n", wss);
377 }
378 /* Correct fitted parameters to match constraints like inside the function */
379 (void)modelCheckParameters(parNr, pmin, pmax, p, p, NULL);
380 /* Set parameters in results */
381 {
382 res.voi[0].parameter[parNr-1]=p[0]; // delay
383 res.voi[0].parameter[0]=p[1]; // k1
384 res.voi[0].parameter[1]=p[2]; // k3
385 if(model==1) res.voi[0].parameter[1]+=res.voi[0].parameter[0]; // k1+k3
386 if(model==2) res.voi[0].parameter[2]=p[3]; // k3/k4
387 res.voi[0].parameter[parNr]=wss_wo_penalty;
388 }
389 /* function messes up the frame start times, so make sure those are not used
390 after fitting */
392
393
394 /*
395 * Print results on screen
396 */
397 if(verbose>0) {resPrint(&res); fprintf(stdout, "\n");}
398
399
400 /*
401 * Save results
402 */
403 if(verbose>1) printf("writing results in %s\n", parfile);
404 /* Check whether user wants to save parameters in IFT or RES format */
405 cptr=filenameGetExtension(parfile);
406 if(strcasecmp(cptr, ".RES")==0) {
407 ret=resWrite(&res, parfile, verbose-4);
408 if(ret) {
409 fprintf(stderr, "Error in writing '%s': %s\n", parfile, reserrmsg);
410 dftEmpty(&blood); dftEmpty(&water); resEmpty(&res);
411 return(11);
412 }
413 } else {
414 IFT ift; iftInit(&ift);
415 ret=res2ift(&res, &ift, verbose-3);
416 if(ret) {
417 fprintf(stderr, "Error in converting results.\n");
418 dftEmpty(&blood); dftEmpty(&water); resEmpty(&res); iftEmpty(&ift);
419 return(12);
420 }
421 ret=iftWrite(&ift, parfile, 0);
422 if(ret) {
423 fprintf(stderr, "Error in writing '%s'.\n", parfile);
424 dftEmpty(&blood); dftEmpty(&water); resEmpty(&res); iftEmpty(&ift);
425 return(13);
426 }
427 iftEmpty(&ift);
428 }
429 if(verbose>0) fprintf(stdout, "Model parameters written in %s\n", parfile);
430
431
432 /*
433 * Saving and/or plotting of fitted TACs
434 */
435 if(svgfile[0] || ftacfile[0]) {
436
437 /* Create a DFT containing fitted TACs */
438 char tmp[64];
439 DFT fit;
440 dftInit(&fit); ret=dftdup(&water, &fit);
441 if(ret) {
442 fprintf(stderr, "Error: cannot save fitted curves.\n");
443 dftEmpty(&blood); dftEmpty(&water); dftEmpty(&fit); resEmpty(&res);
444 return(21);
445 }
446 for(int ri=0; ri<water.voiNr; ri++) for(int fi=0; fi<fitframeNr; fi++)
447 fit.voi[ri].y[fi]=fit.voi[ri].y2[fi];
448 fit.frameNr=fitframeNr;
449 fit.isweight=0;
450
451 /* Save SVG plot of fitted and original data */
452 if(svgfile[0]) {
453 if(verbose>1) printf("saving SVG plot\n");
454 sprintf(tmp, "Fitted [O-15]H2O BTAC");
455 if(strlen(water.studynr)>0) {
456 strcat(tmp, ": "); strcat(tmp, water.studynr);
457 }
458 ret=plot_fitrange_svg(&water, &fit, tmp, 0.0, 1.02*tstop, 0.0, nan(""), svgfile, verbose-8);
459 if(ret) {
460 fprintf(stderr, "Error (%d) in writing '%s'.\n", ret, svgfile);
461 dftEmpty(&blood); dftEmpty(&water); dftEmpty(&fit); resEmpty(&res);
462 return(30+ret);
463 }
464 if(verbose>0) printf("Plots written in %s\n", svgfile);
465 }
466
467 /* Save fitted TACs */
468 if(ftacfile[0]) {
469 if(verbose>1) printf("saving fitted curves\n");
470 if(times_changed) dftMin2sec(&fit);
471 if(dftWrite(&fit, ftacfile)) {
472 fprintf(stderr, "Error in writing '%s': %s\n", ftacfile, dfterrmsg);
473 dftEmpty(&blood); dftEmpty(&water); dftEmpty(&fit); resEmpty(&res);
474 return(22);
475 }
476 if(verbose>0) printf("Fitted TACs written in %s\n", ftacfile);
477 }
478
479 dftEmpty(&fit);
480 }
481
482 if(verbose>0) printf("\n");
483 dftEmpty(&blood); dftEmpty(&water); resEmpty(&res);
484 return(0);
485}
486/*****************************************************************************/
487
488/*****************************************************************************
489 *
490 * Functions to be minimized
491 *
492 *****************************************************************************/
493double func(int parNr, double *p, void *fdata)
494{
495 int i, ret;
496 double dt, k1, k2, k3, k4=0.0, wss=0.0;
497 double pa[MAX_PARAMETERS], penalty=1.0, d;
498
499
500 /* Check parameters against the constraints */
501 ret=modelCheckParameters(parNr, pmin, pmax, p, pa, &penalty);
502 if(fdata) {}
503 /* Get parameters */
504 dt=pa[0]; k1=k2=pa[1]; k3=pa[2]; if(parNr>=4) k4=k3/pa[3];
505
506 /* Simulate the water BTAC (compartment 1, not the sum of compartments) */
507 ret=simC3s(
508 blood.x, blood.voi[0].y, blood.frameNr,
509 k1, k2, k3, k4, 0.0, 0.0,
510 blood.voi[0].y3, blood.voi[0].y2, NULL, NULL);
511 if(ret) {
512 printf("error %d in simulation\n", ret);
513 return(nan(""));
514 }
515
516 /* Correct simulated H2O data for delay; this equals O15-water */
517 for(i=0; i<blood.frameNr; i++) blood.x1[i]=blood.x[i]+dt;
518
519 /* Interpolate & integrate to measured PET frames */
520 if(water.timetype==DFT_TIME_STARTEND)
521 ret=interpolate4pet(
522 blood.x1, blood.voi[0].y2, blood.frameNr,
523 water.x1, water.x2, water.voi[0].y2, NULL, NULL, fitframeNr);
524 else
525 ret=interpolate(
526 blood.x1, blood.voi[0].y2, blood.frameNr,
527 water.x, water.voi[0].y2, NULL, NULL, fitframeNr);
528 if(ret) {
529 printf("error %d in interpolation\n", ret);
530 return(nan(""));
531 }
532
533 /* Calculate error */
534 for(i=0, wss=0.0; i<fitframeNr; i++) if(water.w[i]>0.0) {
535 d=water.voi[0].y[i]-water.voi[0].y2[i];
536 wss+=water.w[i]*d*d;
537 }
538 wss_wo_penalty=wss;
539 wss*=penalty;
540 if(0) printf("k1=%g k2=%g k3=%g k4=%g dt=%g => %g\n",
541 k1, k2, k3, k4, dt, wss);
542
543 return(wss);
544}
545/*****************************************************************************/
546
547/*****************************************************************************/
int modelCheckParameters(int par_nr, double *lower_p, double *upper_p, double *test_p, double *accept_p, double *penalty)
Definition constraints.c:15
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
int dftWrite(DFT *data, char *filename)
Definition dftio.c:594
int res_allocate_with_dft(RES *res, DFT *dft)
Definition dftres.c:14
void dftMin2sec(DFT *dft)
Definition dftunit.c:145
char * filenameGetExtension(char *s)
Get the last extension of a filename.
Definition filename.c:139
void iftEmpty(IFT *ift)
Definition ift.c:60
void iftInit(IFT *ift)
Definition ift.c:45
int iftWrite(IFT *ift, char *filename, int verbose)
Definition iftfile.c:282
int interpolate(double *x, double *y, int nr, double *newx, double *newy, double *newyi, double *newyii, int newnr)
Linear interpolation and integration.
Definition integr.c:28
int interpolate4pet(double *x, double *y, int nr, double *newx1, double *newx2, double *newy, double *newyi, double *newyii, int newnr)
Interpolate and integrate TAC to PET frames.
Definition integr.c:510
Header file for libtpccurveio.
char reserrmsg[64]
Definition result.c:6
void resInit(RES *res)
Definition result.c:52
#define DFT_TIME_MIDDLE
void resPrint(RES *res)
Definition result.c:186
int resWrite(RES *res, char *filename, int verbose)
Definition result.c:565
int res2ift(RES *res, IFT *ift, int verbose)
Definition resift.c:14
#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
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition strext.c:245
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
int simC3s(double *t, double *ca, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double *ct, double *cta, double *ctb, double *ctc)
Definition simulate.c:27
Header file for libtpcmodext.
int dftWeightByFreq(DFT *dft)
int plot_fitrange_svg(DFT *dft1, DFT *dft2, char *main_title, double x1, double x2, double y1, double y2, char *fname, int verbose)
Definition plotfit.c:16
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
int parNr
char parname[MAX_RESPARAMS][MAX_RESPARNAME_LEN+1]
int datanr
ResVOI * voi
char program[1024]
char datarange[128]
int isweight
char datafile[FILENAME_MAX]
char fitmethod[128]
char parunit[MAX_RESPARAMS][MAX_RESPARNAME_LEN+1]
char bloodfile[FILENAME_MAX]
time_t time
double parameter[MAX_RESPARAMS]
double * y2
double * y
double * y3