TPCCLIB
Loading...
Searching...
No Matches
ecat7p.c
Go to the documentation of this file.
1
5/*****************************************************************************/
6#include "libtpcimgio.h"
7/*****************************************************************************/
8
9/*****************************************************************************/
17 ECAT7_mainheader *h, FILE *fp
18) {
19 char tmp[64];
20 time_t t;
21
22 if(ECAT7_TEST) fprintf(stdout, "ecat7PrintMainheader()\n");
23 fprintf(fp, "magic_number := %.14s\n", h->magic_number);
24 fprintf(fp, "original_file_name := %.32s\n", h->original_file_name);
25 fprintf(fp, "sw_version := %d\n", h->sw_version);
26 fprintf(fp, "system_type := %d\n", h->system_type);
27 fprintf(fp, "file_type := %d (%s)\n", h->file_type, ecat7filetype(h->file_type) );
28 fprintf(fp, "serial_number := %.10s\n", h->serial_number);
29 t=(time_t)h->scan_start_time;
30 if(!ctime_r_int(&t, tmp)) strcpy(tmp, "1900-01-01 00:00:00");
31 fprintf(fp, "scan_start_time := %s\n", tmp);
32 fprintf(fp, "isotope_name := %.8s\n", h->isotope_name);
33 fprintf(fp, "isotope_halflife := %E sec\n", h->isotope_halflife);
34 fprintf(fp, "radiopharmaceutical := %.32s\n", h->radiopharmaceutical);
35 fprintf(fp, "gantry_tilt := %g\n", h->gantry_tilt);
36 fprintf(fp, "gantry_rotation := %g\n", h->gantry_rotation);
37 fprintf(fp, "bed_elevation := %g\n", h->bed_elevation);
38 fprintf(fp, "intrinsic_tilt := %g\n", h->intrinsic_tilt);
39 fprintf(fp, "wobble_speed := %d\n", h->wobble_speed);
40 fprintf(fp, "transm_source_type := %d\n", h->transm_source_type);
41 fprintf(fp, "distance_scanned := %g\n", h->distance_scanned);
42 fprintf(fp, "transaxial_fov := %g\n", h->transaxial_fov);
43 fprintf(fp, "angular_compression := %d\n", h->angular_compression);
44 fprintf(fp, "coin_samp_mode := %d\n", h->coin_samp_mode);
45 fprintf(fp, "axial_samp_mode := %d\n", h->axial_samp_mode);
46 fprintf(fp, "ecat_calibration_factor := %E\n", h->ecat_calibration_factor);
47 fprintf(fp, "calibration_units := %d\n", h->calibration_units);
48 fprintf(fp, "calibration_units_label := %d\n", h->calibration_units_label);
49 fprintf(fp, "compression_code := %d\n", h->compression_code);
50 fprintf(fp, "study_type := %.12s\n", h->study_type);
51 fprintf(fp, "patient_id := %.16s\n", h->patient_id);
52 fprintf(fp, "patient_name := %.32s\n", h->patient_name);
53 fprintf(fp, "patient_sex := %c\n", (h->patient_sex!=0)?h->patient_sex:(char)32);
54 fprintf(fp, "patient_dexterity := %c\n", (h->patient_dexterity!=0)?h->patient_dexterity:(char)32 );
55 fprintf(fp, "patient_age := %g\n", h->patient_age);
56 fprintf(fp, "patient_height := %g\n", h->patient_height);
57 fprintf(fp, "patient_weight := %g\n", h->patient_weight);
58 fprintf(fp, "patient_birth_date := %d\n", h->patient_birth_date);
59 fprintf(fp, "physician_name := %.32s\n", h->physician_name);
60 fprintf(fp, "operator_name := %.32s\n", h->operator_name);
61 fprintf(fp, "study_description := %.32s\n", h->study_description);
62 fprintf(fp, "acquisition_type := %d (%s)\n", h->acquisition_type,
64 fprintf(fp, "patient_orientation := %d\n", h->patient_orientation);
65 fprintf(fp, "facility_name := %.20s\n", h->facility_name);
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);
69 fprintf(fp, "num_bed_pos := %d\n", h->num_bed_pos);
70 fprintf(fp, "init_bed_position := %g\n", h->init_bed_position);
71 fprintf(fp, "bed_position :=");
72 for(int i=0; i<15; i++) fprintf(fp, " %g", h->bed_position[i]);
73 fprintf(fp, "\n");
74 fprintf(fp, "plane_separation := %g cm\n", h->plane_separation);
75 fprintf(fp, "lwr_sctr_thres := %d\n", h->lwr_sctr_thres);
76 fprintf(fp, "lwr_true_thres := %d\n", h->lwr_true_thres);
77 fprintf(fp, "upr_true_thres := %d\n", h->upr_true_thres);
78 fprintf(fp, "user_process_code := %.10s\n", h->user_process_code);
79 fprintf(fp, "acquisition_mode := %d\n", h->acquisition_mode);
80 fprintf(fp, "bin_size := %g cm\n", h->bin_size);
81 fprintf(fp, "branching_fraction := %g\n", h->branching_fraction);
82 t=(time_t)h->dose_start_time;
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);
86 fprintf(fp, "well_counter_corr_factor := %E\n", h->well_counter_corr_factor);
87 fprintf(fp, "data_units := %.32s\n", h->data_units);
88 fprintf(fp, "septa_state := %d\n", h->septa_state);
89 fprintf(fp, "fill_cti :=");
90 for(int i=0; i<6; i++) fprintf(fp, " %d", h->fill_cti[i]);
91 fprintf(fp, "\n");
92}
93/*****************************************************************************/
94
95/*****************************************************************************/
103 ECAT7_imageheader *h, FILE *fp
104) {
105 if(ECAT7_TEST) fprintf(stdout, "ecat7PrintImageheader()\n");
106 fprintf(fp, "data_type := %d (%s)\n", h->data_type, ecat7datatype(h->data_type) );
107 fprintf(fp, "num_dimensions := %d\n", h->num_dimensions);
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);
115 fprintf(fp, "scale_factor := %E\n", h->scale_factor);
116 fprintf(fp, "image_min := %d\n", h->image_min);
117 fprintf(fp, "image_max := %d\n", h->image_max);
118 fprintf(fp, "x_pixel_size := %g\n", h->x_pixel_size);
119 fprintf(fp, "y_pixel_size := %g\n", h->y_pixel_size);
120 fprintf(fp, "z_pixel_size := %g\n", h->z_pixel_size);
121 fprintf(fp, "frame_duration := %d\n", h->frame_duration);
122 fprintf(fp, "frame_start_time := %d\n", h->frame_start_time);
123 fprintf(fp, "filter_code := %d\n", h->filter_code);
124 fprintf(fp, "x_resolution := %g\n", h->x_resolution);
125 fprintf(fp, "y_resolution := %g\n", h->y_resolution);
126 fprintf(fp, "z_resolution := %g\n", h->z_resolution);
127 fprintf(fp, "num_r_elements := %g\n", h->num_r_elements);
128 fprintf(fp, "num_angles := %g\n", h->num_angles);
129 fprintf(fp, "z_rotation_angle := %g\n", h->z_rotation_angle);
130 fprintf(fp, "decay_corr_fctr := %g\n", h->decay_corr_fctr);
131 fprintf(fp, "processing_code := %d\n", h->processing_code);
132 fprintf(fp, "gate_duration := %d\n", h->gate_duration);
133 fprintf(fp, "r_wave_offset := %d\n", h->r_wave_offset);
134 fprintf(fp, "num_accepted_beats := %d\n", h->num_accepted_beats);
135 fprintf(fp, "filter_cutoff_frequency := %E\n", h->filter_cutoff_frequency);
136 fprintf(fp, "filter_resolution := %E\n", h->filter_resolution);
137 fprintf(fp, "filter_ramp_slope := %E\n", h->filter_ramp_slope);
138 fprintf(fp, "filter_order := %d\n", h->filter_order);
139 fprintf(fp, "filter_scatter_fraction := %E\n", h->filter_scatter_fraction);
140 fprintf(fp, "filter_scatter_slope := %E\n", h->filter_scatter_slope);
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);
151 fprintf(fp, "rfilter_cutoff := %g\n", h->rfilter_cutoff);
152 fprintf(fp, "rfilter_resolution := %g\n", h->rfilter_resolution);
153 fprintf(fp, "rfilter_code := %d\n", h->rfilter_code);
154 fprintf(fp, "rfilter_order := %d\n", h->rfilter_order);
155 fprintf(fp, "zfilter_cutoff := %g\n", h->zfilter_cutoff);
156 fprintf(fp, "zfilter_resolution := %g\n", h->zfilter_resolution);
157 fprintf(fp, "zfilter_code := %d\n", h->zfilter_code);
158 fprintf(fp, "zfilter_order := %d\n", h->zfilter_order);
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);
162 fprintf(fp, "scatter_type := %d\n", h->scatter_type);
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]);
167 fprintf(fp, "\n");
168 fprintf(fp, "fill_user :=");
169 for(int i=0; i<49; i++) fprintf(fp, " %d", h->fill_user[i]);
170 fprintf(fp, "\n");
171}
172/*****************************************************************************/
173
174/*****************************************************************************/
182 ECAT7_scanheader *h, FILE *fp
183) {
184 if(ECAT7_TEST) fprintf(stdout, "ecat7PrintScanheader()\n");
185 fprintf(fp, "data_type := %d (%s)\n", h->data_type,
187 fprintf(fp, "num_dimensions := %d\n", h->num_dimensions);
188 fprintf(fp, "num_r_elements := %d\n", h->num_r_elements);
189 fprintf(fp, "num_angles := %d\n", h->num_angles);
190 fprintf(fp, "corrections_applied := %d\n", h->corrections_applied);
191 fprintf(fp, "num_z_elements :=");
192 for(int i=0; i<64; i++) fprintf(fp, " %d", h->num_z_elements[i]);
193 fprintf(fp, "\n");
194 fprintf(fp, "ring_difference := %d\n", h->ring_difference);
195 fprintf(fp, "storage_order := %d\n", h->storage_order);
196 fprintf(fp, "axial_compression := %d (span)\n", h->axial_compression);
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);
200 fprintf(fp, "w_resolution := %g\n", h->w_resolution);
201 fprintf(fp, "gate_duration := %d\n", h->gate_duration);
202 fprintf(fp, "r_wave_offset := %d\n", h->r_wave_offset);
203 fprintf(fp, "num_accepted_beats := %d\n", h->num_accepted_beats);
204 fprintf(fp, "scale_factor := %E\n", h->scale_factor);
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);
212 fprintf(fp, "tot_avg_uncor := %g\n", h->tot_avg_uncor);
213 fprintf(fp, "total_coin_rate := %d\n", h->total_coin_rate);
214 fprintf(fp, "frame_start_time := %d\n", h->frame_start_time);
215 fprintf(fp, "frame_duration := %d\n", h->frame_duration);
216 fprintf(fp, "deadtime_correction_factor := %g\n", h->deadtime_correction_factor);
217 fprintf(fp, "uncor_singles :=");
218 for(int i=0; i<128; i++) fprintf(fp, " %g", h->uncor_singles[i]);
219 fprintf(fp, "\n");
220}
221/*****************************************************************************/
222
223/*****************************************************************************/
231 ECAT7_attenheader *h, FILE *fp
232) {
233 if(ECAT7_TEST) fprintf(stdout, "ecat7PrintAttenheader()\n");
234 fprintf(fp, "data_type := %d (%s)\n", h->data_type,
236 fprintf(fp, "num_dimensions := %d\n", h->num_dimensions);
237 fprintf(fp, "attenuation_type := %d\n", h->attenuation_type);
238 fprintf(fp, "num_r_elements := %d\n", h->num_r_elements);
239 fprintf(fp, "num_angles := %d\n", h->num_angles);
240 fprintf(fp, "num_z_elements := %d\n", h->num_z_elements);
241 fprintf(fp, "ring_difference := %d\n", h->ring_difference);
242 fprintf(fp, "x_resolution := %g\n", h->x_resolution);
243 fprintf(fp, "y_resolution := %g\n", h->y_resolution);
244 fprintf(fp, "z_resolution := %g\n", h->z_resolution);
245 fprintf(fp, "w_resolution := %g\n", h->w_resolution);
246 fprintf(fp, "scale_factor := %E\n", h->scale_factor);
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);
252 fprintf(fp, "attenuation_coeff := %E\n", h->attenuation_coeff);
253 fprintf(fp, "attenuation_min := %E\n", h->attenuation_min);
254 fprintf(fp, "attenuation_max := %E\n", h->attenuation_max);
255 fprintf(fp, "skull_thickness := %g\n", h->skull_thickness);
256 fprintf(fp, "num_additional_atten_coeff := %d\n", h->num_additional_atten_coeff);
257 fprintf(fp, "additional_atten_coeff :=");
258 for(int i=0; i<8; i++) fprintf(fp, " %E", h->additional_atten_coeff[i]);
259 fprintf(fp, "\n");
260 fprintf(fp, "edge_finding_threshold := %g\n", h->edge_finding_threshold);
261 fprintf(fp, "storage_order := %d\n", h->storage_order);
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]);
265 fprintf(fp, "\n");
266}
267/*****************************************************************************/
268
269/*****************************************************************************/
277 ECAT7_polmapheader *h, FILE *fp
278) {
279 int i;
280
281 if(ECAT7_TEST) fprintf(stdout, "ecat7PrintPolmapheader()\n");
282 fprintf(fp, "data_type := %d (%s)\n", h->data_type,
284 fprintf(fp, "polar_map_type := %d\n", h->polar_map_type);
285 fprintf(fp, "num_rings := %d\n", h->num_rings);
286 fprintf(fp, "sectors_per_ring :=");
287 for(i=0; i<32; i++) fprintf(fp, " %d", h->sectors_per_ring[i]);
288 fprintf(fp, "\n");
289 fprintf(fp, "ring_position :=");
290 for(i=0; i<32; i++) fprintf(fp, " %g", h->ring_position[i]);
291 fprintf(fp, "\n");
292 fprintf(fp, "ring_angle :=");
293 for(i=0; i<32; i++) fprintf(fp, " %d", h->ring_angle[i]);
294 fprintf(fp, "\n");
295 fprintf(fp, "start_angle := %d\n", h->start_angle);
296 fprintf(fp, "long_axis_left :=");
297 for(i=0; i<3; i++) fprintf(fp, " %d", h->long_axis_left[i]);
298 fprintf(fp, "\n");
299 fprintf(fp, "long_axis_right :=");
300 for(i=0; i<3; i++) fprintf(fp, " %d", h->long_axis_right[i]);
301 fprintf(fp, "\n");
302 fprintf(fp, "position_data := %d\n", h->position_data);
303 fprintf(fp, "image_min := %d\n", h->image_min);
304 fprintf(fp, "image_max := %d\n", h->image_max);
305 fprintf(fp, "scale_factor := %E\n", h->scale_factor);
306 fprintf(fp, "pixel_size := %g\n", h->pixel_size);
307 fprintf(fp, "frame_duration := %d\n", h->frame_duration);
308 fprintf(fp, "frame_start_time := %d\n", h->frame_start_time);
309 fprintf(fp, "processing_code := %d\n", h->processing_code);
310 fprintf(fp, "quant_units := %d\n", h->quant_units);
311 fprintf(fp, "annotation := %.40s\n", h->annotation);
312 fprintf(fp, "gate_duration := %d\n", h->gate_duration);
313 fprintf(fp, "r_wave_offset := %d\n", h->r_wave_offset);
314 fprintf(fp, "num_accepted_beats := %d\n", h->num_accepted_beats);
315 fprintf(fp, "polar_map_protocol := %.20s\n", h->polar_map_protocol);
316 fprintf(fp, "database_name := %.30s\n", h->database_name);
317}
318/*****************************************************************************/
319
320/*****************************************************************************/
328 ECAT7_normheader *h, FILE *fp
329) {
330 if(ECAT7_TEST) fprintf(stdout, "ecat7PrintNormheader()\n");
331 fprintf(fp, "data_type := %d (%s)\n", h->data_type,
333 fprintf(fp, "num_r_elements := %d\n", h->num_r_elements);
334 fprintf(fp, "num_transaxial_crystals := %d\n", h->num_transaxial_crystals);
335 fprintf(fp, "num_crystal_rings := %d\n", h->num_crystal_rings);
336 fprintf(fp, "crystals_per_ring := %d\n", h->crystals_per_ring);
337 fprintf(fp, "num_geo_corr_planes := %d\n", h->num_geo_corr_planes);
338 fprintf(fp, "uld := %d\n", h->uld);
339 fprintf(fp, "lld := %d\n", h->lld);
340 fprintf(fp, "scatter_energy := %d\n", h->scatter_energy);
341 fprintf(fp, "norm_quality_factor := %g\n", h->norm_quality_factor);
342 fprintf(fp, "norm_quality_factor_code := %d\n", h->norm_quality_factor_code);
343 fprintf(fp, "ring_dtcor1 :=");
344 for(int i=0; i<32; i++) fprintf(fp, " %E", h->ring_dtcor1[i]);
345 fprintf(fp, "\n");
346 fprintf(fp, "ring_dtcor2 :=");
347 for(int i=0; i<32; i++) fprintf(fp, " %E", h->ring_dtcor2[i]);
348 fprintf(fp, "\n");
349 fprintf(fp, "crystal_dtcor :=");
350 for(int i=0; i<8; i++) fprintf(fp, " %E", h->crystal_dtcor[i]);
351 fprintf(fp, "\n");
352 fprintf(fp, "span := %d\n", h->span);
353 fprintf(fp, "max_ring_diff := %d\n", h->max_ring_diff);
354}
355/*****************************************************************************/
356
357/*****************************************************************************/
365 ECAT7_2Dscanheader *h, FILE *fp
366) {
367 if(ECAT7_TEST) fprintf(stdout, "ecat7Print2DScanheader()\n");
368 fprintf(fp, "data_type := %d (%s)\n", h->data_type,
370 fprintf(fp, "num_dimensions := %d\n", h->num_dimensions);
371 fprintf(fp, "num_r_elements := %d\n", h->num_r_elements);
372 fprintf(fp, "num_angles := %d\n", h->num_angles);
373 fprintf(fp, "corrections_applied := %d\n", h->corrections_applied);
374 fprintf(fp, "num_z_elements := %d\n", h->num_z_elements);
375 fprintf(fp, "ring_difference := %d\n", h->ring_difference);
376 fprintf(fp, "x_resolution := %g\n", h->x_resolution);
377 fprintf(fp, "y_resolution := %g\n", h->y_resolution);
378 fprintf(fp, "z_resolution := %g\n", h->z_resolution);
379 fprintf(fp, "w_resolution := %g\n", h->w_resolution);
380 fprintf(fp, "gate_duration := %d\n", h->gate_duration);
381 fprintf(fp, "r_wave_offset := %d\n", h->r_wave_offset);
382 fprintf(fp, "num_accepted_beats := %d\n", h->num_accepted_beats);
383 fprintf(fp, "scale_factor := %E\n", h->scale_factor);
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]);
392 fprintf(fp, "\n");
393 fprintf(fp, "uncor_singles :=");
394 for(int i=0; i<16; i++) fprintf(fp, " %g", h->uncor_singles[i]);
395 fprintf(fp, "\n");
396 fprintf(fp, "tot_avg_cor := %g\n", h->tot_avg_cor);
397 fprintf(fp, "tot_avg_uncor := %g\n", h->tot_avg_uncor);
398 fprintf(fp, "total_coin_rate := %d\n", h->total_coin_rate);
399 fprintf(fp, "frame_start_time := %d\n", h->frame_start_time);
400 fprintf(fp, "frame_duration := %d\n", h->frame_duration);
401 fprintf(fp, "deadtime_correction_factor := %E\n", h->deadtime_correction_factor);
402 fprintf(fp, "physical_planes :=");
403 for(int i=0; i<8; i++) fprintf(fp, " %d", h->physical_planes[i]);
404 fprintf(fp, "\n");
405}
406/*****************************************************************************/
407
408/*****************************************************************************/
416 ECAT7_2Dnormheader *h, FILE *fp
417) {
418 if(ECAT7_TEST) fprintf(stdout, "ecat7Print2DNormheader()\n");
419 fprintf(fp, "data_type := %d (%s)\n", h->data_type,
421 fprintf(fp, "num_dimensions := %d\n", h->num_dimensions);
422 fprintf(fp, "num_r_elements := %d\n", h->num_r_elements);
423 fprintf(fp, "num_angles := %d\n", h->num_angles);
424 fprintf(fp, "num_z_elements := %d\n", h->num_z_elements);
425 fprintf(fp, "ring_difference := %d\n", h->ring_difference);
426 fprintf(fp, "scale_factor := %E\n", h->scale_factor);
427 fprintf(fp, "norm_min := %g\n", h->norm_min);
428 fprintf(fp, "norm_max := %g\n", h->norm_max);
429 fprintf(fp, "fov_source_width := %g\n", h->fov_source_width);
430 fprintf(fp, "norm_quality_factor := %g\n", h->norm_quality_factor);
431 fprintf(fp, "norm_quality_factor_code := %d\n", h->norm_quality_factor_code);
432 fprintf(fp, "storage_order := %d\n", h->storage_order);
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]);
436 fprintf(fp, "\n");
437}
438/*****************************************************************************/
439
440/*****************************************************************************/
448 short int file_type
449) {
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",
455 0};
456 if(file_type>=0 && file_type<=14) return((char*)info[file_type]);
457 else return((char*)info[0]);
458}
459/*****************************************************************************/
460
461/*****************************************************************************/
469 short int acquisition_type
470) {
471 static char *info[] = {
472 "undefined", "blank", "transmission", "static emission",
473 "dynamic emission", "gated emission", "transmission rectilinear",
474 "emission rectilinear",
475 0};
476 if(acquisition_type>=0 && acquisition_type<=7)
477 return((char*)info[acquisition_type]);
478 else return((char*)info[0]);
479}
480/*****************************************************************************/
481
482/*****************************************************************************/
490 short int data_type
491) {
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",
496 0};
497 if(data_type>=0 && data_type<=7) return((char*)info[data_type]);
498 else return((char*)info[0]);
499}
500/*****************************************************************************/
501
502/*****************************************************************************/
510 FILE *fp,
512 int plane,
514 int frame,
516 FILE *ofp
517) {
518 int mi, ret, nr=0;
519 ECAT7_imageheader image_header;
520 ECAT7_scanheader scan_header;
521 ECAT7_2Dscanheader scan2D_header;
522 ECAT7_2Dnormheader norm2D_header;
523 ECAT7_normheader norm_header;
524 ECAT7_attenheader atten_header;
525 ECAT7_polmapheader polmap_header;
526 static ECAT7_MATRIXLIST mlist;
527 ECAT7_Matval matval;
528
529
530 /*
531 * Read matrix list
532 */
533 ecat7InitMatlist(&mlist);
534 ret=ecat7ReadMatlist(fp, &mlist, ECAT7_TEST);
535 if(ret) {
536 fprintf(stderr, "Error (%d): cannot read matrix list.\n", ret);
537 return(2);
538 }
539 if(mlist.matrixNr<=0) {
540 fprintf(stderr, "Error: matrix list is empty.\n");
541 return(2);
542 }
543 if(ECAT7_TEST>1) ecat7PrintMatlist(&mlist);
544
545 /*
546 * Read and print subheaders one at a time
547 */
548 for(mi=nr=0; mi<mlist.matrixNr; mi++) {
549 /* Get frame nr */
550 ecat7_id_to_val(mlist.matdir[mi].id, &matval);
551 /* Check if this is supposed to be listed or not */
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",
555 matval.plane, matval.frame, matval.gate, matval.bed);
556 /* Read and print subheader */
557 ret=0;
558 switch(mh.file_type) {
559 case ECAT7_ATTEN:
560 ret=ecat7ReadAttenheader(fp, mlist.matdir[mi].strtblk, &atten_header);
561 if(ret==0) ecat7PrintAttenheader(&atten_header, ofp);
562 break;
563 case ECAT7_3DNORM:
564 ret=ecat7ReadNormheader(fp, mlist.matdir[mi].strtblk, &norm_header);
565 if(ret==0) ecat7PrintNormheader(&norm_header, ofp);
566 break;
567 case ECAT7_IMAGE8:
568 case ECAT7_IMAGE16:
569 case ECAT7_VOLUME8:
570 case ECAT7_VOLUME16:
571 ret=ecat7ReadImageheader(fp, mlist.matdir[mi].strtblk, &image_header);
572 if(ret==0) ecat7PrintImageheader(&image_header, ofp);
573 break;
574 case ECAT7_3DSCAN:
575 case ECAT7_3DSCAN8:
576 case ECAT7_3DSCANFIT:
577 ret=ecat7ReadScanheader(fp, mlist.matdir[mi].strtblk, &scan_header);
578 if(ret==0) ecat7PrintScanheader(&scan_header, ofp);
579 break;
580 case ECAT7_POLARMAP:
581 ret=ecat7ReadPolmapheader(fp, mlist.matdir[mi].strtblk, &polmap_header);
582 if(ret==0) ecat7PrintPolmapheader(&polmap_header, ofp);
583 break;
584 case ECAT7_2DSCAN:
585 ret=ecat7Read2DScanheader(fp, mlist.matdir[mi].strtblk, &scan2D_header);
586 if(ret==0) ecat7Print2DScanheader(&scan2D_header, ofp);
587 break;
588 case ECAT7_2DNORM:
589 ret=ecat7Read2DNormheader(fp, mlist.matdir[mi].strtblk, &norm2D_header);
590 if(ret==0) ecat7Print2DNormheader(&norm2D_header, ofp);
591 break;
592 default:
593 fprintf(stderr, "Error: matrix filetype %d is not yet supported.\n",
594 mh.file_type);
595 ecat7EmptyMatlist(&mlist);
596 return(8);
597 }
598 if(ret) {
599 fprintf(stderr, "Error %d in reading subheader.\n", ret);
600 ecat7EmptyMatlist(&mlist); return(5);
601 }
602 nr++; // counter
603 } /* next matrix */
604 ecat7EmptyMatlist(&mlist);
605
606 if(nr==0 && (plane>=0 || frame>=0)) {
607 fprintf(stderr, "Error: specified matrices not found.\n");
608 return(11);
609 }
610
611 return(0);
612}
613/*****************************************************************************/
614
615/*****************************************************************************/
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,...
Definition datetime.c:110
int ECAT7_TEST
Definition ecat7h.c:6
void ecat7InitMatlist(ECAT7_MATRIXLIST *mlist)
Definition ecat7ml.c:15
void ecat7_id_to_val(int matrix_id, ECAT7_Matval *matval)
Definition ecat7ml.c:262
int ecat7ReadMatlist(FILE *fp, ECAT7_MATRIXLIST *ml, int verbose)
Definition ecat7ml.c:41
void ecat7EmptyMatlist(ECAT7_MATRIXLIST *mlist)
Definition ecat7ml.c:26
void ecat7PrintMatlist(ECAT7_MATRIXLIST *ml)
Definition ecat7ml.c:112
void ecat7PrintNormheader(ECAT7_normheader *h, FILE *fp)
Definition ecat7p.c:327
void ecat7PrintImageheader(ECAT7_imageheader *h, FILE *fp)
Definition ecat7p.c:102
char * ecat7acquisitiontype(short int acquisition_type)
Definition ecat7p.c:468
char * ecat7filetype(short int file_type)
Definition ecat7p.c:447
void ecat7PrintPolmapheader(ECAT7_polmapheader *h, FILE *fp)
Definition ecat7p.c:276
char * ecat7datatype(short int data_type)
Definition ecat7p.c:489
void ecat7PrintAttenheader(ECAT7_attenheader *h, FILE *fp)
Definition ecat7p.c:230
void ecat7Print2DScanheader(ECAT7_2Dscanheader *h, FILE *fp)
Definition ecat7p.c:364
void ecat7PrintMainheader(ECAT7_mainheader *h, FILE *fp)
Definition ecat7p.c:16
int ecat7PrintSubheader(ECAT7_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp)
Definition ecat7p.c:506
void ecat7PrintScanheader(ECAT7_scanheader *h, FILE *fp)
Definition ecat7p.c:181
void ecat7Print2DNormheader(ECAT7_2Dnormheader *h, FILE *fp)
Definition ecat7p.c:415
int ecat7ReadScanheader(FILE *fp, int blk, ECAT7_scanheader *h)
Definition ecat7r.c:536
int ecat7ReadPolmapheader(FILE *fp, int blk, ECAT7_polmapheader *h)
Definition ecat7r.c:397
int ecat7ReadNormheader(FILE *fp, int blk, ECAT7_normheader *h)
Definition ecat7r.c:472
int ecat7ReadAttenheader(FILE *fp, int blk, ECAT7_attenheader *h)
Definition ecat7r.c:311
int ecat7Read2DScanheader(FILE *fp, int blk, ECAT7_2Dscanheader *h)
Definition ecat7r.c:631
int ecat7ReadImageheader(FILE *fp, int blk, ECAT7_imageheader *h)
Definition ecat7r.c:162
int ecat7Read2DNormheader(FILE *fp, int blk, ECAT7_2Dnormheader *h)
Definition ecat7r.c:725
Header file for libtpcimgio.
#define ECAT7_VOLUME8
#define ECAT7_ATTEN
#define ECAT7_3DSCAN
#define ECAT7_3DSCAN8
#define ECAT7_IMAGE16
#define ECAT7_3DSCANFIT
#define ECAT7_VOLUME16
#define ECAT7_3DNORM
#define ECAT7_IMAGE8
#define ECAT7_2DNORM
#define ECAT7_POLARMAP
#define ECAT7_2DSCAN
short int z_elements[64]
short int num_dimensions
short int ring_difference
short int storage_order
short int num_z_elements
short int norm_quality_factor_code
short int num_r_elements
short int corrections_applied
float deadtime_correction_factor
short int num_z_elements
short int num_r_elements
short int ring_difference
short int physical_planes[8]
float cor_singles[16]
float uncor_singles[16]
short int num_dimensions
ECAT7_MatDir * matdir
short int num_r_elements
short int z_elements[64]
short int attenuation_type
short int num_additional_atten_coeff
short int num_dimensions
float edge_finding_threshold
short int num_z_elements
short int data_type
short int num_angles
short int storage_order
short int ring_difference
float additional_atten_coeff[8]
short int fill_cti[87]
float filter_scatter_fraction
short int filter_code
short int image_max
short int image_min
short int zfilter_order
short int fill_user[49]
short int rfilter_code
float filter_cutoff_frequency
short int zfilter_code
short int filter_order
short int y_dimension
short int z_dimension
short int recon_type
short int scatter_type
short int recon_views
short int num_dimensions
short int rfilter_order
short int x_dimension
short int data_type
short int file_type
short int compression_code
float bed_position[15]
short int system_type
char facility_name[20]
short int num_frames
char operator_name[32]
short int coin_samp_mode
char data_units[32]
char magic_number[14]
float well_counter_corr_factor
char study_type[12]
char user_process_code[10]
short int angular_compression
short int calibration_units
char patient_name[32]
short int fill_cti[6]
short int septa_state
short int num_gates
short int num_planes
short int lwr_true_thres
char physician_name[32]
short int wobble_speed
short int acquisition_mode
short int calibration_units_label
char serial_number[10]
short int num_bed_pos
float ecat_calibration_factor
short int sw_version
short int transm_source_type
short int acquisition_type
char study_description[32]
short int axial_samp_mode
char patient_id[16]
char radiopharmaceutical[32]
short int patient_orientation
short int upr_true_thres
short int lwr_sctr_thres
char original_file_name[32]
short int num_r_elements
short int data_type
short int num_transaxial_crystals
short int num_geo_corr_planes
short int crystals_per_ring
short int max_ring_diff
float norm_quality_factor
float ring_dtcor1[32]
short int num_crystal_rings
short int norm_quality_factor_code
float ring_dtcor2[32]
float crystal_dtcor[8]
short int scatter_energy
short int ring_angle[32]
short int long_axis_left[3]
short int processing_code
short int sectors_per_ring[32]
char polar_map_protocol[20]
short int start_angle
short int polar_map_type
short int position_data
float ring_position[32]
short int quant_units
short int long_axis_right[3]
short int scan_min
short int num_r_elements
short int num_angles
short int data_type
float deadtime_correction_factor
short int num_dimensions
short int axial_compression
short int storage_order
float uncor_singles[128]
short int scan_max
short int num_z_elements[64]
short int ring_difference
short int corrections_applied