TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcimgio
imgunits.c
Go to the documentation of this file.
1
5
/*****************************************************************************/
6
#include "
libtpcimgio.h
"
7
/*****************************************************************************/
8
9
/*****************************************************************************/
14
int
imgUnitId
(
16
char
*unit
17
) {
18
if
(unit==NULL)
return
(-1);
19
if
(strlen(unit)==0)
return
CUNIT_UNKNOWN;
20
else
if
(strcasecmp(unit,
"unknown"
)==0)
return
CUNIT_UNKNOWN;
21
else
if
(strcasecmp(unit,
"cnts/sec"
)==0)
return
CUNIT_CPS;
22
else
if
(strcasecmp(unit,
"counts/sec"
)==0)
return
CUNIT_CPS;
23
else
if
(strcasecmp(unit,
"ECAT counts/sec"
)==0)
return
CUNIT_CPS;
24
else
if
(strcasecmp(unit,
"cps"
)==0)
return
CUNIT_CPS;
25
else
if
(strcasecmp(unit,
"counts"
)==0)
return
CUNIT_COUNTS;
26
else
if
(strcasecmp(unit,
"cnts"
)==0)
return
CUNIT_COUNTS;
27
else
if
(strcasecmp(unit,
"kBq/cc"
)==0)
return
CUNIT_KBQ_PER_ML;
28
else
if
(strcasecmp(unit,
"kBqcc"
)==0)
return
CUNIT_KBQ_PER_ML;
29
else
if
(strcasecmp(unit,
"kBq/mL"
)==0)
return
CUNIT_KBQ_PER_ML;
30
else
if
(strcasecmp(unit,
"kBqmL"
)==0)
return
CUNIT_KBQ_PER_ML;
31
else
if
(strcasecmp(unit,
"sec*kBq/cc"
)==0)
return
CUNIT_SEC_KBQ_PER_ML;
32
else
if
(strcasecmp(unit,
"sec*kBq/mL"
)==0)
return
CUNIT_SEC_KBQ_PER_ML;
33
else
if
(strcasecmp(unit,
"integral"
)==0)
return
CUNIT_SEC_KBQ_PER_ML;
34
else
if
(strcasecmp(unit,
"1/sec"
)==0)
return
CUNIT_PER_SEC;
35
else
if
(strcasecmp(unit,
"1/s"
)==0)
return
CUNIT_PER_SEC;
36
else
if
(strcasecmp(unit,
"s-1"
)==0)
return
CUNIT_PER_SEC;
37
else
if
(strcasecmp(unit,
"1/min"
)==0)
return
CUNIT_PER_MIN;
38
else
if
(strcasecmp(unit,
"min-1"
)==0)
return
CUNIT_PER_MIN;
39
else
if
(strcasecmp(unit,
"mL/mL"
)==0)
return
CUNIT_ML_PER_ML;
40
else
if
(strcasecmp(unit,
"mL/cc"
)==0)
return
CUNIT_ML_PER_ML;
41
else
if
(strcasecmp(unit,
"mL/dL"
)==0)
return
CUNIT_ML_PER_DL;
42
else
if
(strcasecmp(unit,
"mL/100mL"
)==0)
return
CUNIT_ML_PER_DL;
43
else
if
(strcasecmp(unit,
"mL/(mL*min)"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
44
else
if
(strcasecmp(unit,
"mL/(min*mL)"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
45
else
if
(strcasecmp(unit,
"mL/(cc*min)"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
46
else
if
(strcasecmp(unit,
"mL/(min*cc)"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
47
else
if
(strcasecmp(unit,
"mL/mL/min"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
48
else
if
(strcasecmp(unit,
"mL/min/mL"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
49
else
if
(strcasecmp(unit,
"mL/cc/min"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
50
else
if
(strcasecmp(unit,
"mL/min/cc"
)==0)
return
CUNIT_ML_PER_ML_PER_MIN;
51
else
if
(strcasecmp(unit,
"mL/(dL*min)"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
52
else
if
(strcasecmp(unit,
"mL/(min*dL)"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
53
else
if
(strcasecmp(unit,
"mL/(100mL*min)"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
54
else
if
(strcasecmp(unit,
"mL/(min*100mL)"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
55
else
if
(strcasecmp(unit,
"mL/dL/min"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
56
else
if
(strcasecmp(unit,
"mL/min/dL"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
57
else
if
(strcasecmp(unit,
"mL/100mL/min"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
58
else
if
(strcasecmp(unit,
"mL/min/100mL"
)==0)
return
CUNIT_ML_PER_DL_PER_MIN;
59
else
if
(strcasecmp(unit,
"unitless"
)==0)
return
CUNIT_UNITLESS;
60
else
if
(strcasecmp(unit,
"Hounsfield Unit"
)==0)
return
CUNIT_HU;
61
else
if
(strcasecmp(unit,
"HU"
)==0)
return
CUNIT_HU;
62
else
if
(strcasecmp(unit,
"nCi/cc"
)==0)
return
CUNIT_NCI_PER_ML;
63
else
if
(strcasecmp(unit,
"nCicc"
)==0)
return
CUNIT_NCI_PER_ML;
64
else
if
(strcasecmp(unit,
"nCi/mL"
)==0)
return
CUNIT_NCI_PER_ML;
65
else
if
(strcasecmp(unit,
"nCimL"
)==0)
return
CUNIT_NCI_PER_ML;
66
else
if
(strcasecmp(unit,
"MBq/cc"
)==0)
return
CUNIT_MBQ_PER_ML;
67
else
if
(strcasecmp(unit,
"MBqcc"
)==0)
return
CUNIT_MBQ_PER_ML;
68
else
if
(strcasecmp(unit,
"MBq/mL"
)==0)
return
CUNIT_MBQ_PER_ML;
69
else
if
(strcasecmp(unit,
"MBqmL"
)==0)
return
CUNIT_MBQ_PER_ML;
70
else
if
(strcasecmp(unit,
"Bq/cc"
)==0)
return
CUNIT_BQ_PER_ML;
71
else
if
(strcasecmp(unit,
"Bqcc"
)==0)
return
CUNIT_BQ_PER_ML;
72
else
if
(strcasecmp(unit,
"Bq/mL"
)==0)
return
CUNIT_BQ_PER_ML;
73
else
if
(strcasecmp(unit,
"BqmL"
)==0)
return
CUNIT_BQ_PER_ML;
74
else
if
(strcasecmp(unit,
"uCi/cc"
)==0)
return
CUNIT_UCI_PER_ML;
75
else
if
(strcasecmp(unit,
"uCicc"
)==0)
return
CUNIT_UCI_PER_ML;
76
else
if
(strcasecmp(unit,
"uCi/mL"
)==0)
return
CUNIT_UCI_PER_ML;
77
else
if
(strcasecmp(unit,
"uCimL"
)==0)
return
CUNIT_UCI_PER_ML;
78
else
if
(strcasecmp(unit,
"umol/(100g*min)"
)==0)
return
CUNIT_UMOL_PER_MIN_PER_100G;
79
else
if
(strcasecmp(unit,
"umol/(min*100g)"
)==0)
return
CUNIT_UMOL_PER_MIN_PER_100G;
80
else
if
(strcasecmp(unit,
"umol/100g/min"
)==0)
return
CUNIT_UMOL_PER_MIN_PER_100G;
81
else
if
(strcasecmp(unit,
"umol/min/100g"
)==0)
return
CUNIT_UMOL_PER_MIN_PER_100G;
82
else
if
(strcasecmp(unit,
"mg/(100g*min)"
)==0)
return
CUNIT_MG_PER_MIN_PER_100G;
83
else
if
(strcasecmp(unit,
"mg/(min*100g)"
)==0)
return
CUNIT_MG_PER_MIN_PER_100G;
84
else
if
(strcasecmp(unit,
"mg/100g/min"
)==0)
return
CUNIT_MG_PER_MIN_PER_100G;
85
else
if
(strcasecmp(unit,
"mg/min/100g"
)==0)
return
CUNIT_MG_PER_MIN_PER_100G;
86
87
return
(-3);
88
}
89
/*****************************************************************************/
90
91
/*****************************************************************************/
95
void
imgUnitFromEcat
(
97
IMG
*img,
99
int
ecat_unit
100
) {
101
switch
(ecat_unit) {
102
case
0:
/* Unknown */
103
img->
unit
=CUNIT_UNKNOWN;
break
;
104
case
1:
/* MBq/mL */
105
img->
unit
=CUNIT_MBQ_PER_ML;
break
;
106
case
2:
/* ECAT counts */
107
img->
unit
=CUNIT_COUNTS;
break
;
108
case
3:
/* uCi/ml */
109
img->
unit
=CUNIT_UCI_PER_ML;
break
;
110
case
4:
/* LMRGlu */
111
img->
unit
=CUNIT_UNKNOWN;
break
;
112
case
5:
/* LMRUGlu umol/min/100g */
113
img->
unit
=CUNIT_UMOL_PER_MIN_PER_100G;
break
;
114
case
6:
/* LMRUGlu mg/min/100g */
115
img->
unit
=CUNIT_MG_PER_MIN_PER_100G;
break
;
116
case
7:
/* nCi/mL */
117
img->
unit
=CUNIT_NCI_PER_ML;
break
;
118
case
8:
/* Well counts */
119
img->
unit
=CUNIT_CPS;
break
;
120
case
9:
/* Bq/mL */
121
img->
unit
=CUNIT_BQ_PER_ML;
break
;
122
case
10:
/* kBq/mL */
123
img->
unit
=CUNIT_KBQ_PER_ML;
break
;
124
case
11:
/* 1/min */
125
img->
unit
=CUNIT_PER_MIN;
break
;
126
case
12:
/* mL/min/100g */
127
img->
unit
=CUNIT_ML_PER_DL_PER_MIN;
break
;
128
case
13:
/* sec*kBq/mL */
129
img->
unit
=CUNIT_SEC_KBQ_PER_ML;
break
;
130
case
14:
/* sec*nCi/mL */
131
img->
unit
=CUNIT_UNKNOWN;
break
;
132
case
15:
/* 1/sec */
133
img->
unit
=CUNIT_PER_SEC;
break
;
134
case
16:
/* Unitless */
135
img->
unit
=CUNIT_UNITLESS;
break
;
136
case
17:
/* Hounsfield Unit */
137
img->
unit
=CUNIT_HU;
break
;
138
case
18:
/* Unknown */
139
default
:
140
img->
unit
=CUNIT_UNKNOWN;
break
;
141
}
142
}
143
/*****************************************************************************/
144
145
/*****************************************************************************/
149
void
imgUnitFromEcat7
(
151
IMG
*img,
153
ECAT7_mainheader
*h
154
) {
155
if
(h->
calibration_units
==0) {
/* Not calibrated */
156
img->
unit
=1;
157
}
else
if
(h->
calibration_units
==1) {
158
if
(h->
calibration_units_label
==0)
159
img->
unit
=CUNIT_BQ_PER_ML;
160
else
161
img->
unit
=
imgUnitId
(h->
data_units
);
162
}
else
if
(h->
calibration_units
==2) {
163
img->
unit
=
imgUnitId
(h->
data_units
);
164
}
else
{
165
img->
unit
=CUNIT_UNKNOWN;
166
}
167
}
168
/*****************************************************************************/
169
170
/*****************************************************************************/
175
int
imgUnitToEcat6
(
177
IMG
*img
178
) {
179
int
ecat_unit;
180
switch
(img->
unit
) {
181
case
CUNIT_CPS: ecat_unit=9;
break
;
182
case
CUNIT_COUNTS: ecat_unit=2;
break
;
183
case
CUNIT_KBQ_PER_ML: ecat_unit=10;
break
;
184
case
CUNIT_SEC_KBQ_PER_ML: ecat_unit=13;
break
;
185
case
CUNIT_PER_SEC: ecat_unit=15;
break
;
186
case
CUNIT_PER_MIN: ecat_unit=11;
break
;
187
case
CUNIT_ML_PER_ML: ecat_unit=16;
break
;
188
case
CUNIT_ML_PER_DL: ecat_unit=16;
break
;
189
case
CUNIT_ML_PER_ML_PER_MIN: ecat_unit=11;
break
;
190
case
CUNIT_ML_PER_DL_PER_MIN: ecat_unit=12;
break
;
191
case
CUNIT_UNITLESS: ecat_unit=16;
break
;
192
case
CUNIT_HU: ecat_unit=17;
break
;
193
case
CUNIT_NCI_PER_ML: ecat_unit=7;
break
;
194
case
CUNIT_MBQ_PER_ML: ecat_unit=1;
break
;
195
case
CUNIT_BQ_PER_ML: ecat_unit=9;
break
;
196
case
CUNIT_UCI_PER_ML: ecat_unit=3;
break
;
197
case
CUNIT_UMOL_PER_MIN_PER_100G: ecat_unit=5;
break
;
198
case
CUNIT_MG_PER_MIN_PER_100G: ecat_unit=6;
break
;
199
default
: ecat_unit=0;
break
;
200
}
201
return
(ecat_unit);
202
}
203
/*****************************************************************************/
204
205
/*****************************************************************************/
209
void
imgUnitToEcat7
(
211
IMG
*img,
213
ECAT7_mainheader
*h
214
) {
215
switch
(img->
unit
) {
216
case
CUNIT_CPS:
217
case
CUNIT_COUNTS:
218
h->
calibration_units
=0;
219
h->
calibration_units_label
=1;
220
strcpy(h->
data_units
,
"ECAT counts/sec"
);
221
break
;
222
case
CUNIT_KBQ_PER_ML:
223
h->
calibration_units
=1;
224
h->
calibration_units_label
=1;
225
strcpy(h->
data_units
,
"kBq/cc"
);
226
break
;
227
case
CUNIT_SEC_KBQ_PER_ML:
228
h->
calibration_units
=2;
229
h->
calibration_units_label
=1;
230
strcpy(h->
data_units
,
"sec*kBq/mL"
);
231
break
;
232
case
CUNIT_PER_SEC:
233
h->
calibration_units
=2;
234
h->
calibration_units_label
=1;
235
strcpy(h->
data_units
,
"1/sec"
);
236
break
;
237
case
CUNIT_PER_MIN:
238
h->
calibration_units
=2;
239
h->
calibration_units_label
=1;
240
strcpy(h->
data_units
,
"1/min"
);
241
break
;
242
case
CUNIT_ML_PER_ML:
243
h->
calibration_units
=2;
244
h->
calibration_units_label
=1;
245
strcpy(h->
data_units
,
"mL/mL"
);
246
break
;
247
case
CUNIT_ML_PER_DL:
248
h->
calibration_units
=2;
249
h->
calibration_units_label
=1;
250
strcpy(h->
data_units
,
"mL/dL"
);
251
break
;
252
case
CUNIT_ML_PER_ML_PER_MIN:
253
h->
calibration_units
=2;
254
h->
calibration_units_label
=1;
255
strcpy(h->
data_units
,
"mL/(mL*min)"
);
256
break
;
257
case
CUNIT_ML_PER_DL_PER_MIN:
258
h->
calibration_units
=2;
259
h->
calibration_units_label
=1;
260
strcpy(h->
data_units
,
"mL/(dL*min)"
);
261
break
;
262
case
CUNIT_UNITLESS:
263
h->
calibration_units
=1;
264
h->
calibration_units_label
=1;
265
strcpy(h->
data_units
,
"unitless"
);
266
break
;
267
case
CUNIT_NCI_PER_ML:
268
h->
calibration_units
=1;
269
h->
calibration_units_label
=1;
270
strcpy(h->
data_units
,
"nCi/cc"
);
271
break
;
272
case
CUNIT_MBQ_PER_ML:
273
h->
calibration_units
=1;
274
h->
calibration_units_label
=1;
275
strcpy(h->
data_units
,
"MBq/cc"
);
276
break
;
277
case
CUNIT_BQ_PER_ML:
278
h->
calibration_units
=1;
279
h->
calibration_units_label
=1;
280
strcpy(h->
data_units
,
"Bq/cc"
);
281
break
;
282
case
CUNIT_UCI_PER_ML:
283
h->
calibration_units
=1;
284
h->
calibration_units_label
=1;
285
strcpy(h->
data_units
,
"uCi/cc"
);
286
break
;
287
case
CUNIT_UMOL_PER_MIN_PER_100G:
288
h->
calibration_units
=1;
289
h->
calibration_units_label
=1;
290
strcpy(h->
data_units
,
"umol/min/100g"
);
291
break
;
292
case
CUNIT_MG_PER_MIN_PER_100G:
293
h->
calibration_units
=1;
294
h->
calibration_units_label
=1;
295
strcpy(h->
data_units
,
"mg/min/100g"
);
296
break
;
297
case
CUNIT_HU:
298
h->
calibration_units
=1;
299
h->
calibration_units_label
=1;
300
strcpy(h->
data_units
,
"HU"
);
301
break
;
302
default
:
303
h->
calibration_units
=2;
304
h->
calibration_units_label
=0;
305
strcpy(h->
data_units
,
""
);
306
break
;
307
}
308
}
309
/*****************************************************************************/
310
311
/*****************************************************************************/
315
char
*
imgUnit
(
317
int
dunit
318
) {
319
return
(
petCunit
(dunit));
320
}
321
/*****************************************************************************/
322
323
/*****************************************************************************/
328
int
imgSetUnit
(
IMG
*img,
char
*unit)
329
{
330
int
new_unit;
331
332
if
(img==NULL || unit==NULL)
return
(1);
333
new_unit=
imgUnitId
(unit);
if
(new_unit<0)
return
(1-new_unit);
334
img->
unit
=new_unit;
335
return
(0);
336
}
337
/*****************************************************************************/
338
339
/*****************************************************************************/
imgUnitToEcat6
int imgUnitToEcat6(IMG *img)
Definition
imgunits.c:175
imgSetUnit
int imgSetUnit(IMG *img, char *unit)
Definition
imgunits.c:328
imgUnit
char * imgUnit(int dunit)
Definition
imgunits.c:315
imgUnitId
int imgUnitId(char *unit)
Definition
imgunits.c:14
imgUnitFromEcat
void imgUnitFromEcat(IMG *img, int ecat_unit)
Definition
imgunits.c:95
imgUnitToEcat7
void imgUnitToEcat7(IMG *img, ECAT7_mainheader *h)
Definition
imgunits.c:209
imgUnitFromEcat7
void imgUnitFromEcat7(IMG *img, ECAT7_mainheader *h)
Definition
imgunits.c:149
libtpcimgio.h
Header file for libtpcimgio.
petCunit
char * petCunit(int cunit)
Definition
petunits.c:211
ECAT7_mainheader
Definition
libtpcimgio.h:300
ECAT7_mainheader::data_units
char data_units[32]
Definition
libtpcimgio.h:420
ECAT7_mainheader::calibration_units
short int calibration_units
Definition
libtpcimgio.h:346
ECAT7_mainheader::calibration_units_label
short int calibration_units_label
Definition
libtpcimgio.h:348
IMG
Definition
libtpcimgio.h:1657
IMG::unit
char unit
Definition
libtpcimgio.h:1673
Generated on
for TPCCLIB by
1.17.0