TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcpar
parexample.c
Go to the documentation of this file.
1
4
/*****************************************************************************/
5
#include "tpcclibConfig.h"
6
/*****************************************************************************/
7
#include <stdio.h>
8
#include <stdlib.h>
9
#include <math.h>
10
#include <time.h>
11
#include <string.h>
12
/*****************************************************************************/
13
#include "
tpcpar.h
"
14
/*****************************************************************************/
15
16
/*****************************************************************************/
24
int
parExampleTTACs
(
27
PAR
*d,
29
int
type,
31
TPCSTATUS
*status
32
) {
33
int
verbose=0;
if
(status!=NULL) verbose=status->
verbose
;
34
if
(verbose>0) printf(
"%s(par, %d)\n"
, __func__, type);
35
36
/* Check that required data exists */
37
if
(d==NULL) {
38
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_NO_DATA
);
39
return
TPCERROR_NO_DATA
;
40
}
41
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_OK
);
42
43
int
ret, pi, ri, parNr;
44
45
/* Allocate memory */
46
parNr=
modelParNr
(
modelCodeIndex
(
"fengm2"
));
47
ret=
parAllocate
(d, parNr, 3);
if
(ret!=
TPCERROR_OK
)
return
(ret);
48
d->
tacNr
=3; d->
parNr
=5;
49
d->
format
=
PAR_FORMAT_CSV_INT
;
50
/* Set header fields */
51
iftPut
(&d->
h
,
"studynr"
,
"ttac1313"
, 1, NULL);
52
iftPut
(&d->
h
,
"analysis_time"
,
"2016-07-01 15:05:43"
, 1, NULL);
53
iftPut
(&d->
h
,
"program"
,
"libtpcpar (c) 2016"
, 1, NULL);
54
iftPut
(&d->
h
,
"datafile"
,
"ttac1313.tac"
,1,NULL);
55
iftPut
(&d->
h
,
"weighting"
,
"no"
, 1, NULL);
56
iftPut
(&d->
h
,
"unit"
,
unitName
(
UNIT_KBQ_PER_ML
), 1, NULL);
57
iftPut
(&d->
h
,
"timeunit"
,
unitName
(
UNIT_MIN
), 1, NULL);
58
/* Set parameter names */
59
pi=0; strcpy(d->
n
[pi].
name
,
"A1"
); d->
n
[pi].
unit
=
UNIT_KBQ_PER_ML
;
60
pi++; strcpy(d->
n
[pi].
name
,
"L1"
); d->
n
[pi].
unit
=
UNIT_PER_MIN
;
61
pi++; strcpy(d->
n
[pi].
name
,
"A2"
); d->
n
[pi].
unit
=
UNIT_KBQ_PER_ML
;
62
pi++; strcpy(d->
n
[pi].
name
,
"L2"
); d->
n
[pi].
unit
=
UNIT_PER_MIN
;
63
pi++; strcpy(d->
n
[pi].
name
,
"A3"
); d->
n
[pi].
unit
=
UNIT_KBQ_PER_ML
;
64
pi++; strcpy(d->
n
[pi].
name
,
"L4"
); d->
n
[pi].
unit
=
UNIT_PER_MIN
;
65
pi++; strcpy(d->
n
[pi].
name
,
"tDelay"
); d->
n
[pi].
unit
=
UNIT_MIN
;
66
/* Set regional fit options */
67
for
(ri=0; ri<d->
tacNr
; ri++) {
68
d->
r
[ri].
model
=
modelCodeIndex
(
"fengm2"
);
69
d->
r
[ri].
fitNr
=parNr;
70
d->
r
[ri].
dataNr
=100;
71
d->
r
[ri].
start
=0.0;
72
d->
r
[ri].
end
=60.0;
73
d->
r
[ri].
wss
=0.0E+000;
74
}
75
/* Set parameter values and region names */
76
ri=0;
77
strcpy(d->
r
[ri].
name
,
"fast"
);
78
pi=0; d->
r
[ri].
p
[pi]=200.;
79
pi++; d->
r
[ri].
p
[pi]=-0.8;
80
pi++; d->
r
[ri].
p
[pi]=50.;
81
pi++; d->
r
[ri].
p
[pi]=-0.2;
82
pi++; d->
r
[ri].
p
[pi]=20.;
83
pi++; d->
r
[ri].
p
[pi]=-0.005;
84
pi++; d->
r
[ri].
p
[pi]=0.0;
85
ri++;
86
strcpy(d->
r
[ri].
name
,
"moder"
);
87
pi=0; d->
r
[ri].
p
[pi]=50.;
88
pi++; d->
r
[ri].
p
[pi]=-0.2;
89
pi++; d->
r
[ri].
p
[pi]=50.;
90
pi++; d->
r
[ri].
p
[pi]=-0.02;
91
pi++; d->
r
[ri].
p
[pi]=3.;
92
pi++; d->
r
[ri].
p
[pi]=-0.001;
93
pi++; d->
r
[ri].
p
[pi]=0.0;
94
ri++;
95
strcpy(d->
r
[ri].
name
,
"slow"
);
96
pi=0; d->
r
[ri].
p
[pi]=5.;
97
pi++; d->
r
[ri].
p
[pi]=-0.05;
98
pi++; d->
r
[ri].
p
[pi]=70.;
99
pi++; d->
r
[ri].
p
[pi]=-0.001;
100
pi++; d->
r
[ri].
p
[pi]=30.;
101
pi++; d->
r
[ri].
p
[pi]=-0.0005;
102
pi++; d->
r
[ri].
p
[pi]=0.0;
103
104
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_OK
);
105
return
TPCERROR_OK
;
106
}
107
/*****************************************************************************/
108
109
/*****************************************************************************/
120
int
parExamplePerfectBolus
(
123
PAR
*d,
125
TPCSTATUS
*status
126
) {
127
int
verbose=0;
if
(status!=NULL) verbose=status->
verbose
;
128
if
(verbose>0) printf(
"%s(par)\n"
, __func__);
129
130
/* Check that required data exists */
131
if
(d==NULL) {
132
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_NO_DATA
);
133
return
TPCERROR_NO_DATA
;
134
}
135
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_OK
);
136
137
int
ret, pi, parNr;
138
139
/* Allocate memory */
140
parNr=
modelParNr
(
modelCodeIndex
(
"gammav"
));
141
ret=
parAllocate
(d, parNr, 1);
if
(ret!=
TPCERROR_OK
)
return
(ret);
142
d->
tacNr
=1; d->
parNr
=4;
143
d->
format
=
PAR_FORMAT_CSV_INT
;
144
/* Set header fields */
145
iftPut
(&d->
h
,
"studynr"
,
"ptac1401"
, 1, NULL);
146
iftPut
(&d->
h
,
"analysis_time"
,
"2016-07-05 15:40:03"
, 1, NULL);
147
iftPut
(&d->
h
,
"program"
,
"libtpcpar (c) 2016"
, 1, NULL);
148
iftPut
(&d->
h
,
"datafile"
,
"ptac1401.tac"
,1,NULL);
149
iftPut
(&d->
h
,
"weighting"
,
"no"
, 1, NULL);
150
iftPut
(&d->
h
,
"unit"
,
unitName
(
UNIT_KBQ_PER_ML
), 1, NULL);
151
iftPut
(&d->
h
,
"timeunit"
,
unitName
(
UNIT_SEC
), 1, NULL);
152
/* Set parameter names */
153
pi=0; strcpy(d->
n
[pi].
name
,
"A"
); d->
n
[pi].
unit
=
UNIT_KBQ_PER_ML
;
154
pi++; strcpy(d->
n
[pi].
name
,
"B"
); d->
n
[pi].
unit
=
UNIT_UNITLESS
;
155
pi++; strcpy(d->
n
[pi].
name
,
"C"
); d->
n
[pi].
unit
=
UNIT_PER_SEC
;
156
pi++; strcpy(d->
n
[pi].
name
,
"tDelay"
); d->
n
[pi].
unit
=
UNIT_SEC
;
157
/* Set region names */
158
sprintf(d->
r
[0].
name
,
"bolus"
);
159
/* Set regional fit options */
160
d->
r
[0].
model
=
modelCodeIndex
(
"gammav"
);
161
d->
r
[0].
fitNr
=parNr;
162
d->
r
[0].
dataNr
=100;
163
d->
r
[0].
start
=0.0;
164
d->
r
[0].
end
=60.0;
165
d->
r
[0].
wss
=0.0E+000;
166
/* Set parameter values and region names */
167
pi=0; d->
r
[0].
p
[pi]=226.523;
168
pi++; d->
r
[0].
p
[pi]=1.0;
169
pi++; d->
r
[0].
p
[pi]=1.2;
170
pi++; d->
r
[0].
p
[pi]=0.0;
171
172
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_OK
);
173
return
TPCERROR_OK
;
174
}
175
/*****************************************************************************/
176
177
/*****************************************************************************/
184
int
parExampleRadiowaterBolus
(
187
PAR
*d,
189
TPCSTATUS
*status
190
) {
191
int
verbose=0;
if
(status!=NULL) verbose=status->
verbose
;
192
if
(verbose>0) printf(
"%s(par)\n"
, __func__);
193
194
/* Check that required data exists */
195
if
(d==NULL) {
196
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_NO_DATA
);
197
return
TPCERROR_NO_DATA
;
198
}
199
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_OK
);
200
201
int
ret, pi, parNr;
202
203
/* Allocate memory */
204
parNr=
modelParNr
(
modelCodeIndex
(
"fengm2"
));
205
ret=
parAllocate
(d, parNr, 1);
if
(ret!=
TPCERROR_OK
)
return
(ret);
206
d->
tacNr
=1; d->
parNr
=7;
207
d->
format
=
PAR_FORMAT_CSV_INT
;
208
/* Set header fields */
209
iftPut
(&d->
h
,
"studynr"
,
"btac1313"
, 1, NULL);
210
iftPut
(&d->
h
,
"analysis_time"
,
"2025-11-14 11:46:02"
, 1, NULL);
211
iftPut
(&d->
h
,
"program"
,
"libtpcpar (c) 2025"
, 1, NULL);
212
iftPut
(&d->
h
,
"datafile"
,
"meanaorta.tac"
,1,NULL);
213
iftPut
(&d->
h
,
"weighting"
,
"no"
, 1, NULL);
214
iftPut
(&d->
h
,
"unit"
,
unitName
(
UNIT_KBQ_PER_ML
), 1, NULL);
215
iftPut
(&d->
h
,
"timeunit"
,
unitName
(
UNIT_SEC
), 1, NULL);
216
/* Set parameter names */
217
pi=0; strcpy(d->
n
[pi].
name
,
"A1"
); d->
n
[pi].
unit
=
UNIT_UNITLESS
;
218
pi++; strcpy(d->
n
[pi].
name
,
"L1"
); d->
n
[pi].
unit
=
UNIT_UNITLESS
;
219
pi++; strcpy(d->
n
[pi].
name
,
"A2"
); d->
n
[pi].
unit
=
UNIT_UNITLESS
;
220
pi=0; strcpy(d->
n
[pi].
name
,
"L2"
); d->
n
[pi].
unit
=
UNIT_UNITLESS
;
221
pi++; strcpy(d->
n
[pi].
name
,
"A3"
); d->
n
[pi].
unit
=
UNIT_UNITLESS
;
222
pi++; strcpy(d->
n
[pi].
name
,
"L3"
); d->
n
[pi].
unit
=
UNIT_UNITLESS
;
223
pi++; strcpy(d->
n
[pi].
name
,
"tDelay"
); d->
n
[pi].
unit
=
UNIT_SEC
;
224
/* Set region names */
225
sprintf(d->
r
[0].
name
,
"bolus"
);
226
/* Set regional fit options */
227
d->
r
[0].
model
=
modelCodeIndex
(
"fengm2"
);
228
d->
r
[0].
fitNr
=parNr;
229
d->
r
[0].
dataNr
=100;
230
d->
r
[0].
start
=0.0;
231
d->
r
[0].
end
=420.0;
232
d->
r
[0].
wss
=0.0E+000;
233
/* Set parameter values and region names */
234
pi=0; d->
r
[0].
p
[pi]=66.;
235
pi++; d->
r
[0].
p
[pi]=-0.14;
236
pi++; d->
r
[0].
p
[pi]=50.;
237
pi++; d->
r
[0].
p
[pi]=-0.024;
238
pi++; d->
r
[0].
p
[pi]=40;
239
pi++; d->
r
[0].
p
[pi]=-0.001;
240
pi++; d->
r
[0].
p
[pi]=10.;
// delay time
241
242
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_OK
);
243
return
TPCERROR_OK
;
244
}
245
/*****************************************************************************/
246
247
/*****************************************************************************/
iftPut
int iftPut(IFT *ift, const char *key, const char *value, char comment, TPCSTATUS *status)
Definition
ift.c:63
modelParNr
unsigned int modelParNr(const unsigned int code)
Definition
modell.c:256
modelCodeIndex
unsigned int modelCodeIndex(const char *s)
Definition
modell.c:237
parAllocate
int parAllocate(PAR *par, int parNr, int tacNr)
Definition
par.c:108
parExampleTTACs
int parExampleTTACs(PAR *d, int type, TPCSTATUS *status)
Definition
parexample.c:24
parExamplePerfectBolus
int parExamplePerfectBolus(PAR *d, TPCSTATUS *status)
Definition
parexample.c:120
parExampleRadiowaterBolus
int parExampleRadiowaterBolus(PAR *d, TPCSTATUS *status)
Definition
parexample.c:184
statusSet
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition
statusmsg.c:142
PAR
Definition
tpcpar.h:100
PAR::format
int format
Definition
tpcpar.h:102
PAR::h
IFT h
Optional (but often useful) header information.
Definition
tpcpar.h:147
PAR::parNr
int parNr
Definition
tpcpar.h:108
PAR::tacNr
int tacNr
Definition
tpcpar.h:104
PAR::r
PARR * r
Definition
tpcpar.h:114
PAR::n
PARN * n
Definition
tpcpar.h:112
PARN::unit
int unit
Definition
tpcpar.h:86
PARN::name
char name[MAX_PARNAME_LEN+1]
Definition
tpcpar.h:82
PARR::wss
double wss
Definition
tpcpar.h:72
PARR::fitNr
int fitNr
Definition
tpcpar.h:58
PARR::name
char name[MAX_TACNAME_LEN+1]
Definition
tpcpar.h:50
PARR::dataNr
int dataNr
Definition
tpcpar.h:62
PARR::model
unsigned int model
Definition
tpcpar.h:48
PARR::p
double * p
Definition
tpcpar.h:64
PARR::start
double start
Definition
tpcpar.h:52
PARR::end
double end
Definition
tpcpar.h:54
TPCSTATUS
Definition
tpcextensions.h:241
TPCSTATUS::verbose
int verbose
Verbose level, used by statusPrint() etc.
Definition
tpcextensions.h:242
UNIT_MIN
@ UNIT_MIN
minutes
Definition
tpcextensions.h:90
UNIT_PER_SEC
@ UNIT_PER_SEC
1/s
Definition
tpcextensions.h:155
UNIT_KBQ_PER_ML
@ UNIT_KBQ_PER_ML
kBq/mL
Definition
tpcextensions.h:128
UNIT_UNITLESS
@ UNIT_UNITLESS
Unitless.
Definition
tpcextensions.h:86
UNIT_SEC
@ UNIT_SEC
seconds
Definition
tpcextensions.h:89
UNIT_PER_MIN
@ UNIT_PER_MIN
1/min
Definition
tpcextensions.h:156
TPCERROR_OK
@ TPCERROR_OK
No error.
Definition
tpcextensions.h:191
TPCERROR_NO_DATA
@ TPCERROR_NO_DATA
File contains no data.
Definition
tpcextensions.h:203
unitName
char * unitName(int unit_code)
Definition
units.c:143
tpcpar.h
Header file for libtpcpar.
PAR_FORMAT_CSV_INT
@ PAR_FORMAT_CSV_INT
International CSV.
Definition
tpcpar.h:32
Generated on
for TPCCLIB by
1.17.0