25
25
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26
/* $Id: m-conc.c,v 1.79 2004/10/16 20:36:34 enlf Exp $
26
/* $Id: m-conc.c,v 1.82 2005/05/16 07:35:00 enlf Exp $
30
Copyright (C) 1997-2004 by Erik Nolf
30
Copyright (C) 1997-2005 by Erik Nolf
32
32
This program is free software; you can redistribute it and/or modify it
33
33
under the terms of the GNU General Public License as published by the
143
143
char * MdcConcReconTypeNames[MDC_CONC_NUM_RECON_TYPES] = {
144
144
"Unknown, or no, algorithm type",
145
145
"Filtered Backprojection",
150
"OSEM 3D followed by MAP"
149
153
char * MdcConcOSEM2DTypeNames[MDC_CONC_NUM_OSEM2D_TYPES] = {
1148
1160
if (MDC_INFO) MdcPrntScrn("Reconstruction version:\t\t%f\n",
1149
1161
conc_get_float(line, &return_code));
1163
case MDC_CONC_HDR_MAP_SUBSETS:
1164
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1165
temp_int = conc_get_int(line, &return_code);
1167
MdcPrntScrn("OSEM3D Subsets:\t\t\t%d\n", temp_int);
1170
case MDC_CONC_HDR_MAP_OSEM3D_ITERATIONS:
1171
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1172
temp_int = conc_get_int(line, &return_code);
1174
MdcPrntScrn("OSEM3D Iterations:\t\t%d\n", temp_int);
1177
case MDC_CONC_HDR_MAP_ITERATIONS:
1178
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1179
temp_int = conc_get_int(line, &return_code);
1181
MdcPrntScrn("MAP Iterations:\t\t\t%d\n", temp_int);
1184
case MDC_CONC_HDR_MAP_BETA:
1185
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1186
temp_float = conc_get_float(line, &return_code);
1188
MdcPrntScrn("MAP Beta:\t\t\t%5.3f\n", temp_float);
1191
case MDC_CONC_HDR_MAP_BLUR_TYPE:
1192
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1193
temp_int = conc_get_int(line, &return_code);
1195
MdcPrntScrn("MAP Blur Type:\t\t\t%d\n", temp_int);
1198
case MDC_CONC_HDR_MAP_PRIOR_TYPE:
1199
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1200
temp_int = conc_get_int(line, &return_code);
1202
MdcPrntScrn("MAP Prior Type:\t\t\t%d\n", temp_int);
1205
case MDC_CONC_HDR_MAP_BLUR_FILE:
1206
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1207
temp_string = conc_get_string(line, &return_code);
1208
if (MDC_INFO) MdcPrntScrn("MAP Blur File:\t\t\t%s\n",temp_string);
1209
MdcFree(temp_string);
1212
case MDC_CONC_HDR_MAP_PMATRIX_FILE:
1213
if (recon_type == MDC_CONC_RECON_OSEM3D_MAP) {
1214
temp_string = conc_get_string(line, &return_code);
1215
if (MDC_INFO) MdcPrntScrn("MAP PMatrix File:\t\t%s\n",temp_string);
1216
MdcFree(temp_string);
1151
1219
case MDC_CONC_HDR_OSEM2D_METHOD:
1152
1220
if (recon_type == MDC_CONC_RECON_OSEM2D) {
1153
1221
MdcConcOSEM2DTypes osem_type;
2056
2124
fprintf(fi->ofp, "#\n%s %e\n"
2057
2125
, MdcConcHdrValueNames[MDC_CONC_HDR_ISOTOPE_HALF_LIFE]
2058
2126
, fi->isotope_halflife);
2059
fprintf(fi->ofp, "# Note: isotope branching fraction is included in the calibration fraction\n%s %f\n"
2127
fprintf(fi->ofp, "# Note: isotope branching fraction is included in the calibration fraction\n%s %g\n"
2060
2128
, MdcConcHdrValueNames[MDC_CONC_HDR_ISOTOPE_BRANCHING_FRACTION]
2062
fprintf(fi->ofp, "#\n%s %f\n"
2130
fprintf(fi->ofp, "#\n%s %g\n"
2063
2131
, MdcConcHdrValueNames[MDC_CONC_HDR_AXIAL_CRYSTAL_PITCH]
2064
2132
, 2.0*fi->pixdim[3]/10.0);
2129
2197
fprintf(fi->ofp, "#\n%s %d\n"
2130
2198
, MdcConcHdrValueNames[MDC_CONC_HDR_DECAY_CORRECTION_APPLIED]
2131
2199
, fi->decay_corrected);
2132
fprintf(fi->ofp, "#\n%s %f\n", MdcConcHdrValueNames[MDC_CONC_HDR_PIXEL_SIZE]
2200
fprintf(fi->ofp, "#\n%s %g\n", MdcConcHdrValueNames[MDC_CONC_HDR_PIXEL_SIZE]
2133
2201
, fi->pixdim[1]/10.0);
2134
2202
/* eNlf: don't use, scales always combined internally
2135
2203
calibration_factor = fi->image[0].calibr_fctr; */
2136
2204
calibration_factor = 1.0;
2137
fprintf(fi->ofp, "#\n%s %f\n"
2205
fprintf(fi->ofp, "#\n%s %g\n"
2138
2206
, MdcConcHdrValueNames[MDC_CONC_HDR_CALIBRATION_FACTOR]
2139
2207
, calibration_factor);
2158
2226
fprintf(fi->ofp, "#\n%s %d\n"
2159
2227
, MdcConcHdrValueNames[MDC_CONC_HDR_DOSE_UNITS]
2160
2228
, MDC_CONC_DOSE_UNITS_MEGA_BEQUERELS);
2161
fprintf(fi->ofp, "#\n%s %f\n"
2229
fprintf(fi->ofp, "#\n%s %g\n"
2162
2230
, MdcConcHdrValueNames[MDC_CONC_HDR_INJECTED_DOSE]
2163
2231
, fi->injected_dose);
2164
fprintf(fi->ofp, "#\n%s %f\n"
2232
fprintf(fi->ofp, "#\n%s %g\n"
2165
2233
, MdcConcHdrValueNames[MDC_CONC_HDR_INJECTION_DECAY_CORRECTION]
2170
2238
, fi->gatednr);
2171
2239
for (i_gate=0; i_gate < fi->gatednr; i_gate++) {
2172
2240
gd = &(fi->gdata[i_gate]);
2173
fprintf(fi->ofp, "#\n%s %d %1.0f %f %f\n"
2241
fprintf(fi->ofp, "#\n%s %d %1.0f %g %g\n"
2174
2242
, MdcConcHdrValueNames[MDC_CONC_HDR_GATE_BINS]
2176
2244
, gd->nr_projections
2181
2249
fprintf(fi->ofp, "#\n%s %d\n"
2182
2250
, MdcConcHdrValueNames[MDC_CONC_HDR_SUBJECT_WEIGHT_UNITS]
2183
2251
, MDC_CONC_WEIGHT_UNITS_KILOGRAMS);
2184
fprintf(fi->ofp, "#\n%s %f\n"
2252
fprintf(fi->ofp, "#\n%s %g\n"
2185
2253
, MdcConcHdrValueNames[MDC_CONC_HDR_SUBJECT_WEIGHT]
2186
2254
, fi->patient_weight);
2219
2287
fprintf(fi->ofp, "#\n%s %d\n"
2220
2288
, MdcConcBlockValueNames[MDC_CONC_BLOCK_BED], i_bed);
2221
2289
if (bd != NULL) {
2222
fprintf(fi->ofp, "#\n%s %f\n"
2290
fprintf(fi->ofp, "#\n%s %g\n"
2223
2291
, MdcConcBlockValueNames[MDC_CONC_BLOCK_BED_OFFSET]
2224
2292
, bd->hoffset/10.);
2225
fprintf(fi->ofp, "#\n%s %f\n"
2293
fprintf(fi->ofp, "#\n%s %g\n"
2226
2294
, MdcConcBlockValueNames[MDC_CONC_BLOCK_VERTICAL_BED_OFFSET]
2227
2295
, bd->voffset/10.);
2231
2299
fprintf(fi->ofp, "%s %d %d\n"
2232
2300
, MdcConcBlockValueNames[MDC_CONC_BLOCK_DATA_FILE_POINTER]
2233
2301
, high_file_pointer, low_file_pointer);
2234
fprintf(fi->ofp, "#\n%s %f\n"
2302
fprintf(fi->ofp, "#\n%s %g\n"
2235
2303
, MdcConcBlockValueNames[MDC_CONC_BLOCK_FRAME_START]
2237
fprintf(fi->ofp, "#\n%s %f\n"
2305
fprintf(fi->ofp, "#\n%s %g\n"
2238
2306
, MdcConcBlockValueNames[MDC_CONC_BLOCK_FRAME_DURATION]
2254
2322
if (first_plane->rescaled) {
2255
fprintf(fi->ofp, "#\n%s %f\n"
2323
fprintf(fi->ofp, "#\n%s %g\n"
2256
2324
, MdcConcBlockValueNames[MDC_CONC_BLOCK_SCALE_FACTOR]
2257
2325
, first_plane->rescaled_fctr);
2259
2327
/* eNlf: must use combined scale factor
2260
fprintf(fi->ofp, "#\n%s %f\n"
2328
fprintf(fi->ofp, "#\n%s %g\n"
2261
2329
, MdcConcBlockValueNames[MDC_CONC_BLOCK_SCALE_FACTOR]
2262
2330
, first_plane->quant_scale); */
2263
fprintf(fi->ofp, "#\n%s %f\n"
2331
fprintf(fi->ofp, "#\n%s %g\n"
2264
2332
, MdcConcBlockValueNames[MDC_CONC_BLOCK_SCALE_FACTOR]
2265
2333
, first_plane->rescale_slope);
2267
2335
/* Concorde's ASIPro program requires the dead time correction entry on gated data.... */
2268
fprintf(fi->ofp, "#\n# Not 1.0, Unknown\n%s %f\n"
2336
fprintf(fi->ofp, "#\n# Not 1.0, Unknown\n%s %g\n"
2269
2337
, MdcConcBlockValueNames[MDC_CONC_BLOCK_DEADTIME_CORRECTION]
2271
2339
/* Concorde's ASIPro program requires the decay correction entry on gated data.... */
2275
2343
if (fi->isotope_halflife > 0.) {
2276
2344
num_half_lifes = (fstart+fduration/2.0)/fi->isotope_halflife;
2278
fprintf(fi->ofp, "#\n# Check decay_correction_applied to know if already applied\n%s %f\n"
2346
fprintf(fi->ofp, "#\n# Check decay_correction_applied to know if already applied\n%s %g\n"
2279
2347
, MdcConcBlockValueNames[MDC_CONC_BLOCK_DECAY_CORRECTION]
2280
2348
, pow(0.5,(double)num_half_lifes));