21 if(
ECAT63_TEST) fprintf(stdout,
"ecat63PrintMainheader()\n");
24 fprintf(fp,
"sw_version := %d\n", h->
sw_version);
25 fprintf(fp,
"data_type := %d (%s)\n",
28 if(h->
file_type==1) strcpy(tmp,
"sinogram");
29 else if(h->
file_type==2) strcpy(tmp,
"image");
30 else if(h->
file_type==3) strcpy(tmp,
"attenuation");
31 else if(h->
file_type==4) strcpy(tmp,
"normalization");
32 else strcpy(tmp,
"unknown");
33 fprintf(fp,
"file_type := %d (%s)\n", h->
file_type, tmp);
34 fprintf(fp,
"scan_start_time := %04d-%02d-%02d %02d:%02d:%02d\n",
48 fprintf(fp,
"axial_fov := %g\n", h->
axial_fov);
51 fprintf(fp,
"calibration_units := %d (%s)\n",
53 fprintf(fp,
"study_name := %.12s\n", h->
study_name);
54 fprintf(fp,
"patient_id := %.32s\n", h->
patient_id);
59 else fprintf(fp,
"patient_sex := \n");
61 fprintf(fp,
"patient_age := %.10s\n", h->
patient_age);
67 else fprintf(fp,
"patient_dexterity := \n");
73 fprintf(fp,
"bed_type := %d\n", h->
bed_type);
74 fprintf(fp,
"septa_type := %d\n", h->
septa_type);
77 fprintf(fp,
"num_planes := %d\n", h->
num_planes);
78 fprintf(fp,
"num_frames := %d\n", h->
num_frames);
79 fprintf(fp,
"num_gates := %d\n", h->
num_gates);
97 if(
ECAT63_TEST) printf(
"ecat63PrintImageheader()\n");
100 fprintf(fp,
"dimension_2 := %d\n", h->
dimension_2);
101 fprintf(fp,
"x_origin := %g\ny_origin := %g\nrecon_scale := %g\n",
103 fprintf(fp,
"quant_scale := %g\nimage_min := %d\nimage_max := %d\n",
106 fprintf(fp,
"frame_start_time := %d\nframe_duration := %d\n",
113 fprintf(fp,
"reconstruction_start := %04d-%02d-%02d %02d:%02d:%02d\n",
116 fprintf(fp,
"filter_code := %d\nimage_rotation := %g\nintrinsic_tilt := %g\n",
118 fprintf(fp,
"filter_params :=");
119 for(
int i=0; i<6; i++) fprintf(fp,
" %g", h->
filter_params[i]);
121 fprintf(fp,
"plane_eff_corr_fctr := %g\ndecay_corr_fctr := %g\nloss_corr_fctr := %g\n",
124 fprintf(fp,
"ecat_calibration_fctr := %g\nwell_counter_cal_fctr := %g\n",
126 fprintf(fp,
"annotation := %.40s\n", h->
annotation);
140 if(
ECAT63_TEST) printf(
"ecat63PrintScanheader()\n");
142 fprintf(fp,
"dimension_1 := %d\n", h->
dimension_1);
143 fprintf(fp,
"dimension_2 := %d\n", h->
dimension_2);
146 fprintf(fp,
"gate_duration := %d\nr_wave_offset := %d\n",
150 fprintf(fp,
"prompts := %d\ndelayed := %d\nmultiples := %d\nnet_trues := %d\n",
152 fprintf(fp,
"cor_singles :=");
153 for(
int i=0; i<16; i++) fprintf(fp,
" %8.0f", h->
cor_singles[i]);
155 fprintf(fp,
"uncor_singles :=");
156 for(
int i=0; i<16; i++) fprintf(fp,
" %8.0f", h->
uncor_singles[i]);
160 fprintf(fp,
"frame_start_time := %d\nframe_duration := %d\n",
176 if(
ECAT63_TEST) printf(
"ecat63PrintAttnheader()\n");
178 fprintf(fp,
"dimension_1 := %d\n", h->
dimension_1);
179 fprintf(fp,
"dimension_2 := %d\n", h->
dimension_2);
183 fprintf(fp,
"x_origin := %g\ny_origin := %g\nx_radius := %g\ny_radius := %g\n",
185 fprintf(fp,
"tilt_angle := %g\nattenuation_coeff := %g\n",
200 if(
ECAT63_TEST) printf(
"ecat63PrintNormheader()\n");
202 fprintf(fp,
"dimension_1 := %d\n", h->
dimension_1);
203 fprintf(fp,
"dimension_2 := %d\n", h->
dimension_2);
205 fprintf(fp,
"norm_time := %04d-%02d-%02d %02d:%02d:%02d\n",
221 static char *ecat63_datatype[]={
233 if(dtype>=0 && dtype<10)
return(ecat63_datatype[dtype]);
234 else return(ecat63_datatype[0]);
246 static char *ecat63_unit[]={
252 "LMRUGlu umol/min/100g",
253 "LMRUGlu mg/min/100g",
266 if(dunit>=0 && dunit<18)
return(ecat63_unit[dunit]);
267 else return(ecat63_unit[0]);
280 unsigned int u, exp, mantissa;
283 memcpy(&u, buf, 4);
if(u & 1L<<31) sign=
'-';
else sign=
'+';
284 exp=u<<1; exp=exp>>24; mantissa=u<<9; mantissa=mantissa>>9;
285 printf(
"%e = %c (%u/8388608 + 1)*2^(%u-127)\n", *buf, sign, mantissa, exp);
318 fprintf(stderr,
"Error (%d): cannot read matrix list.\n", ret);
322 fprintf(stderr,
"Error: matrix list is empty.\n");
330 char errmsg[128];
int errCount=0;
331 for(mi=nr=0; mi<mlist.
matrixNr; mi++) {
335 if(frame>=0 && frame!=matval.
frame)
continue;
336 if(plane>=0 && plane!=matval.
plane)
continue;
337 fprintf(ofp,
"\nMatrix: plane %d frame %d gate %d bed %d\n",
350 fprintf(stderr,
"Error: %s.\n", errmsg);
370 if(errCount>0 && nr>0 && (plane<0 || frame<0)) {
371 if(errCount==1) fprintf(stderr,
"\nWarning: one matrix could not be read.\n");
372 else fprintf(stderr,
"\nWarning: %d matrices could not be read.\n", errCount);
375 if(nr==0 && (plane>=0 || frame>=0)) {
376 fprintf(stderr,
"Error: specified matrices not found.\n");
399 if(buf==NULL)
return(NULL);
401 if(h==NULL)
return(NULL);
408 sprintf(buf,
"%04d-%02d-%02d %02d:%02d:%02d",
int ecat63ReadMatlist(FILE *fp, MATRIXLIST *ml, int verbose)
void ecat63InitMatlist(MATRIXLIST *mlist)
void ecat63EmptyMatlist(MATRIXLIST *mlist)
void ecat63PrintMatlist(MATRIXLIST *ml)
void mat_numdoc(int matnum, Matval *matval)
void ecat63PrintMainheader(ECAT63_mainheader *h, FILE *fp)
char * ecat63Datatype(short int dtype)
void ecat63PrintImageheader(ECAT63_imageheader *h, FILE *fp)
void ecat63PrintScanheader(ECAT63_scanheader *h, FILE *fp)
void ecat63PrintNormheader(ECAT63_normheader *h, FILE *fp)
void float2parts(float *buf)
char * ecat63ScanstarttimeInt(const ECAT63_mainheader *h, char *buf)
Convert scan_start_time in ECAT 6.3 main header into a null-terminated string of the form YYYY-MM-DD ...
void ecat63PrintAttnheader(ECAT63_attnheader *h, FILE *fp)
char * ecat63Unit(short int dunit)
int ecat6PrintSubheader(ECAT63_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp)
int ecat63ReadNormheader(FILE *fp, int blk, ECAT63_normheader *h, int verbose, char *errmsg)
int ecat63ReadScanheader(FILE *fp, int blk, ECAT63_scanheader *h, int verbose, char *errmsg)
int ecat63ReadAttnheader(FILE *fp, int blk, ECAT63_attnheader *h, int verbose, char *errmsg)
int ecat63ReadImageheader(FILE *fp, int blk, ECAT63_imageheader *h, int verbose, char *errmsg)
Header file for libtpcimgio.
char radiopharmaceutical[32]
short int scan_start_month
short int scan_start_second
short int acquisition_type
short int calibration_units
short int scan_start_year
char original_file_name[20]
char study_description[32]
short int scan_start_minute
char user_process_code[10]
short int scan_start_hour