TPCCLIB
Loading...
Searching...
No Matches
p2t_di.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 "libtpcmisc.h"
16#include "libtpcmodel.h"
17#include "libtpccurveio.h"
18/*****************************************************************************/
19
20/*****************************************************************************/
21static char *info[] = {
22 "Simulation of PET tissue time-radioactivity concentration curve (TTAC) using",
23 "dual-input four-tissue compartmental models. Input consists of parent tracer",
24 "and metabolite concentration curves in arterial plasma (Cap and Cam) and",
25 "total radioactivity concentration in arterial blood (Cb).",
26 " ",
27 "Tissue compartments for parent tracer are in series [1] (by default):",
28 " ",
29 " _____ K1 ____ k3 ____ k5 ____ k7 ",
30 " | Cap | ----> | C1 | ----> | C2 | ----> | C3 | ----> ",
31 " |_____| <---- |____| <---- |____| <---- |____| ",
32 " k2 | k4 k6 ",
33 " km| ",
34 " v ",
35 " _____ K1m ____ ",
36 " | Cam | ----> | C4 | ",
37 " |_____| <---- |____| ",
38 " k2m ",
39 " ",
40 " dC1(t)/dt = K1*Cap(T) - (k2+k3+km)*C1(T) + k4*C2(T) ",
41 " dC2(t)/dt = k3*C1(T) - (k4+k5)*C2(T) + k6*C3(T) ",
42 " dC3(t)/dt = k5*C2(T) - (k6+k7)*C3(T) ",
43 " dC4(t)/dt = K1m*Cam(T) + km*C1(T) - k2m*C4(T) ",
44 " Ct(T) = C1(T) + C2(T) + C3(T) + C4(T) ",
45 " Cvb(T) = Cab(T) - dCt(t)/dt / f ",
46 " Cpet(T)= Vb*fA*Cab(T) + Vb*(1-fA)*Cvb(T) + (1-Vb)*Ct(T) ",
47 " ",
48 ", or, optionally, the 2nd and 3rd tissue compartments are parallel [2],",
49 "often used to represent specific and non-specific binding:",
50 " ",
51 " ____ ",
52 " | C3 | k7 ",
53 " |____| ----> ",
54 " ^ | ",
55 " k5 | | k6 ",
56 " | v ",
57 " _____ K1 ____ k3 ____ ",
58 " | Cap | ----> | C1 | ----> | C2 | ",
59 " |_____| <---- |____| <---- |____| ",
60 " k2 | k4 ",
61 " km| ",
62 " v ",
63 " _____ K1m ____ ",
64 " | Cam | ----> | C4 | ",
65 " |_____| <---- |____| ",
66 " k2m ",
67 " ",
68 " dC1(t)/dt = K1*Ca(T) - (k2+k3+k5+km)*C1(T) + k4*C2(T) + k6*C3(T) ",
69 " dC2(t)/dt = k3*C1(T) - k4*C2(T) ",
70 " dC3(t)/dt = k5*C2(T) - (k6+k7)*C3(T) ",
71 " dC4(t)/dt = K1m*Cam(T) + km*C1(T) - k2m*C4(T) ",
72 " Ct(T) = C1(T) + C2(T) + C3(T) + C4(T) ",
73 " Cvb(T) = Cab(T) - dCt(t)/dt / f ",
74 " Cpet(T)= Vb*fA*Cab(T) + Vb*(1-fA)*Cvb(T) + (1-Vb)*Ct(T) ",
75 " ",
76 "Usage: @P [options] parentfile metabolitefile bloodfile"
77 " K1 k2 k3 k4 k5 k6 k7 km K1m k2m Vb simfile",
78 " ",
79 "Options:",
80 " -paral[lel]",
81 " Model with parallel compartments C2 and C3 is applied.",
82 " -ser[ies]",
83 " Model with compartments C1, C2, and C3 in series is applied (default).",
84 " -sub | -nosub",
85 " TACs of sub-compartments (C1, C2 and C3) are written (-sub)",
86 " or not written (-nosub, default) into the output file.",
87 " -f=<Perfusion (ml/(min*ml) or ml/(sec*ml))>",
88 " Difference between concentrations in venous and arterial blood can",
89 " be simulated if tissue perfusion (f>K1) is specified with this option",
90 " and arterial fraction of vascular volume is set with option -fA;",
91 " by default it is assumed that venous and arterial activities are",
92 " the same (f>>K1).",
93 " -fA=<Arterial fraction of vascular volume (%)>",
94 " Difference between concentrations in venous and arterial blood can",
95 " be simulated if arterial fraction of vascular volume is specified with",
96 " this option and tissue perfusion is set with option -f;",
97 " by default it is assumed that Vb consists of only arterial blood.",
98 " -stdoptions", // List standard options like --help, -v, etc
99 " ",
100 "If the times in plasma file are in seconds, the units of rate constants",
101 "(k's) and blood flow (f) must also be specified as 1/sec.",
102 "For accurate results, plasma TAC should have very short sampling intervals.",
103 "To reduce the model, k7, k5, and k3 can be set to 0.",
104 " ",
105 "Simulated TACs are written in ASCII format with columns:",
106 " 1) Sample time",
107 " 2) Total tissue activity concentration (Cpet)",
108 " 3) Activity concentration in 1st tissue compartment, (1-Vb)*C1 (optional)",
109 " 4) Activity concentration in 2nd tissue compartment, (1-Vb)*C2 (optional)",
110 " 5) Activity concentration in 3rd tissue compartment, (1-Vb)*C3 (optional)",
111 " 6) Activity concentration in 4th tissue compartment, (1-Vb)*C4 (optional)",
112 " 7) Arterial contribution to tissue activity, Vb*fA*Cab (optional)",
113 " 8) Venous contribution to tissue activity, Vb*(1-fA)*Cvb (optional)",
114 " ",
115 "References:",
116 "1. TPCMOD0001 Appendix B.",
117 "2. TPCMOD0001 Appendix C.",
118 " ",
119 "See also: sim_3tcm, tacadd, tacren, simframe, tacformat, dft2img",
120 " ",
121 "Keywords: TAC, simulation, modelling, compartmental model, dual-input",
122 0};
123/*****************************************************************************/
124
125/*****************************************************************************/
126/* Turn on the globbing of the command line, since it is disabled by default in
127 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
128 In Unix&Linux wildcard command line processing is enabled by default. */
129/*
130#undef _CRT_glob
131#define _CRT_glob -1
132*/
133int _dowildcard = -1;
134/*****************************************************************************/
135
136/*****************************************************************************/
140int main(int argc, char **argv)
141{
142 int ai, help=0, version=0, verbose=1;
143 int fi, ri, ret, save_only_total=1;
144 int parallel=0;
145 DFT plasma, sim;
146 double k1, k2, k3, k4, k5, k6, k7, km, k1m, k2m, f, Vb, fA;
147 double *t, *cap, *cam, *cab, *cpet, *ct1, *ct2, *ct3, *ct4, *ctab, *ctvb;
148 char pfile[FILENAME_MAX], mfile[FILENAME_MAX], bfile[FILENAME_MAX],
149 sfile[FILENAME_MAX], *cptr, tmp[FILENAME_MAX+128];
150
151
152
153 /*
154 * Get arguments
155 */
156 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
157 pfile[0]=mfile[0]=bfile[0]=sfile[0]=(char)0;
158 k1=k2=k3=k4=k5=k6=k7=km=k1m=k2m=Vb=-1.0;
159 f=0.0; fA=1.0;
160 dftInit(&plasma); dftInit(&sim);
161 /* Options */
162 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
163 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(cptr==NULL) continue;
164 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
165 cptr=argv[ai]+1;
166 if(strncasecmp(cptr, "NOSUB", 5)==0) {
167 save_only_total=1; continue;
168 } else if(strncasecmp(cptr, "SUB", 3)==0) {
169 save_only_total=0; continue;
170 } else if(strncasecmp(cptr, "PARALLEL", 5)==0) {
171 parallel=1; continue;
172 } else if(strncasecmp(cptr, "SERIES", 3)==0) {
173 parallel=0; continue;
174 } else if(strncasecmp(cptr, "F=", 2)==0) {
175 ret=atof_with_check(cptr+2, &f); if(ret==0 && f>=0.0) continue;
176 } else if(strncasecmp(cptr, "FA=", 3)==0) {
177 ret=atof_with_check(cptr+3, &fA);
178 if(ret==0 && fA>=0.0 && fA<100.0) {fA*=0.01; continue;}
179 }
180 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
181 return(1);
182 } else break;
183
184 /* Print help or version? */
185 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
186 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
187 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
188
189 /* Process other arguments, starting from the first non-option */
190 for(; ai<argc; ai++) {
191 if(!pfile[0]) {
192 strcpy(pfile, argv[ai]); continue;
193 } else if(!mfile[0]) {
194 strcpy(mfile, argv[ai]); continue;
195 } else if(!bfile[0]) {
196 strcpy(bfile, argv[ai]); continue;
197 } else if(k1<0.0) {
198 k1=atof_dpi(argv[ai]); if(k1<0.0) k1=0.0; continue;
199 } else if(k2<0.0) {
200 k2=atof_dpi(argv[ai]); if(k2<0.0) k2=0.0; continue;
201 } else if(k3<0.0) {
202 k3=atof_dpi(argv[ai]); if(k3<0.0) k3=0.0; continue;
203 } else if(k4<0.0) {
204 k4=atof_dpi(argv[ai]); if(k4<0.0) k4=0.0; continue;
205 } else if(k5<0.0) {
206 k5=atof_dpi(argv[ai]); if(k5<0.0) k5=0.0; continue;
207 } else if(k6<0.0) {
208 k6=atof_dpi(argv[ai]); if(k6<0.0) k6=0.0; continue;
209 } else if(k7<0.0) {
210 k7=atof_dpi(argv[ai]); if(k7<0.0) k7=0.0; continue;
211 } else if(km<0.0) {
212 km=atof_dpi(argv[ai]); if(km<0.0) km=0.0; continue;
213 } else if(k1m<0.0) {
214 k1m=atof_dpi(argv[ai]); if(k1m<0.0) k1m=0.0; continue;
215 } else if(k2m<0.0) {
216 k2m=atof_dpi(argv[ai]); if(k2m<0.0) k2m=0.0; continue;
217 } else if(Vb<0.0) {
218 ret=atof_with_check(argv[ai], &Vb);
219 if(ret==0 && Vb>=0.0 && Vb<100.0) {Vb*=0.01; continue;}
220 } else if(!sfile[0]) {
221 strcpy(sfile, argv[ai]); continue;
222 } else {
223 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
224 return(1);
225 }
226 }
227
228 /* Is something missing? */
229 if(!sfile[0] || Vb<0.0) {tpcPrintUsage(argv[0], info, stdout); return(1);}
230 /* Or otherwise wrong? */
231 if(f>0.0 && k1>0.0 && f<k1) {
232 fprintf(stderr, "Error: f cannot be lower than K1!\n"); return(1);}
233 if(f>0.0 && k1m>0.0 && f<k1m) {
234 fprintf(stderr, "Error: f cannot be lower than K1m!\n"); return(1);}
235 if(Vb<=0.0 && (fA<1.0 || f>0.0))
236 fprintf(stderr, "Warning: options -fA and -f are ignored when Vb=0%%\n");
237 else if(f>0.0 && fA==1.0)
238 fprintf(stderr, "Warning: option -f is ignored when fA=100%%\n");
239 if(k1>1.0E+08 || k2>1.0E+08 || k3>1.0E+08 || k4>1.0E+08 || k5>1.0E+08 ||
240 k6>1.0E+08 || k7>1.0E+08 || km>1.0E+08 || k1m>1.0E+08 || k2m>1.0E+08) {
241 fprintf(stderr, "Error: too high rate constant.\n"); return(1);
242 }
243
244 /* In verbose mode print arguments and options */
245 if(verbose>1) {
246 printf("pfile := %s\n", pfile);
247 printf("mfile := %s\n", mfile);
248 printf("bfile := %s\n", bfile);
249 printf("sfile := %s\n", sfile);
250 printf("rate_constants := %g %g %g %g %g %g %g %g %g %g\n",
251 k1, k2, k3, k4, k5, k6, k7, km, k1m, k2m);
252 printf("Vb := %g\n", Vb);
253 printf("fA := %g\n", fA);
254 printf("f := %g\n", f);
255 printf("save_only_total := %d\n", save_only_total);
256 printf("parallel := %d\n", parallel);
257 }
258
259
260 /*
261 * Read plasma parent data
262 */
263 if(verbose>1) printf("reading plasma parent TAC\n");
264 if(dftRead(pfile, &plasma)) {
265 fprintf(stderr, "Error in reading '%s': %s\n", pfile, dfterrmsg);
266 dftEmpty(&plasma); return(2);
267 }
268 if(plasma.frameNr<3) {
269 fprintf(stderr, "Error: too few samples in plasma data.\n");
270 dftEmpty(&plasma); return(2);
271 }
272 if(plasma.voiNr>1) {
273 fprintf(stderr, "Error: plasma data contains more than one curve.\n");
274 dftEmpty(&plasma); return(2);
275 }
276 if(plasma.timeunit==TUNIT_UNKNOWN) {
277 plasma.timeunit=TUNIT_MIN;
278 if(verbose>=0) printf("assuming that time unit is min\n");
279 }
280 strcpy(plasma.voi[0].voiname, "Parent");
281 strcpy(plasma.voi[0].name, plasma.voi[0].voiname);
282
283
284 /*
285 * Read plasma metabolite data; interpolate it to the parent times
286 */
287 if(verbose>1) printf("reading plasma metabolite TAC\n");
288 if(dftRead(mfile, &sim)) {
289 fprintf(stderr, "Error in reading '%s': %s\n", mfile, dfterrmsg);
290 dftEmpty(&plasma); dftEmpty(&sim); return(3);
291 }
292 if(sim.frameNr<3) {
293 fprintf(stderr, "Error: too few samples in metabolite data.\n");
294 dftEmpty(&plasma); dftEmpty(&sim); return(3);
295 }
296 if(sim.voiNr>1) {
297 fprintf(stderr, "Error: metabolite data contains more than one curve.\n");
298 dftEmpty(&plasma); dftEmpty(&sim); return(3);
299 }
300 /* Check that blood has been measured for long enough */
301 if(sim.x[sim.frameNr-1] < 0.85*plasma.x[plasma.frameNr-1]) {
302 fprintf(stderr, "Warning: metabolite TAC is shorter than parent TAC.\n");
303 }
304 /* Allocate memory for interpolated metabolite data */
305 if(dftAddmem(&plasma, 1)) {
306 fprintf(stderr, "Error: cannot allocate memory for metabolite TAC.\n");
307 dftEmpty(&plasma); dftEmpty(&sim); return(3);
308 }
309 strcpy(plasma.voi[1].voiname, "Metab");
310 strcpy(plasma.voi[1].name, plasma.voi[1].voiname);
311 /* Interpolate */
312 ret=interpolate(sim.x, sim.voi[0].y, sim.frameNr, plasma.x, plasma.voi[1].y,
313 plasma.voi[1].y2, NULL, plasma.frameNr);
314 dftEmpty(&sim);
315 if(ret) {
316 fprintf(stderr, "Error: cannot interpolate metabolite data.\n");
317 dftEmpty(&plasma); return(3);
318 }
319 plasma.voiNr++;
320 if(verbose>20) dftPrint(&plasma);
321 /* Verify that metabolite TAC is > 0 */
322 if(plasma.voi[1].y2[plasma.frameNr-1]<=0.0) {
323 fprintf(stderr, "Warning: plasma metabolite concentration <= 0.\n");
324 }
325
326
327 /*
328 * Read blood data; interpolate it to the plasma times
329 */
330 if(verbose>1) printf("reading blood\n");
331 if(dftRead(bfile, &sim)) {
332 fprintf(stderr, "Error in reading '%s': %s\n", bfile, dfterrmsg);
333 dftEmpty(&plasma); dftEmpty(&sim); return(3);
334 }
335 if(sim.frameNr<3) {
336 fprintf(stderr, "Error: too few samples in blood data.\n");
337 dftEmpty(&plasma); dftEmpty(&sim); return(3);
338 }
339 if(sim.voiNr>1) {
340 fprintf(stderr, "Error: blood data contains more than one curve.\n");
341 dftEmpty(&plasma); dftEmpty(&sim); return(3);
342 }
343 /* Check that blood has been measured for long enough */
344 if(sim.x[sim.frameNr-1] < 0.67*plasma.x[plasma.frameNr-1]) {
345 fprintf(stderr, "Warning: blood TAC is much shorter than plasma TAC.\n");
346 }
347 /* Allocate memory for interpolated blood data */
348 if(dftAddmem(&plasma, 1)) {
349 fprintf(stderr, "Error: cannot allocate memory for blood TAC.\n");
350 dftEmpty(&plasma); dftEmpty(&sim); return(3);
351 }
352 strcpy(plasma.voi[2].voiname, "Blood");
353 strcpy(plasma.voi[2].name, plasma.voi[2].voiname);
354 /* Interpolate */
355 ret=interpolate(sim.x, sim.voi[0].y, sim.frameNr, plasma.x, plasma.voi[2].y,
356 plasma.voi[2].y2, NULL, plasma.frameNr);
357 dftEmpty(&sim);
358 if(ret) {
359 fprintf(stderr, "Error: cannot interpolate blood data.\n");
360 dftEmpty(&plasma); return(3);
361 }
362 plasma.voiNr++;
363 if(verbose>8) dftPrint(&plasma);
364 /* Verify that blood TAC is > 0 */
365 if(plasma.voi[2].y2[plasma.frameNr-1]<=0.0) {
366 fprintf(stderr, "Warning: blood concentration <= 0.\n");
367 }
368
369
370 if(verbose>5) {
371 strcpy(tmp, "simulation_input.dat");
372 printf("Saving input in %s for testing.\n", tmp);
373 if(dftWrite(&plasma, tmp)) {
374 fprintf(stderr, "Error in writing '%s': %s\n", tmp, dfterrmsg);
375 }
376 }
377
378
379 /*
380 * Allocate memory for simulated tissue data.
381 */
382 if(verbose>1) printf("allocating memory\n");
383 /* allocate */
384 ret=dftSetmem(&sim, plasma.frameNr, 7);
385 if(ret) {
386 fprintf(stderr,
387 "Error (%d): cannot allocate memory for simulated TACs.\n", ret);
388 dftEmpty(&plasma); return(4);
389 }
390 sim.frameNr=plasma.frameNr; sim.voiNr=7;
391 /* Copy times & header info */
392 dftCopymainhdr(&plasma, &sim);
393 for(fi=0; fi<sim.frameNr; fi++) {
394 sim.x[fi]=plasma.x[fi];
395 sim.x1[fi]=plasma.x1[fi]; sim.x2[fi]=plasma.x2[fi];
396 }
397 /* column headers */
398 for(ri=0; ri<sim.voiNr; ri++) {
399 sim.voi[ri].sw=0;
400 switch(ri) {
401 case 0: strcpy(sim.voi[ri].voiname, "Cpet");
402 sim.voi[ri].size=100.0;
403 break;
404 case 1: strcpy(sim.voi[ri].voiname, "C1");
405 sim.voi[ri].size=100.*(1.-Vb);
406 break;
407 case 2: strcpy(sim.voi[ri].voiname, "C2");
408 sim.voi[ri].size=100.*(1.-Vb);
409 break;
410 case 3: strcpy(sim.voi[ri].voiname, "C3");
411 sim.voi[ri].size=100.*(1.-Vb);
412 break;
413 case 4: strcpy(sim.voi[ri].voiname, "C4");
414 sim.voi[ri].size=100.*(1.-Vb);
415 break;
416 case 5: strcpy(sim.voi[ri].voiname, "Cab");
417 sim.voi[ri].size=100.0*fA*Vb;
418 break;
419 case 6: strcpy(sim.voi[ri].voiname, "Cvb");
420 sim.voi[ri].size=100.0*(1.0-fA)*Vb;
421 break;
422 }
423 strcpy(sim.voi[ri].hemisphere, ""); strcpy(sim.voi[ri].place, "");
424 strcpy(sim.voi[ri].name, sim.voi[ri].voiname);
425 }
426
427 /*
428 * Simulate TACs
429 */
430 if(verbose>1) printf("simulating\n");
431 t=sim.x; cap=plasma.voi[0].y; cam=plasma.voi[1].y; cab=plasma.voi[2].y;
432 cpet=sim.voi[0].y; ct1=sim.voi[1].y; ct2=sim.voi[2].y; ct3=sim.voi[3].y;
433 ct4=sim.voi[4].y; ctab=sim.voi[5].y; ctvb=sim.voi[6].y;
434 if(parallel==0)
435 ret=simC4DIvs(t, cap, cam, cab, sim.frameNr,
436 k1, k2, k3, k4, k5, k6, k7, km, k1m, k2m, f, Vb, fA,
437 cpet, ct1, ct2, ct3, ct4, ctab, ctvb, verbose-1);
438 else
439 ret=simC4DIvp(t, cap, cam, cab, sim.frameNr,
440 k1, k2, k3, k4, k5, k6, k7, km, k1m, k2m, f, Vb, fA,
441 cpet, ct1, ct2, ct3, ct4, ctab, ctvb, verbose-1);
442 dftEmpty(&plasma);
443 if(ret!=0) {
444 fprintf(stderr, "Error (%d) in simulation.\n", ret);
445 dftEmpty(&sim); return(8);
446 }
447
448
449 /*
450 * Save simulated TACs
451 */
452 if(verbose>1) printf("saving PET curves\n");
454 if(save_only_total) sim.voiNr=1;
455 else if(Vb<=0.0) sim.voiNr=5;
456 else sim.voiNr=7;
457 /* Set comments */
458 dftSetComments(&sim);
459 sprintf(tmp, "# parentfile := %s\n", pfile); strcat(sim.comments, tmp);
460 sprintf(tmp, "# metabolitefile := %s\n", mfile); strcat(sim.comments, tmp);
461 sprintf(tmp, "# bloodfile := %s\n", bfile); strcat(sim.comments, tmp);
462 strcpy(tmp, "# model := ");
463 if(parallel==0) strcat(tmp, "C4DIVS\n"); else strcat(tmp, "C4DIVP\n");
464 strcat(sim.comments, tmp);
465 sprintf(tmp, "# K1 := %g\n", k1); strcat(sim.comments, tmp);
466 sprintf(tmp, "# k2 := %g\n", k2); strcat(sim.comments, tmp);
467 sprintf(tmp, "# k3 := %g\n", k3); strcat(sim.comments, tmp);
468 sprintf(tmp, "# k4 := %g\n", k4); strcat(sim.comments, tmp);
469 sprintf(tmp, "# k5 := %g\n", k5); strcat(sim.comments, tmp);
470 sprintf(tmp, "# k6 := %g\n", k6); strcat(sim.comments, tmp);
471 sprintf(tmp, "# k7 := %g\n", k7); strcat(sim.comments, tmp);
472 sprintf(tmp, "# km := %g\n", km); strcat(sim.comments, tmp);
473 sprintf(tmp, "# K1m := %g\n", k1m); strcat(sim.comments, tmp);
474 sprintf(tmp, "# k2m := %g\n", k2m); strcat(sim.comments, tmp);
475 if(Vb>0.0) {
476 sprintf(tmp, "# f := %g\n", f); strcat(sim.comments, tmp);
477 sprintf(tmp, "# Vb := %g [%%]\n", 100.0*Vb); strcat(sim.comments, tmp);
478 sprintf(tmp, "# fA := %g [%%]\n", 100.0*fA); strcat(sim.comments, tmp);
479 }
480 /* Set file format to PMOD, if extension is .tac */
481 if(!strcasecmp(filenameGetExtension(sfile), ".tac"))
483 /* Some format has to be set anyway, and simple format would lose information */
486 /* Write file */
487 if(dftWrite(&sim, sfile)) {
488 fprintf(stderr, "Error in writing '%s': %s\n", sfile, dfterrmsg);
489 dftEmpty(&sim); return(11);
490 }
491 if(verbose>0) fprintf(stdout, "simulated TAC(s) written in %s\n", sfile);
492
493 return(0);
494}
495/*****************************************************************************/
496
497/*****************************************************************************/
int atof_with_check(char *double_as_string, double *result_value)
Definition decpoint.c:107
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 dftAddmem(DFT *dft, int voiNr)
Definition dft.c:107
void dftSetComments(DFT *dft)
Definition dft.c:1326
int dftSetmem(DFT *data, int frameNr, int voiNr)
Definition dft.c:57
void dftEmpty(DFT *data)
Definition dft.c:20
int dftCopymainhdr(DFT *dft1, DFT *dft2)
Definition dft.c:561
int dftRead(char *filename, DFT *data)
Definition dftio.c:22
int DFT_NR_OF_DECIMALS
Definition dftio.c:13
void dftPrint(DFT *data)
Definition dftio.c:538
int dftWrite(DFT *data, char *filename)
Definition dftio.c:594
char * filenameGetExtension(char *s)
Get the last extension of a filename.
Definition filename.c:139
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
Header file for libtpccurveio.
#define DFT_FORMAT_PMOD
#define DFT_FORMAT_STANDARD
#define DFT_FORMAT_PLAIN
#define DFT_FORMAT_UNKNOWN
Header file for libtpcmisc.
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:40
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 simC4DIvp(double *t, double *ca1, double *ca2, double *cb, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double k7, double km, double k1b, double k2b, double f, double vb, double fa, double *scpet, double *sct1, double *sct2, double *sct3, double *sct1b, double *sctab, double *sctvb, int verbose)
Definition simulate.c:1533
int simC4DIvs(double *t, double *ca1, double *ca2, double *cb, int nr, double k1, double k2, double k3, double k4, double k5, double k6, double k7, double km, double k1b, double k2b, double f, double vb, double fa, double *scpet, double *sct1, double *sct2, double *sct3, double *sct1b, double *sctab, double *sctvb, int verbose)
Definition simulate.c:1724
int _type
Voi * voi
int timeunit
double * x1
char comments[_DFT_COMMENT_LEN+1]
int voiNr
double * x2
int frameNr
double * x
double size
double * y2
char voiname[MAX_REGIONSUBNAME_LEN+1]
char sw
double * y
char name[MAX_REGIONNAME_LEN+1]
char hemisphere[MAX_REGIONSUBNAME_LEN+1]
char place[MAX_REGIONSUBNAME_LEN+1]