~ubuntu-branches/ubuntu/gutsy/xmedcon/gutsy

« back to all changes in this revision

Viewing changes to source/m-conc.c

  • Committer: Bazaar Package Importer
  • Author(s): Roland Marcus Rutschmann
  • Date: 2005-05-23 11:54:09 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050523115409-03nil7bhtpqvarrh
Tags: 0.9.8.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * Credits      :                                                          *
24
24
 *                                                                         *
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 $
27
27
 */
28
28
 
29
29
/*
30
 
   Copyright (C) 1997-2004 by Erik Nolf
 
30
   Copyright (C) 1997-2005 by Erik Nolf
31
31
 
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",
146
 
  "OSEM 2D"
 
146
  "OSEM 2D",
 
147
  "unused",
 
148
  "unused",
 
149
  "unused",
 
150
  "OSEM 3D followed by MAP"
147
151
};
148
152
 
149
153
char * MdcConcOSEM2DTypeNames[MDC_CONC_NUM_OSEM2D_TYPES] = {
297
301
  "rebinning_version",
298
302
  "recon_algorithm",
299
303
  "recon_version",
 
304
  "map_subsets",
 
305
  "map_osem3d_iterations",
 
306
  "map_iterations",
 
307
  "map_beta",
 
308
  "map_blur_type",
 
309
  "map_prior_type",
 
310
  "map_blur_file",
 
311
  "map_pmatrix_file",
300
312
  "osem2d_method",
301
313
  "osem2d_subsets",
302
314
  "osem2d_iterations",
1148
1160
      if (MDC_INFO) MdcPrntScrn("Reconstruction version:\t\t%f\n",
1149
1161
                                conc_get_float(line, &return_code));
1150
1162
      break;
 
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);
 
1166
        if (MDC_INFO)
 
1167
          MdcPrntScrn("OSEM3D Subsets:\t\t\t%d\n", temp_int);
 
1168
      }
 
1169
      break;
 
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);
 
1173
        if (MDC_INFO)
 
1174
          MdcPrntScrn("OSEM3D Iterations:\t\t%d\n", temp_int);
 
1175
      }
 
1176
      break;
 
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);
 
1180
        if (MDC_INFO)
 
1181
          MdcPrntScrn("MAP Iterations:\t\t\t%d\n", temp_int);
 
1182
      }
 
1183
      break;
 
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);
 
1187
        if (MDC_INFO)
 
1188
          MdcPrntScrn("MAP Beta:\t\t\t%5.3f\n", temp_float);
 
1189
      }
 
1190
      break;
 
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);
 
1194
        if (MDC_INFO)
 
1195
          MdcPrntScrn("MAP Blur Type:\t\t\t%d\n", temp_int);
 
1196
      }
 
1197
      break;
 
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);
 
1201
        if (MDC_INFO)
 
1202
          MdcPrntScrn("MAP Prior Type:\t\t\t%d\n", temp_int);
 
1203
      }
 
1204
      break;
 
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);
 
1210
      }
 
1211
      break;
 
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);
 
1217
      }
 
1218
      break;
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]
2061
2129
                , 1.0);
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);
2065
2133
 
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);
2140
2208
                                                                                
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]
2166
2234
                ,  1.0);
2167
2235
 
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]
2175
2243
                   ,  i_gate
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);
2187
2255
 
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.);
2228
2296
        }
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]
2236
2304
                      , fstart);
2237
 
        fprintf(fi->ofp, "#\n%s %f\n"
 
2305
        fprintf(fi->ofp, "#\n%s %g\n"
2238
2306
                      , MdcConcBlockValueNames[MDC_CONC_BLOCK_FRAME_DURATION]
2239
2307
                      , fduration);
2240
2308
 
2252
2320
        }
2253
2321
        
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);
2258
2326
        } else {
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);
2266
2334
        }
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]
2270
2338
                      , 1.0);
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;
2277
2345
          }
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));
2281
2349
        }