TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcmodext
units_check.c
Go to the documentation of this file.
1
5
/*****************************************************************************/
6
7
/*****************************************************************************/
8
#include "
libtpcmodext.h
"
9
/*****************************************************************************/
10
11
/*****************************************************************************/
18
int
cunit_check_dft_vs_img
(
20
DFT
*dft,
22
IMG
*img,
25
char
*errmsg,
27
int
verbose
28
) {
29
int
iunit, punit;
30
31
if
(verbose>0) printf(
"calibration_unit_check_dft_vs_img()\n"
);
32
if
(errmsg!=NULL) sprintf(errmsg,
"program error"
);
33
if
(dft==NULL || img==NULL)
return
1;
34
35
iunit=
petCunitId
(dft->
unit
);
// identify input file unit
36
punit=img->
unit
;
37
38
if
(iunit==CUNIT_UNKNOWN) {
// Input file unit is unknown
39
// If PET unit is not known either, give a warning
40
if
(punit==CUNIT_UNKNOWN) {
41
if
(errmsg!=NULL) sprintf(errmsg,
"unknown concentration units"
);
42
return
-1;
43
}
else
{
// Set to PET unit, and give a warning
44
if
(errmsg!=NULL)
45
sprintf(errmsg,
"unknown input concentration unit, now set to PET unit"
);
46
strcpy(dft->
unit
,
imgUnit
(img->
unit
));
47
return
-2;
48
}
49
}
50
51
// Input unit is known; if PET unit is not, then give a warning
52
if
(punit==CUNIT_UNKNOWN) {
53
if
(errmsg!=NULL) sprintf(errmsg,
"unknown concentration units in PET data"
);
54
return
-3;
55
}
56
57
// Both units are known, so convert input data if necessary/possible
58
if
(iunit==CUNIT_KBQ_PER_ML) {
// input is in units kBq/ml
59
// If PET unit is the same, then everything is fine
60
if
(punit==CUNIT_KBQ_PER_ML) {
61
if
(errmsg!=NULL)
62
sprintf(errmsg,
"input and PET data have the same concentration units.\n"
);
63
return
0;
64
}
else
if
(punit==CUNIT_BQ_PER_ML) {
// image is in Bq/ml, convert input
65
dftUnitConversion
(dft, CUNIT_BQ_PER_ML);
66
if
(errmsg!=NULL)
67
sprintf(errmsg,
"input units converted to %s\n"
, dft->
unit
);
68
return
0;
69
}
else
{
// image is in some other units, just give a warning for now
70
if
(errmsg!=NULL)
71
sprintf(errmsg,
"different concentration units in input and PET data"
);
72
return
-4;
73
}
74
}
else
if
(iunit==CUNIT_BQ_PER_ML) {
// input is in units Bq/ml
75
// If PET unit is the same, then everything is fine
76
if
(punit==CUNIT_BQ_PER_ML) {
77
if
(errmsg!=NULL)
78
sprintf(errmsg,
"input and PET data have the same concentration units.\n"
);
79
return
0;
80
}
else
if
(punit==CUNIT_KBQ_PER_ML) {
// image is in kBq/ml, convert input
81
dftUnitConversion
(dft, CUNIT_KBQ_PER_ML);
82
if
(errmsg!=NULL)
83
sprintf(errmsg,
"input units converted to %s\n"
, dft->
unit
);
84
return
0;
85
}
else
{
// image is in some other units, just give a warning for now
86
if
(errmsg!=NULL)
87
sprintf(errmsg,
"different concentration units in input and PET data"
);
88
return
-4;
89
}
90
}
else
{
// input unit is known, but not kBq/ml or Bq/ml
91
if
(errmsg!=NULL)
92
sprintf(errmsg,
"check the concentration units in input and PET data"
);
93
return
-5;
94
}
95
96
return
0;
97
}
98
/*****************************************************************************/
99
100
/*****************************************************************************/
dftUnitConversion
int dftUnitConversion(DFT *dft, int dunit)
Definition
dftunit.c:25
imgUnit
char * imgUnit(int dunit)
Definition
imgunits.c:315
petCunitId
int petCunitId(const char *unit)
Definition
petunits.c:74
libtpcmodext.h
Header file for libtpcmodext.
DFT
Definition
libtpccurveio.h:73
DFT::unit
char unit[MAX_UNITS_LEN+1]
Definition
libtpccurveio.h:83
IMG
Definition
libtpcimgio.h:1657
IMG::unit
char unit
Definition
libtpcimgio.h:1673
cunit_check_dft_vs_img
int cunit_check_dft_vs_img(DFT *dft, IMG *img, char *errmsg, int verbose)
Definition
units_check.c:18
Generated on
for TPCCLIB by
1.17.0