TPCCLIB
Loading...
Searching...
No Matches
sim_av.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 "tpcift.h"
17#include "tpctac.h"
18#include "tpcpar.h"
19#include "tpctacmod.h"
20#include "tpccm.h"
21/*****************************************************************************/
22
23/*****************************************************************************/
24static char *info[] = {
25 "Simulation of venous BTAC (Cv) from arterial BTAC (Ca), based on",
26 "three-tissue compartmental model:",
27 " ",
28 " ____ K1 ____ k3 ____ k5 ____ ",
29 " | Ca | ----> | C1 | ----> | C2 | ----> | C3 | ",
30 " |____| <---- |____| <---- |____| <---- |____| ",
31 " k2 k4 k6 ",
32 " ",
33 " dC1(t)/dt = K1*Ca(T) - (k2+k3)*C1(T) + k4*C2(T) ",
34 " dC2(t)/dt = k3*C1(T) - (k4+k5)*C2(T) + k6*C3(T) ",
35 " dC3(t)/dt = k5*C2(T) - k6*C3(T) ",
36 " Ct(T) = C1(T) + C2(T) + C3(T) ",
37 " Cv(T) = Ca(T) - dCt(t)/dt / f ",
38 " ",
39 "Usage: @P [options] parfile [abtacfile simfile]",
40 " ",
41 "Options:",
42 " -ttac=<Filename>",
43 " Simulated tissue curve is written in specified file.",
44 " -stdoptions", // List standard options like --help, -v, etc
45 " ",
46 "To create a template parameter file, do not enter names for input and",
47 "simulated TACs. Obligatory parameters are f, K1, K1/k2, k3, k3/k4.",
48 "Parameters k5 and k5/k6 are optional.",
49 "If parameter file does not contain units, then per min and per mL units",
50 "are assumed.",
51 "For accurate results, BTAC should have very short sampling intervals.",
52 "To reduce the model, k3 or k3/k4 can be set to 0, to apply one-tissue or",
53 "irreversible two-tissue model, respectively, or k5 or k5/k6 can be set to 0,",
54 "to apply two-tissue or irreversible three-tissue model, respectively.",
55 " ",
56 "See also: sim_3tcm, tacadd, taccalc, tac2svg, convexpf, fit_xexp",
57 " ",
58 "Keywords: input, simulation, modelling, compartmental model",
59 0};
60/*****************************************************************************/
61
62/*****************************************************************************/
63/* Turn on the globbing of the command line, since it is disabled by default in
64 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
65 In Unix&Linux wildcard command line processing is enabled by default. */
66/*
67#undef _CRT_glob
68#define _CRT_glob -1
69*/
70int _dowildcard = -1;
71/*****************************************************************************/
72
73/*****************************************************************************/
75
90 double *t,
92 double *cab,
94 const int nr,
96 double f,
98 double k1,
100 double k2,
102 double k3,
104 double k4,
106 double k5,
108 double k6,
110 double *cvb,
112 double *ct
113) {
114 int i;
115 double b, c, d, w, z, dt2;
116 double cai, ca_last, t_last;
117 double ct1, ct1_last, ct2, ct2_last, ct3, ct3_last;
118 double ct1i, ct1i_last, ct2i, ct2i_last, ct3i, ct3i_last;
119
120
121 /* Check for data */
122 if(nr<2) return 1;
123 if(cvb==NULL) return 2;
124
125 /* Check actual parameter number */
126 if(!(f>=0.0) || !(k1>=0.0) || k1>f) return 3;
127 if(k3<=0.0) {k3=0.0; if(k2<=0.0) k2=0.0;}
128 else if(k5<=0.0) {k5=0.0; if(k4<=0.0) k4=0.0;}
129 else {if(k6<=0.0) k6=0.0;}
130
131 /* Calculate curves */
132 t_last=0.0; if(t[0]<t_last) t_last=t[0];
133 cai=ca_last=0.0;
134 ct1_last=ct2_last=ct3_last=ct1i_last=ct2i_last=ct3i_last=0.0;
135 ct1=ct2=ct3=ct1i=ct2i=ct3i=0.0;
136 for(i=0; i<nr; i++) {
137 /* delta time / 2 */
138 dt2=0.5*(t[i]-t_last);
139 /* calculate values */
140 if(dt2<0.0) {
141 return 5;
142 } else if(dt2>0.0) {
143 /* arterial integral */
144 cai+=(cab[i]+ca_last)*dt2;
145 /* partial results */
146 b=ct1i_last+dt2*ct1_last;
147 c=ct2i_last+dt2*ct2_last;
148 d=ct3i_last+dt2*ct3_last;
149 w=k4 + k5 - (k5*k6*dt2)/(1.0+k6*dt2);
150 z=1.0+w*dt2;
151 /* 1st tissue compartment and its integral */
152 ct1 = (
153 + k1*z*cai + (k3*k4*dt2 - (k2+k3)*z)*b
154 + k4*c + k4*k6*dt2*d/(1.0+k6*dt2)
155 ) / ( z*(1.0 + dt2*(k2+k3)) - k3*k4*dt2*dt2 );
156 ct1i = ct1i_last + dt2*(ct1_last+ct1);
157 /* 2nd tissue compartment and its integral */
158 ct2 = (k3*ct1i - w*c + k6*d/(1.0+k6*dt2)) / z;
159 ct2i = ct2i_last + dt2*(ct2_last+ct2);
160 /* 3rd tissue compartment and its integral */
161 ct3 = (k5*ct2i - k6*d) / (1.0 + k6*dt2);
162 ct3i = ct3i_last + dt2*(ct3_last+ct3);
163 }
164 if(f>0.0) {
165 double dct = k1*cab[i] - k2*ct1;
166 cvb[i] = cab[i] - dct/f;
167 } else
168 cvb[i]=cab[i];
169
170 /* copy values to argument arrays; set very small values to zero */
171 if(ct!=NULL) {ct[i]=ct1+ct2+ct3; if(fabs(ct[i])<1.0e-12) ct[i]=0.0;}
172
173 /* prepare to the next loop */
174 t_last=t[i]; ca_last=cab[i];
175 ct1_last=ct1; ct1i_last=ct1i;
176 ct2_last=ct2; ct2i_last=ct2i;
177 ct3_last=ct3; ct3i_last=ct3i;
178 }
179
180 return 0;
181}
182
183/*****************************************************************************/
184
185/*****************************************************************************/
189int main(int argc, char **argv)
190{
191 int ai, help=0, version=0, verbose=1;
192 char blofile[FILENAME_MAX], simfile[FILENAME_MAX], parfile[FILENAME_MAX];
193 char tisfile[FILENAME_MAX];
194 unsigned int parNr=0;
195 PAR par;
196 int ret;
197
198
199 /*
200 * Get arguments
201 */
202 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
203 blofile[0]=simfile[0]=parfile[0]=tisfile[0]=(char)0;
204 parInit(&par);
205 /* Options */
206 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
207 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
208 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
209 if(strncasecmp(cptr, "TTAC=", 5)==0 && strlen(cptr)>5) {
210 strlcpy(tisfile, cptr+5, FILENAME_MAX); continue;
211 }
212 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
213 return(1);
214 } else break; // tac name argument may start with '-'
215
216 TPCSTATUS status; statusInit(&status);
217 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
218 status.verbose=verbose-1;
219
220 /* Print help or version? */
221 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
222 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
223 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
224
225 /* Process other arguments, starting from the first non-option */
226 if(ai<argc) strlcpy(parfile, argv[ai++], FILENAME_MAX);
227 if(ai<argc) strlcpy(blofile, argv[ai++], FILENAME_MAX);
228 if(ai<argc) strlcpy(simfile, argv[ai++], FILENAME_MAX);
229 if(ai<argc) {
230 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
231 return(1);
232 }
233
234 /* Is something missing? */
235 if(!parfile[0]) {
236 fprintf(stderr, "Error: missing parameter file; use option --help\n");
237 return(1);
238 }
239 if(blofile[0] && !simfile[0]) {
240 fprintf(stderr, "Error: missing filename.\n");
241 return(1);
242 }
243 if(tisfile[0] && (strcasecmp(tisfile, blofile)==0 || strcasecmp(tisfile, simfile)==0)) {
244 fprintf(stderr, "Error: invalid file name for simulated TTAC.\n");
245 return(1);
246 }
247
248
249 /* In verbose mode print arguments and options */
250 if(verbose>1) {
251 printf("parfile := %s\n", parfile);
252 printf("abtacfile := %s\n", blofile);
253 printf("simfile := %s\n", simfile);
254 if(!tisfile[0]) printf("ttacfile := %s\n", tisfile);
255 }
256
257 /*
258 * Make template parameter file, if no other file names were given, and then quit
259 */
260 if(!blofile[0]) {
261 parNr=7;
262 ret=parAllocate(&par, parNr, 3);
263 if(ret) {
264 fprintf(stderr, "Error: cannot allocate memory for parameters.\n");
265 parFree(&par); return(1);
266 }
267 par.parNr=parNr; par.tacNr=3;
268 strcpy(par.n[0].name, "f"); par.n[0].unit=UNIT_ML_PER_ML_MIN;
269 strcpy(par.n[1].name, "K1"); par.n[1].unit=UNIT_ML_PER_ML_MIN;
270 strcpy(par.n[2].name, "K1/k2"); par.n[2].unit=UNIT_ML_PER_ML;
271 strcpy(par.n[3].name, "k3"); par.n[3].unit=UNIT_PER_MIN;
272 strcpy(par.n[4].name, "k3/k4"); par.n[4].unit=UNIT_UNITLESS;
273 strcpy(par.n[5].name, "k5"); par.n[5].unit=UNIT_PER_MIN;
274 strcpy(par.n[6].name, "k5/k6"); par.n[6].unit=UNIT_UNITLESS;
275 for(int i=0; i<par.tacNr; i++) {
276 sprintf(par.r[i].name, "btac%d", 1+i);
277 par.r[i].model=0;
278 par.r[i].p[0]=0.2;
279 par.r[i].p[1]=0.1;
280 par.r[i].p[2]=1.0;
281 par.r[i].p[3]=0.05;
282 par.r[i].p[4]=1.0;
283 par.r[i].p[5]=0.0;
284 par.r[i].p[6]=0.0;
285 }
286 int i=1;
287 par.r[i].p[1]=0.1;
288 par.r[i].p[2]=1.0;
289 par.r[i].p[3]=0.1;
290 par.r[i].p[4]=2.0;
291 i=2;
292 par.r[i].p[1]=0.1;
293 par.r[i].p[2]=1.0;
294 par.r[i].p[3]=0.1;
295 par.r[i].p[4]=0.5;
296 if(verbose>1) printf("writing %s\n", parfile);
297 FILE *fp; fp=fopen(parfile, "w");
298 if(fp==NULL) {
299 fprintf(stderr, "Error: cannot open file for writing (%s)\n", parfile);
300 parFree(&par); return(11);
301 }
302 ret=parWrite(&par, fp, PAR_FORMAT_TSV_UK, 1, &status);
303 fclose(fp); parFree(&par);
304 if(ret!=TPCERROR_OK) {fprintf(stderr, "Error: cannot write %s\n", parfile); return(11);}
305 return(0);
306 }
307
308
309 /*
310 * Read parameter file to get parameters for the simulation, and
311 * set model in case it was given with command-line option.
312 */
313 if(verbose>1) fprintf(stdout, "reading %s\n", parfile);
314 if(parRead(&par, parfile, &status)) {
315 fprintf(stderr, "Error: %s (%s)\n", errorMsg(status.error), parfile);
316 parFree(&par);
317 return(3);
318 }
319 if(verbose>5) parWrite(&par, stdout, PAR_FORMAT_TSV_UK, 1, NULL);
320 /* Check the validity of model and its parameters */
321 for(int i=0; i<par.tacNr; i++) {
322 /* check that we got at least five parameters */
323 if((unsigned int)par.parNr<5) {
324 fprintf(stderr, "Error: invalid parameters for selected model.\n");
325 parFree(&par); return(3);
326 }
327 /* check that we can find the obligatory model parameters */
328 ret=0;
329 if(parFindParameter(&par, "f")<0) ret++;
330 if(parFindParameter(&par, "K1")<0) ret++;
331 if(parFindParameter(&par, "K1/k2")<0) ret++;
332 if(parFindParameter(&par, "k3")<0) ret++;
333 if(parFindParameter(&par, "k3/k4")<0) ret++;
334 if(ret) {
335 fprintf(stderr, "Error: required parameters not available.\n");
336 parFree(&par); return(3);
337 }
338 }
339
340 /*
341 * Read input TACs
342 */
343 if(verbose>1) fprintf(stdout, "reading input TAC\n");
344 TAC input; tacInit(&input);
345 ret=tacReadModelingInput(blofile, NULL, NULL, &input, &status);
346 if(ret!=TPCERROR_OK) {
347 fprintf(stderr, "Error: %s (input files)\n", errorMsg(status.error));
348 tacFree(&input); parFree(&par); return(4);
349 }
350 if(verbose>2) {
351 printf("fileformat := %s\n", tacFormattxt(input.format));
352 printf("tacNr := %d\n", input.tacNr);
353 printf("sampleNr := %d\n", input.sampleNr);
354 printf("xunit := %s\n", unitName(input.tunit));
355 printf("yunit := %s\n", unitName(input.cunit));
356 }
357 if(verbose>10) tacWrite(&input, stdout, TAC_FORMAT_PMOD, 1, NULL);
358 if(input.sampleNr<3) {
359 fprintf(stderr, "Error: too few samples in input TAC.\n");
360 tacFree(&input); parFree(&par); return(4);
361 }
362 if(input.sampleNr<10) {
363 fprintf(stderr, "Warning: too few samples for reliable simulation.\n");
364 }
365
366
367 /*
368 * Check parameter and data units
369 */
370 {
371 int i, punit;
372 /* Perfusion */
373 i=parFindParameter(&par, "f");
374 if(i>=0) {
375 punit=par.n[i].unit;
376 if(punit==UNIT_ML_PER_DL_MIN) {
377 if(verbose>1) printf("Note: converting f from per dL to per mL.\n");
379 for(int j=0; j<par.tacNr; j++) par.r[j].p[i]*=0.01;
380 }
381 if(input.tunit==UNIT_MIN && (punit==UNIT_PER_SEC || punit==UNIT_ML_PER_ML_SEC)) {
382 if(verbose>1) printf("Note: converting f from per sec to per min.\n");
383 if(punit==UNIT_PER_SEC) par.n[i].unit=UNIT_PER_MIN;
384 else par.n[i].unit=UNIT_ML_PER_ML_MIN;
385 for(int j=0; j<par.tacNr; j++) par.r[j].p[i]*=60.;
386 } else if(input.tunit==UNIT_SEC && (punit==UNIT_PER_MIN || punit==UNIT_ML_PER_ML_MIN)) {
387 if(verbose>1) printf("Note: converting f from per min to per sec.\n");
388 if(punit==UNIT_PER_MIN) par.n[i].unit=UNIT_PER_SEC;
389 else par.n[i].unit=UNIT_ML_PER_ML_SEC;
390 for(int j=0; j<par.tacNr; j++) par.r[j].p[i]/=60.;
391 }
392 }
393 /* Rate constants */
394 for(int ri=1; ri<=6; ri++) {
395 char rcname[3]; sprintf(rcname, "k%d", ri);
396 if((i=parFindParameter(&par, rcname))>=0) {
397 punit=par.n[i].unit;
398 if(input.tunit==UNIT_MIN && (punit==UNIT_PER_SEC || punit==UNIT_ML_PER_ML_SEC)) {
399 if(verbose>1) printf("Note: converting %s from per sec to per min.\n", rcname);
400 if(punit==UNIT_PER_SEC) par.n[i].unit=UNIT_PER_MIN;
401 else par.n[i].unit=UNIT_ML_PER_ML_MIN;
402 for(int j=0; j<par.tacNr; j++) par.r[j].p[i]*=60.;
403 } else if(input.tunit==UNIT_SEC && (punit==UNIT_PER_MIN || punit==UNIT_ML_PER_ML_MIN)) {
404 if(verbose>1) printf("Note: converting %s from per min to per sec.\n", rcname);
405 if(punit==UNIT_PER_MIN) par.n[i].unit=UNIT_PER_SEC;
406 else par.n[i].unit=UNIT_ML_PER_ML_SEC;
407 for(int j=0; j<par.tacNr; j++) par.r[j].p[i]/=60.;
408 }
409 }
410 }
411 }
412
413
414 /*
415 * Allocate space for simulated data
416 */
417 if(verbose>1) fprintf(stdout, "allocating space for simulated BTACs\n");
418 TAC sim; tacInit(&sim);
419 ret=tacAllocateWithPAR(&sim, &par, input.sampleNr, &status);
420 if(ret!=TPCERROR_OK) {
421 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
422 tacFree(&input); tacFree(&sim); parFree(&par); return(4);
423 }
426 sim.cunit=input.cunit;
427 sim.tunit=input.tunit;
428 sim.format=input.format;
429 sim.isframe=0;
430 for(int j=0; j<sim.sampleNr; j++) sim.x[j]=input.x[j];
431
432 TAC ttac; tacInit(&ttac);
433 if(tisfile[0]) {
434 if(verbose>1) fprintf(stdout, "allocating space for simulated TTACs\n");
435 ret=tacDuplicate(&sim, &ttac);
436 if(ret!=TPCERROR_OK) {
437 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
438 tacFree(&sim); tacFree(&input); tacFree(&sim); parFree(&par); return(4);
439 }
440 }
441
442
443 /*
444 * Simulation
445 */
446 if(verbose>1) printf("simulating\n");
447 double *px=input.x;
448 double *py=input.c[0].y;
449 double K1, k2, k3, k4, k5, k6, Flow;
450 int i;
451 for(i=0; i<par.tacNr; i++) {
452 if(verbose>2) printf("simulating %s\n", sim.c[i].name);
453 /* Create pointers for simulated data. */
454 double *pcvb=sim.c[i].y;
455 double *pct=NULL; if(tisfile[0]) pct=ttac.c[i].y;
456 /* Get parameters */
457 K1=k2=k3=k4=Flow=nan("");
458 Flow=parGetParameter(&par, "f", i);
459 if(isnan(Flow)) Flow=parGetParameter(&par, "Flow", i);
460 K1=parGetParameter(&par, "K1", i);
461 k2=parGetParameter(&par, "k2", i);
462 if(isnan(k2)) {
463 double r=parGetParameter(&par, "K1/k2", i);
464 if(!(r>0.0)) k2=nan(""); else k2=K1/r;
465 }
466 k3=parGetParameter(&par, "k3", i);
467 k4=parGetParameter(&par, "k4", i);
468 if(isnan(k4)) {
469 double r=parGetParameter(&par, "k3/k4", i);
470 if(!(r>0.0)) k4=nan(""); else k4=k3/r;
471 }
472 k5=parGetParameter(&par, "k5", i);
473 k6=parGetParameter(&par, "k6", i);
474 if(isnan(k6)) {
475 double r=parGetParameter(&par, "k5/k6", i);
476 if(!(r>0.0)) k6=nan(""); else k6=k5/r;
477 }
478 /* Verify and fix parameters */
479 if(!(Flow>=0.0) || !(K1>=0.0) || k2<0 || k3<0 || k4<0 || k5<0 || k6<0) {
480 fprintf(stderr, "Error: invalid rate constant.\n");
481 tacFree(&sim); tacFree(&ttac); tacFree(&input); parFree(&par); return(5);
482 }
483 if(K1>Flow) {
484 fprintf(stderr, "Error: K1 cannot be higher than f.\n");
485 tacFree(&sim); tacFree(&ttac); tacFree(&input); parFree(&par); return(5);
486 }
487 if(Flow==0.0) {K1=k2=k3=k4=k5=k6=0.0;}
488 if(K1==0.0) {k2=k3=k4=k5=k6=0.0;}
489 if(k3==0.0) {k4=k5=k6=0.0;}
490 if(k5==0.0) k6=0.0;
491 if(verbose>3) {
492 printf("f := %g\n", Flow);
493 printf("K1 := %g\n", K1);
494 printf("k2 := %g\n", k2);
495 if(!isnan(k3)) printf("k3 := %g\n", k3);
496 if(!isnan(k4)) printf("k4 := %g\n", k4);
497 if(!isnan(k5)) printf("k5 := %g\n", k5);
498 if(!isnan(k6)) printf("k6 := %g\n", k6);
499 }
500 /* Simulate */
501 if(isnan(Flow)) Flow=0.0;
502 if(isnan(K1)) K1=0.0;
503 if(isnan(k2)) k2=0.0;
504 if(isnan(k3)) k3=0.0;
505 if(isnan(k4)) k4=0.0;
506 if(isnan(k5)) k5=0.0;
507 if(isnan(k6)) k6=0.0;
508 ret=simC3vb(px, py, sim.sampleNr, Flow, K1, k2, k3, k4, k5, k6, pcvb, pct);
509 if(ret) {
510 fprintf(stderr, "Error: invalid data for simulation.\n");
511 if(verbose>1) printf("sim_return_code := %d\n", ret);
512 tacFree(&sim); tacFree(&ttac); tacFree(&input); parFree(&par); return(6);
513 }
514 }
515
516 /* simulation done */
517 tacFree(&input); parFree(&par);
518
519
520 /*
521 * Save simulated data
522 */
523 if(verbose>1) printf("writing %s\n", simfile);
524 FILE *fp; fp=fopen(simfile, "w");
525 if(fp==NULL) {
526 fprintf(stderr, "Error: cannot open file for writing (%s)\n", simfile);
527 tacFree(&sim); tacFree(&ttac); return(11);
528 }
529 ret=tacWrite(&sim, fp, TAC_FORMAT_PMOD, 1, &status);
530 fclose(fp); tacFree(&sim);
531 if(ret!=TPCERROR_OK) {
532 fprintf(stderr, "Error (%d): %s\n", ret, errorMsg(status.error));
533 tacFree(&ttac); return(12);
534 }
535 if(verbose>=0) printf("%s saved.\n", simfile);
536
537 if(tisfile[0]) {
538 if(verbose>1) printf("writing %s\n", tisfile);
539 FILE *fp; fp=fopen(tisfile, "w");
540 if(fp==NULL) {
541 fprintf(stderr, "Error: cannot open file for writing (%s)\n", tisfile);
542 tacFree(&ttac); return(13);
543 }
544 ret=tacWrite(&ttac, fp, TAC_FORMAT_PMOD, 1, &status);
545 fclose(fp); tacFree(&ttac);
546 if(ret!=TPCERROR_OK) {
547 fprintf(stderr, "Error (%d): %s\n", ret, errorMsg(status.error));
548 return(14);
549 }
550 if(verbose>=0) printf("%s saved.\n", tisfile);
551 }
552
553 return(0);
554}
555/*****************************************************************************/
556
557/*****************************************************************************/
void parFree(PAR *par)
Definition par.c:75
int parAllocate(PAR *par, int parNr, int tacNr)
Definition par.c:108
void parInit(PAR *par)
Definition par.c:25
int parWrite(PAR *par, FILE *fp, parformat format, int extra, TPCSTATUS *status)
Definition pario.c:148
int parRead(PAR *par, const char *fname, TPCSTATUS *status)
Definition pario.c:232
double parGetParameter(PAR *d, const char *par_name, const int ti)
Definition parselect.c:242
int parFindParameter(PAR *d, const char *par_name)
Definition parselect.c:219
int tacAllocateWithPAR(TAC *tac, PAR *par, int sampleNr, TPCSTATUS *status)
Allocate TAC based on data in PAR.
Definition partac.c:28
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:47
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 simC3vb(double *t, double *cab, const int nr, double f, double k1, double k2, double k3, double k4, double k5, double k6, double *cvb, double *ct)
Definition sim_av.c:88
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
Definition tpcpar.h:100
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
char name[MAX_TACNAME_LEN+1]
Definition tpcpar.h:50
unsigned int model
Definition tpcpar.h:48
double * p
Definition tpcpar.h:64
char name[MAX_TACNAME_LEN+1]
Definition tpctac.h:81
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
int isframe
Definition tpctac.h:95
TACC * c
Definition tpctac.h:117
weights weighting
Definition tpctac.h:115
unit tunit
Definition tpctac.h:109
int tacNr
Definition tpctac.h:91
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
char * tacFormattxt(tacformat c)
Definition tacio.c:98
int tacWrite(TAC *tac, FILE *fp, tacformat format, int extra, TPCSTATUS *status)
Definition tacio.c:332
int tacReadModelingInput(const char *inputfile1, const char *inputfile2, const char *inputfile3, TAC *inp, TPCSTATUS *status)
Read arterial input data for modelling.
Header file for libtpccm.
Header file for library libtpcextensions.
@ WEIGHTING_OFF
Not weighted or weights not available (weights for all included samples are 1.0).
@ UNIT_MIN
minutes
@ UNIT_ML_PER_ML
mL/mL
@ UNIT_ML_PER_ML_MIN
mL/(mL*min)
@ UNIT_PER_SEC
1/s
@ UNIT_ML_PER_DL_MIN
mL/(dL*min)
@ UNIT_UNITLESS
Unitless.
@ UNIT_SEC
seconds
@ UNIT_ML_PER_ML_SEC
mL/(mL*sec)
@ UNIT_PER_MIN
1/min
@ TPCERROR_OK
No error.
char * unitName(int unit_code)
Definition units.c:143
Header file for library libtpcift.
Header file for libtpcpar.
@ PAR_FORMAT_TSV_UK
UK TSV (point as decimal separator).
Definition tpcpar.h:35
Header file for library libtpctac.
@ TAC_FORMAT_PMOD
PMOD TAC format.
Definition tpctac.h:33
Header file for libtpctacmod.