55 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintMainheader()\n");
58 fprintf(fp,
"sw_version := %d\n", h->
sw_version);
63 if(st!=NULL) strftime(tmp, 32,
"%Y-%m-%d %H:%M:%S", st);
64 else strcpy(tmp,
"1900-01-01 00:00:00");
65 fprintf(fp,
"scan_start_time := %s\n", tmp);
84 fprintf(fp,
"study_type := %.12s\n", h->
study_type);
85 fprintf(fp,
"patient_id := %.16s\n", h->
patient_id);
100 fprintf(fp,
"num_planes := %d\n", h->
num_planes);
101 fprintf(fp,
"num_frames := %d\n", h->
num_frames);
102 fprintf(fp,
"num_gates := %d\n", h->
num_gates);
103 fprintf(fp,
"num_bed_pos := %d\n", h->
num_bed_pos);
105 fprintf(fp,
"bed_position :=");
106 for(i=0; i<15; i++) fprintf(fp,
" %g", h->
bed_position[i]);
114 fprintf(fp,
"bin_size := %g cm\n", h->
bin_size);
117 if(st!=NULL) strftime(tmp, 32,
"%Y-%m-%d %H:%M:%S", st);
118 else strcpy(tmp,
"1900-01-01 00:00:00");
119 fprintf(fp,
"dose_start_time := %s\n", tmp);
120 fprintf(fp,
"dosage := %g\n", h->
dosage);
122 fprintf(fp,
"data_units := %.32s\n", h->
data_units);
123 fprintf(fp,
"septa_state := %d\n", h->
septa_state);
124 fprintf(fp,
"fill_cti :=");
125 for(i=0; i<6; i++) fprintf(fp,
" %d", h->
fill_cti[i]);
140 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintImageheader()\n");
141 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
144 fprintf(fp,
"x_dimension := %d\n", h->
x_dimension);
145 fprintf(fp,
"y_dimension := %d\n", h->
y_dimension);
146 fprintf(fp,
"z_dimension := %d\n", h->
z_dimension);
147 fprintf(fp,
"x_offset := %g\n", h->
x_offset);
148 fprintf(fp,
"y_offset := %g\n", h->
y_offset);
149 fprintf(fp,
"z_offset := %g\n", h->
z_offset);
150 fprintf(fp,
"recon_zoom := %g\n", h->
recon_zoom);
152 fprintf(fp,
"image_min := %d\n", h->
image_min);
153 fprintf(fp,
"image_max := %d\n", h->
image_max);
159 fprintf(fp,
"filter_code := %d\n", h->
filter_code);
164 fprintf(fp,
"num_angles := %g\n", h->
num_angles);
177 fprintf(fp,
"annotation := %.40s\n", h->
annotation);
178 fprintf(fp,
"mt_1_1 := %g\n", h->
mt_1_1);
179 fprintf(fp,
"mt_1_2 := %g\n", h->
mt_1_2);
180 fprintf(fp,
"mt_1_3 := %g\n", h->
mt_1_3);
181 fprintf(fp,
"mt_2_1 := %g\n", h->
mt_2_1);
182 fprintf(fp,
"mt_2_2 := %g\n", h->
mt_2_2);
183 fprintf(fp,
"mt_2_3 := %g\n", h->
mt_2_3);
184 fprintf(fp,
"mt_3_1 := %g\n", h->
mt_3_1);
185 fprintf(fp,
"mt_3_2 := %g\n", h->
mt_3_2);
186 fprintf(fp,
"mt_3_3 := %g\n", h->
mt_3_3);
195 fprintf(fp,
"mt_1_4 := %g\n", h->
mt_1_4);
196 fprintf(fp,
"mt_2_4 := %g\n", h->
mt_2_4);
197 fprintf(fp,
"mt_3_4 := %g\n", h->
mt_3_4);
199 fprintf(fp,
"recon_type := %d\n", h->
recon_type);
200 fprintf(fp,
"recon_views := %d\n", h->
recon_views);
201 fprintf(fp,
"fill_cti :=");
202 for(i=0; i<87; i++) fprintf(fp,
" %d", h->
fill_cti[i]); fprintf(fp,
"\n");
203 fprintf(fp,
"fill_user :=");
204 for(i=0; i<49; i++) fprintf(fp,
" %d", h->
fill_user[i]); fprintf(fp,
"\n");
218 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintScanheader()\n");
219 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
223 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
225 fprintf(fp,
"num_z_elements :=");
231 fprintf(fp,
"x_resolution := %g cm\n", h->
x_resolution);
232 fprintf(fp,
"v_resolution := %g rad\n", h->
v_resolution);
233 fprintf(fp,
"z_resolution := %g cm\n", h->
z_resolution);
239 fprintf(fp,
"scan_min := %d\n", h->
scan_min);
240 fprintf(fp,
"scan_max := %d\n", h->
scan_max);
241 fprintf(fp,
"prompts := %d\n", h->
prompts);
242 fprintf(fp,
"delayed := %d\n", h->
delayed);
243 fprintf(fp,
"multiples := %d\n", h->
multiples);
244 fprintf(fp,
"net_trues := %d\n", h->
net_trues);
245 fprintf(fp,
"tot_avg_cor := %g\n", h->
tot_avg_cor);
251 fprintf(fp,
"uncor_singles :=");
252 for(i=0; i<128; i++) fprintf(fp,
" %g", h->
uncor_singles[i]);
267 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintAttenheader()\n");
268 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
273 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
281 fprintf(fp,
"x_offset := %g\n", h->
x_offset);
282 fprintf(fp,
"y_offset := %g\n", h->
y_offset);
283 fprintf(fp,
"x_radius := %g\n", h->
x_radius);
284 fprintf(fp,
"y_radius := %g\n", h->
y_radius);
285 fprintf(fp,
"tilt_angle := %g\n", h->
tilt_angle);
291 fprintf(fp,
"additional_atten_coeff :=");
296 fprintf(fp,
"span := %d\n", h->
span);
297 fprintf(fp,
"z_elements :=");
298 for(i=0; i<64; i++) fprintf(fp,
" %d", h->
z_elements[i]);
313 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintPolmapheader()\n");
314 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
317 fprintf(fp,
"num_rings := %d\n", h->
num_rings);
318 fprintf(fp,
"sectors_per_ring :=");
321 fprintf(fp,
"ring_position :=");
324 fprintf(fp,
"ring_angle :=");
325 for(i=0; i<32; i++) fprintf(fp,
" %d", h->
ring_angle[i]);
327 fprintf(fp,
"start_angle := %d\n", h->
start_angle);
328 fprintf(fp,
"long_axis_left :=");
331 fprintf(fp,
"long_axis_right :=");
335 fprintf(fp,
"image_min := %d\n", h->
image_min);
336 fprintf(fp,
"image_max := %d\n", h->
image_max);
338 fprintf(fp,
"pixel_size := %g\n", h->
pixel_size);
342 fprintf(fp,
"quant_units := %d\n", h->
quant_units);
343 fprintf(fp,
"annotation := %.40s\n", h->
annotation);
362 if(
ECAT7_TEST) fprintf(stdout,
"ecat7PrintNormheader()\n");
363 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
370 fprintf(fp,
"uld := %d\n", h->
uld);
371 fprintf(fp,
"lld := %d\n", h->
lld);
375 fprintf(fp,
"ring_dtcor1 :=");
376 for(i=0; i<32; i++) fprintf(fp,
" %E", h->
ring_dtcor1[i]);
378 fprintf(fp,
"ring_dtcor2 :=");
379 for(i=0; i<32; i++) fprintf(fp,
" %E", h->
ring_dtcor2[i]);
381 fprintf(fp,
"crystal_dtcor :=");
384 fprintf(fp,
"span := %d\n", h->
span);
399 if(
ECAT7_TEST) fprintf(stdout,
"ecat7Print2DScanheader()\n");
400 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
404 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
416 fprintf(fp,
"scan_min := %d\n", h->
scan_min);
417 fprintf(fp,
"scan_max := %d\n", h->
scan_max);
418 fprintf(fp,
"prompts := %d\n", h->
prompts);
419 fprintf(fp,
"delayed := %d\n", h->
delayed);
420 fprintf(fp,
"multiples := %d\n", h->
multiples);
421 fprintf(fp,
"net_trues := %d\n", h->
net_trues);
422 fprintf(fp,
"cor_singles :=");
423 for(i=0; i<16; i++) fprintf(fp,
" %g", h->
cor_singles[i]);
425 fprintf(fp,
"uncor_singles :=");
428 fprintf(fp,
"tot_avg_cor := %g\n", h->
tot_avg_cor);
434 fprintf(fp,
"physical_planes :=");
450 if(
ECAT7_TEST) fprintf(stdout,
"ecat7Print2DNormheader()\n");
451 fprintf(fp,
"data_type := %d (%s)\n", h->
data_type,
455 fprintf(fp,
"num_angles := %d\n", h->
num_angles);
459 fprintf(fp,
"norm_min := %g\n", h->
norm_min);
460 fprintf(fp,
"norm_max := %g\n", h->
norm_max);
465 fprintf(fp,
"span := %d\n", h->
span);
466 fprintf(fp,
"z_elements :=");
467 for(i=0; i<64; i++) fprintf(fp,
" %d", h->
z_elements[i]);
480 static char *info[] = {
481 "unknown",
"2D sinogram",
"image-16",
"attenuation correction",
482 "2D normalization",
"polar map",
"volume 8",
"volume 16",
483 "projection 8",
"projection 16",
"image 8",
"3D sinogram 16",
484 "3D sinogram 8",
"3D normalization",
"3D sinogram fit",
486 if(file_type>=0 && file_type<=14)
return((
char*)info[file_type]);
487 else return((
char*)info[0]);
499 static char *info[] = {
500 "undefined",
"blank",
"transmission",
"static emission",
501 "dynamic emission",
"gated emission",
"transmission rectilinear",
502 "emission rectilinear",
504 if(acquisition_type>=0 && acquisition_type<=7)
505 return((
char*)info[acquisition_type]);
506 else return((
char*)info[0]);
518 static char *info[] = {
519 "unknown",
"byte",
"VAX 2 byte integer",
"VAX 4 byte integer",
520 "VAX 4 byte float",
"IEEE 4 byte float",
"SUN 2 byte integer",
521 "SUN 4 byte integer",
523 if(data_type>=0 && data_type<=7)
return((
char*)info[data_type]);
524 else return((
char*)info[0]);
562 fprintf(stderr,
"Error (%d): cannot read matrix list.\n", ret);
566 fprintf(stderr,
"Error: matrix list is empty.\n");
574 for(mi=nr=0; mi<mlist.
matrixNr; mi++) {
578 if(frame>=0 && frame!=matval.
frame)
continue;
579 if(plane>=0 && plane!=matval.
plane)
continue;
580 fprintf(fp,
"Matrix: plane %d frame %d gate %d bed %d\n",
619 fprintf(stderr,
"Error: matrix filetype %d is not yet supported.\n",
625 fprintf(stderr,
"Error %d in reading subheader.\n", ret);
632 if(nr==0 && (plane>=0 || frame>=0)) {
633 fprintf(stderr,
"Error: specified matrices not found.\n");
short int calibration_units_label
float well_counter_corr_factor
int ecat7PrintSubheader(ECAT7_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp)
short int compression_code
void ecat7PrintAttenheader(ECAT7_attenheader *h, FILE *fp)
void ecat7PrintImageheader(ECAT7_imageheader *h, FILE *fp)
float ecat_calibration_factor
short int patient_orientation
char original_file_name[32]
void ecat7PrintMainheader(ECAT7_mainheader *h, FILE *fp)
char * ecat7filetype(short int file_type)
void ecat7PrintNormheader(ECAT7_normheader *h, FILE *fp)
int ecat7ReadScanheader(FILE *fp, int blk, ECAT7_scanheader *h)
int ecat7ReadAttenheader(FILE *fp, int blk, ECAT7_attenheader *h)
short int angular_compression
short int calibration_units
int ecat7Read2DScanheader(FILE *fp, int blk, ECAT7_2Dscanheader *h)
char * ecat7acquisitiontype(short int acquisition_type)
int ecat7Read2DNormheader(FILE *fp, int blk, ECAT7_2Dnormheader *h)
void ecat7InitMatlist(ECAT7_MATRIXLIST *mlist)
void ecat7PrintMatlist(ECAT7_MATRIXLIST *ml)
void ecat7EmptyMatlist(ECAT7_MATRIXLIST *mlist)
short int acquisition_mode
int ecat7ReadPolmapheader(FILE *fp, int blk, ECAT7_polmapheader *h)
char user_process_code[10]
void ecat7Print2DScanheader(ECAT7_2Dscanheader *h, FILE *fp)
void ecat7Print2DNormheader(ECAT7_2Dnormheader *h, FILE *fp)
short int transm_source_type
int ecat7ReadNormheader(FILE *fp, int blk, ECAT7_normheader *h)
void ecat7_id_to_val(int matrix_id, ECAT7_Matval *matval)
short int acquisition_type
int ecat7ReadMatlist(FILE *fp, ECAT7_MATRIXLIST *ml)
char study_description[32]
short int axial_samp_mode
void ecat7PrintScanheader(ECAT7_scanheader *h, FILE *fp)
char radiopharmaceutical[32]
char * ecat7datatype(short int data_type)
int ecat7ReadImageheader(FILE *fp, int blk, ECAT7_imageheader *h)
void ecat7PrintPolmapheader(ECAT7_polmapheader *h, FILE *fp)