TPCCLIB
Loading...
Searching...
No Matches
imgunits.c File Reference

Setting image calibration unit. More...

#include "libtpcimgio.h"

Go to the source code of this file.

Functions

int imgUnitId (char *unit)
 
void imgUnitFromEcat (IMG *img, int ecat_unit)
 
void imgUnitFromEcat7 (IMG *img, ECAT7_mainheader *h)
 
int imgUnitToEcat6 (IMG *img)
 
void imgUnitToEcat7 (IMG *img, ECAT7_mainheader *h)
 
char * imgUnit (int dunit)
 
int imgSetUnit (IMG *img, char *unit)
 

Detailed Description

Setting image calibration unit.

Author
Vesa Oikonen

Definition in file imgunits.c.

Function Documentation

◆ imgSetUnit()

int imgSetUnit ( IMG * img,
char * unit )

Sets the unit in IMG based on specified unit string.

See also
imgUnitId, imgUnitFromEcat, imgUnitFromEcat7
Returns
Returns 0 if successful.

Definition at line 328 of file imgunits.c.

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}
int imgUnitId(char *unit)
Definition imgunits.c:14
char unit

◆ imgUnit()

char * imgUnit ( int dunit)

Return pointer to string describing the calibrated image data unit

Returns
Pointer to string
Parameters
dunitUnit id number.

Definition at line 315 of file imgunits.c.

318 {
319 return(petCunit(dunit));
320}
char * petCunit(int cunit)
Definition petunits.c:211

Referenced by clusterTACs(), cunit_check_dft_vs_img(), dftAllocateWithIMG(), imgInfo(), and sif2dft().

◆ imgUnitFromEcat()

void imgUnitFromEcat ( IMG * img,
int ecat_unit )

Set IMG calibration unit based on ECAT 6.3 unit.

See also
imgUnitFromEcat7, imgUnitId, imgUnitToEcat6, imgSetUnit
Parameters
imgPointer to target IMG structure.
ecat_unitCalibration unit code id.

Definition at line 95 of file imgunits.c.

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}

Referenced by ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), imgGetEcat63MHeader(), and imgReadEcat63Header().

◆ imgUnitFromEcat7()

void imgUnitFromEcat7 ( IMG * img,
ECAT7_mainheader * h )

Set IMG calibration unit based on ECAT7 main header.

See also
imgUnitFromEcat, imgUnitId, imgUnitToEcat7, imgSetUnit
Parameters
imgPointer to target IMG structure.
hPointer to source ECAT 7 main header structure.

Definition at line 149 of file imgunits.c.

154 {
155 if(h->calibration_units==0) { /* Not calibrated */
156 img->unit=1;
157 } else if(h->calibration_units==1) {
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}
char data_units[32]
short int calibration_units
short int calibration_units_label

Referenced by imgGetEcat7MHeader().

◆ imgUnitId()

int imgUnitId ( char * unit)

Identify the specified unit string as IMG unit.

See also
imgSetUnit, imgUnitId, petCunitId
Returns
unit id number, -1 invalid input, -3 no match found
Parameters
unitPointer to string containing the unit to be identified.

Definition at line 14 of file imgunits.c.

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}

Referenced by imgConvertUnit(), imgSetUnit(), and imgUnitFromEcat7().

◆ imgUnitToEcat6()

int imgUnitToEcat6 ( IMG * img)

Return ECAT 6.3 calibration unit based on IMG unit

See also
imgUnitFromEcat, imgUnitId, imgUnitToEcat7, imgSetUnit
Returns
calibration unit code number.
Parameters
imgPointer to IMG structure.

Definition at line 175 of file imgunits.c.

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}

Referenced by ecat63AddImg(), ecat63WriteAllImg(), imgSetEcat63MHeader(), and imgSetEcat63SHeader().

◆ imgUnitToEcat7()

void imgUnitToEcat7 ( IMG * img,
ECAT7_mainheader * h )

Set ECAT 7 main header calibration units based on IMG unit.

See also
imgUnitFromEcat7, imgUnitId, imgUnitToEcat6, imgSetUnit
Parameters
imgPointer to source IMG structure.
hPointer to target ECAT 7 main header structure.

Definition at line 209 of file imgunits.c.

214 {
215 switch(img->unit) {
216 case CUNIT_CPS:
217 case CUNIT_COUNTS:
220 strcpy(h->data_units, "ECAT counts/sec");
221 break;
222 case CUNIT_KBQ_PER_ML:
225 strcpy(h->data_units, "kBq/cc");
226 break;
227 case CUNIT_SEC_KBQ_PER_ML:
230 strcpy(h->data_units, "sec*kBq/mL");
231 break;
232 case CUNIT_PER_SEC:
235 strcpy(h->data_units, "1/sec");
236 break;
237 case CUNIT_PER_MIN:
240 strcpy(h->data_units, "1/min");
241 break;
242 case CUNIT_ML_PER_ML:
245 strcpy(h->data_units, "mL/mL");
246 break;
247 case CUNIT_ML_PER_DL:
250 strcpy(h->data_units, "mL/dL");
251 break;
252 case CUNIT_ML_PER_ML_PER_MIN:
255 strcpy(h->data_units, "mL/(mL*min)");
256 break;
257 case CUNIT_ML_PER_DL_PER_MIN:
260 strcpy(h->data_units, "mL/(dL*min)");
261 break;
262 case CUNIT_UNITLESS:
265 strcpy(h->data_units, "unitless");
266 break;
267 case CUNIT_NCI_PER_ML:
270 strcpy(h->data_units, "nCi/cc");
271 break;
272 case CUNIT_MBQ_PER_ML:
275 strcpy(h->data_units, "MBq/cc");
276 break;
277 case CUNIT_BQ_PER_ML:
280 strcpy(h->data_units, "Bq/cc");
281 break;
282 case CUNIT_UCI_PER_ML:
285 strcpy(h->data_units, "uCi/cc");
286 break;
287 case CUNIT_UMOL_PER_MIN_PER_100G:
290 strcpy(h->data_units, "umol/min/100g");
291 break;
292 case CUNIT_MG_PER_MIN_PER_100G:
295 strcpy(h->data_units, "mg/min/100g");
296 break;
297 case CUNIT_HU:
300 strcpy(h->data_units, "HU");
301 break;
302 default:
305 strcpy(h->data_units, "");
306 break;
307 }
308}

Referenced by imgSetEcat7MHeader().