22 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintMainheader()\n");
25 fprintf(fp,
"sw_version := %d\n", h->
sw_version);
30 if(!
ctime_r_int(&t, tmp)) strcpy(tmp,
"1900-01-01 00:00:00");
31 fprintf(fp,
"scan_start_time := %s\n", tmp);
50 fprintf(fp,
"study_type := %.12s\n", h->
study_type);
51 fprintf(fp,
"patient_id := %.16s\n", h->
patient_id);
66 fprintf(fp,
"num_planes := %d\n", h->
num_planes);
67 fprintf(fp,
"num_frames := %d\n", h->
num_frames);
68 fprintf(fp,
"num_gates := %d\n", h->
num_gates);
71 fprintf(fp,
"bed_position :=");
72 for(
int i=0; i<15; i++) fprintf(fp,
" %g", h->
bed_position[i]);
80 fprintf(fp,
"bin_size := %g cm\n", h->
bin_size);
83 if(!
ctime_r_int(&t, tmp)) strcpy(tmp,
"1900-01-01 00:00:00");
84 fprintf(fp,
"dose_start_time := %s\n", tmp);
85 fprintf(fp,
"dosage := %g\n", h->
dosage);
87 fprintf(fp,
"data_units := %.32s\n", h->
data_units);
89 fprintf(fp,
"fill_cti :=");
90 for(
int i=0; i<6; i++) fprintf(fp,
" %d", h->
fill_cti[i]);
105 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintImageheader()\n");
108 fprintf(fp,
"x_dimension := %d\n", h->
x_dimension);
109 fprintf(fp,
"y_dimension := %d\n", h->
y_dimension);
110 fprintf(fp,
"z_dimension := %d\n", h->
z_dimension);
111 fprintf(fp,
"x_offset := %g\n", h->
x_offset);
112 fprintf(fp,
"y_offset := %g\n", h->
y_offset);
113 fprintf(fp,
"z_offset := %g\n", h->
z_offset);
114 fprintf(fp,
"recon_zoom := %g\n", h->
recon_zoom);
116 fprintf(fp,
"image_min := %d\n", h->
image_min);
117 fprintf(fp,
"image_max := %d\n", h->
image_max);
123 fprintf(fp,
"filter_code := %d\n", h->
filter_code);
128 fprintf(fp,
"num_angles := %g\n", h->
num_angles);
141 fprintf(fp,
"annotation := %.40s\n", h->
annotation);
142 fprintf(fp,
"mt_1_1 := %g\n", h->
mt_1_1);
143 fprintf(fp,
"mt_1_2 := %g\n", h->
mt_1_2);
144 fprintf(fp,
"mt_1_3 := %g\n", h->
mt_1_3);
145 fprintf(fp,
"mt_2_1 := %g\n", h->
mt_2_1);
146 fprintf(fp,
"mt_2_2 := %g\n", h->
mt_2_2);
147 fprintf(fp,
"mt_2_3 := %g\n", h->
mt_2_3);
148 fprintf(fp,
"mt_3_1 := %g\n", h->
mt_3_1);
149 fprintf(fp,
"mt_3_2 := %g\n", h->
mt_3_2);
150 fprintf(fp,
"mt_3_3 := %g\n", h->
mt_3_3);
159 fprintf(fp,
"mt_1_4 := %g\n", h->
mt_1_4);
160 fprintf(fp,
"mt_2_4 := %g\n", h->
mt_2_4);
161 fprintf(fp,
"mt_3_4 := %g\n", h->
mt_3_4);
163 fprintf(fp,
"recon_type := %d\n", h->
recon_type);
164 fprintf(fp,
"recon_views := %d\n", h->
recon_views);
165 fprintf(fp,
"fill_cti :=");
166 for(
int i=0; i<87; i++) fprintf(fp,
" %d", h->
fill_cti[i]);
168 fprintf(fp,
"fill_user :=");
169 for(
int i=0; i<49; i++) fprintf(fp,
" %d", h->
fill_user[i]);
184 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintScanheader()\n");
185 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
189 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
191 fprintf(fp,
"num_z_elements :=");
197 fprintf(fp,
"x_resolution := %g cm\n", h->
x_resolution);
198 fprintf(fp,
"v_resolution := %g rad\n", h->
v_resolution);
199 fprintf(fp,
"z_resolution := %g cm\n", h->
z_resolution);
205 fprintf(fp,
"scan_min := %d\n", h->
scan_min);
206 fprintf(fp,
"scan_max := %d\n", h->
scan_max);
207 fprintf(fp,
"prompts := %d\n", h->
prompts);
208 fprintf(fp,
"delayed := %d\n", h->
delayed);
209 fprintf(fp,
"multiples := %d\n", h->
multiples);
210 fprintf(fp,
"net_trues := %d\n", h->
net_trues);
211 fprintf(fp,
"tot_avg_cor := %g\n", h->
tot_avg_cor);
217 fprintf(fp,
"uncor_singles :=");
218 for(
int i=0; i<128; i++) fprintf(fp,
" %g", h->
uncor_singles[i]);
233 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintAttenheader()\n");
234 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
239 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
247 fprintf(fp,
"x_offset := %g\n", h->
x_offset);
248 fprintf(fp,
"y_offset := %g\n", h->
y_offset);
249 fprintf(fp,
"x_radius := %g\n", h->
x_radius);
250 fprintf(fp,
"y_radius := %g\n", h->
y_radius);
251 fprintf(fp,
"tilt_angle := %g\n", h->
tilt_angle);
257 fprintf(fp,
"additional_atten_coeff :=");
262 fprintf(fp,
"span := %d\n", h->
span);
263 fprintf(fp,
"z_elements :=");
264 for(
int i=0; i<64; i++) fprintf(fp,
" %d", h->
z_elements[i]);
281 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintPolmapheader()\n");
282 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
285 fprintf(fp,
"num_rings := %d\n", h->
num_rings);
286 fprintf(fp,
"sectors_per_ring :=");
289 fprintf(fp,
"ring_position :=");
292 fprintf(fp,
"ring_angle :=");
293 for(i=0; i<32; i++) fprintf(fp,
" %d", h->
ring_angle[i]);
295 fprintf(fp,
"start_angle := %d\n", h->
start_angle);
296 fprintf(fp,
"long_axis_left :=");
299 fprintf(fp,
"long_axis_right :=");
303 fprintf(fp,
"image_min := %d\n", h->
image_min);
304 fprintf(fp,
"image_max := %d\n", h->
image_max);
306 fprintf(fp,
"pixel_size := %g\n", h->
pixel_size);
310 fprintf(fp,
"quant_units := %d\n", h->
quant_units);
311 fprintf(fp,
"annotation := %.40s\n", h->
annotation);
330 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintNormheader()\n");
331 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
338 fprintf(fp,
"uld := %d\n", h->
uld);
339 fprintf(fp,
"lld := %d\n", h->
lld);
343 fprintf(fp,
"ring_dtcor1 :=");
344 for(
int i=0; i<32; i++) fprintf(fp,
" %E", h->
ring_dtcor1[i]);
346 fprintf(fp,
"ring_dtcor2 :=");
347 for(
int i=0; i<32; i++) fprintf(fp,
" %E", h->
ring_dtcor2[i]);
349 fprintf(fp,
"crystal_dtcor :=");
350 for(
int i=0; i<8; i++) fprintf(fp,
" %E", h->
crystal_dtcor[i]);
352 fprintf(fp,
"span := %d\n", h->
span);
367 if(
ECAT7_TEST) fprintf(stdout,
"ecat7Print2DScanheader()\n");
368 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
372 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
384 fprintf(fp,
"scan_min := %d\n", h->
scan_min);
385 fprintf(fp,
"scan_max := %d\n", h->
scan_max);
386 fprintf(fp,
"prompts := %d\n", h->
prompts);
387 fprintf(fp,
"delayed := %d\n", h->
delayed);
388 fprintf(fp,
"multiples := %d\n", h->
multiples);
389 fprintf(fp,
"net_trues := %d\n", h->
net_trues);
390 fprintf(fp,
"cor_singles :=");
391 for(
int i=0; i<16; i++) fprintf(fp,
" %g", h->
cor_singles[i]);
393 fprintf(fp,
"uncor_singles :=");
394 for(
int i=0; i<16; i++) fprintf(fp,
" %g", h->
uncor_singles[i]);
396 fprintf(fp,
"tot_avg_cor := %g\n", h->
tot_avg_cor);
402 fprintf(fp,
"physical_planes :=");
418 if(
ECAT7_TEST) fprintf(stdout,
"ecat7Print2DNormheader()\n");
419 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
423 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
427 fprintf(fp,
"norm_min := %g\n", h->
norm_min);
428 fprintf(fp,
"norm_max := %g\n", h->
norm_max);
433 fprintf(fp,
"span := %d\n", h->
span);
434 fprintf(fp,
"z_elements :=");
435 for(
int i=0; i<64; i++) fprintf(fp,
" %d", h->
z_elements[i]);
450 static char *info[] = {
451 "unknown",
"2D sinogram",
"image-16",
"attenuation correction",
452 "2D normalization",
"polar map",
"volume 8",
"volume 16",
453 "projection 8",
"projection 16",
"image 8",
"3D sinogram 16",
454 "3D sinogram 8",
"3D normalization",
"3D sinogram fit",
456 if(file_type>=0 && file_type<=14)
return((
char*)info[file_type]);
457 else return((
char*)info[0]);
469 short int acquisition_type
471 static char *info[] = {
472 "undefined",
"blank",
"transmission",
"static emission",
473 "dynamic emission",
"gated emission",
"transmission rectilinear",
474 "emission rectilinear",
476 if(acquisition_type>=0 && acquisition_type<=7)
477 return((
char*)info[acquisition_type]);
478 else return((
char*)info[0]);
492 static char *info[] = {
493 "unknown",
"byte",
"VAX 2 byte integer",
"VAX 4 byte integer",
494 "VAX 4 byte float",
"IEEE 4 byte float",
"SUN 2 byte integer",
495 "SUN 4 byte integer",
497 if(data_type>=0 && data_type<=7)
return((
char*)info[data_type]);
498 else return((
char*)info[0]);
536 fprintf(stderr,
"Error (%d): cannot read matrix list.\n", ret);
540 fprintf(stderr,
"Error: matrix list is empty.\n");
548 for(mi=nr=0; mi<mlist.
matrixNr; mi++) {
552 if(frame>=0 && frame!=matval.
frame)
continue;
553 if(plane>=0 && plane!=matval.
plane)
continue;
554 fprintf(fp,
"Matrix: plane %d frame %d gate %d bed %d\n",
593 fprintf(stderr,
"Error: matrix filetype %d is not yet supported.\n",
599 fprintf(stderr,
"Error %d in reading subheader.\n", ret);
606 if(nr==0 && (plane>=0 || frame>=0)) {
607 fprintf(stderr,
"Error: specified matrices not found.\n");
char * ctime_r_int(const time_t *t, char *buf)
Convert calendard time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss,...
void ecat7InitMatlist(ECAT7_MATRIXLIST *mlist)
void ecat7_id_to_val(int matrix_id, ECAT7_Matval *matval)
int ecat7ReadMatlist(FILE *fp, ECAT7_MATRIXLIST *ml, int verbose)
void ecat7EmptyMatlist(ECAT7_MATRIXLIST *mlist)
void ecat7PrintMatlist(ECAT7_MATRIXLIST *ml)
void ecat7PrintNormheader(ECAT7_normheader *h, FILE *fp)
void ecat7PrintImageheader(ECAT7_imageheader *h, FILE *fp)
char * ecat7acquisitiontype(short int acquisition_type)
char * ecat7filetype(short int file_type)
void ecat7PrintPolmapheader(ECAT7_polmapheader *h, FILE *fp)
char * ecat7datatype(short int data_type)
void ecat7PrintAttenheader(ECAT7_attenheader *h, FILE *fp)
void ecat7Print2DScanheader(ECAT7_2Dscanheader *h, FILE *fp)
void ecat7PrintMainheader(ECAT7_mainheader *h, FILE *fp)
int ecat7PrintSubheader(ECAT7_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp)
void ecat7PrintScanheader(ECAT7_scanheader *h, FILE *fp)
void ecat7Print2DNormheader(ECAT7_2Dnormheader *h, FILE *fp)
int ecat7ReadScanheader(FILE *fp, int blk, ECAT7_scanheader *h)
int ecat7ReadPolmapheader(FILE *fp, int blk, ECAT7_polmapheader *h)
int ecat7ReadNormheader(FILE *fp, int blk, ECAT7_normheader *h)
int ecat7ReadAttenheader(FILE *fp, int blk, ECAT7_attenheader *h)
int ecat7Read2DScanheader(FILE *fp, int blk, ECAT7_2Dscanheader *h)
int ecat7ReadImageheader(FILE *fp, int blk, ECAT7_imageheader *h)
int ecat7Read2DNormheader(FILE *fp, int blk, ECAT7_2Dnormheader *h)
Header file for libtpcimgio.
short int compression_code
float well_counter_corr_factor
char user_process_code[10]
short int angular_compression
short int calibration_units
short int acquisition_mode
short int calibration_units_label
float ecat_calibration_factor
short int transm_source_type
short int acquisition_type
char study_description[32]
short int axial_samp_mode
char radiopharmaceutical[32]
short int patient_orientation
char original_file_name[32]