TPCCLIB
Loading...
Searching...
No Matches
sim_wliv.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 "tpctacmod.h"
21#include "tpccm.h"
22/*****************************************************************************/
23
24/*****************************************************************************/
25static char *info[] = {
26 "Simulation of PET tissue time-radioactivity concentration curves (TACs)",
27 "from arterial blood (Ca) TACs, based on compartmental model for radiowater",
28 "kinetics in the liver. Liver has two inputs, hepatic artery and portal vein.",
29 "Portal vein input is simulated by assuming that GI tract can be modelled",
30 "with time delay and dispersion of the arterial input function.",
31 "Model has two parameters for the perfusion, represented by K1a and K1p for",
32 "the arterial and portal blood flow, respectively, and a single parameter p",
33 "for the partition coefficient of water (p).",
34 "There are two delay times, LdT, which is the delay between the Ca and liver,",
35 "and PdT, which is the additional delay in the portal vein blood.",
36 "Dispersion the the GI tract is accounted for by rate constant kGI.",
37 "The volume fraction of arterial blood (Vb) is assumed to contain arterial",
38 "and portal blood in proportion to their contribution to the total blood flow.",
39 " ",
40 "Usage: @P [options] parfile [bloodfile simfile]",
41 " ",
42 "Options:",
43// " -TTM",
44// " Use transit-time model for simulating portal vein curve.",
45 " -stdoptions", // List standard options like --help, -v, etc
46 " ",
47 "To create a template parameter file, do not enter names for arterial input",
48 "and simulated TACs.",
49 "If parameter file does not contain units, then per min and per mL units",
50 "are assumed for K1a, K1p, p, kGI, and Vb, and seconds for deley times.",
51 "For accurate results, blood TAC should have very short sampling intervals.",
52 " ",
53 "See also: sim_h2o, fit_wliv, liverpv, simdisp, fit_h2o, tacadd, simframe",
54 " ",
55 "Keywords: liver, simulation, compartmental model, perfusion, radiowater",
56 0};
57/*****************************************************************************/
58
59/*****************************************************************************/
60/* Turn on the globbing of the command line, since it is disabled by default in
61 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
62 In Unix&Linux wildcard command line processing is enabled by default. */
63/*
64#undef _CRT_glob
65#define _CRT_glob -1
66*/
67int _dowildcard = -1;
68/*****************************************************************************/
69
70/*****************************************************************************/
74int main(int argc, char **argv)
75{
76 int ai, help=0, version=0, verbose=1;
77 char blofile[FILENAME_MAX], simfile[FILENAME_MAX], parfile[FILENAME_MAX];
78 PAR par;
79 int TTM=0; // Use transit-time model instead of portal compartment (1) or not (0)
80
81
82 /*
83 * Get arguments
84 */
85 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
86 blofile[0]=simfile[0]=parfile[0]=(char)0;
87 parInit(&par);
88 /* Options */
89 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
90 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
91 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
92 if(strcasecmp(cptr, "TTM")==0) {
93 TTM=1; continue;
94 }
95 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
96 return(1);
97 } else break; // tac name argument may start with '-'
98
99 TPCSTATUS status; statusInit(&status);
100 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
101 status.verbose=verbose-1;
102
103 /* Print help or version? */
104 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
105 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
106 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
107
108 /* Process other arguments, starting from the first non-option */
109 if(ai<argc) strlcpy(parfile, argv[ai++], FILENAME_MAX);
110 if(ai<argc) strlcpy(blofile, argv[ai++], FILENAME_MAX);
111 if(ai<argc) strlcpy(simfile, argv[ai++], FILENAME_MAX);
112 if(ai<argc) {
113 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
114 return(1);
115 }
116
117 /* Is something missing? */
118 if(!parfile[0]) {
119 fprintf(stderr, "Error: missing parameter file; use option --help\n");
120 return(1);
121 }
122 if(blofile[0]) {
123 if(!simfile[0]) {fprintf(stderr, "Error: missing file name.\n"); return(1);}
124 if(!fileExist(parfile)) {fprintf(stderr, "Error: parameter file not found.\n"); return(1);}
125 } else {
126 if(fileExist(parfile)) {fprintf(stderr, "Error: parameter template exists.\n"); return(1);}
127 }
128
129
130 /* In verbose mode print arguments and options */
131 if(verbose>1) {
132 printf("parfile := %s\n", parfile);
133 printf("blofile := %s\n", blofile);
134 printf("simfile := %s\n", simfile);
135 printf("TTM := %d\n", TTM);
136 fflush(stdout);
137 }
138
139
140 /*
141 * Make template parameter file, if no other file names were given, and then quit
142 */
143 if(!blofile[0]) {
144 /* We have already checked that parameter file does not exist */
145
146 /* Allocate space for 6 parameters, 4 TTACs */
147 if(parAllocate(&par, 7, 3)) {
148 fprintf(stderr, "Error: cannot allocate memory for parameters.\n");
149 parFree(&par); return(1);
150 }
151 par.parNr=7; par.tacNr=3;
152 strcpy(par.n[0].name, "K1a"); par.n[0].unit=UNIT_ML_PER_ML_MIN;
153 strcpy(par.n[1].name, "K1p"); par.n[1].unit=UNIT_ML_PER_ML_MIN;
154 strcpy(par.n[2].name, "p"); par.n[2].unit=UNIT_ML_PER_ML;
155 strcpy(par.n[3].name, "Vb"); par.n[3].unit=UNIT_ML_PER_ML;
156 strcpy(par.n[4].name, "LdT"); par.n[4].unit=UNIT_SEC;
157 strcpy(par.n[5].name, "PdT"); par.n[5].unit=UNIT_SEC;
158 strcpy(par.n[6].name, "kGI"); par.n[6].unit=UNIT_ML_PER_ML_MIN;
159 for(int i=0; i<par.tacNr; i++) {
160 sprintf(par.r[i].name, "tac%d", 1+i);
161 par.r[i].model=modelCodeIndex("radiowater-liver");
162 }
163 int ri=0; // first TTAC
164 par.r[ri].p[0]=0.5;
165 par.r[ri].p[1]=3.5;
166 par.r[ri].p[2]=0.8;
167 par.r[ri].p[3]=0.02;
168 par.r[ri].p[4]=10.0;
169 par.r[ri].p[5]=15.0;
170 par.r[ri].p[6]=1.0;
171 ri++;
172 par.r[ri].p[0]=0.4;
173 par.r[ri].p[1]=2.6;
174 par.r[ri].p[2]=0.6;
175 par.r[ri].p[3]=0.02;
176 par.r[ri].p[4]=10.0;
177 par.r[ri].p[5]=15.0;
178 par.r[ri].p[6]=1.0;
179 ri++;
180 par.r[ri].p[0]=0.8;
181 par.r[ri].p[1]=0.0;
182 par.r[ri].p[2]=0.8;
183 par.r[ri].p[3]=0.02;
184 par.r[ri].p[4]=10.0;
185 par.r[ri].p[5]=15.0;
186 par.r[ri].p[6]=1.0;
187
188 if(TTM) {
189 /* In transit-time model PdT and kGI are replaced by beta */
190 par.parNr=6;
191 strcpy(par.n[5].name, "beta"); par.n[5].unit=UNIT_SEC;
192 for(ri=0; ri<par.tacNr; ri++) {
193 par.r[ri].model=modelCodeIndex("radiowater-liver-TTM");
194 par.r[ri].p[5]=60.0*2.17;
195 }
196 }
197
198 if(verbose>1) {printf("writing %s\n", parfile); fflush(stdout);}
199
200 FILE *fp; fp=fopen(parfile, "w");
201 if(fp==NULL) {
202 fprintf(stderr, "Error: cannot open file for writing (%s)\n", parfile); fflush(stderr);
203 parFree(&par); return(11);
204 }
205 int ret=parWrite(&par, fp, PAR_FORMAT_TSV_UK, 1, &status);
206 fclose(fp); parFree(&par);
207 if(ret!=TPCERROR_OK) {
208 fprintf(stderr, "Error: cannot write %s\n", parfile);
209 return(12);
210 }
211 if(verbose>=0) {printf("%s saved.\n", parfile); fflush(stdout);}
212 return(0);
213 }
214
215
216 /*
217 * Read parameter file to get parameters for the simulation
218 */
219 if(verbose>1) fprintf(stdout, "reading %s\n", parfile);
220 if(parRead(&par, parfile, &status)) {
221 fprintf(stderr, "Error: %s (%s)\n", errorMsg(status.error), parfile);
222 parFree(&par);
223 return(3);
224 }
225 if(verbose>5) parWrite(&par, stdout, PAR_FORMAT_TSV_UK, 1, NULL);
226 /* Check the validity of model and its parameters */
227 unsigned int model=par.r[0].model;
228 if(model!=modelCodeIndex("radiowater-liver") && model!=modelCodeIndex("radiowater-liver-TTM")) {
229 fprintf(stderr, "Error: invalid model in parameter file.\n");
230 parFree(&par); return(3);
231 }
232 for(int i=0; i<par.tacNr; i++) {
233 if(verbose>3) printf("model %s for tac %s\n", modelCode(par.r[i].model), par.r[i].name);
234 if(par.r[i].model!=model) {
235 fprintf(stderr, "Error: different models in parameter file.\n");
236 parFree(&par); return(3);
237 }
238 /* check that we got at least as many parameters as the model has */
239 if(par.parNr<(int)modelParNr(par.r[i].model)) {
240 fprintf(stderr, "Error: invalid parameters for selected model.\n");
241 parFree(&par); return(3);
242 }
243 }
244 /* check that we can find the obligatory model parameters */
245 int i_LdT=-1, i_PdT=-1, i_kGI=-1, i_K1a=-1, i_K1p=-1, i_p=-1, i_Vb=-1, i_beta=-1;
246 if(model==modelCodeIndex("radiowater-liver")) {
247 int ret=0;
248 if((i_K1a=parFindParameter(&par, "K1a"))<0) ret++;
249 if((i_K1p=parFindParameter(&par, "K1p"))<0) ret++;
250 if((i_p=parFindParameter(&par, "p"))<0) ret++;
251 if((i_Vb=parFindParameter(&par, "Vb"))<0) ret++;
252 if((i_LdT=parFindParameter(&par, "LdT"))<0) ret++;
253 if((i_PdT=parFindParameter(&par, "PdT"))<0) ret++;
254 if((i_kGI=parFindParameter(&par, "kGI"))<0) ret++;
255 if(ret) {
256 fprintf(stderr, "Error: required parameters not available.\n");
257 parFree(&par); return(3);
258 }
259 if(verbose>5) {
260 printf("parameter indices:\n");
261 printf(" K1a=p[%d]\n", i_K1a);
262 printf(" K1p=p[%d]\n", i_K1p);
263 printf(" p=p[%d]\n", i_p);
264 printf(" Vb=p[%d]\n", i_Vb);
265 printf(" LdT=p[%d]\n", i_LdT);
266 printf(" PdT=p[%d]\n", i_PdT);
267 printf(" kGI=p[%d]\n", i_kGI);
268 }
269 } else { // Transit-time model
270 int ret=0;
271 if((i_K1a=parFindParameter(&par, "K1a"))<0) ret++;
272 if((i_K1p=parFindParameter(&par, "K1p"))<0) ret++;
273 if((i_p=parFindParameter(&par, "p"))<0) ret++;
274 if((i_Vb=parFindParameter(&par, "Vb"))<0) ret++;
275 if((i_LdT=parFindParameter(&par, "LdT"))<0) ret++;
276 if((i_beta=parFindParameter(&par, "beta"))<0) ret++;
277 if(ret) {
278 fprintf(stderr, "Error: required parameters not available.\n");
279 parFree(&par); return(3);
280 }
281 if(verbose>5) {
282 printf("parameter indices:\n");
283 printf(" K1a=p[%d]\n", i_K1a);
284 printf(" K1p=p[%d]\n", i_K1p);
285 printf(" p=p[%d]\n", i_p);
286 printf(" Vb=p[%d]\n", i_Vb);
287 printf(" LdT=p[%d]\n", i_LdT);
288 printf(" beta=p[%d]\n", i_beta);
289 }
290 }
291
292
293 /*
294 * Read input TAC
295 */
296 if(verbose>1) fprintf(stdout, "reading input TAC\n");
297 TAC input; tacInit(&input);
298 if(tacReadModelingInput(blofile, NULL, NULL, &input, &status)!=TPCERROR_OK) {
299 fprintf(stderr, "Error: %s (input files)\n", errorMsg(status.error));
300 tacFree(&input); parFree(&par); return(4);
301 }
302 if(verbose>2) {
303 printf("fileformat := %s\n", tacFormattxt(input.format));
304 printf("tacNr := %d\n", input.tacNr);
305 printf("sampleNr := %d\n", input.sampleNr);
306 printf("xunit := %s\n", unitName(input.tunit));
307 printf("yunit := %s\n", unitName(input.cunit));
308 }
309 if(verbose>10) tacWrite(&input, stdout, TAC_FORMAT_PMOD, 1, NULL);
310 /* Check for missing sample times */
311 if(tacXNaNs(&input)>0) {
312 fprintf(stderr, "Error: missing sample times.\n");
313 tacFree(&input); parFree(&par); return(4);
314 }
315 /* Check for missing concentrations */
316 if(tacYNaNs(&input, -1)>0) {
317 fprintf(stderr, "Error: missing concentrations.\n");
318 tacFree(&input); parFree(&par); return(4);
319 }
320 if(input.sampleNr<3) {
321 fprintf(stderr, "Error: too few samples in input TAC.\n");
322 tacFree(&input); parFree(&par); return(4);
323 }
324 if(input.sampleNr<10) {
325 fprintf(stderr, "Warning: too few samples for reliable simulation.\n"); fflush(stderr);
326 }
327 if(tacXUnitConvert(&input, UNIT_SEC, &status)!=TPCERROR_OK) {
328 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
329 tacFree(&input); parFree(&par); return(4);
330 }
331 if(tacSortByTime(&input, &status)!=TPCERROR_OK) {
332 fprintf(stderr, "Error: invalid sample times.\n");
333 tacFree(&input); parFree(&par); return(4);
334 }
335
336
337 /*
338 * Allocate space for simulated data
339 */
340 if(verbose>1) fprintf(stdout, "allocating space for simulated TACs\n");
341 TAC sim; tacInit(&sim);
342 if(tacAllocateWithPAR(&sim, &par, input.sampleNr, &status)!=TPCERROR_OK) {
343 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
344 tacFree(&input); tacFree(&sim); parFree(&par); return(4);
345 }
348 sim.cunit=input.cunit;
349 sim.tunit=input.tunit;
350 sim.format=input.format;
351 sim.isframe=0;
352 for(int j=0; j<sim.sampleNr; j++) sim.x[j]=input.x[j];
353
354
355 /*
356 * Simulation
357 */
358 if(verbose>1) {printf("simulating...\n"); fflush(stdout);}
359 for(int ri=0; ri<sim.tacNr; ri++) {
360 if(verbose>2) {printf(" %s\n", sim.c[ri].name); fflush(stdout);}
361 double cf;
362
363 /* Make delayed arterial input TAC */
364 double LdT=par.r[ri].p[i_LdT];
365 cf=unitConversionFactor(par.n[i_LdT].unit, UNIT_SEC); if(isfinite(cf)) LdT*=cf;
366 if(verbose>4) printf(" LdT := %g s\n", LdT);
367 double ca[sim.sampleNr];
368 if(fabs(LdT)<1.0E-08) {
369 for(int i=0; i<sim.sampleNr; i++) ca[i]=input.c[0].y[i];
370 } else {
371 double buf[sim.sampleNr]; for(int i=0; i<sim.sampleNr; i++) buf[i]=input.x[i]+LdT;
372 if(liInterpolate(buf, input.c[0].y, sim.sampleNr, sim.x, ca, NULL, NULL, sim.sampleNr, 3, 1, 0))
373 {
374 fprintf(stderr, "Error: cannot simulate arterial delay.\n");
375 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
376 }
377 }
378
379 /* Make delayed and dispersed portal vein TAC */
380 double cp[sim.sampleNr]; for(int i=0; i<sim.sampleNr; i++) cp[i]=0.0;
381 if(model==modelCodeIndex("radiowater-liver")) {
382 double PdT=par.r[ri].p[i_PdT];
383 cf=unitConversionFactor(par.n[i_PdT].unit, UNIT_SEC); if(isfinite(cf)) PdT*=cf;
384 if(verbose>4) printf(" PdT := %g s\n", PdT);
385 if(fabs(PdT)<1.0E-08) {
386 for(int i=0; i<sim.sampleNr; i++) cp[i]=ca[i]; // including LdT
387 } else {
388 double buf[sim.sampleNr]; for(int i=0; i<sim.sampleNr; i++) buf[i]=input.x[i]+LdT+PdT;
389 if(liInterpolate(buf, input.c[0].y, sim.sampleNr, sim.x, cp, NULL, NULL, sim.sampleNr, 3, 1, 0))
390 {
391 fprintf(stderr, "Error: cannot simulate portal delay.\n");
392 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
393 }
394 }
395 double kGI=par.r[ri].p[i_kGI];
397 if(!isfinite(cf)) cf=unitConversionFactor(par.n[i_kGI].unit, UNIT_PER_SEC);
398 if(isfinite(cf)) kGI*=cf; else kGI/=60.0;
399 if(verbose>4) printf(" kGI := %g 1/s\n", kGI);
400 double tau=0.0; if(kGI>0.0) tau=1.0/kGI;
401 if(verbose>4) printf(" tauGI := %g s\n", tau);
402 if(simDispersion(sim.x, cp, sim.sampleNr, tau, 0.0, NULL)) {
403 fprintf(stderr, "Error: cannot simulate dispersion.\n");
404 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
405 }
406 } else { // Transit-time model
407 double beta=par.r[ri].p[i_beta];
408 cf=unitConversionFactor(par.n[i_beta].unit, UNIT_SEC); if(isfinite(cf)) beta*=cf;
409 if(verbose>4) printf(" beta := %g s\n", beta);
410
411 // To be continued...
412
413
414
415 }
416
417 /* Simulate pure tissue TAC */
418 double K1a=par.r[ri].p[i_K1a];
420 if(isfinite(cf)) K1a*=cf; else K1a/=60.0;
421 if(verbose>4) printf(" K1a := %g mL/(s*mL)\n", K1a);
422 if(!(K1a>=0.0)) {
423 fprintf(stderr, "Error: invalid K1a for '%s'.\n", sim.c[ri].name);
424 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
425 }
426 double K1p=par.r[ri].p[i_K1p];
428 if(isfinite(cf)) K1p*=cf; else K1p/=60.0;
429 if(verbose>4) printf(" K1p := %g mL/(s*mL)\n", K1p);
430 if(!(K1p>=0.0)) {
431 fprintf(stderr, "Error: invalid K1p for '%s'.\n", sim.c[ri].name);
432 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
433 }
434 double p=par.r[ri].p[i_p];
435 if(!(p>0.0) && (K1a+K1p)>0.0) {
436 fprintf(stderr, "Error: invalid p for '%s'.\n", sim.c[ri].name);
437 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
438 }
439 cf=unitConversionFactor(par.n[i_p].unit, UNIT_ML_PER_ML); if(isfinite(cf)) p*=cf;
440 if(verbose>4) printf(" p := %g mL/mL\n", p);
441 double k2=0.0;
442 if(p>0.0) {
443 k2=(K1a+K1p)/p; if(!(k2>=0.0)) {
444 fprintf(stderr, "Error: invalid k2 for '%s'.\n", sim.c[ri].name);
445 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
446 }
447 }
448 if(verbose>4) printf(" k2 := %g 1/s\n", k2);
449
450 if(simC1DI(sim.x, ca, cp, sim.sampleNr, K1a, K1p, k2, sim.c[ri].y)) {
451 fprintf(stderr, "Error: cannot simulate '%s'.\n", sim.c[ri].name);
452 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
453 }
454
455 /* Add the contribution of arterial blood in tissue vasculature */
456 double Vb=par.r[ri].p[i_Vb];
457 cf=unitConversionFactor(par.n[i_Vb].unit, UNIT_ML_PER_ML); if(isfinite(cf)) Vb*=cf;
458 if(verbose>4) printf(" Vb := %g mL/mL\n", Vb);
459 if(!(Vb>=0.0) || Vb>1.0) {
460 fprintf(stderr, "Error: invalid Vb for '%s'.\n", sim.c[ri].name);
461 tacFree(&input); tacFree(&sim); parFree(&par); return(5);
462 }
463 if(Vb>0.0) {
464 for(int i=0; i<sim.sampleNr; i++) sim.c[ri].y[i]*=(1.0-Vb);
465 if(K1a+K1p > 0.0)
466 for(int i=0; i<sim.sampleNr; i++) sim.c[ri].y[i]+=Vb*(K1a*ca[i]+K1p*cp[i])/(K1a+K1p);
467 else
468 for(int i=0; i<sim.sampleNr; i++) sim.c[ri].y[i]+=Vb*ca[i];
469 }
470
471 }
472 /* simulation done */
473 tacFree(&input); parFree(&par);
474
475
476 /*
477 * Save simulated data
478 */
479 {
480 if(verbose>1) printf("writing %s\n", simfile);
481 FILE *fp; fp=fopen(simfile, "w");
482 if(fp==NULL) {
483 fprintf(stderr, "Error: cannot open file for writing (%s)\n", simfile);
484 tacFree(&sim); return(11);
485 }
486 int ret=tacWrite(&sim, fp, TAC_FORMAT_PMOD, 1, &status);
487 fclose(fp); tacFree(&sim);
488 if(ret!=TPCERROR_OK) {
489 fprintf(stderr, "Error (%d): %s\n", ret, errorMsg(status.error));
490 return(12);
491 }
492 if(verbose>=0) {printf("%s saved.\n", simfile); fflush(stdout);}
493 }
494
495 return(0);
496}
497/*****************************************************************************/
498
499/*****************************************************************************/
int fileExist(const char *filename)
Definition filexist.c:17
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.
char * modelCode(const unsigned int i)
Definition modell.c:176
unsigned int modelParNr(const unsigned int code)
Definition modell.c:256
unsigned int modelCodeIndex(const char *s)
Definition modell.c:237
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
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 simC1DI(double *t, double *cba, double *cbb, const int nr, const double k1a, const double k1b, const double k2, double *ct)
Definition simdicm.c:30
int simDispersion(double *x, double *y, const int n, const double tau1, const double tau2, double *tmp)
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
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.
int tacYNaNs(TAC *tac, const int i)
Definition tacnan.c:47
int tacXNaNs(TAC *tac)
Definition tacnan.c:23
int tacSortByTime(TAC *d, TPCSTATUS *status)
Definition tacorder.c:74
int tacXUnitConvert(TAC *tac, const int u, TPCSTATUS *status)
Definition tacunits.c:23
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_ML_PER_ML
mL/mL
@ UNIT_ML_PER_ML_MIN
mL/(mL*min)
@ UNIT_PER_SEC
1/s
@ UNIT_SEC
seconds
@ UNIT_ML_PER_ML_SEC
mL/(mL*sec)
@ TPCERROR_OK
No error.
double unitConversionFactor(const int u1, const int u2)
Definition units.c:487
char * unitName(int unit_code)
Definition units.c:143
Header file for libtpcfileutil.
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.