[med-svn] r14232 - in trunk/packages/xmedcon/trunk/debian: . patches

Andreas Tille tille at alioth.debian.org
Thu Jul 25 12:36:13 UTC 2013


Author: tille
Date: 2013-07-25 12:36:12 +0000 (Thu, 25 Jul 2013)
New Revision: 14232

Added:
   trunk/packages/xmedcon/trunk/debian/patches/legal-dummies.patch
Modified:
   trunk/packages/xmedcon/trunk/debian/README.source
   trunk/packages/xmedcon/trunk/debian/changelog
Log:
Restore patches by Roland Marcus Rutschmann regarding ecat7 format and document issue in README.source.  The patch is *not* activated because it is unclear whether these issues might remain these days.


Modified: trunk/packages/xmedcon/trunk/debian/README.source
===================================================================
--- trunk/packages/xmedcon/trunk/debian/README.source	2013-07-25 12:11:21 UTC (rev 14231)
+++ trunk/packages/xmedcon/trunk/debian/README.source	2013-07-25 12:36:12 UTC (rev 14232)
@@ -3,36 +3,16 @@
 
 The source of xmedcon contains some third party libraries:
 
-
-libs/dicom: (X)MedCon's DICOM library
-  It somehow seems to be a DICOM implementation of the xmedcon author
-  which does not have to do anything with any DICOM library packaged
-  for Debian
-
-
-libs/ljpg: (X)MedCon's LossLess JPEG Decompression Library (DICOM)
-  The software is based in part on the work of:
-  a) the Cornell University LossLess JPEG library
-        see ftp://ftp.cs.cornell.edu/pub/multimed
-  b) the Independent JPEG Group's JPEG software
-        see http://www.ijg.org
-
-
 libs/nifti: Nifti-1 C libraries
   This code is not used because (x)medcon is linked against the
   Debian packaged version.
 
+Please also read the description of debian/patches/legal-dummies.patch
+which contains the original patches done by Roland Marcus Rutschmann wo
+claimed that "The code handling ecat format had to be removed for legal
+reasons."  This needs to be clarified and the patch needs to be
+acticated or deactivated.  In case it turns out that even the source
+could can not be distributed the source tarball needs to be stripped
+and the patch needs to be adapted to reinject the missing files.
 
-libs/tpc: the Turku PET Centre libraries
-  http://www.turkupetcentre.fi/
-  
-  Files: ecat7*.[ch]
-    http://www.turkupetcentre.net/software/libsrc/libtpcimgio_2_1_8_src.zip
-    
-  Files: petc99.[ch], swap.[ch]
-    http://www.turkupetcentre.net/programs/libpet_src.zip
-    
-  It might make sense to create separate packages of libtpcimgio
-
-
  -- Andreas Tille <tille at debian.org>  Tue, 23 Jul 2013 08:46:18 +0200

Modified: trunk/packages/xmedcon/trunk/debian/changelog
===================================================================
--- trunk/packages/xmedcon/trunk/debian/changelog	2013-07-25 12:11:21 UTC (rev 14231)
+++ trunk/packages/xmedcon/trunk/debian/changelog	2013-07-25 12:36:12 UTC (rev 14232)
@@ -4,6 +4,7 @@
      - currently just make sure that package builds somehow with dh
      - needs checking the result
      - needs patching to use Debian packaged libs
+     - clarifying legal issue with ecat7 format (see debian/patches/legal-dummies.patch)
      - needs testing
      - when building with pdebuild I get
        ...
@@ -28,8 +29,11 @@
     Closes: #633237
   * debian/man-spelling.patch: Enhance manpages syntax and spelling
   * debian/README.Debian: Removed now invalid information
-  * debian/README.source: Add basic information for third party libraries
+  * debian/README.source: Add basic information about potential legal issues
+    of ecat7 format
   * debian/copyright: DEP5 copyright
+  * debian/patches/legal-dummies.patch: Restore the patches done by
+    Roland Marcus Rutschmann except for gif format which is legal these days
 
  -- Andreas Tille <tille at debian.org>  Tue, 23 Jul 2013 08:46:18 +0200
 

Added: trunk/packages/xmedcon/trunk/debian/patches/legal-dummies.patch
===================================================================
--- trunk/packages/xmedcon/trunk/debian/patches/legal-dummies.patch	                        (rev 0)
+++ trunk/packages/xmedcon/trunk/debian/patches/legal-dummies.patch	2013-07-25 12:36:12 UTC (rev 14232)
@@ -0,0 +1,5551 @@
+Author: Roland Marcus Rutschmann <Roland.M.Rutschmann at uni-oldenburg.de>
+LastChanged: Thu, 14 Oct 2010 10:32:22 +0000
+Description: THIS PATCH IS NOT ACTIVATED
+ The former maintainer of this package Roland Marcus Rutschmann has put
+ the following text into README.Debian:
+ .
+ The code handling ecat format had to be removed for legal reasons.
+ The following files from the original source code where replaced by mostly
+ empty dummies:
+ .
+ m-ecat64.c + m-ecat64.h
+ m-ecat72.c + m-ecat72.h
+ m-matrix.c + m-matrix.h
+ .
+ Remark of Andreas Tille (Debian Med team):  The author also replaced m-gif.[ch]
+ which is definitely not needed any more and so this patch was not incorporated.
+ Moreover because it is not clear what "legal reasons" here are suspected the
+ patch is deactivated for the moment but keep here in case it will be really
+ needed
+
+--- a/source/m-ecat64.c
++++ b/source/m-ecat64.c
+@@ -7,28 +7,18 @@
+  *                                                                         *
+  * project      : (X)MedCon by Erik Nolf                                   *
+  *                                                                         *
+- * Functions    : MdcCheckECAT6()         - Check for ECAT 6.4 format      * 
+- *                MdcReadECAT6()          - Read ECAT 6.4 file             *
+- *                MdcWriteECAT6()         - Write ECAT 6.4 file            *
+- *                MdcGetSliceLocation()   - Get slice location             *
+- *                MdcGetFilterCode()      - Get code number of filter      *
+- *                MdcFillMainHeader()     - Fill in Main Header            *
+- *                MdcFillImageSubHeader() - Fill in Image SubHeader        *
+- *                MdcPrintEcatInfoDB()    - Print ECAT database info       *
++ * Functions    : MdcCheckECAT()          - Check for ECAT format          * 
++ *                MdcReadECAT()           - Read ECAT 6.4 file             *
++ *                MdcWriteECAT()          - Write ECAT 6.4 file            *
+  *                                                                         *
+- *                                                                         *
+- * Notes        : source needs m-matrix.h & m-matrix.c                     *
+- *                                                                         *
+- * Credits      : - CTI coders       - for creating the basic code         *
+- *                - Johan Keppens    - getting it to work initially        *
+- *                - Sakari Alenius   - reading using a matrix list         *
++ * Notes        : DEBIAN - code removed due to unclear licensing           * 
+  *                                                                         *
+  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+-/* $Id: m-ecat64.c,v 1.89 2013/06/23 21:51:19 enlf Exp $
++/* - debian dummy file v0.2 -
+  */
+ 
+ /*
+-   Copyright (C) 1997-2013 by Erik Nolf
++   Copyright (C) 1997-2002 by Erik Nolf
+ 
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+@@ -66,1282 +56,20 @@
+ #include "medcon.h"
+ 
+ /****************************************************************************
+-                              D E F I N E S
+-****************************************************************************/
+-
+-#define MDC_NUM_BEDS_TWEAK      MDC_YES /* check on zero/one based num_beds   */
+-
+-#ifdef _WIN32
+-#define MDC_ECAT6_RESTRICT_DIMS MDC_YES /* only square dim and max 256 (safe) */
+-#else
+-#define MDC_ECAT6_RESTRICT_DIMS MDC_NO  /* no square dim and no max  (danger) */
+-#endif
+-
+-static Uint32 saved_mwidth;
+-static Uint32 saved_mheight;
+-
+-static char MdcEcatDataTypes
+-        [MDC_MAX_ECATDATATYPES][MDC_MAX_ECATDATATYPES_SIZE]=
+-                      {"Unknown","ByteData","VAX Int16","VAX Int32",
+-                       "VAX float","IEEE float","SUN Int16","SUN Int32"};
+-static char MdcEcatFileTypes
+-        [MDC_MAX_ECATFILETYPES][MDC_MAX_ECATFILETYPES_SIZE]=
+-                      {"Unknown","Sinogram","PetImage","Attenuation",
+-                       "Normalization","Smooth File"};
+-static char MdcEcatAcquisitionTypes
+-        [MDC_MAX_ECATACQTYPES][MDC_MAX_ECATACQTYPES_SIZE]=
+-                      {"Undefined","Blank","Transmission",
+-                       "Static Emission","Dynamic Emission","Gated Emission",
+-                       "Transmission Rectilinear","Emission Rectilinear",
+-                       "Whole Body Transmission","Whole Body Static"};
+-
+-static char MdcEcatFilterTypes
+-        [MDC_MAX_ECATFLTRTYPES][MDC_MAX_ECATFLTRTYPES_SIZE]=
+-                      {"None","Ramp","Butter","Hann",
+-                       "Hamm","Parzen","Shepp","Unknown"};
+-
+-static char MdcEcatQuantificationUnits
+-        [MDC_MAX_ECATQUANTTYPES][MDC_MAX_ECATQUANTTYPES_SIZE]=
+-                      {"Total Counts","Undefined",
+-                       "ECAT counts/second/pixel","uCi/ml [1uCi = 37Bq]",
+-                       "LMRGlu","LMRGlu umol/min/100g","LMRGlu mg/min/100g",
+-                       "nCi/ml","Well counts","Becquerels","ml/min/100g",
+-                       "ml/min/g"};
+-
+-static Int16 MdcEcatSystemTypes[MDC_MAX_ECATSYSTEMTYPES]=
+-                      {831, 911, 931, 933, 951, 953};
+-
+-/****************************************************************************
+                             F U N C T I O N S
+ ****************************************************************************/
+ int MdcCheckECAT6(FILEINFO *fi)
+-{ 
+-  Mdc_Main_header mh;
+-  int i;
+-
+-  if (mdc_mat_read_main_header(fi->ifp,&mh)) return MDC_BAD_READ;
+-
+-  if (mh.system_type == MDC_ECAT6_SYST_TYPE) return MDC_FRMT_ECAT6;
+-
+-  for (i=0; i < MDC_MAX_ECATSYSTEMTYPES; i++) {
+-     if (mh.system_type == MdcEcatSystemTypes[i])
+-       return MDC_FRMT_ECAT6;
+-  }
+-
+-  return MDC_FRMT_NONE;
+-
+-}
+-
+-
+-const char *MdcReadECAT6(FILEINFO *fi)
+-{
+-  FILE *fp = fi->ifp;
+-  IMG_DATA *id=NULL;
+-  DYNAMIC_DATA *dd=NULL;
+-  int i, error;
+-  const char *err;
+-  char *str;
+-  Uint32 bytes, img=0, found=0, number;
+-  Mdc_Main_header mh;
+-  Mdc_Image_subheader ish;
+-  Mdc_Scan_subheader ssh;
+-  Mdc_Attn_subheader ash;
+-  Mdc_Norm_subheader nsh;
+-  struct Mdc_MatDir entry, matrix_list[MDC_ECAT6_MAX_MATRICES];
+-  struct Mdc_Matval matval;
+-  Int16 data_type=BIT16_S;
+-  int bed,gate,frame,plane,data=0,nb,ng,nf,np,nd;
+-  int  matnum, startblk, endblk, num_matrices;
+-  float slice_position;
+-
+-  if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Reading ECAT6:");
+-
+-  if (MDC_VERBOSE) MdcPrntMesg("ECAT6 Reading <%s> ...",fi->ifname);
+-
+-  /* put some defaults we use */
+-  fi->endian=MDC_FILE_ENDIAN=MDC_LITTLE_ENDIAN;
+-  fi->modality = M_PT;
+-
+-  /* read the main header */
+-  error = mdc_mat_read_main_header(fp, &mh);
+-  if (error) return("ECAT6 Bad read main header");
+-
+-/*
+-  if (MDC_INFO_DB) {
+-    MdcPrintEcatInfoDB(&mh);
+-    return NULL;
+-  }
+-*/
+-
+-  if (MDC_INFO || MDC_INFO_DB) { 
+-
+-    MdcPrntScrn("Main Header (%d bytes)\n",MH_64_SIZE);
+-    MdcPrintLine('-',MDC_HALF_LENGTH);
+- 
+-    MdcPrntScrn("Original Filename        : "); 
+-       MdcPrintStr(mh.original_file_name);
+-    MdcPrntScrn("Software Version         : %d\n",mh.sw_version);
+-    MdcPrntScrn("Data Type                : %d ",mh.data_type);
+-    if ((mh.data_type > -1) && (mh.data_type < 8))
+-      MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[mh.data_type]);
+-    else
+-      MdcPrntScrn("(= Unknown)\n");
+-    MdcPrntScrn("System Type              : %d\n",mh.system_type);
+-    MdcPrntScrn("File Type                : %d ",mh.file_type);
+-    if ((mh.file_type > -1) && (mh.file_type < 5)) 
+-      MdcPrntScrn("(= %s)\n",MdcEcatFileTypes[mh.file_type]);
+-    else
+-      MdcPrntScrn("(= Unknown)\n");
+-    MdcPrntScrn("Node Id                  : "); MdcPrintStr(mh.node_id);
+-    MdcPrntScrn("Scan Date - Day          : %d\n",mh.scan_start_day);
+-    MdcPrntScrn("          - Month        : %d\n",mh.scan_start_month);
+-    MdcPrntScrn("          - Year         : %d\n",mh.scan_start_year);
+-    MdcPrntScrn("          - Hour         : %d\n",mh.scan_start_hour);
+-    MdcPrntScrn("          - Minute       : %d\n",mh.scan_start_minute);
+-    MdcPrntScrn("          - Second       : %d\n",mh.scan_start_second);
+-    MdcPrntScrn("Isotope Code             : "); MdcPrintStr(mh.isotope_code);
+-    MdcPrntScrn("Isotope Halflife         : %f [sec]\n",mh.isotope_halflife);
+-    MdcPrntScrn("Radiopharmaceutical      : "); 
+-      MdcPrintStr(mh.radiopharmaceutical);
+-    MdcPrntScrn("Gantry Tilt              : %f [degrees]\n",mh.gantry_tilt);
+-    MdcPrntScrn("Gantry Rotation          : %f [degrees]\n"
+-                                                          ,mh.gantry_rotation);
+-    MdcPrntScrn("Bed Elevation            : %f [cm]\n",mh.bed_elevation);
+-    MdcPrntScrn("Rotating Source Speed    : %d [revolutions/minute]\n"
+-                                       ,mh.rot_source_speed);
+-    MdcPrntScrn("Wobble Control Speed     : %d [revolutions/minute]\n"
+-                                       ,mh.wobble_speed);
+-    MdcPrntScrn("Transmission Source      : %d\n",mh.transm_source_type);
+-    MdcPrntScrn("Axial Field of View      : %f [cm]\n",mh.axial_fov);
+-    MdcPrntScrn("Transaxial Field of View : %f [cm]\n",mh.transaxial_fov);
+-    MdcPrntScrn("Transaxial Sampling Mode : %d\n",mh.transaxial_samp_mode);
+-    MdcPrntScrn("Coincidence Sampling Mode: %d\n",mh.coin_samp_mode);
+-    MdcPrntScrn("Axial Sampling Mode      : %d\n",mh.axial_samp_mode);
+-    MdcPrntScrn("Calibration Factor       : %f\n",mh.calibration_factor);
+-    MdcPrntScrn("Calibration Units        : %d ",mh.calibration_units);
+-    if ((mh.calibration_units > -1) && (mh.calibration_units < 12))
+-      MdcPrntScrn("(= %s)\n"
+-                    ,MdcEcatQuantificationUnits[mh.calibration_units]);
+-    else 
+-      MdcPrntScrn("(= Unknown)\n");
+-    MdcPrntScrn("Compression Code         : %d\n",mh.compression_code);
+-    MdcPrntScrn("Study Name               : "); MdcPrintStr(mh.study_name);
+-    MdcPrntScrn("Patient Id               : "); MdcPrintStr(mh.patient_id);
+-    MdcPrntScrn("Patient Name             : "); MdcPrintStr(mh.patient_name);
+-    MdcPrntScrn("Patient Sex              : "); MdcPrintChar(mh.patient_sex);  
+-    MdcPrntScrn("\n");
+-    MdcPrntScrn("Patient Age              : "); MdcPrintStr(mh.patient_age);
+-    MdcPrntScrn("Patient Height           : ");
+-       MdcPrintStr(mh.patient_height);
+-    MdcPrntScrn("Patient Weight           : ");
+-       MdcPrintStr(mh.patient_weight);
+-    MdcPrntScrn("Patient Dexterity        : "); 
+-       MdcPrintChar(mh.patient_dexterity);
+-    MdcPrntScrn("\n");
+-    MdcPrntScrn("Physician Name           : ");
+-       MdcPrintStr(mh.physician_name);
+-    MdcPrntScrn("Operator Name            : ");
+-       MdcPrintStr(mh.operator_name);
+-    MdcPrntScrn("Study Description        : ");
+-       MdcPrintStr(mh.study_description);
+-    MdcPrntScrn("Acquisition Type         : %d ",mh.acquisition_type);
+-    if ((mh.acquisition_type > -1) && (mh.acquisition_type <= 9))
+-      MdcPrntScrn("(= %s)\n",MdcEcatAcquisitionTypes[mh.acquisition_type]);
+-    else
+-      MdcPrntScrn("(= Unknown)\n");
+-    MdcPrntScrn("Bed Type                 : %d\n",mh.bed_type);
+-    MdcPrntScrn("Septa Type               : %d\n",mh.septa_type);
+-    MdcPrntScrn("Facility Name            : "); MdcPrintStr(mh.facility_name);
+-    MdcPrntScrn("Number of Planes         : %d\n",mh.num_planes);
+-    MdcPrntScrn("Number of Frames         : %d\n",mh.num_frames);
+-    MdcPrntScrn("Number of Gates          : %d\n",mh.num_gates);
+-    MdcPrntScrn("Number of Bed Positions  : %d\n",mh.num_bed_pos);
+-    MdcPrntScrn("Initial Bed Position     : %f [cm]\n",mh.init_bed_position);
+-    for (i=0; i<15; i++)
+-    MdcPrntScrn("Bed Offset[%02d]           : %f [cm]\n",i+1
+-                                                           ,mh.bed_offset[i]);
+-    MdcPrntScrn("Plane Separation         : %f [cm]\n",mh.plane_separation);
+-    MdcPrntScrn("Lower Scatter Treshold   : %d [KeV]\n",mh.lwr_sctr_thres);
+-    MdcPrntScrn("Lower True Treshold      : %d [KeV]\n",mh.lwr_true_thres);
+-    MdcPrntScrn("Upper True Treshold      : %d [KeV]\n",mh.upr_true_thres);
+-    MdcPrntScrn("Collimator               : %6.0f\n",mh.collimator);
+-    MdcPrntScrn("User Process Code        : ");
+-       MdcPrintStr(mh.user_process_code);
+-    MdcPrntScrn("Acquisition Mode         : %d\n",mh.acquisition_mode);
+-
+-  }
+-
+-  if (MDC_INFO_DB) return(NULL); /* just needed db info */
+-
+-  if ((mh.file_type!=MDC_ECAT6_SCAN_FILE)  && 
+-      (mh.file_type!=MDC_ECAT6_IMAGE_FILE) &&
+-      (mh.file_type!=MDC_ECAT6_ATTN_FILE)  && 
+-      (mh.file_type!=MDC_ECAT6_NORM_FILE) ) 
+-    return("ECAT6 Unsupported file type");
+-
+-  if (mh.num_frames  <= 0 ) mh.num_frames  = 1;
+-  if (mh.num_gates   <= 0 ) mh.num_gates   = 1;
+-  if (mh.num_bed_pos <  0 ) mh.num_bed_pos = 0;
+-
+-  /* fill in global FILEINFO data */
+-  fi->dim[0]= 6;
+-  fi->dim[3]= mh.num_planes;
+-  fi->dim[4]= mh.num_frames;
+-  fi->dim[5]= mh.num_gates;
+-  fi->dim[6]= mh.num_bed_pos + 1; /* must be 1-based */
+-
+-#if MDC_NUM_BEDS_TWEAK
+-  /* double check num_bed_pos value due to */
+-  /* inconsistent use as zero or one based */
+-  bed = mh.num_bed_pos;
+-  while (!mdc_mat_lookup(fp,mdc_mat_numcod(1,1,1,0,bed),&entry) && (bed > 0)) {
+-       bed--;
+-  }
+-  fi->dim[6] = bed + 1;
+-#endif
+-
+-  /* check for unsupported bed overlap */
+-  if (fi->dim[6] > 1) {
+-    float axial_width, bed_offset=mh.bed_offset[0];
+-
+-    if (bed_offset < 0) bed_offset = -bed_offset;
+-
+-    axial_width = mh.plane_separation * (float)fi->dim[3];
+-    if ((axial_width - bed_offset) >= 1.0) {
+-      MdcPrntWarn("ECAT6 Bed overlaps unsupported"); 
+-    }
+-  }
+-
+-  for (i=3, number=1; i<=6; i++) number*=fi->dim[i];
+-
+-  if (number == 0) return("ECAT6 No valid images specified");
+-
+-  /* fill in orientation information */ 
+-  fi->pat_slice_orient = MDC_SUPINE_HEADFIRST_TRANSAXIAL; /* default! */
+-  str = MdcGetStrPatPos(fi->pat_slice_orient);
+-  MdcStringCopy(fi->pat_pos,str,strlen(str));
+-
+-  if ( (strncmp(mh.user_process_code,"COR",10)==0) ||
+-       (strncmp(mh.user_process_code,"SAG",10)==0)) {
+-    /* CORONAL SLICES  or SAGITTAL SLICES 
+-       The images Ecat 6.4 software writes are useless:
+-       128x128 images with the small coronal/sagittal slice in it ...
+-       This means their pixel_xsize & pixel_ysize doesn't quite
+-       fit the real world dimensions any more !! 
+-       Therefore we don't even try to attempt writing the proper 
+-       orientation information.
+-     */
+-  }else{
+-    /* "TRA" or nothing 
+-       TRANSAXIAL SLICES (Transverse)
+-       Writing the proper orientation information
+-       See man-page `m-acr.4' for more info (!)
+-     */
+-    str = MdcGetStrPatOrient(fi->pat_slice_orient);
+-    MdcStringCopy(fi->pat_orient,str,strlen(str));
+-  }
+-
+-  /* fill in patient study related information */
+-  fi->patient_sex[0] = mh.patient_sex; fi->patient_sex[1]='\0';
+-  MdcStringCopy(fi->patient_name,mh.patient_name,32);
+-  MdcStringCopy(fi->patient_id,mh.patient_id,16);
+-  fi->patient_weight   = (float)atof(mh.patient_weight);
+-  fi->patient_height   = (float)atof(mh.patient_height);
+-  fi->study_date_day   = mh.scan_start_day;
+-  fi->study_date_month = mh.scan_start_month;
+-  fi->study_date_year  = mh.scan_start_year;
+-  fi->study_time_hour  = mh.scan_start_hour;
+-  fi->study_time_minute= mh.scan_start_minute;
+-  fi->study_time_second= mh.scan_start_second;
+-
+-  if ((mh.file_type==MDC_ECAT6_SCAN_FILE) || 
+-      (mh.file_type==MDC_ECAT6_IMAGE_FILE)) {
+-    switch (mh.acquisition_type) {
+-      case MDC_ECAT6_ACQTYPE_UNKNOWN : 
+-          fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break;
+-      case MDC_ECAT6_ACQTYPE_BLANK : 
+-          fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break;
+-      case MDC_ECAT6_ACQTYPE_TRANSMISSION : 
+-          fi->acquisition_type = MDC_ACQUISITION_TOMO;    break;
+-      case MDC_ECAT6_ACQTYPE_STATIC_EMISSION : 
+-          fi->acquisition_type = MDC_ACQUISITION_TOMO;    break;
+-      case MDC_ECAT6_ACQTYPE_DYNAMIC_EMISSION : 
+-          fi->acquisition_type = MDC_ACQUISITION_DYNAMIC; break;
+-      case MDC_ECAT6_ACQTYPE_GATED_EMISSION : 
+-          fi->acquisition_type = MDC_ACQUISITION_GSPECT;  break;
+-      case MDC_ECAT6_ACQTYPE_TRANSMISSION_RECT : 
+-          fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break;
+-      case MDC_ECAT6_ACQTYPE_EMISSION_RECT : 
+-          fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break;
+-      case MDC_ECAT6_ACQTYPE_WHOLE_BODY_TRANSM :
+-          fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break;
+-      case MDC_ECAT6_ACQTYPE_WHOLE_BODY_STATIC :
+-          fi->acquisition_type = MDC_ACQUISITION_TOMO;    break;
+-      default: 
+-          fi->acquisition_type = MDC_ACQUISITION_UNKNOWN;
+-    }
+-  }else{
+-    fi->acquisition_type = MDC_ACQUISITION_UNKNOWN;
+-  }
+-  sprintf(mdcbufr,"ECAT%hd",mh.system_type);
+-  MdcStringCopy(fi->manufacturer,mdcbufr,strlen(mdcbufr));
+-  MdcStringCopy(fi->operator_name,mh.operator_name,32);
+-  MdcStringCopy(fi->study_descr,mh.study_description,32);
+-  MdcStringCopy(fi->study_id,mh.study_name,12);
+-  MdcStringCopy(fi->institution,mh.facility_name,20);
+-  MdcStringCopy(fi->radiopharma,mh.radiopharmaceutical,32);
+-  MdcStringCopy(fi->isotope_code,mh.isotope_code,8);
+-
+-  fi->isotope_halflife = mh.isotope_halflife;
+-  fi->gantry_tilt      = mh.gantry_tilt;
+-
+-  if (MDC_ECHO_ALIAS == MDC_YES) {
+-    MdcEchoAliasName(fi); return(NULL);
+-  }
+-
+-  if (!MdcGetStructID(fi,number))
+-    return("ECAT6 Bad malloc IMG_DATA structs");
+-
+-  /* always malloc dyndata structs */
+-  if (!MdcGetStructDD(fi,(Uint32)fi->dim[4]*fi->dim[5]*fi->dim[6]))
+-    return("ECAT6 Couldn't malloc DYNAMIC_DATA structs");
+-
+-  /* always malloc beddata structs */
+-  if (!MdcGetStructBD(fi,(unsigned)fi->dim[6]))
+-    return("ECAT6 Couldn't malloc BED_DATA structs");
+-
+-  /* fill in BED_DATA struct */
+-  fi->beddata[0].hoffset = mh.init_bed_position * 10.; /* mm */
+-  fi->beddata[0].voffset = mh.bed_elevation * 10.;     /* mm */
+-  for (i=1; i<fi->bednr; i++) {
+-    fi->beddata[i].hoffset  = mh.init_bed_position + mh.bed_offset[i-1];
+-    fi->beddata[i].hoffset *= 10.; /* mm */
+-
+-    fi->beddata[i].voffset  = mh.bed_elevation * 10.;  /* mm */
+-  }
+-
+-  /* ECAT6: matrices for each slice */
+-  num_matrices = mdc_mat_list(fp, matrix_list, MDC_ECAT6_MAX_MATRICES);
+-  if (num_matrices == 0)
+-    return("ECAT6 No matrices found");
+-  if ((Uint32)num_matrices > fi->number)
+-    return("ECAT6 Too many matrices found");
+-
+-  /* sort matrices */
+-  if ( num_matrices > 1) {
+-
+-    switch (MDC_ECAT6_SORT) {
+-
+-      case MDC_ANATOMICAL: /* anatomical */
+-          bed = fi->dim[6]; /* one based */
+-          if (fi->dim[4] > 1) { 
+-            mdc_plane_sort(matrix_list, num_matrices);
+-          }else{
+-            mdc_anatomical_sort(matrix_list, num_matrices, &mh, bed);
+-          } 
+-          break;
+-      case MDC_BYFRAME   : /* by frame   */
+-          mdc_matnum_sort(matrix_list, num_matrices);
+-          break;
+-    }
+-
+-  }
+-
+-  for (bed=0; bed<fi->dim[6]; bed++)
+-  for (gate=1; gate<=fi->dim[5]; gate++)
+-  for (frame=1; frame<=fi->dim[4]; frame++)
+-  for (plane=1; plane<=fi->dim[3]; plane++) {
+-
+-     if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL);
+-
+-     if (img == (Uint32)num_matrices) break;
+-
+-     if (fi->dynnr > 0) dd = &fi->dyndata[(fi->dim[4]*bed) + (frame-1)];
+-
+-     mdc_mat_numdoc(matrix_list[img].matnum,&matval);
+-     nf = matval.frame; np = matval.plane; ng = matval.gate;
+-     nb = matval.bed;   nd = matval.data;
+-     matnum = mdc_mat_numcod(nf,np,ng,nd,nb);
+-     if (!mdc_mat_lookup(fp, matnum, &entry)) continue;
+-     startblk = entry.strtblk + 1;
+-     endblk = entry.endblk - entry.strtblk;
+-
+-     switch (mh.file_type) {
+-
+-      case MDC_ECAT6_SCAN_FILE:
+-
+-       error = mdc_mat_read_scan_subheader(fp, startblk-1, &ssh);
+-       if (error) return("ECAT6 Bad read scan subheader");
+-       if (MDC_INFO) {
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-        MdcPrntScrn("SINOGRAM SUBHEADER %05d:  ",img+1);
+-        MdcPrntScrn("Frame: %d  Plane: %d  Gate: %d  Data: %d  Bed: %d\n"
+-               ,frame,plane,gate,data,bed);
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-        MdcPrntScrn("Data Type           : %d ",ssh.data_type);
+-        if ((ssh.data_type > -1) && (ssh.data_type < 8))
+-          MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[ssh.data_type]);
+-        else
+-          MdcPrntScrn("(= Unknown)\n");
+-        MdcPrntScrn("Number of Elements  : %d (width)\n",ssh.dimension_1);
+-        MdcPrntScrn("Number of Views     : %d (height)\n",ssh.dimension_2);
+-        MdcPrntScrn("Smoothing           : %d ",ssh.smoothing);
+-        switch (ssh.smoothing) {
+-          case 0: MdcPrntScrn("(= Not Smoothed)\n"); break;
+-          case 1: MdcPrntScrn("(= 9x9 Smoothing)\n"); break;
+-         default: MdcPrntScrn("(= Unknown)\n"); 
+-        }
+-        MdcPrntScrn("Processing Code     : %d\n",ssh.processing_code);
+-        MdcPrntScrn("Sample Distance     : %f [cm]\n",ssh.sample_distance);
+-        MdcPrntScrn("Isotope Halflife    : %f [sec]\n",ssh.isotope_halflife);
+-        MdcPrntScrn("Frame Duration (sec): %d [sec]\n"
+-                                                       ,ssh.frame_duration_sec);
+-        MdcPrntScrn("Gate Duration       : %d [ms]\n",ssh.gate_duration);
+-        MdcPrntScrn("R-Wave Offset       : %d [ms]\n",ssh.r_wave_offset);
+-        MdcPrntScrn("Scale factor        : %f\n",ssh.scale_factor);
+-        MdcPrntScrn("Minimum Scan Value  : %d\n",ssh.scan_min);
+-        MdcPrntScrn("Maximum Scan Value  : %d\n",ssh.scan_max);
+-        MdcPrntScrn("Total Prompts       : %d\n",ssh.prompts);
+-        MdcPrntScrn("Total Delayed Events: %d\n",ssh.delayed);
+-        MdcPrntScrn("Total Multiples     : %d\n",ssh.multiples);
+-        MdcPrntScrn("Total Net Trues     : %d (Prompts - Random)\n"
+-                                      ,ssh.net_trues);
+-        for (i=0; i<16; i++) 
+-        MdcPrntScrn("Corrected   Singles [%2d] : %f\n",i+1
+-                                                         ,ssh.cor_singles[i]);
+-        for (i=0; i<16; i++)
+-        MdcPrntScrn("Uncorrected Singles [%2d] : %f\n",i+1
+-                                                         ,ssh.uncor_singles[i]);
+-        MdcPrntScrn("Total Average Corrected   Singles: %f\n"
+-                                                         ,ssh.tot_avg_cor);
+-        MdcPrntScrn("Total Average Uncorrected Singles: %f\n"
+-                                                         ,ssh.tot_avg_uncor);
+-        MdcPrntScrn("Total Coincidence Rage  : %d (from IPCP)\n"
+-                                                         ,ssh.total_coin_rate);
+-        MdcPrntScrn("Frame Start Time        : %d [ms]\n"
+-                                                         ,ssh.frame_start_time);
+-        MdcPrntScrn("Frame Duration          : %d [ms]\n"
+-                                                         ,ssh.frame_duration);
+-        MdcPrntScrn("Loss Correction Factor  : %f\n"
+-                                                     ,ssh.loss_correction_fctr);
+-        for (i=0; i<8; i++) MdcPrntScrn("Phy_Planes [%d]          : %d\n",i+1
+-                                                         ,ssh.phy_planes[i]);
+-       }
+- 
+-       /* fill in DYNAMIC_DATA struct */
+-       if ((dd != NULL) && (plane == (fi->dim[3]/2))) {
+-         /* take values from a plane halfway */
+-         dd->nr_of_slices        = fi->dim[3];
+-         dd->time_frame_start    = (float)ssh.frame_start_time;
+-         dd->time_frame_duration = (float)ssh.frame_duration;
+-       }
+-
+-       /* fill in IMG_DATA struct */
+-       id = &fi->image[img];
+-       id->width = (Uint32)ssh.dimension_1;
+-       id->height = (Uint32)ssh.dimension_2;
+-
+-       id->quant_units = 1;
+-       id->quant_scale = 1;
+-       id->calibr_units= 1;
+-       id->calibr_fctr = 1;
+-
+-       id->quant_scale = ssh.scale_factor;
+-
+-       id->pixel_xsize = id->pixel_ysize = ssh.sample_distance * 10.;/* mm */
+-       data_type = ssh.data_type; 
+-       switch( data_type ) {
+-         case  BYTE_TYPE:  id->bits = 8; id->type = BIT8_U; break;
+-         case  M68K_I2  :
+-     /*  case  SUN_I2   : */
+-         case  VAX_I2   :  id->bits =16; id->type = BIT16_S; break;
+-         case  M68K_I4  :
+-     /*  case  SUN_I4   : */
+-         case  VAX_I4   :  id->bits =32; id->type = BIT32_S; break;
+-         case  IEEE_R4  :
+-     /*  case  SUN_R4   : */
+-         case  VAX_R4   :  id->bits =32; id->type = FLT32; break;
+-       }
+-
+-       break;
+-
+-      case MDC_ECAT6_IMAGE_FILE:
+-
+-       error = mdc_mat_read_image_subheader(fp, startblk-1, &ish);
+-       if (error) return("ECAT6 Bad read image subheader");
+-       if (MDC_INFO) { 
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-        MdcPrntScrn("IMAGE SUBHEADER %05d:  ",img+1);
+-        MdcPrntScrn("Frame: %d  Plane: %d  Gate: %d  Data: %d  Bed: %d\n"
+-               ,frame,plane,gate,data,bed);
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-
+-        MdcPrntScrn("Data Type            : %d ",ish.data_type);
+-        if ((ish.data_type > -1) && (ish.data_type < 8))
+-          MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[ish.data_type]);
+-        else
+-          MdcPrntScrn("(= Unknown)\n");
+-        MdcPrntScrn("Number of Dimensions : %d\n",ish.num_dimensions);
+-        MdcPrntScrn("X Dimension          : %d\n",ish.dimension_1);
+-        MdcPrntScrn("Y Dimension          : %d\n",ish.dimension_2);
+-        MdcPrntScrn("X Offset             : %f [cm]\n",ish.x_origin);
+-        MdcPrntScrn("Y Offset             : %f [cm]\n",ish.y_origin);
+-        MdcPrntScrn("Recon Magnification Factor  : %f\n",ish.recon_scale);
+-        MdcPrntScrn("Quantification Scale Factor : %e\n",ish.quant_scale);
+-        MdcPrntScrn("Image Minimum Pixel Value   : %d\n",ish.image_min);
+-        MdcPrntScrn("Image Maximum Pixel Value   : %d\n",ish.image_max);
+-        MdcPrntScrn("Pixel Size         : %f [cm]\n",ish.pixel_size);
+-        MdcPrntScrn("Slice Width        : %f [cm]\n",ish.slice_width);
+-        MdcPrntScrn("Frame Duration     : %d [ms]\n",ish.frame_duration);
+-        MdcPrntScrn("Frame Start Time   : %d [ms]\n",ish.frame_start_time);
+-        MdcPrntScrn("Slice Location     : %d [cm]\n",ish.slice_location);
+-        MdcPrntScrn("Recon Start Hour   : %d\n",ish.recon_start_hour);
+-        MdcPrntScrn("Recon Start Minute : %d\n",ish.recon_start_minute);
+-        MdcPrntScrn("Recon Start Second : %d\n",ish.recon_start_sec);
+-        MdcPrntScrn("Gate Duration      : %d [ms]\n",ish.gate_duration); 
+-        MdcPrntScrn("Filter code        : %d ",ish.filter_code);
+-        ish.filter_code = abs(ish.filter_code); 
+-        if ((ish.filter_code > -1) && (ish.filter_code < 7))
+-          MdcPrntScrn("(= %s)\n",MdcEcatFilterTypes[ish.filter_code]);
+-        else
+-          MdcPrntScrn("(= Unknown)\n");
+-        MdcPrntScrn("Scan Matrix Number : %d\n",ish.scan_matrix_num);
+-        MdcPrntScrn("Normalization Matrix Number : %d\n",ish.norm_matrix_num);
+-        MdcPrntScrn("Attenuation Matrix Number   : %d\n"
+-                                              ,ish.atten_cor_matrix_num);
+-        MdcPrntScrn("Image Rotation              : %f [degrees]\n"
+-                                              ,ish.image_rotation);
+-        MdcPrntScrn("Plane Efficiency Correction Factor: %f\n"
+-                                                  ,ish.plane_eff_corr_fctr);
+-        MdcPrntScrn("Decay Correction Factor    : %f\n",ish.decay_corr_fctr);
+-        MdcPrntScrn("Loss Correction Factor     : %f\n",ish.loss_corr_fctr);
+-        MdcPrntScrn("Processing Code            : %d\n",ish.processing_code);
+-        MdcPrntScrn("Quantification Units       : %d ",ish.quant_units);
+-        if ((ish.quant_units > -1) && (ish.quant_units < 13))
+-          MdcPrntScrn("(= %s)\n",MdcEcatQuantificationUnits[ish.quant_units]);
+-        else
+-          MdcPrntScrn("(= Unknown)\n");
+-        MdcPrntScrn("Reconstruction Start Day   : %d\n",ish.recon_start_day);
+-        MdcPrntScrn("Reconstruction Start Month : %d\n"
+-                                             ,ish.recon_start_month);
+-        MdcPrntScrn("Reconstruction Start Year  : %d\n"
+-                                             ,ish.recon_start_year);
+-        MdcPrntScrn("Ecat Calibration Factor    : %f\n"
+-                                             ,ish.ecat_calibration_fctr);
+-        MdcPrntScrn("Well Counter Calibribration Factor : %f\n"
+-                                             ,ish.well_counter_cal_fctr);
+-        MdcPrntScrn("Filter Params - Cutoff Frequency : %f\n"
+-                                             ,ish.filter_params[0]);
+-        MdcPrntScrn("Filter Params - DC Component     : %f\n"
+-                                             ,ish.filter_params[1]);
+-        MdcPrntScrn("Filter Params - Ramp Slope       : %f\n"
+-                                             ,ish.filter_params[2]);
+-        MdcPrntScrn("Filter Params - (4)              : %f\n"
+-                                             ,ish.filter_params[3]);
+-        MdcPrntScrn("Filter Params - Scatter Comp 1   : %f\n"
+-                                             ,ish.filter_params[4]);
+-        MdcPrntScrn("Filter Params - Scatter Comp 2   : %f\n"
+-                                             ,ish.filter_params[5]);
+-        MdcPrntScrn("Annotation : "); MdcPrintStr(ish.annotation);
+-
+-       }
+-
+-       /* fill in DYNAMIC_DATA struct */
+-       if ((dd != NULL) && (plane == (fi->dim[3]/2))) {
+-         /* take values from a plane halfway */
+-         dd->nr_of_slices        = fi->dim[3];
+-         dd->time_frame_start    = (float)ish.frame_start_time;
+-         dd->time_frame_duration = (float)ish.frame_duration;
+-       }
+-
+-       /* fill in IMG_DATA struct */
+-
+-       id = &fi->image[img];
+-       id->width = (Uint32)ish.dimension_1;
+-       id->height = (Uint32)ish.dimension_2;
+-       id->recon_scale = ish.recon_scale;
+-
+-       id->quant_units = ish.quant_units;
+-       id->quant_scale = ish.quant_scale;
+-       id->calibr_units= mh.calibration_units;
+-       id->calibr_fctr = ish.ecat_calibration_fctr;
+-
+-       id->pixel_xsize = id->pixel_ysize = ish.pixel_size * 10.; /* in mm */
+-       id->slice_width = ish.slice_width * 10.; /* in mm */
+-       data_type = ish.data_type;
+-       switch( data_type ) {
+-         case  BYTE_TYPE:  id->bits = 8; id->type = BIT8_U;  break;
+-         case  M68K_I2  :
+-     /*  case  SUN_I2   : */
+-         case  VAX_I2   :  id->bits =16; id->type = BIT16_S; break;
+-         case  M68K_I4  :
+-     /*  case  SUN_I4   : */ 
+-         case  VAX_I4   :  id->bits =32; id->type = BIT32_S; break;
+-         case  IEEE_R4  :
+-     /*  case  SUN_R4   : */
+-         case  VAX_R4   :  id->bits =32; id->type = FLT32;   break;
+-       }
+-
+-       id->slice_spacing = mh.plane_separation*10.;  /* separation in mm */
+-
+-       if ( (strncmp(mh.user_process_code,"COR",10)==0) ||
+-            (strncmp(mh.user_process_code,"SAG",10)==0)) {
+-         /* CORONAL SLICES  or SAGITTAL SLICES 
+-            The images Ecat 6.4 software writes are useless:
+-            128x128 images with the small coronal/sagittal slice in it ...
+-            This means their pixel_xsize & pixel_ysize doesn't quite
+-            fit the real world dimensions any more !! 
+-            Therefore we don't even try to attempt writing the proper 
+-            Acr/Nema variables ... 
+-          */
+-       }else{ /* "TRA" or nothing */
+-         /* TRANSAXIAL SLICES (Transverse)             */
+-         /* Writing the proper Acr/Nema variables ...  */
+-         /* See man-page `m-acr.4' for more info (!)   */
+-
+-         /* slice position with bed offset (mm) */
+-         if (bed == 0) {
+-           slice_position = mh.init_bed_position;
+-         }else{
+-           slice_position = mh.init_bed_position + mh.bed_offset[bed-1];
+-         }
+-         slice_position *= 10.; /* mm */
+-
+-         MdcFillImgPos(fi,img,(Uint32)(plane-1),slice_position);
+-         MdcFillImgOrient(fi,img);
+-         
+-       }
+-
+-       break;
+-
+-     case MDC_ECAT6_ATTN_FILE:
+-
+-       error = mdc_mat_read_attn_subheader(fp, startblk-1, &ash);
+-       if (error) return("ECAT6 Bad read attenuation subheader");
+-       if (MDC_INFO) {
+-
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-        MdcPrntScrn("ATTENUATION SUBHEADER %05d:  ",img+1);
+-        MdcPrntScrn("Frame: %d  Plane: %d  Gate: %d  Data: %d  Bed: %d\n"
+-               ,frame,plane,gate,data,bed);
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-        MdcPrntScrn("Data Type                     : %d ",ash.data_type);
+-        if ((ash.data_type > -1) && (ash.data_type < 8))
+-          MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[ash.data_type]);
+-        else
+-          MdcPrntScrn("(= Unknown)\n");
+-        MdcPrntScrn("Attenuation Correction Method : %d\n"
+-                                                ,ash.attenuation_type);
+-        MdcPrntScrn("Number of Elements            : %d (width)\n"
+-                                                ,ash.dimension_1);
+-        MdcPrntScrn("Number of Views               : %d (height)\n"
+-                                                ,ash.dimension_2);
+-        MdcPrntScrn("Attenuation Scale Factor      : %f\n",ash.scale_factor);
+-        MdcPrntScrn("Ellipse X Offset              : %f [cm]\n"
+-                                                ,ash.x_origin);
+-        MdcPrntScrn("Ellipse Y Offset              : %f [cm]\n"
+-                                                ,ash.y_origin);
+-        MdcPrntScrn("Ellipse X Radius              : %f [cm]\n"
+-                                                ,ash.x_radius);
+-        MdcPrntScrn("Ellipse Y Radius              : %f [cm]\n"
+-                                                ,ash.y_radius);
+-        MdcPrntScrn("Ellipse Tilt Angle            : %f [degrees]\n"
+-                                                ,ash.tilt_angle);
+-        MdcPrntScrn("Mu-Absorption Coefficient     : %f [1/cm]\n"
+-                                                ,ash.attenuation_coeff);
+-        MdcPrntScrn("Sample Distance               : %f [cm]\n" 
+-                                                ,ash.sample_distance);
+-       } 
+-
+-       /* fill in IMG_DATA struct */
+-       id = &fi->image[img];
+-       id->width = (Uint32)ash.dimension_1;
+-       id->height = (Uint32)ash.dimension_2;
+-
+-       id->quant_units = 1;
+-       id->quant_scale = 1;
+-       id->calibr_units= 1;
+-       id->calibr_fctr = 1;
+-
+-       id->quant_scale = ash.scale_factor;
+-
+-       data_type = ash.data_type;
+-       switch( data_type ) {
+-         case  BYTE_TYPE:  id->bits = 8; id->type = BIT8_U;  break;
+-         case  M68K_I2  :
+-     /*  case  SUN_I2   : */
+-         case  VAX_I2   :  id->bits =16; id->type = BIT16_S; break;
+-         case  M68K_I4  :
+-     /*  case  SUN_I4   : */
+-         case  VAX_I4   :  id->bits =32; id->type = BIT32_S; break;
+-         case  IEEE_R4  :
+-     /*  case  SUN_R4   : */
+-         case  VAX_R4   :  id->bits =32; id->type = FLT32;   break;
+-       }
+-
+-       break;
+-
+-     case MDC_ECAT6_NORM_FILE:
+-
+-       error = mdc_mat_read_norm_subheader(fp, startblk-1, &nsh);
+-       if (error) return("ECAT6 Bad read normalization subheader");
+-       if (MDC_INFO) {
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-        MdcPrntScrn("NORMALIZATION SUBHEADER %05d:  ",img+1);
+-        MdcPrntScrn("Frame: %d  Plane: %d  Gate: %d  Data: %d  Bed: %d\n"
+-               ,frame,plane,gate,data,bed);
+-        MdcPrintLine('-',MDC_FULL_LENGTH);
+-        MdcPrntScrn("Data Type           : %d ",nsh.data_type);
+-        if ((nsh.data_type > -1) && (nsh.data_type < 8))
+-          MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[nsh.data_type]);
+-        else
+-          MdcPrntScrn("(= Unknown)\n");
+-        MdcPrntScrn("Number of Elements  : %d (width)\n",nsh.dimension_1);
+-        MdcPrntScrn("Number of Views     : %d (height)\n",nsh.dimension_2);
+-        MdcPrntScrn("Normalization Scale Factor  : %f\n",nsh.scale_factor);
+-        MdcPrntScrn("Normalization Start Hour    : %d\n",nsh.norm_hour);
+-        MdcPrntScrn("Normalization Start Minute  : %d\n",nsh.norm_minute);
+-        MdcPrntScrn("Normalization Start Second  : %d\n",nsh.norm_second);
+-        MdcPrntScrn("Normalization Start Day     : %d\n",nsh.norm_day);
+-        MdcPrntScrn("Normalization Start Month   : %d\n",nsh.norm_month);
+-        MdcPrntScrn("Normalization Start Year    : %d\n",nsh.norm_year);
+-        MdcPrntScrn("Field of View Source Width  : %f [cm]\n"
+-                                                     ,nsh.fov_source_width);
+-        MdcPrntScrn("Ecat Calibration Factor     : %f\n"
+-                                                     ,nsh.ecat_calib_factor);
+-       }
+-
+-       /* fill in IMG_DATA struct */
+-       id = &fi->image[img];
+-       id->width = (Uint32)nsh.dimension_1;
+-       id->height = (Uint32)nsh.dimension_2;
+-
+-       id->quant_units = 1;
+-       id->quant_scale = nsh.scale_factor;
+-       id->calibr_units= mh.calibration_units;
+-       id->calibr_fctr = nsh.ecat_calib_factor;
+-
+-       data_type = nsh.data_type;
+-       switch( data_type ) {
+-         case  BYTE_TYPE:  id->bits = 8; id->type = BIT8_U; break;
+-         case  M68K_I2  :
+-     /*  case  SUN_I2   : */
+-         case  VAX_I2   :  id->bits =16; id->type = BIT16_S; break;
+-         case  M68K_I4  :
+-     /*  case  SUN_I4   : */
+-         case  VAX_I4   :  id->bits =32; id->type = BIT32_S; break;
+-         case  IEEE_R4  :
+-     /*  case  SUN_R4   : */
+-         case  VAX_R4   :  id->bits =32; id->type = FLT32; break;
+-       }
+-
+-       break;
+-
+-    }
+-
+-    bytes = id->width*id->height*MdcType2Bytes(id->type);
+-    bytes = MdcMatrixBlocks(bytes);
+-
+-    id->buf = MdcGetImgBuffer(bytes);   
+-    if (id->buf == NULL) return("ECAT6 Bad malloc image buffer");
+-
+-    error = mdc_mat_read_matrix_data(fp,startblk,endblk,(Int16 *)id->buf);
+-
+-    if (error) {
+-      MdcPrntWarn("ECAT6 Bad read matrix data");
+-      err=MdcHandleTruncated(fi,img+1,MDC_YES);
+-      if(err != NULL) return(err);
+-    }
+-
+-    if (fi->truncated) break;
+-      
+-    img+=1;
+-  }
+-
+-  /* check the images really found */
+-  if (num_matrices < fi->number) {
+-    found = (Uint32)num_matrices;
+-  }else if (img < fi->number)    {
+-    found = img;
+-  }else {
+-    found = fi->number;
+-  }
+-  if (found != fi->number) {
+-    err=MdcHandleTruncated(fi,found,MDC_YES);
+-    if (err != NULL) return(err);
+-  }
+-
+-  /* fill in other FILEINFO variables */
+-  id = &fi->image[0];  /* first image */
+-  fi->dim[1] = id->width;
+-  fi->dim[2] = id->height;
+-  fi->bits = id->bits;
+-  fi->type = id->type;
+-  fi->pixdim[0]=3;
+-  fi->pixdim[1]=id->pixel_xsize;
+-  fi->pixdim[2]=id->pixel_ysize;
+-  fi->pixdim[3]=id->slice_width;
+-  if (mh.file_type == MDC_ECAT6_IMAGE_FILE) {
+-    MdcStringCopy(fi->filter_type,MdcEcatFilterTypes[abs(ish.filter_code)],
+-                                  MDC_MAX_ECATFLTRTYPES_SIZE);
+-    fi->reconstructed = MDC_YES;
+-    if (ish.decay_corr_fctr > 1.0 ) fi->decay_corrected = MDC_YES;
+-
+-    MdcStringCopy(fi->recon_method,ish.annotation,strlen(ish.annotation));
+-    if (strcmp(fi->recon_method,MDC_ECAT6_RECON_METHOD)  == 0 ) {
+-      strcpy(fi->recon_method,"Filtered Backprojection");
+-    }
+-  }else{
+-    fi->reconstructed = MDC_NO;
+-    strcpy(fi->recon_method,"None");
+-  }
+-
+-  switch( data_type ) {
+-    case  BYTE_TYPE:  MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break;
+-/*  case  SUN_I2   : */
+-    case  M68K_I2  :  MDC_FILE_ENDIAN = MDC_BIG_ENDIAN;  break;
+-    case  VAX_I2   :  MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break;
+-/*  case  SUN_I4   : */
+-    case  M68K_I4  :  MDC_FILE_ENDIAN = MDC_BIG_ENDIAN;  break;
+-    case  VAX_I4   :  MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break;
+-/*  case  SUN_R4   : */
+-    case  IEEE_R4  :  MDC_FILE_ENDIAN = MDC_BIG_ENDIAN;  break;
+-    case  VAX_R4   :  MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break;
+-  }
+-
+-  MdcCloseFile(fi->ifp);
+-
+-  if (fi->truncated) return("ECAT6 Truncated image file");
+-
+-  return NULL;
+-}
+-
+-float MdcGetSliceLocation(FILEINFO *fi, Int32 img)
+-{
+-   int orient;
+-   float locat=0.;
+-
+-   orient = MdcGetIntSliceOrient((int)fi->pat_slice_orient);
+-
+-   switch (orient) {
+-     case MDC_TRANSAXIAL: /* z-coord */
+-        locat = fi->image[img].image_pos_pat[2];
+-        break; 
+-     case MDC_SAGITTAL  : /* x-coord */
+-        locat = fi->image[img].image_pos_pat[0];
+-        break;
+-     case MDC_CORONAL   : /* y-coord */
+-        locat = fi->image[img].image_pos_pat[1];
+-        break;
+-   }
+-
+-   if (locat < 0.) locat = -locat;
+-
+-   return(locat / 10.); /* cm */
+-
+-}
+-
+-int MdcGetFilterCode(char *string)
+-{
+-  int i = 0;
+-
+-  for (i=0; i<MDC_MAX_ECATFLTRTYPES; i++) 
+-     if (strstr(string,MdcEcatFilterTypes[i]) != NULL) break;
+-
+-  return(i);
+-}
+-
+-void MdcFillMainHeader(FILEINFO *fi, Mdc_Main_header *mh)
+ {
+-  IMG_DATA *dd0=&fi->image[0];
+-  int i;
+-  float init_bed_position=0.;
+-
+-  /* memset(mh,0,MH_64_SIZE); */
+-  memset(mh,0,sizeof(Mdc_Main_header));
+-
+-  sprintf(mh->original_file_name,"%.19s",fi->ofname);
+-  mh->sw_version = 6;
+-  mh->system_type= 951;
+-  mh->file_type  = 2;
+-
+-  mh->data_type = 2;     /* ECAT 6 only reads VAX Int16 */
+-
+-  sprintf(mh->isotope_code,"%.8s",fi->isotope_code);
+-  mh->isotope_halflife = fi->isotope_halflife;
+-  sprintf(mh->radiopharmaceutical,"%.31s",fi->radiopharma);
+-  mh->calibration_units = fi->image[0].calibr_units;
+-  if (fi->pixdim[0] >= 3.) /* only valid for TRANSVERSE slices */
+-  mh->axial_fov = ((float)fi->dim[3] + 1.) * fi->pixdim[3] / 10.;
+-  mh->scan_start_day   = fi->study_date_day;
+-  mh->scan_start_month = fi->study_date_month;
+-  mh->scan_start_year  = fi->study_date_year;
+-  mh->scan_start_hour  = fi->study_time_hour;
+-  mh->scan_start_minute= fi->study_time_minute;
+-  mh->scan_start_second= fi->study_time_second;
+-  mh->plane_separation = fi->image[0].slice_spacing/10.; /* in cm */
+-  sprintf(mh->study_name,"%.11s",fi->study_id);
+-  mh->gantry_tilt = fi->gantry_tilt;
+-  sprintf(mh->patient_id,"%.15s",fi->patient_id);
+-  if (fi->patient_height == 0.) {
+-    mh->patient_height[0] = '\0';
+-  }else{
+-    sprintf(mh->patient_height,"%.2f",fi->patient_height);
+-  }
+-  if (fi->patient_weight == 0.) {
+-    mh->patient_weight[0] = '\0';
+-  }else{ 
+-    sprintf(mh->patient_weight,"%.2f",fi->patient_weight);
+-  }
+-  sprintf(mh->patient_name,"%.31s",fi->patient_name);
+-  mh->patient_sex = fi->patient_sex[0];
+-  sprintf(mh->operator_name,"%.31s",fi->operator_name);
+-  sprintf(mh->study_description,"%.31s",fi->study_descr);
+-  switch (fi->acquisition_type ) {
+-    case MDC_ACQUISITION_STATIC : 
+-        mh->acquisition_type = MDC_ECAT6_ACQTYPE_STATIC_EMISSION;  break;
+-    case MDC_ACQUISITION_TOMO   :   
+-        mh->acquisition_type = MDC_ECAT6_ACQTYPE_STATIC_EMISSION;  break;
+-    case MDC_ACQUISITION_DYNAMIC:   
+-        mh->acquisition_type = MDC_ECAT6_ACQTYPE_DYNAMIC_EMISSION; break;
+-    case MDC_ACQUISITION_GSPECT :
+-        mh->acquisition_type = MDC_ECAT6_ACQTYPE_GATED_EMISSION;   break;
+-    default                     : 
+-        mh->acquisition_type = MDC_ECAT6_ACQTYPE_UNKNOWN;
+-
+-  }
+-  sprintf(mh->facility_name,"%.19s",fi->institution);
+-  sprintf(mh->user_process_code,"%.10s",MDC_PRGR);
+-
+-  mh->num_planes = mh->num_frames = mh->num_gates = 1;
+-  mh->num_bed_pos = 1;
+- 
+-  for ( i=3; i<=fi->dim[0]; i++) {
+-     switch (i) {
+-       case 3: mh->num_planes  = fi->dim[i];     break;
+-       case 4: mh->num_frames  = fi->dim[i];     break;
+-       case 5: mh->num_gates   = fi->dim[i];     break;
+-       case 6: mh->num_bed_pos = fi->dim[i];     break;
+-       case 7: mh->num_bed_pos*= fi->dim[i];     break;
+-     }
+-  }
+-  mh->num_bed_pos -= 1; /* zero-based */
+-
+-  /* bed positions */
+-  if ((fi->bednr > 0) && (fi->beddata != NULL)) {
+-    /* use preserved bed offsets */
+-
+-    mh->init_bed_position = fi->beddata[0].hoffset / 10.; /* cm */
+-    mh->bed_elevation     = fi->beddata[0].voffset / 10.; /* cm */
+-
+-    for (i=1; i<fi->bednr; i++) { 
+-       if ( i==16 ) { 
+-         MdcPrntWarn("ECAT6 Unsupported number of bed positions");
+-         break;
+-       }
+-       mh->bed_offset[i-1]  = fi->beddata[i].hoffset - fi->beddata[0].hoffset;
+-       mh->bed_offset[i-1] /= 10.; /* cm */ 
+-    }
+-  }else{
+-    /* guess bad offsets, assume adjacent bed positions */
+-
+-    switch (MdcGetIntSliceOrient(fi->pat_slice_orient)) {
+-      case MDC_TRANSAXIAL:
+-          init_bed_position = dd0->image_pos_pat[2];  /* x */
+-          break;
+-      case MDC_CORONAL   :
+-          init_bed_position = dd0->image_pos_pat[1];  /* y */
+-          break;
+-      case MDC_SAGITTAL  :
+-          init_bed_position = dd0->image_pos_pat[0];  /* z */
+-          break;
+-    }
+-    if (init_bed_position < 0.)
+-      init_bed_position *= -1.;
+-    if (init_bed_position > dd0->slice_width)
+-      init_bed_position -= dd0->slice_width;
+-
+-    mh->init_bed_position = init_bed_position / 10.; /* cm */
+-
+-    for (i=1; i<fi->dim[6]; i++) {
+-       mh->bed_offset[i-1] = dd0->slice_width * (float)(fi->dim[3] * i / 10);
+-    }
+-  }
+-}
+-
+-void MdcFillImageSubHeader(FILEINFO *fi,Mdc_Image_subheader *ish
+-                            ,int type,Int32 img, Int32 matnum, Uint32 NEWSIZE)
+-{
+-  IMG_DATA *id = &fi->image[img];
+-  Uint32 fnr;
+-  Int32  fstart=0, fduration=0;
+-
+-  /* memset(ish,0,ISH_64_SIZE); */
+-  memset(ish,0,sizeof(Mdc_Image_subheader));
+-
+-  fnr = id->frame_number;
+-  if ((fi->dynnr > 0) && (fnr > 0)) {
+-    fstart    = (Int32)fi->dyndata[fnr-1].time_frame_start;
+-    fduration = (Int32)fi->dyndata[fnr-1].time_frame_duration;
+-  }else{
+-    fstart = 0; fduration = 0;
+-  }
+-
+-  ish->data_type = 2;           /* ECAT 6 only reads VAX Int16 */
+-
+-  ish->num_dimensions = 2;
+-  if (fi->diff_size || NEWSIZE) {
+-    ish->dimension_1 = fi->mwidth;
+-    ish->dimension_2 = fi->mheight;
+-  }else{
+-    ish->dimension_1 = id->width;
+-    ish->dimension_2 = id->height;
+-  }
+-  ish->recon_scale = id->recon_scale; 
+- 
+-  if (ish->data_type == 1 || ish->data_type == 2) {
+-    if (id->rescaled) {
+-      ish->image_min = (Int16) id->rescaled_min;
+-      ish->image_max = (Int16) id->rescaled_max;
+-    }else{
+-      ish->image_min = (Int16) id->min;
+-      ish->image_max = (Int16) id->max; 
+-    }
+-  }else{ /* data types too big for an Int16 */
+-    ish->image_min   = 0;
+-    ish->image_max   = 0;
+-  }
+-  ish->pixel_size  = ((id->pixel_xsize + id->pixel_ysize)/2.) / 10.;
+-  ish->slice_width = id->slice_width / 10.;
+-#ifdef MDC_USE_SLICE_SPACING
+-  if (fi->number > 1) ish->slice_width = id->slice_spacing / 10.;
+-#endif
+-  ish->frame_duration   = fduration;
+-  ish->frame_start_time = fstart;
+-  ish->slice_location   = (Int16)MdcGetSliceLocation(fi,img);
+-  ish->filter_code      = -(MdcGetFilterCode(fi->filter_type));
+-
+-  ish->scan_matrix_num  = matnum;
+-  ish->norm_matrix_num  = matnum;
+-  ish->atten_cor_matrix_num = matnum;
+-
+-  ish->quant_units      = id->quant_units;
+-
+-  if (id->rescaled) {
+-    ish->quant_scale = id->rescaled_fctr;
+-    ish->ecat_calibration_fctr = 1.;
+-  }else{  
+-    ish->quant_scale = id->quant_scale;
+-    ish->ecat_calibration_fctr = id->calibr_fctr;
+-  }
+-
+-  if (strcmp(fi->recon_method,"Filtered Backprojection") == 0 ) {
+-    sprintf(ish->annotation,"%.40s",MDC_ECAT6_RECON_METHOD);
+-  }else{ 
+-    sprintf(ish->annotation,"%.40s",fi->recon_method);
+-  }
++  return MDC_FRMT_NONE;
+ }
+ 
+-static void MdcResetSizes(FILEINFO *fi)
++char *MdcReadECAT6(FILEINFO *fi)
+ {
+-  fi->mwidth = saved_mwidth;
+-  fi->mheight= saved_mheight;
++  return("ECAT Reading unsupported (unclear licensing)");
+ }
+- 
+-const char *MdcWriteECAT6(FILEINFO *fi)
+-{
+-  IMG_DATA *id;
+-  Mdc_Main_header mh;
+-  Mdc_Image_subheader ish; 
+-  Uint8 *buf, *maxbuf;
+-  Uint16 type, FREE;
+-  Int32 matnum, data=0, bed, gate, frame, plane, img=0;
+-  Uint32 size, NEWSIZE=0;
+-
+-  if (MDC_FILE_STDOUT == MDC_YES)
+-    return("ECAT6 Writing to stdout unsupported for this format");
+-
+-  MDC_WRITE_ENDIAN = MDC_LITTLE_ENDIAN; /* always (VAX) */
+-
+-  if (XMDC_GUI == MDC_NO) {
+-    MdcDefaultName(fi,MDC_FRMT_ECAT6,fi->ofname,fi->ifname);
+-  }
+-
+-  if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Writing ECAT6:");
+-
+-  if (MDC_VERBOSE) MdcPrntMesg("ECAT6 Writing <%s> ...",fi->ofname);
+-
+-  /* check for colored files */
+-  if (fi->map == MDC_MAP_PRESENT)
+-    return("ECAT6 Colored files unsupported");
+-
+-  if (MdcKeepFile(fi->ofname)) {
+-    return("ECAT6 File exists!!");
+-  }
+-
+-  if (MDC_FORCE_INT != MDC_NO) {
+-    if (MDC_FORCE_INT != BIT16_S) {
+-      MdcPrntWarn("ECAT6 Only Int16 pixels supported");
+-    }
+-  } 
+-
+-  /* check some integrities */
+-
+-  /* check integrity of planes, frames, gates, beds */
+-  if (fi->dim[3] > MDC_ECAT6_MAX_PLANES)
+-    return("ECAT6 number of planes too big (1024)");
+-  if (fi->dim[4] > MDC_ECAT6_MAX_FRAMES)
+-    return("ECAT6 number of frames too big (512)");
+-  if (fi->dim[5] > MDC_ECAT6_MAX_GATES)
+-    return("ECAT6 number of gates  too big (64)");
+-  if ((fi->dim[6]*fi->dim[7]) > MDC_ECAT6_MAX_BEDS)
+-    return("ECAT6 number of beds   too big (16)");
+-
+-
+-#if MDC_ECAT6_RESTRICT_DIMS
+-  /* check dimensions (ECAT only 64, 128, 256) */
+-  /* we don't do downsaling                    */
+-  if (fi->mwidth > MDC_ECAT6_MAX_DIMS || fi->mheight > MDC_ECAT6_MAX_DIMS)
+-    return("ECAT6 dimensions too big (256)");
+-#endif
+-
+-  /* get maximum dimension */
+-  if (fi->mwidth > fi->mheight) size = fi->mwidth;
+-  else size = fi->mheight;
+-
+-#if MDC_ECAT6_RESTRICT_DIMS
+-  /* allow only 64, 128, 256 */
+-  if      (size <=  64) NEWSIZE=64;
+-  else if (size <= 128) NEWSIZE=128;
+-  else if (size <= 256) NEWSIZE=256;
+-#endif
+-
+-  /* save the original dimensions anyway */
+-  saved_mwidth = fi->mwidth;
+-  saved_mheight= fi->mheight;
+-
+-  /* change to new dimensions */
+-  if (NEWSIZE) {
+-    fi->mwidth = NEWSIZE;
+-    fi->mheight= NEWSIZE;
+-  }
+-
+-  MdcFillMainHeader(fi,&mh);
+-
+-  if ( (fi->ofp = mdc_mat_create(fi->ofname,&mh)) == NULL) {
+-    MdcResetSizes(fi);
+-    return("Couldn't create file");
+-  }
+ 
+-  for (bed=0; bed <= mh.num_bed_pos; bed++)
+-  for (gate=1; gate <= mh.num_gates; gate++)
+-  for (frame=1; frame <= mh.num_frames; frame++)
+-  for (plane=1; plane <= mh.num_planes; plane++) {
+-
+-     if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL);
+-
+-     id = &fi->image[img];
+-
+-     if ((id->type != BIT16_S) || MDC_QUANTIFY || MDC_CALIBRATE) {
+-       buf = MdcGetImgBIT16_S(fi, (Uint32)img);
+-       FREE=MDC_YES;  type=BIT16_S;
+-     }else{
+-       buf = id->buf;
+-       FREE=MDC_NO; type=id->type;
+-     }
+-
+-     matnum = mdc_mat_numcod(frame,plane,gate,data,bed);
+-     MdcFillImageSubHeader(fi,&ish,type,img,matnum,NEWSIZE); 
+-
+-     if (fi->diff_size || NEWSIZE) {
+-       size = fi->mwidth * fi->mheight * MdcType2Bytes(type);
+-
+-       maxbuf = MdcGetResizedImage(fi, buf, type, (Uint32)img);
+-       if (maxbuf == NULL) {
+-         MdcResetSizes(fi);
+-         return("ECAT6 Bad malloc maxbuf");
+-       }
+-
+-       if (FREE) MdcFree(buf); 
+-
+-       FREE=MDC_YES;
+-
+-     }else{ /* NEWSIZE is normally always set */
+-        size = id->width * id->height * MdcType2Bytes(type);
+-        maxbuf = buf;
+-     }
+- 
+-     matnum = mdc_mat_numcod(frame,plane,gate,data,bed);  
+-     if (mdc_mat_write_image(fi->ofp,matnum,&ish,(Uint16 *)maxbuf,(Int32)size))
+-     {
+-       MdcResetSizes(fi);
+-       return("ECAT6 Bad write image matrix");
+-     }
+-
+-     img+=1;
+-
+-     if (FREE) MdcFree(maxbuf);
+-  }
+-
+-  MdcCheckQuantitation(fi);
+-
+-  MdcCloseFile(fi->ofp);
+-
+-  MdcResetSizes(fi);
+-
+-  return NULL;
+-}
+-
+-void MdcPrintEcatInfoDB(Mdc_Main_header *mh)
++char *MdcWriteECAT6(FILEINFO *fi)
+ {
+-  char Unknown[8]="Unknown";
+-
+-  Uint32 i, patient_strlen, study_strlen;
+-
+-  patient_strlen = strlen(mh->patient_name);
+-  study_strlen   = strlen(mh->study_name);
+-
+-  /* remove # from strings, because it is used as field separator! */
+-  for (i=0; i<patient_strlen; i++) {
+-     if ( mh->patient_name[i] == '#' ) {
+-       mh->patient_name[i]='$';
+-     }
+-  }
+-
+-  /* print database info: study_name */
+-  if (study_strlen != 6) {
+-    MdcPrntScrn("%s",Unknown);
+-  }else{
+-    MdcPrntScrn("%s",mh->study_name);
+-  }
+-  MdcPrntScrn("# ");
+-
+-  /* print database info: patient_name */
+-  if (patient_strlen == 0) {
+-    MdcPrntScrn("%-35s",Unknown);
+-  }else{
+-    MdcPrntScrn("%-35s",mh->patient_name);
+-  }
+-
+-  MdcPrntScrn("#");
+-
+-  /* print database info: scan date */
+-  MdcPrntScrn("%02d-",mh->scan_start_day);
+-  switch (mh->scan_start_month) {
+-    case  1: MdcPrntScrn("Jan"); break;
+-    case  2: MdcPrntScrn("Feb"); break;
+-    case  3: MdcPrntScrn("Mar"); break;
+-    case  4: MdcPrntScrn("Apr"); break;
+-    case  5: MdcPrntScrn("May"); break;
+-    case  6: MdcPrntScrn("Jun"); break;
+-    case  7: MdcPrntScrn("Jul"); break;
+-    case  8: MdcPrntScrn("Aug"); break;
+-    case  9: MdcPrntScrn("Sep"); break;
+-    case 10: MdcPrntScrn("Oct"); break;
+-    case 11: MdcPrntScrn("Nov"); break;
+-    case 12: MdcPrntScrn("Dec"); break;
+-  }
+-  MdcPrntScrn("-%4d",mh->scan_start_year);
+-  MdcPrntScrn("\n");
++  return("ECAT Writing unsupported (unclear licensing)");
+ }
+ 
+--- a/source/m-ecat64.h
++++ b/source/m-ecat64.h
+@@ -7,12 +7,14 @@
+  *                                                                         *
+  * project      : (X)MedCon by Erik Nolf                                   *
+  *                                                                         *
++ * Notes        : DEBIAN - code removed due to unclear licensing           *
++ *                                                                         *
+  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+-/* $Id: m-ecat64.h,v 1.21 2013/06/23 21:51:19 enlf Exp $
++/* - debian dummy file v0.1 -
+  */
+ 
+ /*
+-   Copyright (C) 1997-2013 by Erik Nolf
++   Copyright (C) 1997-2002 by Erik Nolf
+ 
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+@@ -37,65 +39,13 @@
+ 
+ #include "m-matrix.h"
+ 
+-/****************************************************************************                              D E F I N E S
+-****************************************************************************/
+-
+-#define MDC_ECAT6_MAX_PLANES  1024
+-#define MDC_ECAT6_MAX_FRAMES   512
+-#define MDC_ECAT6_MAX_GATES     64
+-#define MDC_ECAT6_MAX_BEDS      16
+-
+-#define MDC_ECAT6_MAX_DIMS     256
+-
+-#define MDC_ECAT6_SYST_TYPE    951
+-
+-#define MDC_ECAT6_SCAN_FILE     1 
+-#define MDC_ECAT6_IMAGE_FILE    2 
+-#define MDC_ECAT6_ATTN_FILE     3
+-#define MDC_ECAT6_NORM_FILE     4
+-
+-#define MDC_ECAT6_ACQTYPE_UNKNOWN            0
+-#define MDC_ECAT6_ACQTYPE_BLANK              1
+-#define MDC_ECAT6_ACQTYPE_TRANSMISSION       2
+-#define MDC_ECAT6_ACQTYPE_STATIC_EMISSION    3
+-#define MDC_ECAT6_ACQTYPE_DYNAMIC_EMISSION   4
+-#define MDC_ECAT6_ACQTYPE_GATED_EMISSION     5
+-#define MDC_ECAT6_ACQTYPE_TRANSMISSION_RECT  6
+-#define MDC_ECAT6_ACQTYPE_EMISSION_RECT      7
+-#define MDC_ECAT6_ACQTYPE_WHOLE_BODY_TRANSM  8
+-#define MDC_ECAT6_ACQTYPE_WHOLE_BODY_STATIC  9
+-
+-#define MDC_MAX_ECATDATATYPES        8
+-#define MDC_MAX_ECATDATATYPES_SIZE  11
+-#define MDC_MAX_ECATFILETYPES        6
+-#define MDC_MAX_ECATFILETYPES_SIZE  14
+-#define MDC_MAX_ECATACQTYPES        10 
+-#define MDC_MAX_ECATACQTYPES_SIZE   25
+-#define MDC_MAX_ECATFLTRTYPES        8
+-#define MDC_MAX_ECATFLTRTYPES_SIZE   8
+-#define MDC_MAX_ECATQUANTTYPES      12
+-#define MDC_MAX_ECATQUANTTYPES_SIZE 25
+-
+-#define MDC_MAX_ECATSYSTEMTYPES      6
+-
+-#define MDC_ECAT6_RECON_METHOD "ACS reconstruction with new AP"
+-
+-#define MDC_ECAT6_SORT_ANATOMICAL 1
+-#define MDC_ECAT6_SORT_BYFRAME    2
+-
+-
+ /****************************************************************************
+                             F U N C T I O N S
+ ****************************************************************************/
+ 
+ int MdcCheckECAT6(FILEINFO *fi);
+-const char *MdcReadECAT6(FILEINFO *fi);
+-const char *MdcWriteECAT6(FILEINFO *fi);
+-float MdcGetSliceLocation(FILEINFO *fi, Int32 img);
+-int MdcGetFilterCode(char *string);
+-void MdcFillMainHeader(FILEINFO *fi, Mdc_Main_header *mh);
+-void MdcFillImageSubHeader(FILEINFO *fi, Mdc_Image_subheader *ish,int type,Int32 img,Int32 matnum,Uint32 NEWSIZE);
+-void MdcPrintEcatInfoDB(Mdc_Main_header *mh);
++char *MdcReadECAT6(FILEINFO *fi);
++char *MdcWriteECAT6(FILEINFO *fi);
+ 
+ #endif
+ 
+--- a/source/m-ecat72.c
++++ b/source/m-ecat72.c
+@@ -10,18 +10,17 @@
+  * Functions    : MdcCheckECAT7()          - Check for ECAT7 format        *
+  *                MdcEcatPrintMainHdr()    - Print content main header     *
+  *                MdcEcatPrintImgSubHdr()  - Print content image subheader *
+- *                MdcEcatPrintAttnSubHdr() - Print content attenuation hdr *
+- *                MdcEcatPrintScanSubHdr() - Print content scan header     *
+- *                MdcEcatPrintNormSubHdr() - Print content norm header     *
+  *                MdcReadECAT7()           - Read ECAT7 file               *
+  *                MdcWriteECAT7()          - Write ECAT7 file              *
+  *                                                                         *
+  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+-/* $Id: m-ecat72.c,v 1.75 2013/06/23 21:51:19 enlf Exp $
++/* $Id: m-ecat72.c,v 1.14 2003/04/24 23:25:10 enlf Exp $
++ */
++/* - debian dummy file v0.2 - by Roland Marcus Rutschmann <Rutschmann at gmx.de>
+  */
+ 
+ /*
+-   Copyright (C) 1997-2013 by Erik Nolf
++   Copyright (C) 1997-2003 by Erik Nolf
+ 
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+@@ -44,7 +43,6 @@
+ #include "m-depend.h"
+ 
+ #include <stdio.h>
+-#define __USE_POSIX 1
+ #include <time.h>
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+@@ -60,1448 +58,25 @@
+ 
+ #include "medcon.h"
+ 
+-#if MDC_INCLUDE_TPC
+-#define MDC_TPC_SITE 0       /* 0/1 disable/enable TPC site items */
+-#define __USE_ISOC99 1
+-#include <math.h>
+-#include "ecat7.h"
+-#endif
+-
+-
+ /****************************************************************************
+                               D E F I N E S
+ ****************************************************************************/
+ 
+-#define MDC_NUM_PLANES_FIX    MDC_YES /* fix for wrong num_planes = 1 bug */
+-
+-#define MDC_MAX_ECAT7FILETYPES      15
+-#define MDC_MAX_ECAT7FILETYPES_SIZE 15
+-
+-static char MdcEcat7FileTypes
+-        [MDC_MAX_ECAT7FILETYPES][MDC_MAX_ECAT7FILETYPES_SIZE]=
+-                       {"Unknown","Sinogram","Image16","AttnCorr","Norm",
+-                        "PolarMap","Volume8","Volume16","Projection8",
+-                        "Projection16","Image8","3DSino16","3DSino8",
+-                        "3DNorm","3DSinoFlt"};
+ 
+ /****************************************************************************
+                             F U N C T I O N S
+ ****************************************************************************/
+ int MdcCheckECAT7(FILEINFO *fi)
+ {
+-  Mdc_Main_header7 mh;
+-
+-  if (mdc_mat_read_main_header7(fi->ifp,&mh)) return MDC_BAD_READ;
+-
+-  if (memcmp(mh.magic_number,MDC_ECAT7_SIG,7) ) return(MDC_FRMT_NONE);
+-
+-  return MDC_FRMT_ECAT7;
+-
++  return MDC_FRMT_NONE;
+ }
+ 
+-void MdcEcatPrintMainHdr(Mdc_Main_header7 *mh)
++char *MdcReadECAT7(FILEINFO *fi)
+ {
+-  int i;
+-
+-  MdcPrintLine('-',MDC_HALF_LENGTH);
+-  MdcPrntScrn("ECAT7 Main Header (%d bytes)\n",MH_72_SIZE);
+-  MdcPrintLine('-',MDC_HALF_LENGTH);
+-
+-  MdcGetSafeString(mdcbufr,(char *)mh->magic_number,14,14);
+-  MdcPrntScrn("magic_number             : %s\n",mdcbufr);
+-  MdcGetSafeString(mdcbufr,mh->original_file_name,32,32);
+-  MdcPrntScrn("original_file_name       : %s\n",mdcbufr);
+-  MdcPrntScrn("sw_version               : %hd\n",mh->sw_version);
+-  MdcPrntScrn("system_type              : %hd\n",mh->system_type);
+-  MdcPrntScrn("file_type                : %hd ",mh->file_type);
+-  if ((mh->file_type > -1) && (mh->file_type < 15))
+-    MdcPrntScrn("(= %s)\n",MdcEcat7FileTypes[mh->file_type]);
+-  else
+-    MdcPrntScrn("(= Unknown)\n");
+-  MdcGetSafeString(mdcbufr,mh->serial_number,10,10);
+-  MdcPrntScrn("serial_number            : %s\n",mdcbufr);
+-  MdcPrntScrn("scan_start_time          : %s\n"
+-                                       ,ctime((time_t *)&mh->scan_start_time));
+-  MdcGetSafeString(mdcbufr,mh->isotope_name,8,8);
+-  MdcPrntScrn("isotope_name             : %s\n",mdcbufr);
+-  MdcPrntScrn("isotope_halflife         : %f [sec]\n",mh->isotope_halflife);
+-  MdcGetSafeString(mdcbufr,mh->radiopharmaceutical,32,32);
+-  MdcPrntScrn("radiopharmaceutical      : %s\n",mdcbufr);
+-  MdcPrntScrn("gantry_tilt              : %f [degrees]\n",mh->gantry_tilt);
+-  MdcPrntScrn("gantry_rotation          : %f [degrees]\n",mh->gantry_rotation);
+-  MdcPrntScrn("bed_elevation            : %f [cm]\n",mh->bed_elevation);
+-  MdcPrntScrn("intrinsic_tilt           : %f [degrees]\n",mh->intrinsic_tilt);
+-  MdcPrntScrn("wobble_speed             : %hd [rpm]\n",mh->wobble_speed);
+-  MdcPrntScrn("tansm_source_type        : %hd\n",mh->transm_source_type);
+-  MdcPrntScrn("distance_scanned         : %f [cm]\n",mh->distance_scanned);
+-  MdcPrntScrn("transaxial_fov           : %f [cm]\n",mh->transaxial_fov);
+-  MdcPrntScrn("angular_compression      : %hd\n",mh->angular_compression);
+-  MdcPrntScrn("coin_samp_mode           : %hd\n",mh->coin_samp_mode);
+-  MdcPrntScrn("axial_samp_mode          : %hd\n",mh->axial_samp_mode);
+-  MdcPrntScrn("ecat_calibration_factor  : %e\n",mh->ecat_calibration_factor);
+-  MdcPrntScrn("calibration_units        : %hd\n",mh->calibration_units);
+-  MdcPrntScrn("calibration_units_label  : %hd\n",mh->calibration_units_label);
+-  MdcPrntScrn("compression_code         : %hd\n",mh->compression_code);
+-  MdcGetSafeString(mdcbufr,mh->study_type,14,14);
+-  MdcPrntScrn("study_type               : %s\n",mdcbufr);
+-  MdcGetSafeString(mdcbufr,mh->patient_id,16,16);
+-  MdcPrntScrn("patient_id               : %s\n",mdcbufr);
+-  MdcGetSafeString(mdcbufr,mh->patient_name,32,32);
+-  MdcPrntScrn("patient_name             : %s\n",mdcbufr);
+-  MdcPrntScrn("patient_sex              : ");
+-    switch (mh->patient_sex[0]) {
+-      case 0:  MdcPrntScrn("M\n"); break;
+-      case 1:  MdcPrntScrn("F\n"); break;
+-      default: MdcPrntScrn("U\n");
+-    }
+-  MdcPrntScrn("patient_dexterity        : %c\n",mh->patient_dexterity[0]);
+-  MdcPrntScrn("patient_age              : %f\n",mh->patient_age);
+-  MdcPrntScrn("patient_height           : %f\n",mh->patient_height);
+-  MdcPrntScrn("patient_weight           : %f\n",mh->patient_weight);
+-  MdcPrntScrn("patient_birth_date       : %s\n"
+-                                    ,ctime((time_t *)&mh->patient_birth_date));
+-  MdcGetSafeString(mdcbufr,mh->physician_name,32,32);
+-  MdcPrntScrn("physician_name           : %s\n",mdcbufr);
+-  MdcGetSafeString(mdcbufr,mh->operator_name,32,32);
+-  MdcPrntScrn("operator_name            : %s\n",mdcbufr);
+-  MdcGetSafeString(mdcbufr,mh->study_description,32,32);
+-  MdcPrntScrn("study_description        : %s\n",mdcbufr);
+-  MdcPrntScrn("acquisition_type         : %hd\n",mh->acquisition_type);
+-  MdcPrntScrn("patient_orientation      : %hd\n",mh->patient_orientation);
+-  MdcGetSafeString(mdcbufr,mh->facility_name,20,20);
+-  MdcPrntScrn("facility_name            : %s\n",mdcbufr);
+-  MdcPrntScrn("num_planes               : %hd\n",mh->num_planes);
+-  MdcPrntScrn("num_frames               : %hd\n",mh->num_frames);
+-  MdcPrntScrn("num_gates                : %hd\n",mh->num_gates);
+-  MdcPrntScrn("num_bed_pos              : %hd\n",mh->num_bed_pos);
+-  MdcPrntScrn("init_bed_position        : %f\n",mh->init_bed_position);
+-    for (i=0; i<15; i++) 
+-  MdcPrntScrn("bed_position[%2d]         : %f\n",i,mh->bed_position[i]);
+-  MdcPrntScrn("plane_separation         : %f [cm]\n",mh->plane_separation);
+-  MdcPrntScrn("lwr_sctr_thres           : %hd [Kev]\n",mh->lwr_sctr_thres);
+-  MdcPrntScrn("lwr_true_thres           : %hd [Kev]\n",mh->lwr_true_thres);
+-  MdcPrntScrn("upr_true_thres           : %hd [Kev]\n",mh->upr_true_thres);
+-  MdcGetSafeString(mdcbufr,mh->user_process_code,10,10);
+-  MdcPrntScrn("user_process_code        : %s\n",mdcbufr);
+-  MdcPrntScrn("acquisition_mode         : %hd\n",mh->acquisition_mode);
+-  MdcPrntScrn("bin_size                 : %f [cm]\n",mh->bin_size);
+-  MdcPrntScrn("branching_fraction       : %f\n",mh->branching_fraction);
+-  MdcPrntScrn("dose_start_time          : %s\n"
+-                                       ,ctime((time_t *)&mh->dose_start_time));
+-  MdcPrntScrn("dosage                   : %e [mCi]\n",mh->dosage);
+-  MdcPrntScrn("well_counter_corr_factor : %f\n",mh->well_counter_corr_factor);
+-  MdcGetSafeString(mdcbufr,mh->data_units,32,32);
+-  MdcPrntScrn("data_units               : %s\n",mdcbufr);
+-  MdcPrntScrn("septa_state              : %hd\n",mh->septa_state);
+-    for (i=0; i<6; i++) 
+-  MdcPrntScrn("fill_cti[%d]              : %hd\n",i,mh->fill_cti[i]);
+-
++  return("ECAT7 Reading in debian unsupported (unclear licensing)");
+ }
+ 
+-void MdcEcatPrintImgSubHdr(Mdc_Image_subheader7 *ish, int nr)
+-{
+-  MdcPrintLine('-',MDC_HALF_LENGTH);
+-  MdcPrntScrn("ECAT7 Image Sub Header %05d (%d bytes)\n",nr,ISH_72_SIZE);
+-  MdcPrintLine('-',MDC_HALF_LENGTH);
+-
+-  MdcPrntScrn("data_type                : %hd\n",ish->data_type);
+-  MdcPrntScrn("num_dimensions           : %hd\n",ish->num_dimensions);
+-  MdcPrntScrn("x_dimension              : %hd\n",ish->x_dimension);
+-  MdcPrntScrn("y_dimension              : %hd\n",ish->y_dimension);
+-  MdcPrntScrn("z_dimension              : %hd\n",ish->z_dimension);
+-  MdcPrntScrn("x_offset                 : %f [cm]\n",ish->x_offset);
+-  MdcPrntScrn("y_offset                 : %f [cm]\n",ish->y_offset);
+-  MdcPrntScrn("z_offset                 : %f [cm]\n",ish->z_offset);
+-  MdcPrntScrn("recon_zoom               : %f\n",ish->recon_zoom);
+-  MdcPrntScrn("scale_factor             : %e\n",ish->scale_factor);
+-  MdcPrntScrn("image_min                : %hd\n",ish->image_min);
+-  MdcPrntScrn("image_max                : %hd\n",ish->image_max);
+-  MdcPrntScrn("x_pixel_size             : %f [cm]\n",ish->x_pixel_size);
+-  MdcPrntScrn("y_pixel_size             : %f [cm]\n",ish->y_pixel_size);
+-  MdcPrntScrn("z_pixel_size             : %f [cm]\n",ish->z_pixel_size);
+-  MdcPrntScrn("frame_duration           : %d [ms]\n",ish->frame_duration);
+-  MdcPrntScrn("frame_start_time         : %d [ms]\n",ish->frame_start_time);
+-  MdcPrntScrn("filter_code              : %hd\n",ish->filter_code);
+-  MdcPrntScrn("x_resolution             : %g\n",ish->x_resolution);
+-  MdcPrntScrn("y_resolution             : %g\n",ish->y_resolution);
+-  MdcPrntScrn("z_resolution             : %g\n",ish->z_resolution);
+-  MdcPrntScrn("num_r_elements           : %g\n",ish->num_r_elements);
+-  MdcPrntScrn("num_angles               : %g\n",ish->num_angles);
+-  MdcPrntScrn("z_rotation_angle         ; %g\n",ish->z_rotation_angle);
+-  MdcPrntScrn("decay_corr_fctr          : %g\n",ish->decay_corr_fctr);
+-  MdcPrntScrn("processing_code          : %d\n",ish->processing_code);
+-  MdcPrntScrn("gate_duration            : %u\n",ish->gate_duration);
+-  MdcPrntScrn("r_wave_offset            : %d\n",ish->r_wave_offset);
+-  MdcPrntScrn("num_accepted_beats       : %d\n",ish->num_accepted_beats);
+-  MdcPrntScrn("filter_cutoff_frequency  : %g\n",ish->filter_cutoff_frequency);
+-  MdcPrntScrn("filter_resolution        : %g\n",ish->filter_resolution);
+-  MdcPrntScrn("filter_ramp_slope        : %g\n",ish->filter_ramp_slope);
+-  MdcPrntScrn("filter_order             : %hd\n",ish->filter_order);
+-  MdcPrntScrn("filter_scatter_fraction  : %g\n",ish->filter_scatter_fraction);
+-  MdcPrntScrn("filter_scatter_slope     : %g\n",ish->filter_scatter_slope);
+-  MdcGetSafeString(mdcbufr,ish->annotation,40,40);
+-  MdcPrntScrn("annotation               : %s\n",mdcbufr);
+-  MdcPrntScrn("mt_1_1                   : %g\n",ish->mt_1_1);
+-  MdcPrntScrn("mt_1_2                   : %g\n",ish->mt_1_2);
+-  MdcPrntScrn("mt_1_3                   : %g\n",ish->mt_1_3);
+-  MdcPrntScrn("mt_2_1                   : %g\n",ish->mt_2_1);
+-  MdcPrntScrn("mt_2_2                   : %g\n",ish->mt_2_2);
+-  MdcPrntScrn("mt_2_3                   : %g\n",ish->mt_2_3);
+-  MdcPrntScrn("mt_3_1                   : %g\n",ish->mt_3_1);
+-  MdcPrntScrn("mt_3_2                   : %g\n",ish->mt_3_2);
+-  MdcPrntScrn("mt_3_3                   : %g\n",ish->mt_3_3);
+-  MdcPrntScrn("rfilter_cutoff           : %g\n",ish->rfilter_cutoff);
+-  MdcPrntScrn("rfilter_resolution       : %g\n",ish->rfilter_resolution);
+-  MdcPrntScrn("rfilter_code             : %hd\n",ish->rfilter_code);
+-  MdcPrntScrn("rfilter_order            : %hd\n",ish->rfilter_order);
+-  MdcPrntScrn("zfilter_cutoff           : %g\n",ish->zfilter_cutoff);
+-  MdcPrntScrn("zfilter_resolution       : %g\n",ish->zfilter_resolution);
+-  MdcPrntScrn("zfilter_code             : %hd\n",ish->zfilter_code);
+-  MdcPrntScrn("zfilter_order            : %hd\n",ish->zfilter_order);
+-  MdcPrntScrn("mt_1_4                   : %g\n",ish->mt_1_4);
+-  MdcPrntScrn("mt_2_4                   : %g\n",ish->mt_2_4);
+-  MdcPrntScrn("mt_3_4                   : %g\n",ish->mt_3_4);
+-  MdcPrntScrn("scatter_type             : %hd\n",ish->scatter_type);
+-  MdcPrntScrn("recon_type               : %hd\n",ish->recon_type);
+-  MdcPrntScrn("recon_views              : %hd\n",ish->recon_views);
+-  MdcPrntScrn("fill_cti[87]             : <not printed>\n");
+-  MdcPrntScrn("fill_user[48]            : <not printed>\n"); 
+-
+-}
+-
+-void MdcEcatPrintAttnSubHdr(Mdc_Attn_subheader7 *ash, int nr)
+-{
+-  int i;
+-
+-  MdcPrintLine('-',MDC_HALF_LENGTH);
+-  MdcPrntScrn("ECAT7 Attenuation Sub Header %05d (%d bytes)\n",nr,ASH_72_SIZE);
+-  MdcPrintLine('-',MDC_HALF_LENGTH);
+-
+-  MdcPrntScrn("data_type                : %hd\n",ash->data_type);
+-  MdcPrntScrn("num_dimensions           : %hd\n",ash->num_dimensions);
+-  MdcPrntScrn("attenuation_type         : %hd\n",ash->attenuation_type);
+-  MdcPrntScrn("num_r_elements           : %hd\n",ash->num_r_elements);
+-  MdcPrntScrn("num_angles               : %hd\n",ash->num_angles);
+-  MdcPrntScrn("num_z_elements           : %hd\n",ash->num_z_elements);
+-  MdcPrntScrn("ring_difference          : %hd\n",ash->ring_difference);
+-  MdcPrntScrn("x_resolution             : %g [cm]\n",ash->x_resolution);
+-  MdcPrntScrn("y_resolution             : %g [cm]\n",ash->y_resolution);
+-  MdcPrntScrn("z_resolution             : %g [cm]\n",ash->z_resolution);
+-  MdcPrntScrn("w_resolution             : %g\n",ash->w_resolution);
+-  MdcPrntScrn("scale_factor             : %e\n",ash->scale_factor);
+-  MdcPrntScrn("x_offset                 : %g [cm]\n",ash->x_offset);
+-  MdcPrntScrn("y_offset                 : %g [cm]\n",ash->y_offset);
+-  MdcPrntScrn("x_radius                 : %g [cm]\n",ash->x_radius);
+-  MdcPrntScrn("y_radius                 : %g [cm]\n",ash->y_radius);
+-  MdcPrntScrn("tilt_angle               : %g [degrees]\n",ash->tilt_angle);
+-  MdcPrntScrn("attenuation_coeff        : %g [1/cm]\n",ash->attenuation_coeff);
+-  MdcPrntScrn("attenuation_min          : %g\n",ash->attenuation_min);
+-  MdcPrntScrn("attenuation_max          : %g\n",ash->attenuation_max);
+-  MdcPrntScrn("skull_thickness          : %g [cm]\n",ash->skull_thickness);
+-  MdcPrntScrn("num_xtra_atten_coeff     : %hd\n",ash->num_xtra_atten_coeff);
+-  for (i=0; i<8; i++)
+-  MdcPrntScrn("xtra_atten_coeff[%d]      : %g\n",i,ash->xtra_atten_coeff[i]);
+-  MdcPrntScrn("edge_finding_threshold   : %g\n",ash->edge_finding_threshold);
+-  MdcPrntScrn("storage_order            : %hd\n",ash->storage_order);
+-  MdcPrntScrn("span                     : %hd\n",ash->span);
+-  for (i=0; i<64; i++)
+-  MdcPrntScrn("z_elements[%2d]           : %hd\n",i,ash->z_elements[i]);
+-  MdcPrntScrn("fill_unused[86]          : <not printed>\n");
+-  MdcPrntScrn("fill_user[50]            : <not printed>\n");
+-
+-}
+-
+-void MdcEcatPrintScanSubHdr(Mdc_Scan_subheader7 *ssh)
+-{
+-  MdcPrntScrn("data_type                : %hd\n",ssh->data_type);
+-  MdcPrntScrn("num_dimensions           : %hd\n",ssh->num_dimensions);
+-  MdcPrntScrn("num_r_elements           : %hd\n",ssh->num_r_elements);
+-  MdcPrntScrn("num_angles               : %hd\n",ssh->num_angles);
+-  MdcPrntScrn("corrections_applied      : %hd\n",ssh->corrections_applied);
+-  MdcPrntScrn("num_z_elements           : %hd\n",ssh->num_z_elements);
+-  MdcPrntScrn("ring_difference          : %hd\n",ssh->ring_difference);
+-  MdcPrntScrn("x_resolution             : %g [cm]\n",ssh->x_resolution);
+-  MdcPrntScrn("y_resolution             : %g [cm]\n",ssh->y_resolution);
+-  MdcPrntScrn("z_resolution             : %g [cm]\n",ssh->z_resolution);
+-  MdcPrntScrn("w_resolution             : %g\n",ssh->w_resolution);
+-  MdcPrntScrn("fill[6]                  : <not printed>\n");
+-  MdcPrntScrn("gate_duration            : %u [ms]\n",ssh->gate_duration);
+-  MdcPrntScrn("r_wave_offset            : %d [ms]\n",ssh->r_wave_offset);
+-  MdcPrntScrn("num_accepted_beats       : %d\n",ssh->num_accepted_beats);
+-  MdcPrntScrn("scale_factor             : %e\n",ssh->scale_factor);
+-  MdcPrntScrn("scan_min                 : %hd\n",ssh->scan_min);
+-  MdcPrntScrn("scan_max                 : %hd\n",ssh->scan_max);
+-  MdcPrntScrn("prompts                  : %d\n",ssh->prompts);
+-  MdcPrntScrn("delayed                  : %d\n",ssh->delayed);
+-  MdcPrntScrn("multiples                : %d\n",ssh->multiples);
+-  MdcPrntScrn("net_trues                : %d\n",ssh->net_trues);
+-  MdcPrntScrn("cor_singles[16]          : <not printed>\n"); 
+-  MdcPrntScrn("uncor_singles[16]        : <not printed>\n");
+-  MdcPrntScrn("tot_avg_cor              : %g\n",ssh->tot_avg_cor);
+-  MdcPrntScrn("tot_avg_uncor            : %g\n",ssh->tot_avg_uncor);
+-  MdcPrntScrn("total_coin_rate          : %d\n",ssh->total_coin_rate);
+-  MdcPrntScrn("frame_start_time         : %u\n",ssh->frame_start_time);
+-  MdcPrntScrn("frame_duration           : %u\n",ssh->frame_duration);
+-  MdcPrntScrn("deadtime_correction_factor: %g\n"
+-                                        ,ssh->deadtime_correction_factor);
+-  MdcPrntScrn("phy_planes[8]            : <not printed>\n");
+-  MdcPrntScrn("cti_fill[90]             : <not printed>\n");
+-  MdcPrntScrn("user_fill[50]            : <not printed>\n");
+-
+-}
+-
+-
+-void MdcEcatPrintNormSubHdr(Mdc_Norm_subheader7 *nsh)
+-{
+-  MdcPrntScrn("data_type                : %hd\n",nsh->data_type);
+-  MdcPrntScrn("num_dimensions           : %hd\n",nsh->num_dimensions);
+-  MdcPrntScrn("num_r_elements           : %hd\n",nsh->num_r_elements);
+-  MdcPrntScrn("num_angles               : %hd\n",nsh->num_angles);
+-  MdcPrntScrn("num_z_elements           : %hd\n",nsh->num_z_elements);
+-  MdcPrntScrn("ring_difference          : %hd\n",nsh->ring_difference);
+-  MdcPrntScrn("scale_factor             : %e\n",nsh->scale_factor);
+-  MdcPrntScrn("norm_min                 : %g\n",nsh->norm_min);
+-  MdcPrntScrn("norm_max                 : %g\n",nsh->norm_max);
+-  MdcPrntScrn("fov_source_width         : %g\n",nsh->fov_source_width);
+-  MdcPrntScrn("norm_quality_factor      : %g\n",nsh->norm_quality_factor);
+-  MdcPrntScrn("norm_quality_factor_code : %hd\n",nsh->norm_quality_factor_code);
+-  MdcPrntScrn("storage_order            : %hd\n",nsh->storage_order);
+-  MdcPrntScrn("span                     : %hd\n",nsh->span);
+-  MdcPrntScrn("z_elements[64]           : <not printed>\n");
+-  MdcPrntScrn("cti_fill[123]            : <not printed>\n");
+-  MdcPrntScrn("user_fill[50]            : <not printed>\n");
+-
+-}
+-
+-const char *MdcReadECAT7(FILEINFO *fi)
+-{
+-  FILE *fp = fi->ifp;
+-  int i, error/*, UNSUPPORTED*/;
+-  const char *err;
+-  char *str;
+-  struct tm time, *ptime;
+-  Mdc_Main_header7 mh;
+-  Mdc_Image_subheader7 ish;
+-  Mdc_Attn_subheader7  ash;
+-/*
+-  Mdc_Scan_subheader7 ssh;
+-  Mdc_Norm_subheader7 nsh;
+-*/
+-  struct Mdc_MatDir entry, matrix_list[MDC_ECAT7_MAX_MATRICES];
+-  struct Mdc_Matval matval;
+-  Uint32 number, slice, img=0, vol=0, bytes;
+-  Uint32 group=0, group_slice, skip_bytes=0,  row, rbytes;
+-  int bed,gate,frame,plane,nb,ng,nf,np,nd;
+-  int matnum, startblk, endblk, num_matrices;
+-  IMG_DATA *id;
+-  DYNAMIC_DATA *dd=NULL;
+-  Int16 bits, type;
+-  Uint8 *mbufr, *pmbufr, *pbuf;
+-  float slice_position;
+-
+-  if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Reading ECAT7:");
+-
+-  if (MDC_VERBOSE) MdcPrntMesg("ECAT7 Reading <%s> ...",fi->ifname);
+-
+-  /* put some defaults we use */
+-  fi->endian=MDC_FILE_ENDIAN=MDC_BIG_ENDIAN;
+-  fi->modality = M_PT;
+-
+-  error = mdc_mat_read_main_header7(fp, &mh);
+-  if (error) return("ECAT7 Bad read main header");
+-
+-  if (MDC_INFO || MDC_INFO_DB) MdcEcatPrintMainHdr(&mh);
+-
+-  if (MDC_INFO_DB) return(NULL); /* just needed db info */
+-
+-  /* check for supported file types *
+-  switch (mh.file_type) {
+-    case MDC_ECAT7_FILE_TYPE_IMAGE16 :
+-    case MDC_ECAT7_FILE_TYPE_VOLUME8 :
+-    case MDC_ECAT7_FILE_TYPE_VOLUME16:
+-    case MDC_ECAT7_FILE_TYPE_IMAGE8  :
+-        UNSUPPORTED = MDC_NO;
+-        break;
+-    default:
+-        UNSUPPORTED = MDC_YES;
+-  }*/
+-  /* if (UNSUPPORTED == MDC_YES) return("ECAT7 Unsupported file type"); */
+-
+-  if (mh.num_frames  <= 0 ) mh.num_frames  = 1;
+-  if (mh.num_gates   <= 0 ) mh.num_gates   = 1;
+-  if (mh.num_bed_pos <  0 ) mh.num_bed_pos = 0;
+-
+-  /* fill in global FILEINFO data */
+-  fi->dim[0]= 6;
+-  fi->dim[3]= mh.num_planes;
+-  fi->dim[4]= mh.num_frames;
+-  fi->dim[5]= mh.num_gates;
+-  fi->dim[6]= mh.num_bed_pos + 1; /* must be 1-based */
+-
+-  /* check for unsupported bed overlap */
+-  if (fi->dim[6] > 1) {
+-    float axial_width, bed_offset=mh.bed_position[0];
+-
+-    if (bed_offset < 0) bed_offset = -bed_offset;
+-
+-    axial_width = mh.plane_separation * (float)fi->dim[3];
+-    if ((axial_width - bed_offset) >= 1.0) {
+-      MdcPrntWarn("ECAT7 Bed overlaps unsupported"); 
+-    }
+-  }
+-
+-  for (i=3, number=1; i<=6; i++) number*=fi->dim[i];
+-
+-  if (number == 0) return("ECAT7 No valid images specified");
+-
+-  /* fill in orientation information */
+-  switch (mh.patient_orientation) {
+-    case MDC_ECAT7_FEETFIRST_PRONE:
+-        fi->pat_slice_orient = MDC_PRONE_FEETFIRST_TRANSAXIAL;  break;
+-    case MDC_ECAT7_HEADFIRST_PRONE:
+-        fi->pat_slice_orient = MDC_PRONE_HEADFIRST_TRANSAXIAL;  break;
+-    case MDC_ECAT7_FEETFIRST_SUPINE:
+-        fi->pat_slice_orient = MDC_SUPINE_FEETFIRST_TRANSAXIAL; break;
+-    case MDC_ECAT7_HEADFIRST_SUPINE:
+-        fi->pat_slice_orient = MDC_SUPINE_HEADFIRST_TRANSAXIAL; break;
+-    case MDC_ECAT7_FEETFIRST_RIGHT:
+-        fi->pat_slice_orient = MDC_DECUBITUS_RIGHT_FEETFIRST_TRANSAXIAL; break;
+-    case MDC_ECAT7_HEADFIRST_RIGHT:
+-        fi->pat_slice_orient = MDC_DECUBITUS_RIGHT_HEADFIRST_TRANSAXIAL; break;
+-    case MDC_ECAT7_FEETFIRST_LEFT:
+-        fi->pat_slice_orient = MDC_DECUBITUS_LEFT_FEETFIRST_TRANSAXIAL;  break;
+-    case MDC_ECAT7_HEADFIRST_LEFT:
+-        fi->pat_slice_orient = MDC_DECUBITUS_LEFT_HEADFIRST_TRANSAXIAL;  break;
+-    default:
+-        fi->pat_slice_orient = MDC_SUPINE_HEADFIRST_TRANSAXIAL;
+-        MdcPrntWarn("ECAT7 unknown patient orientation"); 
+-  }
+-
+-  str = MdcGetStrPatPos(fi->pat_slice_orient);
+-  MdcStringCopy(fi->pat_pos,str,strlen(str));
+-
+-  str = MdcGetStrPatOrient(fi->pat_slice_orient);
+-  MdcStringCopy(fi->pat_orient,str,strlen(str));
+-
+-  /* fill in patient study related information */
+-  switch (mh.patient_sex[0]) {
+-    case 0:  fi->patient_sex[0] = 'M'; break;
+-    case 1:  fi->patient_sex[0] = 'F'; break;
+-    default: fi->patient_sex[0] = 'U';
+-  }
+-  fi->patient_sex[1]='\0';
+-  MdcStringCopy(fi->patient_name,mh.patient_name,32);
+-  MdcStringCopy(fi->patient_id,mh.patient_id,16);
+-  fi->patient_height = mh.patient_height;
+-  fi->patient_weight = mh.patient_weight;
+-
+-  ptime = &time;
+-#ifdef HAVE_LOCALTIME_R
+-  localtime_r((time_t *)&(mh.patient_birth_date), ptime);
+-#else
+-  ptime = localtime((time_t *)&(mh.patient_birth_date));
+-#endif
+-  if (ptime == NULL) {
+-    MdcPrntWarn("ECAT7: Couldn't resolve patient birth date");
+-    strcpy(fi->patient_dob,"00000000");
+-  }else{
+-    sprintf(fi->patient_dob,"%.4d%.2d%.2d",ptime->tm_year + 1900
+-                                          ,ptime->tm_mon  + 1
+-					  ,ptime->tm_mday);
+-  }
+-
+-  ptime = &time;
+-#ifdef HAVE_LOCALTIME_R
+-  localtime_r((time_t *)&(mh.scan_start_time), ptime);
+-#else
+-  ptime = localtime((time_t *)&(mh.scan_start_time));
+-#endif
+-  if (ptime == NULL) {
+-    MdcPrntWarn("ECAT7: Couldn't resolve scan start time");
+-    fi->study_date_day   = 0;
+-    fi->study_date_month = 1;
+-    fi->study_date_year  = 1900;
+-    fi->study_time_hour  = 0;
+-    fi->study_time_minute= 0;
+-    fi->study_time_second= 0;
+-  }else{
+-    fi->study_date_day   = ptime->tm_mday;
+-    fi->study_date_month = ptime->tm_mon  + 1;
+-    fi->study_date_year  = ptime->tm_year + 1900;
+-    fi->study_time_hour  = ptime->tm_hour;
+-    fi->study_time_minute= ptime->tm_min;
+-    fi->study_time_second= ptime->tm_sec;
+-  }
+-
+-  switch (mh.acquisition_type) {
+-    case MDC_ECAT7_SCAN_TRANSMISSION:
+-    case MDC_ECAT7_SCAN_STATIC_EMISSION:
+-      fi->acquisition_type = MDC_ACQUISITION_TOMO;    
+-      break;
+-    case MDC_ECAT7_SCAN_DYNAMIC_EMISSION:
+-      fi->acquisition_type = MDC_ACQUISITION_DYNAMIC; 
+-      break;
+-    case MDC_ECAT7_SCAN_GATED_EMISSION:
+-      fi->acquisition_type = MDC_ACQUISITION_GSPECT; 
+-      break;
+-    case MDC_ECAT7_SCAN_BLANK:
+-    case MDC_ECAT7_SCAN_TRANS_RECTILINEAR:
+-    case MDC_ECAT7_SCAN_EMISSION_RECTILINEAR:
+-    default: 
+-      fi->acquisition_type = MDC_ACQUISITION_UNKNOWN;
+-      break;
+-  }
+-
+-  sprintf(mdcbufr,"ECAT%hd",mh.system_type);
+-  MdcStringCopy(fi->manufacturer,mdcbufr,strlen(mdcbufr));
+-  MdcStringCopy(fi->operator_name,mh.operator_name,32);
+-  MdcStringCopy(fi->study_descr,mh.study_description,32);
+-  MdcStringCopy(fi->study_id,mh.study_type,12);
+-  MdcStringCopy(fi->institution,mh.facility_name,20);
+-  MdcStringCopy(fi->radiopharma,mh.radiopharmaceutical,32);
+-  MdcStringCopy(fi->isotope_code,mh.isotope_name,8);
+-
+-  fi->isotope_halflife = mh.isotope_halflife;
+-  fi->injected_dose    = MdcmCi2MBq(mh.dosage);
+-  fi->gantry_tilt      = mh.gantry_tilt;
+-
+-  if (MDC_ECHO_ALIAS == MDC_YES) {
+-    MdcEchoAliasName(fi); return(NULL);
+-  }
+-
+-  if (!MdcGetStructID(fi,number))
+-    return("ECAT7 Bad malloc IMG_DATA structs");
+- 
+-  /* always malloc dyndata structs */
+-  if (!MdcGetStructDD(fi,(Uint32)fi->dim[4]*fi->dim[5]*fi->dim[6]))
+-    return("ECAT7 Couldn't malloc DYNAMIC_DATA structs");
+-
+-  /* ECAT7: matrices for each volume */
+-  num_matrices = mdc_mat_list7(fp, matrix_list, MDC_ECAT7_MAX_MATRICES);
+-  if (num_matrices == 0)
+-    return("ECAT7 No matrices found");
+-  if ((Uint32)num_matrices > (fi->number / fi->dim[3]))
+-    return("ECAT7 Too many matrices found");
+-
+-  if (MDC_MY_DEBUG) {
+-    int t;
+-
+-    MdcDebugPrint("%d.%d.%d.%d",fi->dim[3]
+-                               ,fi->dim[4]
+-                               ,fi->dim[5]
+-                               ,fi->dim[6]);
+-
+-    for (t=0; t<num_matrices; t++) {
+-       MdcDebugPrint("[%2d]\t%d\t%d\t%d\t%d",t
+-                                            ,matrix_list[t].matnum
+-                                            ,matrix_list[t].strtblk
+-                                            ,matrix_list[t].endblk
+-                                            ,matrix_list[t].matstat);
+-    }
+-  } 
+-
+-  img=0; vol=0;
+-  for (bed=0; bed<fi->dim[6]; bed++)
+-  for (gate=1; gate<=fi->dim[5]; gate++)
+-  for (frame=1; frame<=fi->dim[4]; frame++, vol++)
+-  for (plane=1; plane<=fi->dim[3]; ) {
+-
+-     if (vol == num_matrices) break;
+-
+-     if (fi->dynnr > 0) dd = &fi->dyndata[(fi->dim[4]*bed) + (frame-1)];
+-
+-     mdc_mat_numdoc(matrix_list[vol].matnum,&matval);
+-     nf = matval.frame; np = matval.plane; ng = matval.gate;
+-     nb = matval.bed;   nd = matval.data;
+-     matnum = mdc_mat_numcod(nf,np,ng,nd,nb);
+-     MdcDebugPrint("matnum       = %d",matnum);
+-     if (!mdc_mat_lookup7(fp, matnum, &entry)) continue;
+-     startblk = entry.strtblk + 1;
+-     endblk = entry.endblk - entry.strtblk;
+-
+-     MdcDebugPrint("entry.endblk = %d",entry.endblk);
+-     MdcDebugPrint("entry.strtblk= %d",entry.strtblk);
+-     MdcDebugPrint("startblk     = %d",startblk);
+-     MdcDebugPrint("endblk       = %d",endblk);
+-
+-     switch (mh.file_type) {
+-
+-       case MDC_ECAT7_FILE_TYPE_IMAGE8  :
+-       case MDC_ECAT7_FILE_TYPE_IMAGE16 :
+-       case MDC_ECAT7_FILE_TYPE_VOLUME8 :
+-       case MDC_ECAT7_FILE_TYPE_VOLUME16:
+-
+-         error = mdc_mat_read_image_subheader7(fp, startblk-1, &ish);
+-         if (error) return("ECAT7 Bad read image subheader");
+-
+-         if (MDC_INFO) MdcEcatPrintImgSubHdr(&ish, (int)(vol + 1));
+-
+-         fi->dim[1] = ish.x_dimension;
+-         fi->dim[2] = ish.y_dimension;
+-
+-#if MDC_NUM_PLANES_FIX 
+-         if ((mh.num_planes != ish.z_dimension) && (vol == 0)) {
+-
+-           MdcPrntWarn("ECAT7 Fix wrong num_planes value");
+-
+-           mh.num_planes = ish.z_dimension;
+-           fi->dim[3]    = ish.z_dimension;
+-
+-           for (i=3, number=1; i<=6; i++) number*=fi->dim[i];
+-           if (!MdcGetStructID(fi,number))
+-             return("ECAT7 Bad realloc IMG_DATA structs");
+- 
+-         }
+-#endif
+-
+-         switch (ish.data_type) {
+-           case BYTE_TYPE:
+-               bits = 8;  type = BIT8_U;  break;
+-           case VAX_I2:
+-           case SUN_I2:
+-               bits = 16; type = BIT16_S; break;
+-           case VAX_I4:
+-           case SUN_I4:
+-               bits = 32; type = BIT32_S; break;
+-           case VAX_R4:
+-           case IEEE_R4:
+-               bits = 32; type = FLT32;   break;
+-           default:
+-               return("ECAT7: Unsupported data type");
+-         }
+-
+-         /* fill in DYNAMIC_DATA structs */
+-         if ((dd != NULL) && (plane == 1)) {
+-           /* just one subheader */
+-           dd->nr_of_slices        = fi->dim[3];
+-           dd->time_frame_start    = (float)ish.frame_start_time;
+-           dd->time_frame_duration = (float)ish.frame_duration;
+-         }
+-
+-         /* bytes entire volume (matrix blocks) */
+-         bytes = fi->dim[1] * fi->dim[2] * fi->dim[3] * MdcType2Bytes(type);
+-         MdcDebugPrint("volume: %d bytes",bytes);
+-         bytes = MdcMatrixBlocks(bytes);
+- 
+-         MdcDebugPrint("matrix: %d bytes",bytes);
+-
+-         mbufr = malloc(bytes); 
+-         if (mbufr == NULL)
+-           return("ECAT7 Bad malloc image matrix data buffer");
+-
+-         error = mdc_mat_read_mat_data(fp,startblk,endblk,mbufr,ish.data_type);
+-
+-         if (error) {
+-           MdcPrntWarn("ECAT7 Bad read image matrix data");
+-           err=MdcHandleTruncated(fi,img+1,MDC_YES);
+-           if(err != NULL) { MdcFree(mbufr); return(err); }
+-         }
+-
+-         if (fi->truncated) break;
+-
+-         /* bytes each image */
+-         bytes = fi->dim[1] * fi->dim[2] * MdcType2Bytes(type);
+-
+-         for (slice=0; slice < fi->dim[3]; slice++, img++, plane++) {
+-
+-            if (MDC_PROGRESS)
+-              MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL);
+-
+-            /* fill in IMG_DATA struct */
+-            id = &fi->image[img];
+-            id->width = fi->dim[1];
+-            id->height= fi->dim[2];
+-            id->bits  = bits;
+-            id->type  = type;
+-
+-            id->quant_units  = 1;
+-            id->quant_scale  = ish.scale_factor;
+-            id->calibr_units = mh.calibration_units;
+-            id->calibr_fctr  = mh.ecat_calibration_factor;
+-
+-            id->pixel_xsize = ish.x_pixel_size * 10.0; /* mm */
+-            id->pixel_ysize = ish.y_pixel_size * 10.0; /* mm */
+-            id->slice_width = ish.z_pixel_size * 10.0; /* mm */
+-            id->slice_spacing = id->slice_width;
+-
+-            /* slice position with bed offset (mm) */
+-            if (bed == 0) {
+-              slice_position = mh.init_bed_position;
+-            }else{
+-              slice_position = mh.init_bed_position + mh.bed_position[bed-1];
+-            }
+-            slice_position *= 10.; /* mm */
+-
+-            MdcFillImgPos(fi,img,slice,slice_position);
+-
+-            MdcFillImgOrient(fi,img);
+-
+-            id->buf = MdcGetImgBuffer(bytes);
+-            if (id->buf == NULL) {
+-              MdcFree(mbufr);
+-              return("ECAT7 Bad malloc image buffer");
+-            }
+-
+-            memcpy(id->buf, mbufr + (bytes*slice), bytes); 
+-
+-         }
+-
+-         MdcFree(mbufr);
+-
+-         break;
+-
+-       case MDC_ECAT7_FILE_TYPE_ATTNCORR:
+-        
+-         error = mdc_mat_read_attn_subheader7(fp, startblk-1, &ash);
+-         if (error) return("ECAT7 Bad read attenuation subheader");
+-
+-         if (MDC_INFO) MdcEcatPrintAttnSubHdr(&ash, (int)(vol + 1));
+-
+-         fi->dim[1] = ash.num_r_elements;
+-         fi->dim[2] = ash.num_angles;
+-
+-         /* MARK: just retrieve group0 */
+-         /* fi->dim[3] = ash.num_z_elements; */
+-
+-         /* MARK: or   retrieve all    */
+-         fi->dim[3] = 0;
+-         for (i=0; ash.z_elements[i]; i++) fi->dim[3] += ash.z_elements[i];
+-
+-
+-         for (i=3, number=1; i<=6; i++) number*=fi->dim[i];
+-         if (!MdcGetStructID(fi,number))
+-           return("ECAT7 Bad realloc IMG_DATA structs");
+-
+-         switch (ash.data_type) {
+-           case BYTE_TYPE:
+-               bits = 8;  type = BIT8_U;  break;
+-           case VAX_I2:
+-           case SUN_I2:
+-               bits = 16; type = BIT16_S; break;
+-           case VAX_I4:
+-           case SUN_I4:
+-               bits = 32; type = BIT32_S; break;
+-           case VAX_R4:
+-           case IEEE_R4:
+-               bits = 32; type = FLT32;   break;
+-           default:
+-               return("ECAT7: Unsupported data type");
+-         }
+-
+-         /* bytes entire volume (matrix blocks) */
+-         bytes = fi->dim[1] * fi->dim[2] * fi->dim[3] * MdcType2Bytes(type);
+-         MdcDebugPrint("volume: %d bytes",bytes);
+-         bytes = MdcMatrixBlocks(bytes);
+-
+- 
+-         MdcDebugPrint("matrix: %d bytes",bytes);
+-
+-         mbufr = malloc(bytes); 
+-         if (mbufr == NULL)
+-           return("ECAT7 Bad malloc attenuation matrix data buffer");
+-
+-         endblk = startblk + (bytes / MdcMatBLKSIZE) - 1;
+-
+-         error = mdc_mat_read_mat_data(fp,startblk,endblk,mbufr,ash.data_type);
+-
+-         if (error) {
+-           MdcPrntWarn("ECAT7 Bad read attenuation matrix data");
+-           err=MdcHandleTruncated(fi,img+1,MDC_YES);
+-           if(err != NULL) { MdcFree(mbufr); return(err); }
+-         }
+-
+-         if (fi->truncated) break;
+-
+-         /* bytes each image */
+-         bytes = fi->dim[1] * fi->dim[2] * MdcType2Bytes(type);
+-
+-
+-         group_slice=0;
+-         for (slice=0; slice < fi->dim[3]; slice++, img++, plane++) {
+-
+-            if (MDC_PROGRESS)
+-              MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL);
+-
+-            /* fill in IMG_DATA struct */
+-            id = &fi->image[img];
+-            id->width = fi->dim[1];
+-
+-            id->height= fi->dim[2];
+-            id->bits  = bits;
+-            id->type  = type;
+-
+-            id->quant_units  = 1;
+-            id->quant_scale  = ash.scale_factor;
+-            id->calibr_units = mh.calibration_units;
+-            id->calibr_fctr  = mh.ecat_calibration_factor;
+-
+-            id->pixel_xsize = ash.x_resolution * 10.0; /* mm */
+-            id->pixel_ysize = ash.y_resolution * 10.0; /* mm */
+-            id->slice_width = ash.z_resolution * 10.0; /* mm */
+-            id->slice_spacing = id->slice_width;
+-
+-            /* slice position with bed offset (mm) */
+-            if (bed == 0) {
+-              slice_position = mh.init_bed_position;
+-            }else{
+-              slice_position = mh.init_bed_position + mh.bed_position[bed-1];
+-            }
+-            slice_position *= 10.; /* mm */
+-
+-            MdcFillImgPos(fi,img,slice,slice_position);
+-
+-            MdcFillImgOrient(fi,img);
+-
+-            id->buf = MdcGetImgBuffer(bytes);
+-            if (id->buf == NULL) {
+-              MdcFree(mbufr);
+-              return("ECAT7 Bad malloc image buffer");
+-            }
+-
+-            /* copy date */
+-            if (ash.storage_order == 0) {
+-              /* view mode: for the first group of z_elements we have       */
+-              /*            all 1st rows, all 2nd rows, etc. Then follows   */
+-              /*            same storage for next group of z_elements,      */
+-              /*            at least we think                               */
+-              /* MARK: still not proper for all groups, actually only 1st ok*/
+-              rbytes = fi->dim[1] * MdcType2Bytes(type);
+-              if (group_slice == ash.z_elements[group] ) {
+-                skip_bytes += ash.z_elements[group] * bytes;
+-                group += 1;
+-                group_slice = 0;
+-              }
+-              pmbufr = mbufr + skip_bytes  + group_slice * rbytes; /* MARK */
+-
+-              /* MARK printf("DEBUG: skip_bytes(%u) + group_slice(%u) * rbytes (%u) = %u\n",skip_bytes,group_slice,rbytes,skip_bytes+group_slice*rbytes); */
+-
+-              for (row=0; row < fi->dim[2]; row++) {
+-                 pbuf = id->buf+(rbytes * row);
+-                 memcpy(pbuf, pmbufr, rbytes);
+-                 pmbufr += ash.z_elements[group] * rbytes;
+-              }
+-            }else{
+-              /* sinogram mode: fine, just copy */
+-              memcpy(id->buf, mbufr + (bytes*slice), bytes); 
+-            }
+-
+-            group_slice++;
+-
+-         }
+-
+-         MdcFree(mbufr);
+-
+-         break;
+-
+-       default: 
+-
+-              return("ECAT7 Unsupported file type");
+-
+-     }
+-
+-  }
+-
+-  /* set remaing FILEINFO data */
+-  id = &fi->image[0];
+-  fi->bits = id->bits;
+-  fi->type = id->type;
+-  fi->pixdim[0] = 3;
+-  fi->pixdim[1] = id->pixel_xsize;
+-  fi->pixdim[2] = id->pixel_ysize;
+-  fi->pixdim[3] = id->slice_width;
+-
+-  switch (mh.file_type) {
+-    case MDC_ECAT7_FILE_TYPE_IMAGE8  :
+-    case MDC_ECAT7_FILE_TYPE_IMAGE16 :
+-    case MDC_ECAT7_FILE_TYPE_VOLUME8 :
+-    case MDC_ECAT7_FILE_TYPE_VOLUME16:
+-      fi->reconstructed = MDC_YES;
+-      if (ish.decay_corr_fctr > 1.0) fi->decay_corrected = MDC_YES;
+-      break; 
+-    default:
+-      fi->reconstructed = MDC_NO;
+-  }
+-
+-  MdcCloseFile(fi->ifp);
+-
+-  if (fi->truncated) return("ECAT7 Truncated image file");
+- 
+-  return(NULL);
+-
+-}
+-
+-#if MDC_INCLUDE_TPC
+-/*!
+- * Converts FILEINFO structure and MDC mainheader to TPC ecat7 mainheader
+- *
+- * @param mh pointer to MDC mainheader
+- * @param h pointer to TPC imageheader
+- * @param image_i image index number [0..fi->number-1]
+- * @param frame_i frame index number [0..fi->dim[4]-1]
+- */
+-int MdcConvertToTPCEcat7image(FILEINFO* fi,
+-                              ECAT7_imageheader* h, int image_i, int frame_i)
+-{
+-  int i = 0;
+-
+-  /* short int <- ECAT7_SUNI2 (must be for matrix writing) */
+-  h->data_type = ECAT7_SUNI2;
+-  h->num_dimensions = fi->dim[0];
+-  switch (fi->pat_slice_orient) {
+-#if MDC_TPC_SITE
+-    case MDC_SAGITTAL:
+-      /* short int <- Int16 */
+-      h->x_dimension = fi->dim[3];      
+-      h->y_dimension = fi->dim[2];
+-      h->z_dimension = fi->dim[1];
+-      /* float <- ??? */
+-      h->x_offset = 0;                  
+-      h->y_offset = 0;    
+-      h->z_offset = 0;
+-      h->x_pixel_size = fi->pixdim[3]/10;
+-      h->y_pixel_size = fi->pixdim[2]/10;
+-      h->z_pixel_size = fi->pixdim[1]/10;
+-      /* float <- ??? */
+-      h->x_resolution = 0.0f;
+-      h->y_resolution = 0.0f;
+-      h->z_resolution = 0.0f;
+-      break;
+-    case MDC_CORONAL:
+-      /* short int <- Int16 */
+-      h->x_dimension = fi->dim[1];
+-      h->y_dimension = fi->dim[3];
+-      h->z_dimension = fi->dim[2];
+-      /* float <- ??? */
+-      h->x_offset = 0;
+-      h->y_offset = 0;
+-      h->z_offset = 0;
+-      h->x_pixel_size = fi->pixdim[1]/10;
+-      h->y_pixel_size = fi->pixdim[3]/10;
+-      h->z_pixel_size = fi->pixdim[2]/10;
+-      /* float <- ??? */
+-      h->x_resolution = 0.0f;
+-      h->y_resolution = 0.0f;
+-      h->z_resolution = 0.0f;
+-      break;
+-#endif
+-    default:
+-      /* short int <- Int16 */
+-      h->x_dimension = fi->dim[1];
+-      h->y_dimension = fi->dim[2];
+-      h->z_dimension = fi->dim[3];
+-      /* float <- ??? */
+-      h->x_offset = 0;
+-      h->y_offset = 0;
+-      h->z_offset = 0;
+-      h->x_pixel_size = fi->pixdim[1]/10;
+-      h->y_pixel_size = fi->pixdim[2]/10;
+-      h->z_pixel_size = fi->pixdim[3]/10;
+-      /* float <- ??? */
+-      h->x_resolution = 0.0f;
+-      h->y_resolution = 0.0f;
+-      h->z_resolution = 0.0f;
+-      break;
+-  }
+-
+-  if (fi->image) {
+-/* eNlf: MARK - leave out for now, currently no slice_location in IMG_DATA
+-    switch(fi->pat_slice_orient) {
+-#if MDC_TPC_SITE
+-      case MDC_SAGITTAL:
+-             if(fi->dim[3] > 1 && fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location) != 0)
+-        h->x_pixel_size = fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location)/((fi->dim[3]-1)*10.0f);
+-      else
+-        h->x_pixel_size = fi->image[0].slice_width/10;
+-      break;
+-      case MDC_CORONAL:
+-             if(fi->dim[3] > 1 && fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location) != 0)
+-        h->y_pixel_size = fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location)/((fi->dim[3]-1)*10.0f);
+-      else
+-        h->y_pixel_size = fi->image[0].slice_width/10;
+-      break;
+-#endif
+-      default:
+-             if(fi->dim[3] > 1 && fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location) != 0)
+-        h->z_pixel_size = fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location)/((fi->dim[3]-1)*10.0f);
+-      else
+-        h->z_pixel_size = fi->image[0].slice_width/10;
+-    }
+-*/
+-    h->recon_zoom = fi->image[image_i].recon_scale;
+-
+-    if (fi->image[image_i].rescaled) {
+-      h->scale_factor = fi->image[image_i].rescaled_fctr;
+-    }else{
+-      h->scale_factor = 1.;
+-    }
+-
+-    /* short int <- double */
+-    h->image_min = fi->image[image_i].min;
+-    h->image_max = fi->image[image_i].max;
+-  }
+-
+-  if (fi->dyndata && frame_i < fi->dynnr) {
+-    /* int <- float (ms) */
+-    h->frame_duration = fi->dyndata[frame_i].time_frame_duration;
+-    /* int <- float (ms) */
+-    h->frame_start_time = fi->dyndata[frame_i].time_frame_start;
+-  }
+-  /* short int <- ??? */
+-  h->filter_code = 0;
+-  /* float <- ??? */
+-  h->num_r_elements = 0;
+-  /* float <- ??? */
+-  h->num_angles = 0.0f;
+-  /* float <- ??? */
+-  h->z_rotation_angle = 0.0f;
+-  /* float <- ??? */
+-  h->decay_corr_fctr = 0.0f;
+-  /* int <- ??? */
+-  h->processing_code = 0;
+-  if (fi->gdata) {
+-    /* int <- float (ms) */
+-    h->gate_duration = fi->gdata->image_duration;
+-    /* int <- float (ms) */
+-    h->r_wave_offset = fi->gdata->window_low;
+-    h->num_accepted_beats = fi->gdata->cycles_acquired;
+-  }
+-  /* float <- ??? */
+-  h->filter_cutoff_frequency = 0.0f;
+-  /* float <- ??? */
+-  h->filter_resolution = 0.0f;
+-  /* float <- ??? */
+-  h->filter_ramp_slope = 0.0f;
+-  /* short int <- ??? */
+-  h->filter_order = 0;
+-  /* float <- ??? */
+-  h->filter_scatter_fraction = 0.0f;
+-  /* float <- ??? */
+-  h->filter_scatter_slope = 0.0f;
+-/* char annotation[40]; */
+-  /* float <- ??? */
+-  h->mt_1_1 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_1_2 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_1_3 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_2_1 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_2_2 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_2_3 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_3_1 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_3_2 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_2_3 = 0.0f;
+-  /* float <- ??? */
+-  h->rfilter_cutoff = 0.0f;
+-  /* float <- ??? */
+-  h->rfilter_resolution = 0.0f;
+-  /* short int <- ??? */
+-  h->rfilter_code = 0.0f;
+-  /* short int <- ??? */
+-  h->rfilter_order = 0.0f;
+-  /* float <- ??? */
+-  h->zfilter_cutoff = 0.0f;
+-  /* float <- ??? */
+-  h->zfilter_resolution = 0.0f;
+-  /* short int <- ??? */
+-  h->zfilter_code = 0;
+-  /* short int <- ??? */
+-  h->zfilter_order = 0;
+-  /* float <- ??? */
+-  h->mt_1_4 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_2_4 = 0.0f;
+-  /* float <- ??? */
+-  h->mt_3_4 = 0.0f;
+-  /* short int <- ??? */
+-  h->scatter_type = 0;
+-  /* short int <- ??? */
+-  h->recon_type = 0;
+-  /* short int <- ??? */
+-  h->recon_views = 0;
+-  /* short int <- ??? */
+-  for(i = 0; i < 87; i++) h->fill_cti[i] = 0;
+-  /* short int <- ??? */
+-  for(i = 0; i < 49; i++) h->fill_user[i] = 0;
+-
+-  return 0;
+-}
+-
+-/*!
+- * Converts FILEINFO structure and MDC mainheader to TPC ecat7 mainheader
+- *
+- * @param fi file structure
+- * @param mh pointer to MDC mainheader
+- * @param h pointer to TPC mainheader
+- */
+-int MdcConvertToTPCEcat7(FILEINFO* fi, 
+-                         Mdc_Main_header* mh, ECAT7_mainheader* h)
+-{
+-  struct tm timeinfo;
+-  int i = 0;
+-  char number[5];
+-
+-  /* use default ecat7 magic number */
+-  strncpy(h->magic_number, ECAT7V_MAGICNR,14);
+-  strncpy(h->original_file_name,mh->original_file_name,20);
+-  h->sw_version = 72;
+-  /* short int <- Int16 */
+-  h->system_type = mh->system_type;
+-  /* short int <- ECAT7_VOLUME16 */
+-  h->file_type = ECAT7_VOLUME16;
+-  strncpy(h->serial_number,"unknown",10);
+-  /* int <- Int16 Int16 Int16 Int16 */
+-  memset((void *)&timeinfo,0,sizeof(timeinfo));
+-    timeinfo.tm_year = mh->scan_start_year-1900;
+-    timeinfo.tm_mon  = mh->scan_start_month-1;
+-    timeinfo.tm_mday = mh->scan_start_day;
+-    timeinfo.tm_hour = mh->scan_start_hour;
+-    timeinfo.tm_min  = mh->scan_start_minute;
+-    timeinfo.tm_sec  = mh->scan_start_second;
+-    timeinfo.tm_isdst= -1;
+-  h->scan_start_time = (unsigned int)mktime(&timeinfo);
+-  strncpy(h->isotope_name,fi->isotope_code,(8<MDC_MAXSTR ? 8 : MDC_MAXSTR));
+-  h->isotope_halflife = mh->isotope_halflife;
+-  strncpy(h->radiopharmaceutical,
+-          fi->radiopharma,(32<MDC_MAXSTR ? 32 : MDC_MAXSTR));
+-  h->gantry_tilt = mh->gantry_tilt;
+-  h->gantry_rotation = mh->gantry_rotation;
+-  h->bed_elevation = mh->bed_elevation;
+-  /* float <- ??? */
+-  h->intrinsic_tilt = 0.0f;
+-  /* short int <- Int16 */
+-  h->wobble_speed = mh->wobble_speed;
+-  /* short int <- Int16 */
+-  h->transm_source_type = mh->transm_source_type;
+-  /* float <- ??? */
+-  h->distance_scanned = 0.0f;
+-  h->transaxial_fov = mh->transaxial_fov;
+-  /* short int <- Int16 */
+-  h->angular_compression = mh->compression_code;
+-  /* short int <- Int16 */
+-  h->coin_samp_mode = mh->coin_samp_mode;
+-  /* short int <- Int16 */
+-  h->axial_samp_mode = mh->axial_samp_mode;
+-  h->ecat_calibration_factor = 1.; /* eNlf: global, prefer scale per plane*/
+-  /* short int <- Int16 */
+-  h->calibration_units = mh->calibration_units;
+-  /* short int <- ??? */
+-  h->calibration_units_label = 0;
+-  /* short int <- Int16 */
+-  h->compression_code = mh->compression_code;
+-  strncpy(h->study_type,mh->study_name,12);
+-  strncpy(h->patient_id,mh->patient_id,16);
+-  strncpy(h->patient_name,mh->patient_name,32);
+-  switch (fi->patient_sex[0]) {
+-    case 'M': h->patient_sex = 0; break;
+-    case 'F': h->patient_sex = 1; break;
+-    default : h->patient_sex = 3;
+-  }
+-  h->patient_dexterity = mh->patient_dexterity;
+-  sscanf(mh->patient_age,"%f",&h->patient_age);
+-  h->patient_height = fi->patient_height;
+-  h->patient_weight = fi->patient_weight;
+-
+-  /* patient_dob: YYYYMMDD -> tm_year, tm_mon, tm_day -> unsigned int*/
+-  memset((void *)&timeinfo,0,sizeof(timeinfo));
+-     /* YYYY */
+-     memcpy(number,&fi->patient_dob[0],4); number[4]='\0';
+-     timeinfo.tm_year = atoi(number) - 1900;
+-     /* MM */
+-     memcpy(number,&fi->patient_dob[4],2); number[2]='\0';
+-     timeinfo.tm_mon = atoi(number) - 1;
+-     /* DD */
+-     memcpy(number,&fi->patient_dob[6],2); number[2]='\0';
+-     timeinfo.tm_mday = atoi(number);
+-  h->patient_birth_date = (unsigned int)mktime(&timeinfo);
+-
+-  strncpy(h->physician_name,mh->physician_name,32);
+-  strncpy(h->operator_name,mh->operator_name,32);
+-  strncpy(h->study_description,mh->study_description,32);
+-  /* short int <- Int16 */
+-  h->acquisition_type = mh->acquisition_type;
+-  /* short int <- char[MDC_MAXSTR] */
+-  h->patient_orientation = 0;
+-  if(strncmp(fi->pat_pos,"FFP",3) == 0) h->patient_orientation = 0;
+-  else if(strncmp(fi->pat_pos,"HFP",3) == 0) h->patient_orientation = 1;
+-  else if(strncmp(fi->pat_pos,"FFS",3) == 0) h->patient_orientation = 2;
+-  else if(strncmp(fi->pat_pos,"HFS",3) == 0) h->patient_orientation = 3;
+-  else if(strncmp(fi->pat_pos,"FFDR",4) == 0) h->patient_orientation = 4;
+-  else if(strncmp(fi->pat_pos,"HFDR",4) == 0) h->patient_orientation = 5;
+-  else if(strncmp(fi->pat_pos,"FFDL",4) == 0) h->patient_orientation = 6;
+-  else if(strncmp(fi->pat_pos,"HFDL",4) == 0) h->patient_orientation = 7;
+-  else MdcPrntWarn("Unrecognized patient position: %s\n",fi->pat_pos);
+-#if MDC_TPC_SITE
+-  strncpy(h->facility_name,mh->original_file_name,20);
+-#else
+-  strncpy(h->facility_name,fi->institution,20);
+-#endif
+-  /* short int <- Int16 */
+-  switch (fi->pat_slice_orient) {
+-#if MDC_TPC_SITE
+-    case MDC_SAGITTAL: h->num_planes = fi->dim[1]; break;
+-    case MDC_CORONAL:  h->num_planes = fi->dim[2]; break;
+-#endif
+-    default:           h->num_planes = fi->dim[3]; break;
+-  }
+-  /* short int <- Int16 */
+-  h->num_frames = fi->dim[4];
+-  /* short int <- Int16 */
+-  h->num_gates = fi->dim[5];
+-  /* short int (zero-based value) <- Int16 (one-based value) */
+-  h->num_bed_pos = (fi->dim[6]>=1 ? fi->dim[6]-1 : 0);
+-  h->init_bed_position = mh->init_bed_position;
+-  for (i = 0; i < 15; i++) h->bed_position[i] = mh->bed_offset[i];
+-  h->plane_separation = mh->plane_separation;
+-  /* short int <- Int16 */
+-  h->lwr_sctr_thres = mh->lwr_sctr_thres;
+-  /* short int <- Int16 */
+-  h->lwr_true_thres = mh->lwr_true_thres;
+-  /* short int <- Int16 */
+-  h->upr_true_thres = mh->upr_true_thres;
+-  strncpy(h->user_process_code,mh->original_file_name,10);
+-  /* short int <- Int16 */
+-  h->acquisition_mode = mh->acquisition_mode;
+-  /* float <- ?? */
+-  h->bin_size = 0.0f;
+-  /* float <- ?? */
+-  h->branching_fraction = 0.0f;
+-  /* int <- Int16 Int16 Int16 Int16 */
+-  timeinfo.tm_year = fi->study_date_year-1900;
+-  timeinfo.tm_mon = fi->study_date_month-1;
+-  timeinfo.tm_mday = fi->study_date_day;
+-  timeinfo.tm_hour = fi->dose_time_hour;
+-  timeinfo.tm_min = fi->dose_time_minute;
+-  timeinfo.tm_sec = fi->dose_time_second;
+-  h->dose_start_time = (unsigned int)mktime(&timeinfo);
+-  h->dosage = MdcMBq2mCi(fi->injected_dose);
+-  /* float <- ?? */
+-  h->well_counter_corr_factor = 0.0f;
+-  /* char[32] <- char[MDC_MAXSTR] */
+-  strncpy(h->data_units,"unknown",32);
+-/* eNlf: MARK -  doesn't belong in modality XA
+-  if (fi->mod) {
+-    if ( strcmp(fi->mod->xa_info.Photo_Interp,"BQML") == 0 )
+-      strncpy(h->data_units,"kBq/ml",32);
+-  }
+-*/
+-  /* int <- ??? */
+-  h->septa_state = 0;
+-  /* int[6] <- ??? */
+-  for(i = 0; i < 6; i++) h->fill_cti[i] = 0;
+-
+-  return 0;
+-}
+-
+-/*!
+- * Modified to execute TPC ecat7 writing
+- *
+- * @param fi file structure
+- * @return Error message, or NULL if successfull
+- */
+-const char *MdcWriteECAT7(FILEINFO *fi)
+-{
+-  int ret = 0;
+-  int bytes = 0;
+-  ECAT7_mainheader h;
+-  ECAT7_imageheader ih;
+-  float* TPC_frame = 0;
+-  float* TPC_frame_start = 0;
+-  int frame_size = 0;
+-/*  int plane_dir = 0;*/
+-  Uint32 uwidth, uheight;
+-  IMG_DATA *id;
+-  Mdc_Main_header mh;
+-  Uint8 *buf, *maxbuf;
+-  Int16 type;
+-  Int32 matnum, bed, gate, frame, plane, img=0;
+-#if MDC_TPC_SITE
+-  Int32 column, row;
+-  float flt32=0;
+-#else
+-  Uint32 size;
+-#endif
+-
+-  if (MDC_FILE_STDOUT == MDC_YES)
+-    return("ECAT7 Writing to stdout unsupported for this format");
+-
+-  MDC_WRITE_ENDIAN = MDC_LITTLE_ENDIAN; /* always (VAX) */
+-
+-  if (XMDC_GUI == MDC_NO) {
+-    MdcDefaultName(fi,MDC_FRMT_ECAT7,fi->ofname,fi->ifname);
+-  }
+-  if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Writing ECAT7:");
+-  if (MDC_VERBOSE) MdcPrntMesg("ECAT7 Writing <%s> ...",fi->ofname);
+-
+-  /* check for colored files */
+-  if (fi->map == MDC_MAP_PRESENT)
+-    return("ECAT7 Colored files unsupported");
+-
+-  if (MdcKeepFile(fi->ofname)) {
+-    return("ECAT7 File exists!!");
+-  }
+-
+-  if (MDC_FORCE_INT != MDC_NO) {
+-    if (MDC_FORCE_INT != BIT16_S) {
+-      MdcPrntWarn("ECAT7 Only Int16 pixels supported");
+-    }
+-  }
+-
+-  /* check some integrities */
+-
+-  /* check integrity of planes, frames, gates, beds */
+-  if (fi->dim[3] > MDC_ECAT7_MAX_PLANES)
+-    return("ECAT7 number of planes too big (1024)");
+-  if (fi->dim[4] > MDC_ECAT7_MAX_FRAMES)
+-    return("ECAT7 number of frames too big (512)");
+-  if (fi->dim[5] > MDC_ECAT7_MAX_GATES)
+-    return("ECAT7 number of gates  too big (32)");
+-  if ((fi->dim[6]*fi->dim[7]) > MDC_ECAT7_MAX_BEDS)
+-    return("ECAT7 number of beds   too big (32)");
+-
+-  /* use TPC library to open file */
+-  MdcFillMainHeader(fi,&mh);
+-  MdcConvertToTPCEcat7(fi,&mh,&h);
+-  fi->ofp=ecat7Create(fi->ofname, &h);
+-  if (fi->ofp == NULL) {
+-    return("ECAT7 Failed to open file for writing");
+-  }
+-
+-  /* write all planes */
+-  frame_size = mh.num_planes*fi->mwidth*fi->mheight;
+-  TPC_frame_start = (float*)malloc(frame_size*sizeof(float));
+-  if (TPC_frame_start == NULL) {
+-    MdcCloseFile(fi->ofp);
+-    return("ECAT7 Failed to allocate frame buffer");
+-  }
+-
+-  if ( ! ( fi->pat_slice_orient == MDC_TRANSAXIAL || 
+-           fi->pat_slice_orient == MDC_CORONAL    ||
+-           fi->pat_slice_orient == MDC_SAGITTAL   )) {
+-    MdcPrntWarn("ECAT7 Couldn't resolve slice orientation, using transaxial\n");
+-  }
+-
+-  /* head feet direction L\P,L\FP,P\F,L\F,P\FR,R\F
+-  plane_dir = MDC_HEADFIRST;
+-  if      (strcmp(fi->pat_orient,"L\\P")  == 0) plane_dir = MDC_FEETFIRST;
+-  else if (strcmp(fi->pat_orient,"R\\P")  == 0) plane_dir = MDC_FEETFIRST;
+-  else if (strcmp(fi->pat_orient,"L\\FP") == 0) plane_dir = MDC_HEADFIRST;
+-  else if (strcmp(fi->pat_orient,"P\\F")  == 0) plane_dir = MDC_HEADFIRST;
+-  else if (strcmp(fi->pat_orient,"L\\F")  == 0) plane_dir = MDC_HEADFIRST;
+-  else if (strcmp(fi->pat_orient,"P\\FR") == 0) plane_dir = MDC_HEADFIRST;
+-  else if (strcmp(fi->pat_orient,"R\\F")  == 0) plane_dir = MDC_HEADFIRST;
+-  else {
+-    MdcPrntWarn("ECAT7 Unrecognized patient orientation: %s\n",fi->pat_orient);
+-  }*/
+-
+-  for (bed=0; bed <= mh.num_bed_pos; bed++)
+-  for (gate=1; gate <= mh.num_gates; gate++)
+-  for (frame=1; frame <= h.num_frames; frame++) {
+-
+-    TPC_frame = TPC_frame_start;
+-
+-#if MDC_TPC_SITE
+-    for (plane = 0; plane < fi->dim[3]; plane++) {
+-#else
+-    for (plane = 0; plane < fi->dim[3]; plane++, img++) {
+-#endif
+-       if (MDC_PROGRESS)
+-         MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL);
+-       if (img < 0) {
+-         img = fi->number-1;
+-         MdcPrntWarn("ECAT7 underflow %d %d %d %d\n",
+-                      mh.num_bed_pos,mh.num_gates,h.num_frames,fi->dim[3]);
+-       }
+-       if (img >= fi->number) {
+-         img = fi->number-1;
+-         MdcPrntWarn("ECAT7 overflow %d %d %d %d\n",
+-                      mh.num_bed_pos,mh.num_gates,h.num_frames,fi->dim[3]);
+-       }
+-
+-#if MDC_TPC_SITE
+-       img = (h.num_frames - frame)*fi->dim[3]+plane;
+-       id = &fi->image[img];
+-#else
+-       id = &fi->image[img];
+-#endif
+-
+-       /* TPC requires float buffer */
+-       buf = MdcGetImgFLT32(fi, (Uint32)img);
+-       if (buf == NULL) {
+-         MdcFree(TPC_frame_start);
+-         return("ECAT7 Bad malloc float buf");
+-       }
+-       type= FLT32;
+-
+-       if (fi->diff_size) {
+-         uwidth  = fi->mwidth; uheight = fi->mheight;
+-         maxbuf = MdcGetResizedImage(fi, buf, type, (Uint32)img);
+-         if (maxbuf == NULL) {
+-           MdcFree(buf);
+-           MdcFree(TPC_frame_start);
+-           return("ECAT7 Bad malloc maxbuf");
+-         }
+-         MdcFree(buf);
+-       }else{
+-         uwidth = id->width; uheight = id->height;
+-         maxbuf = buf;
+-       }
+-
+-       bytes = MdcType2Bytes(type);
+-
+-#if MDC_TPC_SITE
+-       /* copy plane to row-column-plane orientation as scaled float data */
+-       for (column=0; column < uwidth; column++)
+-       for (row=0; row < uheight*bytes; row+=bytes) {
+-          flt32 = *((float*)&maxbuf[column*uheight*bytes+row]);
+-          *(TPC_frame + ((plane)*uheight*uwidth 
+-                      + column*uheight 
+-                      + (row/bytes))) = flt32;
+-       }
+-#else
+-       /* copy plane at once */
+-       size  = uwidth * uheight;
+-
+-       TPC_frame = TPC_frame_start + (size*plane);
+-       memcpy(TPC_frame,maxbuf,size*bytes);
+-#endif
+-
+-       MdcFree(maxbuf);
+-
+-    }
+-
+-    TPC_frame = TPC_frame_start;
+-    matnum = mdc_mat_numcod(frame,1,1,0,0);
+-    MdcConvertToTPCEcat7image(fi,&ih,img-1,frame-1);
+-    ret = ecat7WriteImageMatrix(fi->ofp, matnum, &ih, TPC_frame);
+-    if (ret) {
+-      MdcFree(maxbuf);
+-      MdcFree(TPC_frame);
+-      MdcPrntWarn("ECAT7: Matrix write error code=%d\n",ret);
+-      return("ECAT7 Bad write image matrix");
+-    }
+-
+-  }
+-
+-  MdcFree(TPC_frame);
+-
+-  MdcCloseFile(fi->ofp);
+-
+-  MdcCheckQuantitation(fi);
+-
+-  return(NULL);
+-}
+-
+-#else
+-
+-const char *MdcWriteECAT7(FILEINFO *fi)
++char *MdcWriteECAT7(FILEINFO *fi)
+ {
+   return("ECAT7 Writing not yet supported");
+ }
+-
+-#endif
+--- a/source/m-ecat72.h
++++ b/source/m-ecat72.h
+@@ -8,11 +8,13 @@
+  * project      : (X)MedCon by Erik Nolf                                   *
+  *                                                                         *
+  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+-/* $Id: m-ecat72.h,v 1.19 2013/06/23 21:51:19 enlf Exp $
++/* $Id: m-ecat72.h,v 1.5 2003/03/30 22:58:52 enlf Exp $
++ */
++/* - debian dummy file v0.1 - by Roland Marcus Rutschmann <Rutschmann at gmx.de>
+  */
+ 
+ /*
+-   Copyright (C) 1997-2013 by Erik Nolf
++   Copyright (C) 1997-2003 by Erik Nolf
+ 
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+@@ -32,70 +34,19 @@
+ #define __M_ECAT72_H__
+ 
+ /****************************************************************************
+-                              D E F I N E S 
++                              D E F I N E S
+ ****************************************************************************/
+ 
+-#define MDC_ECAT7_SIG   "MATRIX7"
+-
+-#define MDC_ECAT7_MAX_MATRICES          5000
+-
+-#define MDC_ECAT7_MAX_PLANES            1024
+-#define MDC_ECAT7_MAX_FRAMES             512
+-#define MDC_ECAT7_MAX_GATES               32
+-#define MDC_ECAT7_MAX_BEDS                32
+-
+-#define MDC_ECAT7_FILE_TYPE_UNKNOWN        0
+-#define MDC_ECAT7_FILE_TYPE_SINOGRAM       1
+-#define MDC_ECAT7_FILE_TYPE_IMAGE16        2
+-#define MDC_ECAT7_FILE_TYPE_ATTNCORR       3
+-#define MDC_ECAT7_FILE_TYPE_NORM           4
+-#define MDC_ECAT7_FILE_TYPE_POLARMAP       5
+-#define MDC_ECAT7_FILE_TYPE_VOLUME8        6
+-#define MDC_ECAT7_FILE_TYPE_VOLUME16       7
+-#define MDC_ECAT7_FILE_TYPE_PROJECTION8    8
+-#define MDC_ECAT7_FILE_TYPE_PROJECTION16   9
+-#define MDC_ECAT7_FILE_TYPE_IMAGE8         10
+-#define MDC_ECAT7_FILE_TYPE_3DSINO16       11
+-#define MDC_ECAT7_FILE_TYPE_3DSINO8        12
+-#define MDC_ECAT7_FILE_TYPE_3DNORM         13
+-#define MDC_ECAT7_FILE_TYPE_3DSINOFLT      14
+-
+-#define MDC_ECAT7_SOURCE_TYPE_NONE         1
+-#define MDC_ECAT7_SOURCE_TYPE_RRING        2
+-#define MDC_ECAT7_SOURCE_TYPE_RING         3
+-#define MDC_ECAT7_SOURCE_TYPE_ROD          4
+-#define MDC_ECAT7_SOURCE_TYPE_RROD         5
+-
+-#define MDC_ECAT7_FEETFIRST_PRONE          0
+-#define MDC_ECAT7_HEADFIRST_PRONE          1
+-#define MDC_ECAT7_FEETFIRST_SUPINE         2
+-#define MDC_ECAT7_HEADFIRST_SUPINE         3
+-#define MDC_ECAT7_FEETFIRST_RIGHT          4
+-#define MDC_ECAT7_HEADFIRST_RIGHT          5
+-#define MDC_ECAT7_FEETFIRST_LEFT           6
+-#define MDC_ECAT7_HEADFIRST_LEFT           7
+-
+-#define MDC_ECAT7_SCAN_UNKNOWN              0
+-#define MDC_ECAT7_SCAN_BLANK                1
+-#define MDC_ECAT7_SCAN_TRANSMISSION         2
+-#define MDC_ECAT7_SCAN_STATIC_EMISSION      3
+-#define MDC_ECAT7_SCAN_DYNAMIC_EMISSION     4
+-#define MDC_ECAT7_SCAN_GATED_EMISSION       5
+-#define MDC_ECAT7_SCAN_TRANS_RECTILINEAR    6
+-#define MDC_ECAT7_SCAN_EMISSION_RECTILINEAR 7
++/* All deleted in dummy
++*/
+ 
+ /****************************************************************************
+                             F U N C T I O N S
+ ****************************************************************************/
+ 
+ int MdcCheckECAT7(FILEINFO *fi);
+-void MdcEcatPrintMainHdr(Mdc_Main_header7 *mh);
+-void MdcEcatPrintImgSubHdr(Mdc_Image_subheader7 *ish, int nr);
+-void MdcEcatPrintAttnSubHdr(Mdc_Attn_subheader7 *ash, int nr);
+-void MdcEcatPrintScanSubHdr(Mdc_Scan_subheader7 *ssh);
+-void MdcEcatPrintNormSubHdr(Mdc_Norm_subheader7 *nsh);
+-const char *MdcReadECAT7(FILEINFO *fi);
+-const char *MdcWriteECAT7(FILEINFO *fi);
++char *MdcReadECAT7(FILEINFO *fi);
++char *MdcWriteECAT7(FILEINFO *fi);
+ 
+ #endif
+ 
+--- a/source/m-matrix.c
++++ b/source/m-matrix.c
+@@ -7,1909 +7,9 @@
+  *                                                                         *
+  * project      : (X)MedCon by Erik Nolf                                   *
+  *                                                                         *
+- * Notes        : Source code addapted from CTI PET Systems, Inc.          *
+- *                Original code 2.6 10/19/93  Copyright 1989-1993          *
+- *                                                                         *
+- *                Changed code for swapping & the use of our data types    *
+- *                with machine independency as target                      *
+- *                                                                         *
+- *                Put "mdc" prefix on functions and structs to prevent     *
+- *                naming conflicts with other tools based on CTI code      *
+- *                                                                         *
+- *                Added functions for ECAT 7 reading support               *
+- *                                                                         *
+- * Original CTI Authors listed:                                            *
+- *   E. Phearson                                                           *
+- *   L. Davis                                                              *
+- *   Yaorong                                                               *
++ * Notes        : DEBIAN - code removed due to licensing issues            *
+  *                                                                         *
+  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+-/* $Id: m-matrix.c,v 1.35 2013/06/23 21:51:19 enlf Exp $
++/* - debian dummy file v0.1 - 
+  */
+ 
+-/*
+-   Copyright (C) 1997-2013 by Erik Nolf
+-
+-   This program is free software; you can redistribute it and/or modify it
+-   under the terms of the GNU General Public License as published by the
+-   Free Software Foundation; either version 2, or (at your option) any later
+-   version.
+-
+-   This program is distributed in the hope that it will be useful, but
+-   WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+-   Public License for more details.
+-
+-   You should have received a copy of the GNU General Public License along
+-   with this program; if not, write to the Free Software Foundation, Inc.,
+-   59 Place - Suite 330, Boston, MA 02111-1307, USA.  */
+-
+-/****************************************************************************
+-                              H E A D E R S
+-****************************************************************************/
+-
+-#include "m-depend.h"
+-
+-#include <stdio.h>
+-#ifdef HAVE_STDLIB_H
+-#include <stdlib.h>
+-#endif
+-#ifdef HAVE_STRING_H
+-#include <string.h>
+-#endif
+-#ifdef HAVE_STRINGS_H
+-#ifndef _WIN32
+-#include <strings.h>
+-#endif
+-#endif
+-
+-#include "medcon.h"
+-
+-/***************************************************************************
+-                              D E F I N E S 
+-***************************************************************************/
+-
+-struct ExpMatDir {
+-        int matnum;
+-        int strtblk;
+-        int endblk;
+-        int matstat;
+-        float anatloc;
+-};
+-
+-/****************************************************************************
+-                            F U N C T I O N S
+-****************************************************************************/
+-
+-
+-	/*********************************************************/
+-	FILE *mdc_mat_open( fname, fmode)
+-	char *fname, *fmode;
+-{
+-	FILE *fptr;
+-
+-	fptr = fopen(fname, fmode);
+-	return (fptr);
+-
+-}
+-	/*********************************************************/
+-	void mdc_mat_close( fptr)
+-	FILE *fptr;
+-{
+-	MdcCloseFile( fptr);
+-}
+-	/*********************************************************/
+-	Int32 mdc_mat_rblk( fptr, blkno, bufr, nblks)
+-	FILE *fptr;
+-	Int32 blkno, nblks;
+-	Uint8 *bufr;
+-{
+-	int r;
+-	fseek( fptr, (blkno-1)*MdcMatBLKSIZE, 0);
+-	r = fread( bufr, 1, (unsigned)(nblks*MdcMatBLKSIZE), fptr);
+-	if (r != (nblks*MdcMatBLKSIZE)) return(-1);
+-
+-	return (0);
+-}
+-	/*********************************************************/
+-
+-	Int32 mdc_mat_list( fptr, mlist, lmax)
+-	FILE *fptr;
+-	struct Mdc_MatDir mlist[];
+-	Int32 lmax;
+-{
+-	Int32 blk, num_entry, num_stored, i;
+-	Int32 nxtblk, matnum, strtblk, endblk, matstat;
+-	Int32 dirbufr[MdcMatBLKSIZE/4];
+-	Uint8 bytebufr[MdcMatBLKSIZE];
+-
+-	blk = MdcMatFirstDirBlk;
+-	num_entry = 0;
+-	num_stored = 0;
+-	while(1) {
+-	mdc_mat_rblk( fptr, blk, bytebufr,1);
+-	if ( MdcHostBig() ) { 
+-          MdcSWAB( (Uint8 *)bytebufr, (Uint8 *)dirbufr, MdcMatBLKSIZE);
+-	  MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, MdcMatBLKSIZE/2);
+-        }else{
+-          memcpy(dirbufr, bytebufr, MdcMatBLKSIZE);
+-        }
+-	/* nfree  = dirbufr[0]; */
+-	nxtblk = dirbufr[1];
+-	/* prvblk = dirbufr[2]; */
+-	/* nused  = dirbufr[3]; */
+-	for (i=4; i<MdcMatBLKSIZE/4; i+=4)
+-	{  matnum  = dirbufr[i];
+-	   strtblk = dirbufr[i+1];
+-	   endblk  = dirbufr[i+2];
+-	   matstat = dirbufr[i+3];
+-	   if (matnum && num_stored < lmax)
+-	   {  mlist[num_stored].matnum = matnum;
+-	      mlist[num_stored].strtblk = strtblk;
+-	      mlist[num_stored].endblk = endblk;
+-	      mlist[num_stored].matstat = matstat;
+-	      num_stored++;
+-	   }
+-	   if (matnum) num_entry++;
+-	}
+-	blk = nxtblk;
+-	if (blk == MdcMatFirstDirBlk) break;
+-	}
+-
+-	return (num_entry);
+-}
+-	/*********************************************************/	
+-	Int32 mdc_mat_list7( fptr, mlist, lmax)
+-	FILE *fptr;
+-	struct Mdc_MatDir mlist[];
+-	Int32 lmax;
+-{
+-	Int32 blk, num_entry, num_stored, i;
+-	Int32 nxtblk, matnum, strtblk, endblk, matstat;
+-	Int32 dirbufr[MdcMatBLKSIZE/4];
+-	Uint8 bytebufr[MdcMatBLKSIZE];
+-
+-	blk = MdcMatFirstDirBlk;
+-	num_entry = 0;
+-	num_stored = 0;
+-	while(1) {
+-	mdc_mat_rblk( fptr, blk, bytebufr,1);
+-	if (! MdcHostBig() ) { 
+-          MdcSWAB( (Uint8 *)bytebufr, (Uint8 *)dirbufr, MdcMatBLKSIZE);
+-	  MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, MdcMatBLKSIZE/2);
+-        }else{
+-          memcpy(dirbufr, bytebufr, MdcMatBLKSIZE);
+-        }
+-	/* nfree  = dirbufr[0]; */
+-	nxtblk = dirbufr[1];
+-	/* prvblk = dirbufr[2]; */
+-	/* nused  = dirbufr[3]; */
+-	for (i=4; i<MdcMatBLKSIZE/4; i+=4)
+-	{  matnum  = dirbufr[i];
+-	   strtblk = dirbufr[i+1];
+-	   endblk  = dirbufr[i+2];
+-	   matstat = dirbufr[i+3];
+-	   if (matnum && num_stored < lmax)
+-	   {  mlist[num_stored].matnum = matnum;
+-	      mlist[num_stored].strtblk = strtblk;
+-	      mlist[num_stored].endblk = endblk;
+-	      mlist[num_stored].matstat = matstat;
+-	      num_stored++;
+-	   }
+-	   if (matnum) num_entry++;
+-	}
+-	blk = nxtblk;
+-	if (blk == MdcMatFirstDirBlk) break;
+-	}
+-
+-	return (num_entry);
+-}
+-
+-        /*********************************************************/
+-        Int32 MdcSWAW( from, to, length)
+-        Uint16 from[], to[];
+-        Int32 length;
+-{
+-        Uint16 temp;
+-        Int32 i;
+-
+-        for (i=0;i<length; i+=2)
+-        {  temp = from[i+1];
+-           to[i+1]=from[i];
+-           to[i] = temp;
+-        }
+-        return 0;
+-}
+-
+-        /*********************************************************/
+-        Int32 MdcSWAB( from, to, length)
+-        Uint8 from[], to[];
+-        Int32 length;
+-{
+-        Uint16 temp;
+-        Int32 i;
+-
+-        for (i=0;i<length; i+=2)
+-        {
+-           temp   = from[i+1];
+-           to[i+1]= from[i];
+-           to[i]  = temp;
+-        }
+-        return 0;
+-}
+-
+-
+-	/********************************************************
+-old version supporting 4096 planes, 256 planes, 4 data types
+-	Int32 mdc_mat_numcod( frame, plane, gate, data, bed)
+-	  Int32 frame, plane, gate, data, bed;
+-{
+-	return ((frame&0xFFF)|((bed&0xF)<<12)|((plane&0xFF)<<16)|
+-	       ((gate&0x3F)<<24)|((data&0x3)<<30));
+-}
+-*/
+-	/********************************************************
+-old version supporting 4096 planes, 256 planes, 4 data types
+-	mdc_mat_numdoc( matnum, matval)
+-	  Int32 matnum; struct Mdc_Matval *matval;
+-{
+-	matval->frame = matnum&0xFFF;
+-	matval->plane = (matnum>>16)&0xFF;
+-	matval->gate  = (matnum>>24)&0x3F;
+-	matval->data  = (matnum>>30)&0x3;
+-	matval->bed   = (matnum>>12)&0xF;
+-	return 0;
+-}
+-*/
+-	/********************************************************
+-new version supporting 512 planes, 1024 planes, 8 data types */
+-	Int32 mdc_mat_numcod( frame, plane, gate, data, bed)
+-	  Int32 frame, plane, gate, data, bed;
+-{
+-	Int32 matnum8data16bed64gate1024plane512frame, loPlane, hiPlane = 0, loData, hiData = 0;
+-
+-	hiPlane = (plane & 0x300);  
+-	loPlane = (plane & 0xFF); 
+-	loData = (data & 0x3);  
+-	hiData = (data & 0x4); 
+-
+-	matnum8data16bed64gate1024plane512frame = ((frame & 0x1FF) | ((bed & 0xF) << 12) |
+-   	    ((loPlane << 16) | (hiPlane << 1)) | ((gate & 0x3F) << 24) | ((loData << 30) | (hiData << 9)));
+-
+-	return (matnum8data16bed64gate1024plane512frame);
+-}
+-	/********************************************************
+-new version supporting 512 planes, 1024 planes, 8 data types */
+-	Int32 mdc_mat_numdoc( matnum, matval)
+-	  Int32 matnum; struct Mdc_Matval *matval;
+-{
+-	Int32 loPlane, hiPlane = 0, loData, hiData = 0;
+-
+-	matval->frame = matnum & 0x1FF;
+-	loPlane = (matnum >> 16) & 0xFF;
+-	hiPlane = (matnum >> 1) & 0x300;
+-	matval->plane = loPlane | hiPlane;
+-	matval->gate = (matnum >> 24) & 0x3F;
+-	loData = (matnum >> 30) & 0x3;
+-	hiData = (matnum >> 9) & 0x4;
+-	matval->data = loData | hiData;
+-	matval->bed = (matnum >> 12) & 0xF;
+-	return 0;
+-}
+-	/*********************************************************/
+-	Int32 mdc_mat_lookup( fptr, matnum, entry)
+-	  FILE *fptr; Int32 matnum; struct Mdc_MatDir *entry;
+-{
+-	
+-	Int32 blk, i;
+-	Int32 nxtblk, matnbr, strtblk, endblk, matstat;
+-	Int32 dirbufr[MdcMatBLKSIZE/4];
+-	Uint8 bytebufr[MdcMatBLKSIZE];
+-
+-	blk = MdcMatFirstDirBlk;
+-	while(1) {
+-	mdc_mat_rblk( fptr, blk, bytebufr,1);
+-        if ( MdcHostBig() ) { 
+- 	  MdcSWAB( (Uint8 *)bytebufr, (Uint8 *)dirbufr, MdcMatBLKSIZE);
+-	  MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, MdcMatBLKSIZE/2);
+-        }else{ 
+-          memcpy(dirbufr, bytebufr, MdcMatBLKSIZE);
+-        }
+-	/* nfree  = dirbufr[0]; */
+-	nxtblk = dirbufr[1];
+-	/* prvblk = dirbufr[2]; */
+-	/* nused  = dirbufr[3]; */
+-	for (i=4; i<MdcMatBLKSIZE/4; i+=4)
+-	{  matnbr  = dirbufr[i];
+-	   strtblk = dirbufr[i+1];
+-	   endblk  = dirbufr[i+2];
+-	   matstat = dirbufr[i+3];
+-	   if (matnum == matnbr) {
+-	      entry->matnum  = matnbr;
+-	      entry->strtblk = strtblk;
+-	      entry->endblk  = endblk;
+-	      entry->matstat = matstat;
+-	      return (1); }
+- 	}
+-	blk = nxtblk;
+-	if (blk == MdcMatFirstDirBlk) break;
+-	}
+-	return (0);
+-}
+-
+-	/*********************************************************/
+-	Int32 mdc_mat_lookup7( fptr, matnum, entry)
+-	  FILE *fptr; Int32 matnum; struct Mdc_MatDir *entry;
+-{
+-	
+-	Int32 blk, i;
+-	Int32 nxtblk, matnbr, strtblk, endblk, matstat;
+-	Int32 dirbufr[MdcMatBLKSIZE/4];
+-	Uint8 bytebufr[MdcMatBLKSIZE];
+-
+-	blk = MdcMatFirstDirBlk;
+-	while(1) {
+-	mdc_mat_rblk( fptr, blk, bytebufr,1);
+-        if ( ! MdcHostBig() ) { 
+- 	  MdcSWAB( (Uint8 *)bytebufr, (Uint8 *)dirbufr, MdcMatBLKSIZE);
+-	  MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, MdcMatBLKSIZE/2);
+-        }else{ 
+-          memcpy(dirbufr, bytebufr, MdcMatBLKSIZE);
+-        }
+-	/* nfree  = dirbufr[0]; */
+-	nxtblk = dirbufr[1];
+-	/* prvblk = dirbufr[2]; */
+-	/* nused  = dirbufr[3]; */
+-	for (i=4; i<MdcMatBLKSIZE/4; i+=4)
+-	{  matnbr  = dirbufr[i];
+-	   strtblk = dirbufr[i+1];
+-	   endblk  = dirbufr[i+2];
+-	   matstat = dirbufr[i+3];
+-	   if (matnum == matnbr) {
+-	      entry->matnum  = matnbr;
+-	      entry->strtblk = strtblk;
+-	      entry->endblk  = endblk;
+-	      entry->matstat = matstat;
+-	      return (1); }
+- 	}
+-	blk = nxtblk;
+-	if (blk == MdcMatFirstDirBlk) break;
+-	}
+-	return (0);
+-}
+-
+-	/*********************************************************/
+-	Int32 mdc_mat_read_main_header( fptr, h)
+-	  FILE *fptr; Mdc_Main_header *h;
+-{
+-	Int16 b[256];
+-	char *bb;
+-	Int32 err, i;
+-
+-	err = mdc_mat_rblk(fptr,1,(Uint8 *)b,1);/* read main header at block 1*/
+-	if (err) return(err);
+-	bb = (char *)b;
+-	strncpy( h->original_file_name, bb+28, 20); 
+-	strncpy( h->node_id, bb+56, 10);
+-	strncpy( h->isotope_code, bb+78, 8);
+-	strncpy( h->radiopharmaceutical, bb+90, 32);
+-	strncpy( h->study_name, bb+162, 12);
+-	strncpy( h->patient_id, bb+174, 16);
+-	strncpy( h->patient_name, bb+190, 32);
+-	h->patient_sex = bb[222];
+-	strncpy( h->patient_age, bb+223, 10);
+-	strncpy( h->patient_height, bb+233, 10);
+-	strncpy( h->patient_weight, bb+243, 10);
+-	h->patient_dexterity = bb[253];
+-	strncpy( h->physician_name, bb+254, 32);
+-	strncpy( h->operator_name, bb+286, 32);
+-	strncpy( h->study_description, bb+318, 32);
+-	strncpy( h->facility_name, bb+356, 20);
+-	strncpy( h->user_process_code, bb+462, 10);
+- 	if (MdcHostBig()) MdcSWAB( (Uint8 *)b, (Uint8 *)b, MdcMatBLKSIZE); 
+-	h->sw_version = b[24];        
+-	h->data_type = b[25];        
+-	h->system_type = b[26]; 
+-	h->file_type = b[27]; 
+-	h->scan_start_day = b[33];
+-	h->scan_start_month = b[34];
+-	h->scan_start_year = b[35];
+-	h->scan_start_hour = b[36];
+-	h->scan_start_minute = b[37];
+-	h->scan_start_second = b[38];
+-	h->isotope_halflife=mdc_get_vax_float((Uint16 *)b, 43); 
+-	h->gantry_tilt = mdc_get_vax_float((Uint16 *)b, 61); 
+-	h->gantry_rotation = mdc_get_vax_float((Uint16 *)b, 63);
+-	h->bed_elevation = mdc_get_vax_float((Uint16 *)b, 65);
+-	h->rot_source_speed = b[67]; 
+-	h->wobble_speed = b[68];
+-	h->transm_source_type = b[69]; 
+-	h->axial_fov = mdc_get_vax_float((Uint16 *)b, 70);
+-	h->transaxial_fov = mdc_get_vax_float((Uint16 *)b, 72); 
+-	h->transaxial_samp_mode = b[74]; 
+-	h->coin_samp_mode = b[75]; 
+-	h->axial_samp_mode = b[76];
+-	h->calibration_factor=mdc_get_vax_float((Uint16 *)b, 77); 
+-	h->calibration_units = b[79];
+-	h->compression_code = b[80];
+-	h->acquisition_type = b[175];
+-	h->bed_type = b[176];
+-	h->septa_type = b[177];
+-	h->num_planes = b[188];
+-	h->num_frames = b[189];  
+-	h->num_gates = b[190];  
+-	h->num_bed_pos = b[191]; 
+-	h->init_bed_position=mdc_get_vax_float((Uint16 *)b, 192); 
+-	for (i=0; i<15; i++) 
+-	  h->bed_offset[i] = mdc_get_vax_float((Uint16 *)b, 194+2*i);
+-	h->plane_separation = mdc_get_vax_float((Uint16 *)b, 224); 
+-	h->lwr_sctr_thres = b[226];
+-	h->lwr_true_thres = b[227];
+-	h->upr_true_thres = b[228];
+-	h->collimator = mdc_get_vax_float((Uint16 *)b, 229);
+-	h->acquisition_mode = b[236];
+-	return (0);
+-}
+-	/*********************************************************/
+-	Int32 mdc_mat_read_matrix_data( fptr, blk, nblks, bufr)
+-	  FILE *fptr; Int32 blk, nblks; Int16 bufr[];
+-{
+-	Int32 error ;
+-	Mdc_Main_header h ;
+-
+-	error = mdc_mat_read_main_header(fptr, &h) ;
+-	if(error)   return(error) ;
+-	error = mdc_mat_read_mat_data(fptr, blk, nblks,
+-		                  (Uint8 *)bufr, h.data_type) ;
+-	return (error);
+-}
+-
+-	/*********************************************************/
+-	Int32 mdc_mat_read_main_header7( fptr, h)
+-	  FILE *fptr; Mdc_Main_header7 *h;
+-{
+-	Int16 b[256];
+-	char *bb;
+-	Int32 err, i;
+-
+-	err = mdc_mat_rblk(fptr,1,(Uint8 *)b,1);/* read main header at block 1*/
+-	if (err) return(err);
+-	bb = (char *)b;
+-
+-  memcpy( h->magic_number        ,bb    ,14);
+-  memcpy( h->original_file_name  ,bb+14 ,32);
+-  memcpy(&h->sw_version          ,bb+46 , 2);  MdcSWAP(h->sw_version);
+-  memcpy(&h->system_type         ,bb+48 , 2);  MdcSWAP(h->system_type);
+-  memcpy(&h->file_type           ,bb+50 , 2);  MdcSWAP(h->file_type);
+-  memcpy( h->serial_number       ,bb+52 ,10);
+-  memcpy(&h->scan_start_time     ,bb+62 , 4);  MdcSWAP(h->scan_start_time);
+-  memcpy( h->isotope_name        ,bb+66 , 8);
+-  memcpy(&h->isotope_halflife    ,bb+74 , 4);  MdcSWAP(h->isotope_halflife);
+-  memcpy( h->radiopharmaceutical ,bb+78 ,32);
+-  memcpy(&h->gantry_tilt         ,bb+110, 4);  MdcSWAP(h->gantry_tilt);
+-  memcpy(&h->gantry_rotation     ,bb+114, 4);  MdcSWAP(h->gantry_rotation);
+-  memcpy(&h->bed_elevation       ,bb+118, 4);  MdcSWAP(h->bed_elevation);
+-  memcpy(&h->intrinsic_tilt      ,bb+122, 4);  MdcSWAP(h->intrinsic_tilt);
+-  memcpy(&h->wobble_speed        ,bb+126, 2);  MdcSWAP(h->wobble_speed);
+-  memcpy(&h->transm_source_type  ,bb+128, 2);  MdcSWAP(h->transm_source_type);
+-  memcpy(&h->distance_scanned    ,bb+130, 4);  MdcSWAP(h->distance_scanned);
+-  memcpy(&h->transaxial_fov      ,bb+134, 4);  MdcSWAP(h->transaxial_fov);
+-  memcpy(&h->angular_compression ,bb+138, 2);  MdcSWAP(h->angular_compression);
+-  memcpy(&h->coin_samp_mode      ,bb+140, 2);  MdcSWAP(h->coin_samp_mode);
+-  memcpy(&h->axial_samp_mode     ,bb+142, 2);  MdcSWAP(h->axial_samp_mode);
+-  memcpy(&h->ecat_calibration_factor,bb+144,4);
+-                                           MdcSWAP(h->ecat_calibration_factor);
+-  memcpy(&h->calibration_units   ,bb+148, 2);  MdcSWAP(h->calibration_units);
+-  memcpy(&h->calibration_units_label,bb+150,2);
+-                                           MdcSWAP(h->calibration_units_label);
+-  memcpy(&h->compression_code    ,bb+152, 2);  MdcSWAP(h->compression_code);
+-  memcpy( h->study_type          ,bb+154,12);
+-  memcpy( h->patient_id          ,bb+166,16);
+-  memcpy( h->patient_name        ,bb+182,32);
+-  memcpy( h->patient_sex         ,bb+214, 1);
+-  memcpy( h->patient_dexterity   ,bb+215, 1); 
+-  memcpy(&h->patient_age         ,bb+216, 4);  MdcSWAP(h->patient_age);
+-  memcpy(&h->patient_height      ,bb+220, 4);  MdcSWAP(h->patient_height);
+-  memcpy(&h->patient_weight      ,bb+224, 4);  MdcSWAP(h->patient_weight);
+-  memcpy(&h->patient_birth_date  ,bb+228, 4);  MdcSWAP(h->patient_birth_date);
+-  memcpy( h->physician_name      ,bb+232,32);
+-  memcpy( h->operator_name       ,bb+264,32);
+-  memcpy( h->study_description   ,bb+296,32);
+-  memcpy(&h->acquisition_type    ,bb+328, 2);  MdcSWAP(h->acquisition_type);
+-  memcpy(&h->patient_orientation ,bb+330, 2);  MdcSWAP(h->patient_orientation);
+-  memcpy( h->facility_name       ,bb+332,20);
+-  memcpy(&h->num_planes          ,bb+352, 2);  MdcSWAP(h->num_planes);
+-  memcpy(&h->num_frames          ,bb+354, 2);  MdcSWAP(h->num_frames);
+-  memcpy(&h->num_gates           ,bb+356, 2);  MdcSWAP(h->num_gates);
+-  memcpy(&h->num_bed_pos         ,bb+358, 2);  MdcSWAP(h->num_bed_pos);
+-  memcpy(&h->init_bed_position   ,bb+360, 4);  MdcSWAP(h->init_bed_position);
+-  memcpy( h->bed_position        ,bb+364,60); 
+-  for (i=0; i<15; i++) MdcSWAP(h->bed_position[i]);
+-  memcpy(&h->plane_separation    ,bb+424, 4);  MdcSWAP(h->plane_separation);
+-  memcpy(&h->lwr_sctr_thres      ,bb+428, 2);  MdcSWAP(h->lwr_sctr_thres);
+-  memcpy(&h->lwr_true_thres      ,bb+430, 2);  MdcSWAP(h->lwr_true_thres);
+-  memcpy(&h->upr_true_thres      ,bb+432, 2);  MdcSWAP(h->upr_true_thres);
+-  memcpy( h->user_process_code   ,bb+434,10);
+-  memcpy(&h->acquisition_mode    ,bb+444, 2);  MdcSWAP(h->acquisition_mode);
+-  memcpy(&h->bin_size            ,bb+446, 4);  MdcSWAP(h->bin_size);
+-  memcpy(&h->branching_fraction  ,bb+450, 4);  MdcSWAP(h->branching_fraction);
+-  memcpy(&h->dose_start_time     ,bb+454, 4);  MdcSWAP(h->dose_start_time);
+-  memcpy(&h->dosage              ,bb+458, 4);  MdcSWAP(h->dosage);
+-  memcpy(&h->well_counter_corr_factor,bb+462,4);
+-                                          MdcSWAP(h->well_counter_corr_factor);
+-  memcpy( h->data_units          ,bb+466,32);
+-  memcpy(&h->septa_state         ,bb+498, 2);  MdcSWAP(h->septa_state);
+-  memcpy( h->fill_cti            ,bb+500,12);
+-
+-	return (0);
+-}
+-
+-/*******************************************************************/
+-/*	May 90, PLuk - Now reads VAX or Sun matrix files.	   */
+-
+-Int32 mdc_mat_read_mat_data( fptr, strtblk, nblks, dptr, dtype)
+-  FILE *fptr;
+-  Int32 strtblk, nblks, dtype;
+-  Uint8 *dptr;
+-{
+-	Int32 i, error;
+-
+-	error = mdc_mat_rblk( fptr, strtblk, dptr, nblks);
+-        if (error) return(error);
+-
+-	switch( dtype)
+-	{
+-		case 1:		/* byte format...no translation necessary */
+-		  break;
+-		case 2:		/* Vax I*2 */
+-		  if (MdcHostBig()) 
+-                    MdcSWAB((Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		  break;
+-		case 3:		/* Vax I*4 */
+-		  if (MdcHostBig()) { 
+-                    MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		    MdcSWAW( (Uint16 *)dptr, (Uint16 *)dptr, 256*nblks);
+-                  }
+-		  break;
+-		case 4:		/* Vax R*4 */
+-		  if (MdcHostBig())
+-                    MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		  for (i=0; i<nblks*128; i++)
+-		    ((float *)dptr)[i] = mdc_get_vax_float((Uint16 *)dptr, i*2);
+-		  break;
+-		case 5:		/* IEEE R*4 */
+-		  break;
+-		case 6:		/* 68K I*2 */
+-		  break;
+-		case 7:		/* 68K I*4 */
+-                  break;
+-		default:	/* something else...treat as Vax I*2 */
+-		  if (MdcHostBig()) 
+-                    MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		  break;
+-	}
+-	return 0;
+-}
+-
+-	/*********************************************************/
+-Int32 mdc_mat_read_mat_data7( fptr, strtblk, nblks, dptr, dtype)
+-  FILE *fptr;
+-  Int32 strtblk, nblks, dtype;
+-  Uint8 *dptr;
+-{
+-	Int32 i, error;
+-
+-	error = mdc_mat_rblk( fptr, strtblk, dptr, nblks);
+-        if (error) return(error);
+-
+-	switch( dtype)
+-	{
+-		case 1:		/* byte format...no translation necessary */
+-		  break;
+-		case 2:		/* Vax I*2 */
+-		  if (! MdcHostBig()) 
+-                    MdcSWAB((Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		  break;
+-		case 3:		/* Vax I*4 */
+-		  if (! MdcHostBig()) { 
+-                    MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		    MdcSWAW( (Uint16 *)dptr, (Uint16 *)dptr, 256*nblks);
+-                  }
+-		  break;
+-		case 4:		/* Vax R*4 */
+-		  if (! MdcHostBig())
+-                    MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		  for (i=0; i<nblks*128; i++)
+-		    ((float *)dptr)[i] = mdc_get_vax_float( (Uint16 *)dptr, i/2);
+-		  break;
+-		case 5:		/* IEEE R*4 */
+-		  break;
+-		case 6:		/* 68K I*2 */
+-		  break;
+-		case 7:		/* 68K I*4 */
+-                  break;
+-		default:	/* something else...treat as Vax I*2 */
+-		  if (! MdcHostBig()) 
+-                    MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks);
+-		  break;
+-	}
+-	return 0;
+-}
+-
+-	/*********************************************************/
+-	Int32 mdc_mat_read_scan_subheader( fptr, blknum, h)
+-	  FILE *fptr; Int32 blknum; Mdc_Scan_subheader *h;
+-{
+-	Int16 b[256];
+-	Int32 i, err;
+-
+-	err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1);
+-	if (err) return(err);
+-	if (MdcHostBig()) 
+-          MdcSWAB( (Uint8 *)b, (Uint8 *)b, MdcMatBLKSIZE);
+-	h->data_type = b[63];
+-	h->dimension_1 = b[66];
+-	h->dimension_2 = b[67];
+-	h->smoothing = b[68];
+-	h->processing_code = b[69];
+-	h->sample_distance = mdc_get_vax_float((Uint16 *)b, 73);
+-	h->isotope_halflife = mdc_get_vax_float((Uint16 *)b, 83);
+-	h->frame_duration_sec = b[85];
+-	h->gate_duration = mdc_get_vax_long((Uint16 *)b, 86);
+-	h->r_wave_offset = mdc_get_vax_long((Uint16 *)b, 88);
+-	h->scale_factor = mdc_get_vax_float((Uint16 *)b, 91);
+-	h->scan_min = b[96];
+-	h->scan_max = b[97];
+-	h->prompts = mdc_get_vax_long((Uint16 *)b, 98);
+-	h->delayed = mdc_get_vax_long((Uint16 *)b, 100);
+-	h->multiples = mdc_get_vax_long((Uint16 *)b, 102);
+-	h->net_trues = mdc_get_vax_long((Uint16 *)b, 104);
+-	for (i=0; i<16; i++)
+-	{ h->cor_singles[i] = mdc_get_vax_float((Uint16 *)b, 158+2*i);
+-	  h->uncor_singles[i] = mdc_get_vax_float((Uint16 *)b, 190+2*i);}
+-	h->tot_avg_cor = mdc_get_vax_float((Uint16 *)b, 222);
+-	h->tot_avg_uncor = mdc_get_vax_float((Uint16 *)b, 224);
+-	h->total_coin_rate = mdc_get_vax_long((Uint16 *)b, 226);
+-	h->frame_start_time = mdc_get_vax_long((Uint16 *)b, 228);
+-	h->frame_duration = mdc_get_vax_long((Uint16 *)b, 230);
+-	h->loss_correction_fctr = mdc_get_vax_float((Uint16 *)b, 232);
+-	for (i=0; i<8; i++)
+-	  h->phy_planes[i] = mdc_get_vax_long((Uint16 *)b, 234+(2*i));
+-	return (0);
+-}
+-	/*********************************************************/
+-	Int32 mdc_mat_read_scan_subheader7( fptr, blknum, h)
+-	  FILE *fptr; Int32 blknum; Mdc_Scan_subheader7 *h;
+-{
+-	Int16 b[256];
+-	Int32 err;
+-	char *bb;
+-
+-	err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1);
+-	if (err) return(err);
+-        bb = (char *)b;
+-
+-  memcpy(&h->data_type             ,bb    , 2); MdcSWAP(h->data_type);
+-  memcpy(&h->num_dimensions        ,bb+  2, 2); MdcSWAP(h->num_dimensions);
+-  memcpy(&h->num_r_elements        ,bb+  4, 2); MdcSWAP(h->num_r_elements);
+-  memcpy(&h->num_angles            ,bb+  6, 2); MdcSWAP(h->num_angles);
+-  memcpy(&h->corrections_applied   ,bb+  8, 2); MdcSWAP(h->corrections_applied);
+-  memcpy(&h->num_z_elements        ,bb+ 10, 2); MdcSWAP(h->num_z_elements);
+-  memcpy(&h->ring_difference       ,bb+ 12, 2); MdcSWAP(h->ring_difference);
+-  memcpy(&h->x_resolution          ,bb+ 14, 4); MdcSWAP(h->x_resolution);
+-  memcpy(&h->y_resolution          ,bb+ 18, 4); MdcSWAP(h->y_resolution);
+-  memcpy(&h->z_resolution          ,bb+ 22, 4); MdcSWAP(h->z_resolution);
+-  memcpy(&h->w_resolution          ,bb+ 26, 4); MdcSWAP(h->w_resolution);
+-
+-	return (0);
+-}
+-	/*********************************************************/
+-	Int32 mdc_mat_read_image_subheader( fptr, blknum, h)
+-	  FILE *fptr; Int32 blknum; Mdc_Image_subheader *h;
+-{
+-	Int16 b[256];
+-	Int32 i, err;
+-	char *bb;
+-
+-	err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1);
+-	if (err) return(err);
+-	bb = (char *)b;
+-	strncpy( h->annotation, bb+420, 40);
+-	if (MdcHostBig()) 
+-          MdcSWAB( (Uint8 *)b, (Uint8 *)b, MdcMatBLKSIZE);
+-	h->data_type = b[63];
+-	h->num_dimensions = b[64];
+-	h->dimension_1 = b[66];
+-	h->dimension_2 = b[67];
+-	h->x_origin = mdc_get_vax_float((Uint16 *)b, 80);
+-	h->y_origin = mdc_get_vax_float((Uint16 *)b, 82);
+-	h->recon_scale = mdc_get_vax_float((Uint16 *)b, 84);
+-	h->quant_scale = mdc_get_vax_float((Uint16 *)b, 86);
+-	h->image_min = b[88];
+-	h->image_max = b[89];
+-	h->pixel_size = mdc_get_vax_float((Uint16 *)b, 92);
+-	h->slice_width = mdc_get_vax_float((Uint16 *)b, 94);
+-	h->frame_duration = mdc_get_vax_long((Uint16 *)b, 96);
+-	h->frame_start_time = mdc_get_vax_long((Uint16 *)b, 98);
+-	h->slice_location = b[100];
+-	h->recon_start_hour = b[101];
+-	h->recon_start_minute = b[102];
+-	h->recon_start_sec = b[103];
+-	h->gate_duration = mdc_get_vax_long((Uint16 *)b, 104);
+-	h->filter_code = b[118];
+-	h->scan_matrix_num = mdc_get_vax_long((Uint16 *)b, 119);
+-	h->norm_matrix_num = mdc_get_vax_long((Uint16 *)b, 121);
+-	h->atten_cor_matrix_num = mdc_get_vax_long((Uint16 *)b, 123);
+-	h->image_rotation = mdc_get_vax_float((Uint16 *)b, 148);
+-	h->plane_eff_corr_fctr = mdc_get_vax_float((Uint16 *)b, 150);
+-	h->decay_corr_fctr = mdc_get_vax_float((Uint16 *)b, 152);
+-	h->loss_corr_fctr = mdc_get_vax_float((Uint16 *)b, 154);
+-	h->intrinsic_tilt = mdc_get_vax_float((Uint16 *)b, 156);
+-	h->processing_code = b[188];
+-	h->quant_units = b[190];
+-	h->recon_start_day = b[191];
+-	h->recon_start_month = b[192];
+-	h->recon_start_year = b[193];
+-	h->ecat_calibration_fctr = mdc_get_vax_float((Uint16 *)b, 194);
+-	h->well_counter_cal_fctr = mdc_get_vax_float((Uint16 *)b, 196);
+-	for (i=0; i<6; i++)
+-	  h->filter_params[i] = mdc_get_vax_float((Uint16 *)b, 198+2*i);
+-	return (0);
+-}
+-	/*********************************************************/
+-	Int32 mdc_mat_read_image_subheader7( fptr, blknum, h)
+-	  FILE *fptr; Int32 blknum; Mdc_Image_subheader7 *h;
+-{
+-	Int16 b[256];
+-	Int32 i, err;
+-	char *bb;
+-
+-	err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1);
+-	if (err) return(err);
+-	bb = (char *)b;
+-
+-  memcpy(&h->data_type              ,bb    , 2); MdcSWAP(h->data_type);
+-  memcpy(&h->num_dimensions         ,bb+  2, 2); MdcSWAP(h->num_dimensions);
+-  memcpy(&h->x_dimension            ,bb+  4, 2); MdcSWAP(h->x_dimension);
+-  memcpy(&h->y_dimension            ,bb+  6, 2); MdcSWAP(h->y_dimension);
+-  memcpy(&h->z_dimension            ,bb+  8, 2); MdcSWAP(h->z_dimension);
+-  memcpy(&h->x_offset               ,bb+ 10, 4); MdcSWAP(h->x_offset);
+-  memcpy(&h->y_offset               ,bb+ 14, 4); MdcSWAP(h->y_offset);
+-  memcpy(&h->z_offset               ,bb+ 18, 4); MdcSWAP(h->z_offset);
+-  memcpy(&h->recon_zoom             ,bb+ 22, 4); MdcSWAP(h->recon_zoom);
+-  memcpy(&h->scale_factor           ,bb+ 26, 4); MdcSWAP(h->scale_factor);
+-  memcpy(&h->image_min              ,bb+ 30, 2); MdcSWAP(h->image_min);
+-  memcpy(&h->image_max              ,bb+ 32, 2); MdcSWAP(h->image_max);
+-  memcpy(&h->x_pixel_size           ,bb+ 34, 4); MdcSWAP(h->x_pixel_size);
+-  memcpy(&h->y_pixel_size           ,bb+ 38, 4); MdcSWAP(h->y_pixel_size);
+-  memcpy(&h->z_pixel_size           ,bb+ 42, 4); MdcSWAP(h->z_pixel_size);
+-  memcpy(&h->frame_duration         ,bb+ 46, 4); MdcSWAP(h->frame_duration);
+-  memcpy(&h->frame_start_time       ,bb+ 50, 4); MdcSWAP(h->frame_start_time);
+-  memcpy(&h->filter_code            ,bb+ 54, 2); MdcSWAP(h->filter_code);
+-  memcpy(&h->x_resolution           ,bb+ 56, 4); MdcSWAP(h->x_resolution);
+-  memcpy(&h->y_resolution           ,bb+ 60, 4); MdcSWAP(h->y_resolution);
+-  memcpy(&h->z_resolution           ,bb+ 64, 4); MdcSWAP(h->z_resolution);
+-  memcpy(&h->num_r_elements         ,bb+ 68, 4); MdcSWAP(h->num_r_elements);
+-  memcpy(&h->num_angles             ,bb+ 72, 4); MdcSWAP(h->num_angles);
+-  memcpy(&h->z_rotation_angle       ,bb+ 76, 4); MdcSWAP(h->z_rotation_angle);
+-  memcpy(&h->decay_corr_fctr        ,bb+ 80, 4); MdcSWAP(h->decay_corr_fctr);
+-  memcpy(&h->processing_code        ,bb+ 84, 4); MdcSWAP(h->processing_code);
+-  memcpy(&h->gate_duration          ,bb+ 88, 4); MdcSWAP(h->gate_duration);
+-  memcpy(&h->r_wave_offset          ,bb+ 92, 4); MdcSWAP(h->r_wave_offset);
+-  memcpy(&h->num_accepted_beats     ,bb+ 96, 4); MdcSWAP(h->num_accepted_beats);
+-  memcpy(&h->filter_cutoff_frequency,bb+100, 4);
+-                                            MdcSWAP(h->filter_cutoff_frequency);
+-  memcpy(&h->filter_resolution      ,bb+104, 4); MdcSWAP(h->filter_resolution);
+-  memcpy(&h->filter_ramp_slope      ,bb+108, 4); MdcSWAP(h->filter_ramp_slope);
+-  memcpy(&h->filter_order           ,bb+112, 2); MdcSWAP(h->filter_order);
+-  memcpy(&h->filter_scatter_fraction,bb+114, 4);
+-                                            MdcSWAP(h->filter_scatter_fraction);
+-  memcpy(&h->filter_scatter_slope   ,bb+118, 4); 
+-                                           MdcSWAP(h->filter_scatter_slope);
+-  memcpy( h->annotation             ,bb+122,40);
+-  memcpy(&h->mt_1_1                 ,bb+162, 4); MdcSWAP(h->mt_1_1);
+-  memcpy(&h->mt_1_2                 ,bb+166, 4); MdcSWAP(h->mt_1_2);
+-  memcpy(&h->mt_1_3                 ,bb+170, 4); MdcSWAP(h->mt_1_3);
+-  memcpy(&h->mt_2_1                 ,bb+174, 4); MdcSWAP(h->mt_2_1);
+-  memcpy(&h->mt_2_2                 ,bb+178, 4); MdcSWAP(h->mt_2_2);
+-  memcpy(&h->mt_2_3                 ,bb+182, 4); MdcSWAP(h->mt_2_3);
+-  memcpy(&h->mt_3_1                 ,bb+186, 4); MdcSWAP(h->mt_3_1);
+-  memcpy(&h->mt_3_2                 ,bb+190, 4); MdcSWAP(h->mt_3_2);
+-  memcpy(&h->mt_3_3                 ,bb+194, 4); MdcSWAP(h->mt_3_3);
+-  memcpy(&h->rfilter_cutoff         ,bb+198, 4); MdcSWAP(h->rfilter_cutoff);
+-  memcpy(&h->rfilter_resolution     ,bb+202, 4); MdcSWAP(h->rfilter_resolution);
+-  memcpy(&h->rfilter_code           ,bb+206, 2); MdcSWAP(h->rfilter_code);
+-  memcpy(&h->rfilter_order          ,bb+208, 2); MdcSWAP(h->rfilter_order);
+-  memcpy(&h->zfilter_cutoff         ,bb+210, 4); MdcSWAP(h->zfilter_cutoff);
+-  memcpy(&h->zfilter_resolution     ,bb+214, 4); MdcSWAP(h->zfilter_resolution);
+-  memcpy(&h->zfilter_code           ,bb+218, 2); MdcSWAP(h->zfilter_code);
+-  memcpy(&h->zfilter_order          ,bb+220, 2); MdcSWAP(h->zfilter_order);
+-  memcpy(&h->mt_1_4                 ,bb+222, 4); MdcSWAP(h->mt_1_4);
+-  memcpy(&h->mt_2_4                 ,bb+226, 4); MdcSWAP(h->mt_2_4);
+-  memcpy(&h->mt_3_4                 ,bb+230, 4); MdcSWAP(h->mt_3_4);
+-  memcpy(&h->scatter_type           ,bb+234, 2); MdcSWAP(h->scatter_type);
+-  memcpy(&h->recon_type             ,bb+236, 2); MdcSWAP(h->recon_type);
+-  memcpy(&h->recon_views            ,bb+238, 2); MdcSWAP(h->recon_views);
+-  memcpy( h->fill_cti               ,bb+240,174);
+-  for (i=0; i<87; i++) MdcSWAP(h->fill_cti[i]);
+-  memcpy( h->fill_user              ,bb+414,96);
+-  for (i=0; i<48; i++) MdcSWAP(h->fill_user[i]); 
+-                                                 
+-	return (0);
+-}
+-
+-
+-	/*********************************************************/
+-	float mdc_get_vax_float( bufr, off)
+-	  Uint16 bufr[]; Int32 off;
+-{
+-	Uint16 t1, t2;
+-	union {Uint32 t3; float t4;} test;
+-
+-	if (bufr[off]==0 && bufr[off+1]==0) return(0.0);
+-	t1 = bufr[off] & 0x80ff;
+-	t2=(((bufr[off])&0x7f00)+0xff00)&0x7f00;
+-	test.t3 = (t1+t2)<<16;
+-	test.t3 =test.t3+bufr[off+1];
+-	return(test.t4);
+-}
+-
+-	/*********************************************************/
+-	Int32 mdc_get_vax_long( bufr, off)
+-	  Uint16 bufr[]; Int32 off;
+-{
+-	return ((bufr[off+1]<<16)+bufr[off]);
+-}
+-  
+-Mdc_Mat_dir mdc_mat_read_dir( fptr, selector)
+-  FILE *fptr;
+-  Uint8 *selector;
+-{	Int32 i, n, blk, nxtblk, ndblks, bufr[128];
+-	Mdc_Mat_dir dir;
+-
+-	blk = MdcMatFirstDirBlk;
+-	nxtblk = 0;
+-	for (ndblks=0; nxtblk != MdcMatFirstDirBlk; ndblks++)
+-	{
+-	  mdc_mat_rblk( fptr, blk, (Uint8 *)bufr, 1);
+-	  if (MdcHostBig()) {
+-            MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 8);
+-	    MdcSWAW( (Uint16 *)bufr, (Uint16 *)bufr, 4);
+-          }
+-	  nxtblk = bufr[1];
+-	  blk = nxtblk;
+-	}
+-	dir = (Mdc_Mat_dir) malloc( sizeof(struct mdc_matdir));
+-	dir->nmats = 0;
+-	dir->nmax = 31 * ndblks;
+-	dir->entry = (struct Mdc_MatDir *) malloc( 31*ndblks*sizeof( struct Mdc_MatDir));
+-	for (n=0, nxtblk=0, blk=MdcMatFirstDirBlk; nxtblk != MdcMatFirstDirBlk; blk = nxtblk)
+-	{
+-	  mdc_mat_rblk( fptr, blk, (Uint8 *)bufr, 1);
+-	  if (MdcHostBig()) {
+-            MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512);
+-	    MdcSWAW( (Uint16 *)bufr, (Uint16 *)bufr, 256);
+-          }
+-	  nxtblk = bufr[1];
+-	  for (i=4; i<MdcMatBLKSIZE/4; n++)
+-	  { dir->entry[n].matnum = bufr[i++];
+-	    dir->entry[n].strtblk = bufr[i++];
+-	    dir->entry[n].endblk = bufr[i++];
+-	    dir->entry[n].matstat = bufr[i++];
+-	    if (dir->entry[n].matnum != 0) dir->nmats++;
+-	  }
+-	}
+-	return dir;
+-}
+-
+-/*********************************************************/
+-
+-Int32 mdc_mat_wblk( fptr, blkno, bufr, nblks)
+-FILE *fptr;
+-Int32 blkno, nblks;
+-Uint8 *bufr;
+-{
+-  Int32 err;
+-  /* seek to position in file */
+-  err=fseek( fptr, (blkno-1)*MdcMatBLKSIZE, 0);
+-  if (err) return(-1);
+-
+-  /* write matrix data */
+-  err=fwrite( bufr, 1, (unsigned)nblks*MdcMatBLKSIZE, fptr);
+-  if (err != nblks*MdcMatBLKSIZE) return(-1);
+-  if (ferror(fptr)) return (-1);
+-  return (0);
+-}
+-
+-FILE *mdc_mat_create( fname, mhead)
+-  char *fname;
+-  Mdc_Main_header *mhead;
+-{
+-	FILE *fptr;
+-	Int32 i, *bufr;
+-	fptr = mdc_mat_open( fname, "wb+");
+-	if (!fptr) return fptr;
+-	mdc_mat_write_main_header( fptr, mhead);
+-	bufr = (Int32 *) malloc( MdcMatBLKSIZE);
+-	for (i=0; i<128; i++)
+-	  bufr[i] = 0;
+-	bufr[0] = 31;
+-	bufr[1] = 2;
+-        if (MdcHostBig()) {
+-	  MdcSWAW( (Uint16 *)bufr, (Uint16 *)bufr, 256);
+-	  MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512);
+-        }
+-	mdc_mat_wblk( fptr, MdcMatFirstDirBlk, (Uint8 *)bufr, 1);
+-	free( bufr);
+-	return (fptr);
+-}
+-
+-Int32 mdc_mat_enter( fptr, matnum, nblks)
+-  FILE *fptr; Int32 matnum, nblks;
+-{
+-
+-	Int32 dirblk, dirbufr[128], i, nxtblk, busy, oldsize;
+-
+-	dirblk = MdcMatFirstDirBlk;
+-	mdc_mat_rblk( fptr, dirblk, (Uint8 *)dirbufr, 1);
+-	if (MdcHostBig()) {
+-          MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512);
+-	  MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256);
+-        }
+-	busy = 1;
+-	while (busy) {
+-	nxtblk = dirblk+1;
+-	for (i=4; i<128; i+=4)
+-	{
+-	  if (dirbufr[i] == 0) 
+-	  { busy = 0;
+-	    break;
+-	  }
+-	  else if (dirbufr[i] == matnum)
+-	  { oldsize = dirbufr[i+2]-dirbufr[i+1]+1;
+-	    if (oldsize < nblks)
+-	    { dirbufr[i] = 0xFFFFFFFF;
+-              if (MdcHostBig()) { 
+-	        MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256);
+-	        MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512);
+-              }
+-	      mdc_mat_wblk( fptr, dirblk, (Uint8 *)dirbufr, 1);
+-	      if (MdcHostBig()) {
+-                MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512);
+-	        MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256);
+-              }
+-	      nxtblk = dirbufr[i+2]+1;
+-	    }
+-	    else
+-	    { nxtblk = dirbufr[i+1];
+-	      dirbufr[0]++;
+-	      dirbufr[3]--;
+-	      busy = 0;
+-	      break;
+-	    }
+-	  }
+-	  else nxtblk = dirbufr[i+2]+1;
+-	}
+-	if (!busy) break;
+-	if (dirbufr[1] != MdcMatFirstDirBlk)
+-	{ dirblk = dirbufr[1];
+-	  mdc_mat_rblk( fptr, dirblk, (Uint8 *)dirbufr, 1);
+-	  if (MdcHostBig()) {
+-            MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512);
+-	    MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256);
+-          }
+-	} else
+-	{ dirbufr[1] = nxtblk;
+-          if (MdcHostBig()) {
+-	    MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256);
+-	    MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512);
+-          }
+-	  mdc_mat_wblk( fptr, dirblk, (Uint8 *)dirbufr, 1);
+-	  dirbufr[0] = 31;
+-	  dirbufr[1] = MdcMatFirstDirBlk;
+-	  dirbufr[2] = dirblk;
+-	  dirbufr[3] = 0;
+-	  dirblk = nxtblk;
+-	  for (i=4; i<128; i++) dirbufr[i] = 0;
+-	 }
+-	}
+-	dirbufr[i] = matnum;
+-	dirbufr[i+1] = nxtblk;
+-	dirbufr[i+2] = nxtblk + nblks;
+-	dirbufr[i+3] = 1;
+-	dirbufr[0]--;
+-	dirbufr[3]++;
+-        if (MdcHostBig()) { 
+-	  MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256);
+-	  MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512);
+-        }
+-	mdc_mat_wblk( fptr, dirblk, (Uint8 *)dirbufr, 1);
+-	return (nxtblk);
+-}
+-
+-Int32 mdc_mat_write_image( fptr, matnum, header, data, data_size)
+-  FILE *fptr;
+-  Int32 matnum;
+-  Mdc_Image_subheader *header;
+-  Uint16 *data;
+-  Int32 data_size;
+-{
+-	Int32 nxtblk, size, error ;
+-
+-	size = (data_size+511)/512;
+-	nxtblk = mdc_mat_enter( fptr, matnum, size);
+-	mdc_mat_write_image_subheader( fptr, nxtblk, header);
+-        error = mdc_write_matrix_data(fptr, nxtblk+1, size,
+-		                  (Uint8 *)data,
+-	                          header->data_type) ;	
+-	return(error) ;
+-}
+-
+-Int32 mdc_mat_write_scan( fptr, matnum, header, data, data_size)
+-  FILE *fptr;
+-  Int32 matnum;
+-  Mdc_Scan_subheader *header;
+-  Uint16 *data;
+-  Int32 data_size;
+-{
+-	Int32 nxtblk, size, error ;
+-
+-	size = (data_size+511)/512;
+-	nxtblk = mdc_mat_enter( fptr, matnum, size);
+-	mdc_mat_write_scan_subheader( fptr, nxtblk, header);
+-        error = mdc_write_matrix_data(fptr, nxtblk+1, size,
+-		                  (Uint8 *)data,
+-	                          header->data_type) ;	
+-	return(error) ;
+-}
+-
+-Int32 mdc_mat_write_attn( fptr, matnum, header, data, data_size)
+-  FILE *fptr;
+-  Int32 matnum;
+-  Mdc_Attn_subheader *header;
+-  float *data;
+-  Int32 data_size;
+-{
+-	Int32 nxtblk, size, error ;
+-
+-	size = (data_size+511)/512;
+-	nxtblk = mdc_mat_enter( fptr, matnum, size);
+-	mdc_mat_write_attn_subheader( fptr, nxtblk, header);
+-        error = mdc_write_matrix_data (fptr, nxtblk+1, size,
+-		                   (Uint8 *)data,
+-	                           header->data_type) ;	
+-	return(error) ;
+-}
+-
+-Int32 mdc_mat_write_norm( fptr, matnum, header, data, data_size)
+-  FILE *fptr;
+-  Int32 matnum;
+-  Mdc_Norm_subheader *header;
+-  float *data;
+-  Int32 data_size;
+-{
+-	Int32 nxtblk, size, error ;
+-
+-	size = (data_size+511)/512;
+-	nxtblk = mdc_mat_enter( fptr, matnum, size);
+-	mdc_mat_write_norm_subheader( fptr, nxtblk, header);
+-        error = mdc_write_matrix_data(fptr, nxtblk+1, size,
+-		                  (Uint8 *)data,
+-	                          header->data_type) ;	
+-	return(error) ;
+-}
+-
+-Int32 mdc_mat_write_idata( fptr, blk, data, size)
+-  FILE *fptr;
+-  Int32 blk, size;
+-  Uint8 *data;
+-{
+-	Uint8 bufr[512];
+-	Int32 i, nbytes, nblks;
+-
+-	nblks = (size+511)/512;
+-	for (i=0; i<nblks; i++)
+-	{
+-	  nbytes = (size < 512) ? size: 512;
+-	  memcpy( (Uint8 *)bufr, (Uint8 *)data, (unsigned)nbytes);
+-	  if (MdcHostBig()) 
+-            MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512);
+-	  mdc_mat_wblk( fptr, blk+i, (Uint8 *)bufr, 1);
+-	  data += nbytes;
+-	  size -= nbytes;
+-	}
+-	return 0;
+-}
+-
+-Int32 mdc_mat_write_fdata( fptr, blk, data, size)
+-  FILE *fptr;
+-  Int32 blk, size;
+-  float *data;
+-{
+-	float bufr[128];
+-	Int32 i, j, nvals, nblks;
+-
+-	nblks = (size+511)/512;
+-	for (i=0; i<nblks; i++)
+-	{
+-	  nvals = (size < 512) ? size/4: 512/4;
+-	  for (j=0; j<nvals; j++)
+-	    mdc_hostftovaxf( *data++, (Uint16 *)&bufr[j]);
+-	  if (MdcHostBig()) 
+-            MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512);
+-	  mdc_mat_wblk( fptr, blk+i, (Uint8 *)bufr, 1);
+-	  size -= 4*nvals;
+-	}
+-	return 0;
+-}
+-
+-Int32 mdc_matrix_selector( matnum, ranges)
+-  Int32 matnum, ranges[2][5];
+-{
+-	struct Mdc_Matval m;
+-
+-	mdc_mat_numdoc( matnum, &m);
+-	if (ranges[0][0] != -1)
+-	  if (m.frame < ranges[0][0] || m.frame > ranges[1][0]) return (0);
+-	if (ranges[0][1] != -1)
+-	  if (m.plane < ranges[0][1] || m.plane > ranges[1][1]) return (0);
+-	if (ranges[0][2] != -1)
+-	  if (m.gate  < ranges[0][2] || m.gate  > ranges[1][2]) return (0);
+-	if (ranges[0][3] != -1)
+-	  if (m.data  < ranges[0][3] || m.data  > ranges[1][3]) return (0);
+-	if (ranges[0][4] != -1)
+-	  if (m.bed   < ranges[0][4] || m.bed   > ranges[1][4]) return (0);
+-	return (matnum);
+-}
+-
+-Int32 mdc_decode_selector( s1, ranges)
+-  char *s1; Int32 ranges[2][5];
+-{	char xword[16];
+-	Int32 i;
+-
+-	mdc_fix_selector( s1, s1);
+-	for (i=0;i<5;i++)	/* set all ranges to all (-1) */
+-	{ ranges[0][i]=ranges[1][i]=-1;
+-	  s1 = mdc_nex_word( s1, xword);
+-	  if (xword[0] == '*') continue;
+-	  else if (strchr(xword,':'))
+-	    sscanf(xword,"%d:%d",&ranges[0][i],&ranges[1][i]);
+-	  else
+-	  { sscanf(xword,"%d",&ranges[0][i]);
+-	    ranges[1][i]=ranges[0][i];
+-	  };
+-	}
+-	return 0;
+-}
+-
+-Int32 mdc_str_find( s1, s2)
+-  char *s1, *s2;
+-{
+-	Int32 i, j, k;
+-
+-	for (i=0;s1[i];i++) {
+-	  for (j=i,k=0; s2[k]!='\0' && s1[j]==s2[k]; j++, k++) ;
+-	  if (s2[k]=='\0') return (i);
+-	} return (-1);
+-}
+-
+-Int32 mdc_str_replace( s1, s2, s3, s4)
+-  char *s1, *s2, *s3, *s4;
+-{
+-	Int32 nf=0, n;
+-
+-	*s1 = '\0';
+-	while (1)
+-	{ if ((n=mdc_str_find(s2, s3))==-1)
+-	  { strcat(s1, s2);
+-	    return (nf);
+-	  } else
+-	  { strncat(s1, s2, (unsigned)n);
+-	    strcat(s1, s4);
+-	    s2+= n+strlen(s3);
+-	    nf++;
+-	  }
+-	}
+-}
+-
+-Int32 mdc_string_replace( s1, s2, s3, s4)
+-  char *s1, *s2, *s3, *s4;
+-{
+-	char temp[256];
+-
+-	strcpy(temp, s2);
+-	while (mdc_str_replace(s1, temp, s3, s4) > 0)
+-	  strcpy(temp, s1);
+-	return 0;
+-}	
+-
+-Int32 mdc_fix_selector( s1, s2)
+-  char *s1, *s2;
+-{
+-	char temp[256];
+-	mdc_string_replace(temp, s2, "," , " ");
+-	mdc_string_replace(s1, temp, "..", ":");
+-	mdc_string_replace(temp, s1, ".", ":");
+-	mdc_string_replace(s1, temp, "-", ":");
+-	mdc_string_replace(temp, s1, "**", "*");
+-	mdc_string_replace(s1, temp, "  ", " ");
+-	mdc_string_replace(temp, s1, " :", ":");
+-	mdc_string_replace(s1, temp, ": ", ":");
+-	return 0;
+-}
+-
+-char* mdc_nex_word(s, w)
+-  char *s, *w;
+-{
+-	while (*s && *s!=' ') *w++=*s++;
+-	*w='\0';
+-	if (*s) s++;
+-	return (s);
+-}
+-
+-/********************************************************/
+-/*  HOSTFTOVAXF                                         */
+-/********************************************************/
+-
+-Int32 mdc_hostftovaxf(float f_orig, Uint16 number[])
+-{
+-
+-  /* convert from host float to vax float */
+-
+-  union {
+- 	  Uint16 t[2]; 
+-	  float t4;
+-        } test ;
+-  Uint16 exp;
+-
+-  number[0] = 0;
+-  number[1] = 0;
+-
+-  test.t4 = f_orig;
+-  if (test.t4 == 0.0)
+-    return 0;
+-
+-  if (!MdcHostBig()) MdcSWAW((Uint16 *)test.t, (Uint16 *)test.t,2);
+-
+-  number[1] = test.t[1];
+-
+-  exp = ((test.t[0] & 0x7f00) + 0x0100) & 0x7f00;
+-  test.t[0] = (test.t[0] & 0x80ff) + exp;
+-
+-  number[0] = test.t[0];
+-  return 0;
+-
+-}
+-
+-/*********************************************************/
+-Int32 mdc_mat_write_main_header( fptr, header)
+-FILE *fptr; Mdc_Main_header *header;
+-{
+-  Uint8 *bbufr;
+-  Int16 bufr[256];
+-  Int32 err,i;
+-
+-  for (i=0; i<256; i++)
+-    bufr[i] = 0;
+-  bbufr = (Uint8 *) bufr;
+-
+-  bufr[24] = header->sw_version;
+-  bufr[25] = header->data_type;
+-  bufr[26] = header->system_type;
+-  bufr[27] = header->file_type;
+-  bufr[33] = header->scan_start_day;
+-  bufr[34] = header->scan_start_month;
+-  bufr[35] = header->scan_start_year;
+-  bufr[36] = header->scan_start_hour;
+-  bufr[37] = header->scan_start_minute;
+-  bufr[38] = header->scan_start_second;
+-  mdc_hostftovaxf (header->isotope_halflife, (Uint16 *)&bufr[43]);
+-  mdc_hostftovaxf (header->gantry_tilt, (Uint16 *)&bufr[61]);
+-  mdc_hostftovaxf (header->gantry_rotation, (Uint16 *)&bufr[63]);
+-  mdc_hostftovaxf (header->bed_elevation, (Uint16 *)&bufr[65]);
+-  bufr[67] = header->rot_source_speed;
+-  bufr[68] = header->wobble_speed;
+-  bufr[69] = header->transm_source_type;
+-  mdc_hostftovaxf (header->axial_fov, (Uint16 *)&bufr[70]);
+-  mdc_hostftovaxf (header->transaxial_fov, (Uint16 *)&bufr[72]);
+-  bufr[74] = header->transaxial_samp_mode;
+-  bufr[75] = header->coin_samp_mode;
+-  bufr[76] = header->axial_samp_mode;
+-  mdc_hostftovaxf (header->calibration_factor,(Uint16 *)&bufr[77]);
+-  bufr[79] = header->calibration_units;
+-  bufr[80] = header->compression_code;
+-  bufr[175] = header->acquisition_type;
+-  bufr[176] = header->bed_type;
+-  bufr[177] = header->septa_type;
+-  bufr[188] = header->num_planes;
+-  bufr[189] = header->num_frames;
+-  bufr[190] = header->num_gates;
+-  bufr[191] = header->num_bed_pos;
+-  mdc_hostftovaxf (header->init_bed_position,(Uint16 *)&bufr[192]);
+-  for (i=0; i<15; i++)
+-  {
+-    mdc_hostftovaxf (header->bed_offset[i],(Uint16 *)&bufr[194+2*i]);
+-  }
+-  mdc_hostftovaxf (header->plane_separation,(Uint16 *)&bufr[224]);
+-  bufr[226] = header->lwr_sctr_thres;
+-  bufr[227] = header->lwr_true_thres;
+-  bufr[228] = header->upr_true_thres;
+-  mdc_hostftovaxf (header->collimator,(Uint16 *)&bufr[229]);
+-  bufr[236] = header->acquisition_mode;
+-
+-  if (MdcHostBig()) 
+-    MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE);
+-
+-  memcpy( bbufr+28, header->original_file_name, 20);
+-  /* write the node_id - character string */
+-  memcpy( bbufr+56, header->node_id, 10);
+-  /* write the isotope code - char string */
+-  memcpy( bbufr+78, header->isotope_code, 8);
+-  /* write the radiopharmaceutical  - char string */
+-  memcpy( bbufr+90, header->radiopharmaceutical, 32);
+-  /* study_name - char string */
+-  memcpy( bbufr+162, header->study_name, 12);
+-  /* patient_id - char string */
+-  memcpy( bbufr+174, header->patient_id, 16);
+-  /* patient_name - char string */
+-  memcpy( bbufr+190, header->patient_name, 32);
+-  /* patient_sex - char */
+-  bbufr[222] = header->patient_sex;
+-  /* patient_age - char string */
+-  memcpy( bbufr+223, header->patient_age, 10);
+-  /* patient_height  - char string */
+-  memcpy( bbufr+233, header->patient_height, 10);
+-  /* patient_weight - char string */
+-  memcpy( bbufr+243, header->patient_weight, 10);
+-  /* patient_dexterity - char */
+-  bbufr[253] = header->patient_dexterity;
+-  /* physician_name - char string */
+-  memcpy( bbufr+254, header->physician_name, 32);
+-  /* operator_name - char string */
+-  memcpy( bbufr+286, header->operator_name, 32);
+-  /* study_description - char string */
+-  memcpy( bbufr+318, header->study_description, 32);
+-  /* facility_name */ 
+-  memcpy( bbufr+356, header->facility_name, 20);
+-  /* user_process_code  - char string */
+-  memcpy( bbufr+462, header->user_process_code, 10);
+-
+-  err = mdc_mat_wblk( fptr, 1, (Uint8 *)bufr, 1); /* write main header at block 1 */
+-  if (err) return(err);
+-
+-  return (0);
+-}
+-
+-/*********************************************************/
+-
+-Int32 mdc_mat_write_image_subheader( fptr, blknum, header)
+-FILE *fptr; Int32 blknum; Mdc_Image_subheader *header;
+-{
+-  Uint8 *bbufr;
+-  Int16 bufr[256];
+-  Int32 i, err;
+-
+-  for (i=0; i<256; i++)
+-    bufr[i] = 0;
+-  bbufr = (Uint8 *) bufr;
+-  /* transfer subheader information */
+-  bufr[63] = header->data_type;
+-  bufr[64] = header->num_dimensions;
+-  bufr[66] = header->dimension_1;
+-  bufr[67] = header->dimension_2;
+-  mdc_hostftovaxf(header->x_origin,(Uint16 *)&bufr[80]);
+-  mdc_hostftovaxf(header->y_origin,(Uint16 *)&bufr[82]);
+-  mdc_hostftovaxf(header->recon_scale,(Uint16 *)&bufr[84]);
+-  mdc_hostftovaxf(header->quant_scale,(Uint16 *)&bufr[86]);
+-  bufr[88] = header->image_min;
+-  bufr[89] = header->image_max;
+-  mdc_hostftovaxf(header->pixel_size,(Uint16 *)&bufr[92]);
+-  mdc_hostftovaxf(header->slice_width,(Uint16 *)&bufr[94]);
+-  mdc_hostltovaxl(header->frame_duration,(Uint16 *)&bufr[96]);
+-  mdc_hostltovaxl(header->frame_start_time,(Uint16 *)&bufr[98]);
+-  bufr[100] = header->slice_location;
+-  bufr[101] = header->recon_start_hour;
+-  bufr[102] = header->recon_start_minute;
+-  bufr[103] = header->recon_start_sec;
+-  mdc_hostltovaxl(header->gate_duration,(Uint16 *)&bufr[104]);
+-  bufr[118] = header->filter_code;
+-  mdc_hostltovaxl(header->scan_matrix_num,(Uint16 *)&bufr[119]);
+-  mdc_hostltovaxl(header->norm_matrix_num,(Uint16 *)&bufr[121]);
+-  mdc_hostltovaxl(header->atten_cor_matrix_num,(Uint16 *)&bufr[123]);
+-  mdc_hostftovaxf(header->image_rotation,(Uint16 *)&bufr[148]);
+-  mdc_hostftovaxf(header->plane_eff_corr_fctr,(Uint16 *)&bufr[150]);
+-  mdc_hostftovaxf(header->decay_corr_fctr,(Uint16 *)&bufr[152]);
+-  mdc_hostftovaxf(header->loss_corr_fctr,(Uint16 *)&bufr[154]);
+-  mdc_hostftovaxf(header->intrinsic_tilt,(Uint16 *)&bufr[156]);
+-  bufr[188] = header->processing_code;
+-  bufr[190] = header->quant_units;
+-  bufr[191] = header->recon_start_day;
+-  bufr[192] = header->recon_start_month;
+-  bufr[193] = header->recon_start_year;
+-  mdc_hostftovaxf(header->ecat_calibration_fctr,(Uint16 *)&bufr[194]);
+-  mdc_hostftovaxf(header->well_counter_cal_fctr,(Uint16 *)&bufr[196]);
+-
+-  for (i=0; i<6; i++)
+-    mdc_hostftovaxf(header->filter_params[i],(Uint16 *)&bufr[198+2*i]);
+-
+-  /* swap the bytes */
+-  if (MdcHostBig()) 
+-    MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE);
+-
+-  strcpy ((char *)(bbufr+420), header->annotation);
+-
+-  /* write to matrix file */
+-  err = mdc_mat_wblk( fptr, blknum, bbufr, 1);
+-  if (err) return(err);
+-
+-  return(0);
+-}
+-
+-/*********************************************************/
+-Int32 mdc_hostltovaxl( in, out)
+-  Int32 in;
+-  Uint16 out[2];
+-{
+-
+-	out[0]=(in&0x0000FFFF);
+-	out[1]=(in&0xFFFF0000)>>16;
+-
+-	return 0;
+-}
+-
+-/*********************************************************/
+-Int32 mdc_mat_write_scan_subheader( fptr, blknum, header)
+-  FILE *fptr; 
+-  Int32 blknum; 
+-  Mdc_Scan_subheader *header;
+-{
+-  	Int16 bufr[256];
+-  	Int32 i, err;
+-  
+-  	for (i=0; i<256; bufr[i++]=0);
+-	bufr[0] = 256;
+-	bufr[1] = 1;
+-	bufr[2] = 22;
+-	bufr[3] = -1;
+-	bufr[4] = 25;
+-	bufr[5] = 62;
+-	bufr[6] = 79;
+-	bufr[7] = 106;
+-	bufr[24] = 37;
+-	bufr[25] = -1;
+-	bufr[61] = 17;
+-	bufr[62] = -1;
+- 	bufr[78] = 27;
+-	bufr[79] = -1;
+-	bufr[105] = 52;
+-	bufr[106] = -1;
+- 	bufr[63] = header->data_type;
+-  	bufr[66] = header->dimension_1;			/* x dimension */
+-  	bufr[67] = header->dimension_2;			/* y_dimension */
+-  	bufr[68] = header->smoothing;			
+-  	bufr[69] = header->processing_code;			
+-  	mdc_hostftovaxf(header->sample_distance,(Uint16 *)&bufr[73]);
+-  	mdc_hostftovaxf(header->isotope_halflife,(Uint16 *)&bufr[83]);
+-  	bufr[85] = header->frame_duration_sec;
+-  	mdc_hostltovaxl(header->gate_duration,(Uint16 *)&bufr[86]);
+-  	mdc_hostltovaxl(header->r_wave_offset,(Uint16 *)&bufr[88]);
+-  	mdc_hostftovaxf(header->scale_factor,(Uint16 *)&bufr[91]);
+-  	bufr[96] = header->scan_min;
+-  	bufr[97] = header->scan_max;
+-  	mdc_hostltovaxl(header->prompts,(Uint16 *)&bufr[98]);
+-  	mdc_hostltovaxl(header->delayed,(Uint16 *)&bufr[100]);
+-  	mdc_hostltovaxl(header->multiples,(Uint16 *)&bufr[102]);
+-  	mdc_hostltovaxl(header->net_trues,(Uint16 *)&bufr[104]);
+-  	for (i=0; i<16; i++)
+-  	{
+-    	  mdc_hostftovaxf(header->cor_singles[i],(Uint16 *)&bufr[158+2*i]);
+-  	  mdc_hostftovaxf(header->uncor_singles[i],(Uint16 *)&bufr[190+2*i]);
+- 	};
+-  	mdc_hostftovaxf(header->tot_avg_cor,(Uint16 *)&bufr[222]);
+-  	mdc_hostftovaxf(header->tot_avg_uncor,(Uint16 *)&bufr[224]);
+-  	mdc_hostltovaxl(header->total_coin_rate,(Uint16 *)&bufr[226]);
+-                                                  /* total coin rate */
+-  	mdc_hostltovaxl(header->frame_start_time,(Uint16 *)&bufr[228]);
+-  	mdc_hostltovaxl(header->frame_duration,(Uint16 *)&bufr[230]);
+-  	mdc_hostftovaxf(header->loss_correction_fctr,(Uint16 *)&bufr[232]);
+-  	for (i=0; i<8; i++)
+-    	  mdc_hostltovaxl(header->phy_planes[i],(Uint16 *)&bufr[234+2*i]);
+-
+-
+-  	if (MdcHostBig()) 
+-          MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE);
+-
+-  	err = mdc_mat_wblk( fptr, blknum, (Uint8 *)bufr, 1);
+-	return (err);
+-}
+-
+-Int32 mdc_mat_write_attn_subheader( fptr, blknum, header)
+-  FILE *fptr;
+-  Int32 blknum;
+-  Mdc_Attn_subheader *header;
+-{
+-	Int16 bufr[256];
+-	Int32 i,err;
+-	
+-	for (i=0; i<256; bufr[i++]=0);
+-	bufr[0] = 256;
+-	bufr[1] = 1;
+-	bufr[2] = 22;
+-	bufr[3] = -1;
+-	bufr[4] = 25;
+-	bufr[5] = 62;
+-	bufr[6] = 79;
+-	bufr[7] = 106;
+-	bufr[24] = 37;
+-	bufr[25] = -1;
+-	bufr[61] = 17;
+-	bufr[62] = -1;
+- 	bufr[78] = 27;
+-	bufr[79] = -1;
+-	bufr[105] = 52;
+-	bufr[106] = -1;
+-	bufr[63] = header->data_type;
+-	bufr[64] = header->attenuation_type;
+-	bufr[66] = header->dimension_1;
+-	bufr[67] = header->dimension_2;
+-	mdc_hostftovaxf( header->scale_factor,(Uint16 *)&bufr[91]);
+-	mdc_hostftovaxf( header->x_origin,(Uint16 *)&bufr[93]);
+-	mdc_hostftovaxf( header->y_origin,(Uint16 *)&bufr[95]);
+-	mdc_hostftovaxf( header->x_radius,(Uint16 *)&bufr[97]);
+-	mdc_hostftovaxf( header->y_radius,(Uint16 *)&bufr[99]);
+-	mdc_hostftovaxf( header->tilt_angle,(Uint16 *)&bufr[101]);
+-	mdc_hostftovaxf( header->attenuation_coeff,(Uint16 *)&bufr[103]);
+-	mdc_hostftovaxf( header->sample_distance,(Uint16 *)&bufr[105]);
+-	if (MdcHostBig()) 
+-          MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512);
+-	err = mdc_mat_wblk( fptr, blknum, (Uint8 *)bufr, 1);
+-	return (err);
+-}
+-
+-Int32 mdc_mat_write_norm_subheader( fptr, blknum, header)
+-  FILE *fptr;
+-  Int32 blknum;
+-  Mdc_Norm_subheader *header;
+-{
+-	Int16 bufr[256];
+-	Int32 i,err;
+-
+-	for (i=0; i<256; bufr[i++]=0);
+-	bufr[0] = 256;
+-	bufr[1] = 1;
+-	bufr[2] = 22;
+-	bufr[3] = -1;
+-	bufr[4] = 25;
+-	bufr[5] = 62;
+-	bufr[6] = 79;
+-	bufr[7] = 106;
+-	bufr[24] = 37;
+-	bufr[25] = -1;
+-	bufr[61] = 17;
+-	bufr[62] = -1;
+- 	bufr[78] = 27;
+-	bufr[79] = -1;
+-	bufr[105] = 52;
+-	bufr[106] = -1;
+-	bufr[63] = header->data_type;
+-	bufr[66] = header->dimension_1;
+-	bufr[67] = header->dimension_2;
+-	mdc_hostftovaxf( header->scale_factor,(Uint16 *)&bufr[91]);
+-	bufr[93] = header->norm_hour;
+-	bufr[94] = header->norm_minute;
+-	bufr[95] = header->norm_second;
+-	bufr[96] = header->norm_day;
+-	bufr[97] = header->norm_month;
+-	bufr[98] = header->norm_year;
+-	mdc_hostftovaxf( header->fov_source_width,(Uint16 *)&bufr[99]);
+-	mdc_hostftovaxf( header->ecat_calib_factor,(Uint16 *)&bufr[101]);
+-	if (MdcHostBig()) 
+-          MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512);
+-	err = mdc_mat_wblk( fptr, blknum, (Uint8 *)bufr, 1);
+-	return (err);
+-}
+-
+-Int32 mdc_mat_read_attn_subheader( fptr, blknum, header)
+-FILE *fptr; 
+-Int32 blknum; 
+-Mdc_Attn_subheader *header;
+-{
+-	Int16 bufr[256];
+-	Int32 err;
+-
+-	err = mdc_mat_rblk( fptr, blknum, (Uint8 *)bufr, 1);
+-	if (err) return(err);
+-	if (MdcHostBig()) 
+-          MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE);
+-
+-	header->data_type = bufr[63];
+-	header->attenuation_type = bufr[64];
+-	header->dimension_1 = bufr[66];
+-	header->dimension_2 = bufr[67];
+-	header->scale_factor = mdc_get_vax_float((Uint16 *)bufr, 91);
+-	header->x_origin = mdc_get_vax_float((Uint16 *)bufr, 93);
+-	header->y_origin = mdc_get_vax_float((Uint16 *)bufr, 95);
+-	header->x_radius = mdc_get_vax_float((Uint16 *)bufr, 97);
+-	header->y_radius = mdc_get_vax_float((Uint16 *)bufr, 99);
+-	header->tilt_angle = mdc_get_vax_float((Uint16 *)bufr, 101);
+-	header->attenuation_coeff = mdc_get_vax_float((Uint16 *)bufr, 103);
+-	header->sample_distance = mdc_get_vax_float((Uint16 *)bufr, 105);
+-	return (0);
+-}
+-
+-Int32 mdc_mat_read_attn_subheader7( fptr, blknum, h)
+-FILE *fptr; 
+-Int32 blknum; 
+-Mdc_Attn_subheader7 *h;
+-{
+-	Int16 b[256];
+-	Int32 err, i;
+-        char *bb;
+-
+-	err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1);
+-	if (err) return(err);
+-        bb = (char *)b;
+-
+-  memcpy(&h->data_type             ,bb    ,  2); MdcSWAP(h->data_type);
+-  memcpy(&h->num_dimensions        ,bb+  2,  2); MdcSWAP(h->num_dimensions);
+-  memcpy(&h->attenuation_type      ,bb+  4,  2); MdcSWAP(h->attenuation_type);
+-  memcpy(&h->num_r_elements        ,bb+  6,  2); MdcSWAP(h->num_r_elements);
+-  memcpy(&h->num_angles            ,bb+  8,  2); MdcSWAP(h->num_angles);
+-  memcpy(&h->num_z_elements        ,bb+ 10,  2); MdcSWAP(h->num_z_elements);
+-  memcpy(&h->ring_difference       ,bb+ 12,  2); MdcSWAP(h->ring_difference);
+-  memcpy(&h->x_resolution          ,bb+ 14,  4); MdcSWAP(h->x_resolution);
+-  memcpy(&h->y_resolution          ,bb+ 18,  4); MdcSWAP(h->y_resolution);
+-  memcpy(&h->z_resolution          ,bb+ 22,  4); MdcSWAP(h->z_resolution);
+-  memcpy(&h->w_resolution          ,bb+ 26,  4); MdcSWAP(h->w_resolution);
+-  memcpy(&h->scale_factor          ,bb+ 30,  4); MdcSWAP(h->scale_factor);
+-  memcpy(&h->x_offset              ,bb+ 34,  4); MdcSWAP(h->x_offset);
+-  memcpy(&h->y_offset              ,bb+ 38,  4); MdcSWAP(h->y_offset);
+-  memcpy(&h->x_radius              ,bb+ 42,  4); MdcSWAP(h->x_radius);
+-  memcpy(&h->y_radius              ,bb+ 46,  4); MdcSWAP(h->y_radius);
+-  memcpy(&h->tilt_angle            ,bb+ 50,  4); MdcSWAP(h->tilt_angle);
+-  memcpy(&h->attenuation_coeff     ,bb+ 54,  4); MdcSWAP(h->attenuation_coeff);
+-  memcpy(&h->attenuation_min       ,bb+ 58,  4); MdcSWAP(h->attenuation_min);
+-  memcpy(&h->attenuation_max       ,bb+ 62,  4); MdcSWAP(h->attenuation_max);
+-  memcpy(&h->skull_thickness       ,bb+ 66,  4); MdcSWAP(h->skull_thickness);
+-  memcpy(&h->num_xtra_atten_coeff  ,bb+ 70,  2); 
+-                       MdcSWAP(h->num_xtra_atten_coeff);
+-  memcpy(&h->xtra_atten_coeff      ,bb+ 72, 32);
+-  for (i=0; i<8;  i++) MdcSWAP(h->xtra_atten_coeff[i]);
+-  memcpy(&h->edge_finding_threshold,bb+104,  4);
+-                       MdcSWAP(h->edge_finding_threshold);
+-  memcpy(&h->storage_order         ,bb+108,  2); MdcSWAP(h->storage_order);
+-  memcpy(&h->span                  ,bb+110,  2); MdcSWAP(h->span);
+-  memcpy(&h->z_elements            ,bb+112,128);
+-  for (i=0; i<64; i++) MdcSWAP(h->z_elements[i]);
+-  memcpy(&h->fill_unused           ,bb+240,172);
+-  for (i=0; i<86; i++) MdcSWAP(h->fill_unused[i]);
+-  memcpy(&h->fill_user             ,bb+412,100);
+-  for (i=0; i<50; i++) MdcSWAP(h->fill_user[i]);
+-
+-	return (0);
+-}
+-
+-	Int32 mdc_mat_read_norm_subheader( fptr, blknum, header)
+-	  FILE *fptr; Int32 blknum; Mdc_Norm_subheader *header;
+-{
+-	Int16 bufr[256];
+-	Int32 err;
+-
+-	err = mdc_mat_rblk( fptr, blknum, (Uint8 *)bufr, 1);
+-	if (err) return(err);
+-	if (MdcHostBig()) 
+-          MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE);
+-
+-	header->data_type = bufr[63];
+-	header->dimension_1 = bufr[66];
+-	header->dimension_2 = bufr[67];
+-	header->scale_factor = mdc_get_vax_float((Uint16 *)bufr, 91);
+-	header->norm_hour = bufr[93];
+-	header->norm_minute = bufr[94];
+-	header->norm_second = bufr[95];
+-	header->norm_day = bufr[96];
+-	header->norm_month = bufr[97];
+-	header->norm_year = bufr[98];
+-	header->fov_source_width = mdc_get_vax_float((Uint16 *)bufr, 99);
+-	header->ecat_calib_factor = mdc_get_vax_float((Uint16 *)bufr, 101);
+-	return (0);
+-}
+-
+-/* Following function was copied from CTI-source file 'matrix_extra.c' */
+-/* and slightly modified ...                                           */ 
+-
+-Int32 mdc_write_matrix_data(fptr, strtblk, nblks, dptr, dtype)
+-FILE *fptr;
+-Int32 strtblk,
+-    nblks,
+-    dtype;
+-Uint8 *dptr;
+-{
+-	Int32 err;
+-
+-	switch (dtype)
+-	{
+-	    case 1:	/* byte format...no
+-			 * translation necessary */
+-		err = mdc_mat_wblk(fptr, strtblk, dptr, nblks);
+-		break;
+-	    case 2:	/* Vax I*2 */
+-		err = mdc_mat_write_idata(fptr, strtblk, (Uint8 *)dptr, 512 * nblks);
+-		break;
+-	    case 4:	/* Vax R*4 */
+-		err = mdc_mat_write_fdata(fptr, strtblk, (float *)dptr, 512 * nblks);
+-		break;
+-	    case 5:	/* IEEE R*4 */
+-		err = mdc_mat_wblk(fptr, strtblk, dptr, nblks);
+-		break;
+-	    case 6:	/* 68K I*2 */
+-		err = mdc_mat_wblk(fptr, strtblk, dptr, nblks);
+-		break;
+-	    case 7:	/* 68K I*4 */
+-		err = mdc_mat_wblk(fptr, strtblk, dptr, nblks);
+-		break;
+-	    default:	/* something
+-			 * else...treat as Vax
+-			 * I*2 */
+-		err = mdc_mat_write_idata(fptr, strtblk, (Uint8 *)dptr, 512 * nblks);
+-		break;
+-	}
+-
+-	return (err);
+-}
+-
+-/* code from mat_get_spec.c */
+-Int32 mdc_mat_get_spec (char *file, Int32 *num_frames, Int32 *num_planes, Int32 *num_gates, Int32 *num_bed)
+-{
+-  struct Mdc_MatDir matrixlist[5000];
+-  FILE *fptr;
+-  Int32 status, num_matrices, i;
+-  struct Mdc_Matval matnum;
+-
+-  /* initialization */
+-  status = 0;
+-  *num_frames = 0;
+-  *num_planes = 0;
+-  *num_gates = 0;
+-  *num_bed = 0;
+-
+-  /* open the specified file */
+-  fptr = mdc_mat_open (file, "r");
+-  if (fptr != NULL)
+-  { 
+-    /* get the matrix entries */
+-    num_matrices = mdc_mat_list( fptr, matrixlist, 5000);
+-
+-    for (i=0; i<num_matrices; i++)
+-    {
+-      mdc_mat_numdoc (matrixlist[i].matnum, &matnum);
+- 
+-     if (matnum.frame > *num_frames)
+-        (*num_frames)++;
+-    
+-      if (matnum.plane > *num_planes)
+-        (*num_planes)++;
+-    
+-      if (matnum.gate > *num_gates)
+-        (*num_gates)++;
+-        
+-      if (matnum.bed > *num_bed)
+-        (*num_bed)++;
+-    }
+-
+-    /* bed is zero based in the matrix number, but all numbers returned */
+-    /* from this function will be one based                             */
+-    (*num_bed)++;
+-    mdc_mat_close (fptr);
+-  }
+-  else
+-    status = 1;
+-
+-  return(status);
+-}
+-
+-/* code from sort_order.c */
+-
+-static int mdc_compare_anatloc(const void *vi, const void *vj)
+-{
+-   struct ExpMatDir *i, *j;
+-
+-   i = (struct ExpMatDir *)vi;
+-   j = (struct ExpMatDir *)vj;
+-
+-   if (i->anatloc < j->anatloc) return (-1);
+-   if (i->anatloc > j->anatloc) return (1);
+-   return (0);
+-}
+-
+-/* matrix list by anatomical position */
+-void mdc_anatomical_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices, Mdc_Main_header *mhead, Int32 num_bed_pos)
+-{
+-   struct Mdc_Matval matval;
+-   Int32 i, plane, bed;
+-   float bed_pos[16], plane_separation;
+-   struct ExpMatDir exp_matlist[5000];
+-
+-   bed_pos[0] = 0.0;
+-   for (i=1; i < num_bed_pos; i++)
+-      bed_pos[i] = mhead->bed_offset[i-1];
+-
+-   plane_separation = mhead->plane_separation;
+-
+-/* if plane separation not filled in main header, use plane number to sort */
+-   if (plane_separation == 0.0) plane_separation = 1.0;
+-
+-   for (i=0; i < num_matrices; i++)
+-   {
+-      mdc_mat_numdoc (matrix_list[i].matnum, &matval);
+-      plane = matval.plane;
+-      bed = matval.bed;
+-      exp_matlist[i].matnum = matrix_list[i].matnum;
+-      exp_matlist[i].strtblk = matrix_list[i].strtblk;
+-      exp_matlist[i].endblk = matrix_list[i].endblk;
+-      exp_matlist[i].matstat = matrix_list[i].matstat;
+-      exp_matlist[i].anatloc = bed_pos[bed]+(plane-1)*plane_separation;
+-   }
+-
+-   qsort(exp_matlist,(unsigned)num_matrices
+-                    ,sizeof(struct ExpMatDir)
+-                    ,mdc_compare_anatloc);
+-
+-   for (i=0; i < num_matrices; i++)
+-   {
+-      matrix_list[i].matnum = exp_matlist[i].matnum;
+-      matrix_list[i].strtblk = exp_matlist[i].strtblk;
+-      matrix_list[i].endblk = exp_matlist[i].endblk;
+-      matrix_list[i].matstat = exp_matlist[i].matstat;
+-   }
+-}
+-
+-static int mdc_compmatdir(const void *vi, const void *vj)
+-{
+-   struct Mdc_MatDir *i, *j;
+-
+-   i = (struct Mdc_MatDir *)vi;
+-   j = (struct Mdc_MatDir *)vj;
+-
+-   return((i->matnum - j->matnum));
+-}
+-
+-
+-void mdc_matnum_sort(struct Mdc_MatDir mlist[], Int32 num_entry)
+-{
+-   qsort(mlist,(unsigned)num_entry, sizeof(struct Mdc_MatDir), mdc_compmatdir);
+-}
+-
+-/* sort by planes varying first */
+-void mdc_plane_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices)
+-{
+-  struct Mdc_Matval matval;
+-  Int32 i, frame, plane, bed;
+-  struct ExpMatDir exp_matlist[5000];
+- 
+-  for (i=0; i < num_matrices; i++)
+-  {
+-     mdc_mat_numdoc (matrix_list[i].matnum, &matval);
+-     plane = matval.plane;
+-     frame = matval.frame;
+-     bed = matval.bed;
+-     exp_matlist[i].matnum = matrix_list[i].matnum;
+-     exp_matlist[i].strtblk = matrix_list[i].strtblk;
+-     exp_matlist[i].endblk = matrix_list[i].endblk;
+-     exp_matlist[i].matstat = matrix_list[i].matstat;
+-     exp_matlist[i].anatloc = (float)(frame*1000 + plane*10 + bed);
+-  }
+-
+-  qsort (exp_matlist,(unsigned)num_matrices
+-                    ,sizeof(struct ExpMatDir)
+-                    ,mdc_compare_anatloc);
+-
+-  for (i=0; i < num_matrices; i++)
+-  {
+-     matrix_list[i].matnum = exp_matlist[i].matnum;
+-     matrix_list[i].strtblk = exp_matlist[i].strtblk;
+-     matrix_list[i].endblk = exp_matlist[i].endblk;
+-     matrix_list[i].matstat = exp_matlist[i].matstat;
+-  }
+-
+-} 
+--- a/source/m-matrix.h
++++ b/source/m-matrix.h
+@@ -7,620 +7,13 @@
+  *                                                                         *
+  * project      : (X)MedCon by Erik Nolf                                   *
+  *                                                                         *
+- * Notes        : Source code addapted from CTI PET Systems, Inc.          *
+- *                Original code 2.2 10/19/93  Copyright 1989-1993          *
+- *                                                                         *
+- *                Changed code for swapping & the use of my data types     *
+- *                with machine independency as purpose                     *
+- *                                                                         *
+- *                Added structs and prototypes for ECAT 7 reading support  *
++ * Notes        : DEBIAN - code removed due to licensing issues            *
+  *                                                                         *
+  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+-/* $Id: m-matrix.h,v 1.25 2013/06/23 21:51:19 enlf Exp $
++/* - debian dummy file v0.1 -
+  */
+ 
+-/*
+-   Copyright (C) 1997-2013 by Erik Nolf
+-
+-   This program is free software; you can redistribute it and/or modify it
+-   under the terms of the GNU General Public License as published by the
+-   Free Software Foundation; either version 2, or (at your option) any later
+-   version.
+-
+-   This program is distributed in the hope that it will be useful, but
+-   WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+-   Public License for more details.
+-
+-   You should have received a copy of the GNU General Public License along
+-   with this program; if not, write to the Free Software Foundation, Inc.,
+-   59 Place - Suite 330, Boston, MA 02111-1307, USA.  */
+-
+ #ifndef __M_MATRIX_H__
+ #define __M_MATRIX_H__
+-
+-/****************************************************************************
+-                              D E F I N E S 
+-****************************************************************************/
+-
+-#define MDC_ECAT6_MAX_MATRICES 5000
+-
+-#define MdcMatBLKSIZE     512
+-#define MdcMatFirstDirBlk 2
+-
+-#define MdcMatrixBlocks(x)   (((x+(MdcMatBLKSIZE-1))/MdcMatBLKSIZE)*MdcMatBLKSIZE);
+-
+-struct Mdc_MatDir {
+-        Int32 matnum;
+-        Int32 strtblk;
+-        Int32 endblk;
+-        Int32 matstat;
+-};
+-
+-typedef struct mdc_matdir {
+-        Int32 nmats;
+-        Int32 nmax;
+-        struct Mdc_MatDir *entry;
+-} *Mdc_Mat_dir;
+-
+-struct Mdc_Matval {
+-        Int32 frame, plane, gate, data, bed;
+-};
+-
+-/*
+-#define TotalCounts      0
+-#define UnknownCalib     TotalCounts + 1
+-#define MDC_ECAT_COUNTS  UnknownCalib + 1
+-#define MCi_ML           MDC_ECAT_COUNTS + 1
+-#define LmrGlu           MCi_ML + 1
+-#define LmrGlu_mMole     LmrGlu + 1
+-#define LmrGlu_mGram     LmrGlu_mMole + 1
+-#define NCi_ML           LmrGlu_mGram + 1
+-#define WELL_COUNTS      NCi_ML + 1
+-#define BECQUERELS       WELL_COUNTS + 1   
+-*/
+-
+-typedef struct mdc_mat_main_header {
+-	char		original_file_name[20];
+-	Int16		sw_version;
+-	Int16		data_type;
+-	Int16		system_type;
+-	Int16		file_type;
+-	char		node_id[10];
+-	Int16		scan_start_day,
+-			scan_start_month,
+-			scan_start_year,
+-			scan_start_hour,
+-			scan_start_minute,
+-			scan_start_second;
+-	char		isotope_code[8];
+-	float		isotope_halflife;
+-	char		radiopharmaceutical[32];
+-	float		gantry_tilt,
+-			gantry_rotation,
+-			bed_elevation;
+-	Int16		rot_source_speed,
+-			wobble_speed,
+-			transm_source_type;
+-	float		axial_fov,
+-			transaxial_fov;
+-	Int16		transaxial_samp_mode,
+-			coin_samp_mode,
+-			axial_samp_mode;
+-	float		calibration_factor;
+-	Int16		calibration_units,
+-			compression_code;
+-	char		study_name[12],
+-			patient_id[16],
+-			patient_name[32],
+-			patient_sex,
+-			patient_age[10],
+-			patient_height[10],
+-			patient_weight[10],
+-			patient_dexterity,
+-			physician_name[32],
+-			operator_name[32],
+-			study_description[32];
+-	Int16		acquisition_type,
+-			bed_type,
+-			septa_type;
+-	char		facility_name[20];
+-	Int16		num_planes,
+-			num_frames,
+-			num_gates,
+-			num_bed_pos;
+-	float		init_bed_position,
+-			bed_offset[15],
+-			plane_separation;
+-	Int16		lwr_sctr_thres,
+-			lwr_true_thres,
+-			upr_true_thres;
+-	float		collimator;
+-	char		user_process_code[10];
+-	Int16		acquisition_mode;
+-
+-} Mdc_Main_header;
+-
+-#define MH_64_SIZE 446
+-
+-typedef struct mdc_mat_main_header7 {
+-
+-  char magic_number[14];
+-  char original_file_name[32];
+-  Int16 sw_version;
+-  Int16 system_type;
+-  Int16 file_type;
+-  char serial_number[10];
+-  Uint32 scan_start_time;
+-  char isotope_name[8];
+-  float isotope_halflife;
+-  char radiopharmaceutical[32];
+-  float gantry_tilt;
+-  float gantry_rotation;
+-  float bed_elevation;
+-  float intrinsic_tilt;
+-  Int16 wobble_speed;
+-  Int16 transm_source_type;
+-  float distance_scanned;
+-  float transaxial_fov;
+-  Int16 angular_compression;
+-  Int16 coin_samp_mode;
+-  Int16 axial_samp_mode;
+-  float ecat_calibration_factor;
+-  Int16 calibration_units;
+-  Int16 calibration_units_label;
+-  Int16 compression_code;
+-  char study_type[12];
+-  char patient_id[16];
+-  char patient_name[32];
+-  char patient_sex[1];
+-  char patient_dexterity[1];
+-  float patient_age;
+-  float patient_height;
+-  float patient_weight;
+-  Uint32 patient_birth_date;
+-  char physician_name[32];
+-  char operator_name[32];
+-  char study_description[32];
+-  Int16 acquisition_type;
+-  Int16 patient_orientation;
+-  char facility_name[20];
+-  Int16 num_planes;
+-  Int16 num_frames;
+-  Int16 num_gates;
+-  Int16 num_bed_pos;
+-  float init_bed_position;
+-  float bed_position[15];
+-  float plane_separation;
+-  Int16 lwr_sctr_thres;
+-  Int16 lwr_true_thres;
+-  Int16 upr_true_thres;
+-  char user_process_code[10];
+-  Int16 acquisition_mode;
+-  float bin_size;
+-  float branching_fraction;
+-  Uint32 dose_start_time;
+-  float dosage;
+-  float well_counter_corr_factor;
+-  char data_units[32];
+-  Int16 septa_state;
+-  Int16 fill_cti[6];
+-
+-} Mdc_Main_header7;
+-
+-#define MH_72_SIZE       512
+-
+-typedef struct mdc_mat_scan_subheader {
+-	Int16		data_type,
+-			dimension_1,
+-			dimension_2,
+-			smoothing,
+-			processing_code;
+-	float		sample_distance,
+-			isotope_halflife;
+-	Int16		frame_duration_sec;
+-	Int32		gate_duration,
+-			r_wave_offset;
+-	float		scale_factor;
+-	Int16		scan_min,
+-			scan_max;
+-	Int32		prompts,
+-			delayed,
+-			multiples,
+-			net_trues;
+-	float		cor_singles[16],
+-			uncor_singles[16],
+-			tot_avg_cor,
+-			tot_avg_uncor;
+-	Int32		total_coin_rate,
+-			frame_start_time,
+-			frame_duration;
+-	float		loss_correction_fctr;
+-	Int32		phy_planes[8];
+-
+-} Mdc_Scan_subheader;
+-
+-#define SSH_64_SIZE 236
+-
+-typedef struct mdc_mat_scan_subheader7 {
+-
+-  Int16 data_type;
+-  Int16 num_dimensions;
+-  Int16 num_r_elements;
+-  Int16 num_angles;
+-  Int16 corrections_applied;
+-  Int16 num_z_elements;
+-  Int16 ring_difference;
+-  float x_resolution;
+-  float y_resolution;
+-  float z_resolution;
+-  float w_resolution;
+-  Int16 fill[6];
+-  Uint32 gate_duration;
+-  Int32 r_wave_offset;
+-  Int32 num_accepted_beats;
+-  float scale_factor;
+-  Int16 scan_min;
+-  Int16 scan_max;
+-  Int32 prompts;
+-  Int32 delayed;
+-  Int32 multiples;
+-  Int32 net_trues;
+-  float cor_singles[16];
+-  float uncor_singles[16];
+-  float tot_avg_cor;
+-  float tot_avg_uncor;
+-  Int32 total_coin_rate;
+-  Uint32 frame_start_time;
+-  Uint32 frame_duration;
+-  float deadtime_correction_factor;
+-  Int16 phy_planes[8];
+-  Int16 cti_fill[83];
+-  Int16 user_fill[50];
+-
+-} Mdc_Scan_subheader7;
+-
+-#define SSH_72_SIZE   234
+-
+-typedef struct mdc_mat_image_subheader {
+-	Int16		data_type,
+-			num_dimensions,
+-			dimension_1,
+-			dimension_2;
+-	float		x_origin,
+-			y_origin,
+-			recon_scale,	/* Image ZOOM from reconstruction */
+-			quant_scale;	/* Scale Factor */
+-	Int16		image_min,
+-			image_max;
+-	float		pixel_size,
+-			slice_width;
+-	Int32		frame_duration,
+-			frame_start_time;
+-	Int16		slice_location,
+-			recon_start_hour,
+-			recon_start_minute,
+-			recon_start_sec;
+-	Int32		gate_duration;
+-	Int16		filter_code;
+-	Int32		scan_matrix_num,
+-			norm_matrix_num,
+-			atten_cor_matrix_num;
+-	float		image_rotation,
+-			plane_eff_corr_fctr,
+-			decay_corr_fctr,
+-			loss_corr_fctr,
+-			intrinsic_tilt ;
+-	Int16		processing_code,
+-			quant_units,
+-			recon_start_day,
+-			recon_start_month,
+-			recon_start_year;
+-	float		ecat_calibration_fctr,
+-			well_counter_cal_fctr,
+-			filter_params[6];
+-	char		annotation[40];
+-
+-} Mdc_Image_subheader;
+-
+-#define ISH_64_SIZE 172
+-
+-typedef struct mdc_mat_image_subheader7 {
+-
+-  Int16 data_type;
+-  Int16 num_dimensions;
+-  Int16 x_dimension;
+-  Int16 y_dimension;
+-  Int16 z_dimension;
+-  float x_offset;
+-  float y_offset;
+-  float z_offset;
+-  float recon_zoom;
+-  float scale_factor;
+-  Int16 image_min;
+-  Int16 image_max;
+-  float x_pixel_size;
+-  float y_pixel_size;
+-  float z_pixel_size;
+-  Uint32 frame_duration;
+-  Uint32 frame_start_time;
+-  Int16 filter_code;
+-  float x_resolution;
+-  float y_resolution;
+-  float z_resolution;
+-  float num_r_elements;
+-  float num_angles;
+-  float z_rotation_angle;
+-  float decay_corr_fctr;
+-  Int32 processing_code;
+-  Uint32 gate_duration;
+-  Int32 r_wave_offset;
+-  Int32 num_accepted_beats;
+-  float filter_cutoff_frequency;
+-  float filter_resolution;
+-  float filter_ramp_slope;
+-  Int16 filter_order;
+-  float filter_scatter_fraction;
+-  float filter_scatter_slope;
+-  char annotation[40];
+-  float mt_1_1;
+-  float mt_1_2;
+-  float mt_1_3;
+-  float mt_2_1;
+-  float mt_2_2;
+-  float mt_2_3;
+-  float mt_3_1;
+-  float mt_3_2;
+-  float mt_3_3;
+-  float rfilter_cutoff;
+-  float rfilter_resolution;
+-  Int16 rfilter_code;
+-  Int16 rfilter_order;
+-  float zfilter_cutoff;
+-  float zfilter_resolution;
+-  Int16 zfilter_code;
+-  Int16 zfilter_order;
+-  float mt_1_4;
+-  float mt_2_4;
+-  float mt_3_4;
+-  Int16 scatter_type;
+-  Int16 recon_type;
+-  Int16 recon_views;
+-  Int16 fill_cti[87];
+-  Int16 fill_user[48];
+-
+-} Mdc_Image_subheader7;
+-
+-#define ISH_72_SIZE  510
+-
+-typedef struct mdc_mat_norm_subheader {
+-	Int16		data_type,
+-			dimension_1,
+-			dimension_2;
+-	float		scale_factor;
+-	Int16		norm_hour,
+-			norm_minute,
+-			norm_second,
+-			norm_day,
+-			norm_month,
+-			norm_year;
+-	float		fov_source_width;
+-	float		ecat_calib_factor;
+-
+-} Mdc_Norm_subheader; 
+-
+-#define NSH_64_SIZE 30
+-
+-typedef struct mdc_mat_norm_subheader7 {
+-
+-  Int16 data_type;
+-  Int16 num_dimensions;
+-  Int16 num_r_elements;
+-  Int16 num_angles;
+-  Int16 num_z_elements;
+-  Int16 ring_difference;
+-  float scale_factor;
+-  float norm_min;
+-  float norm_max;
+-  float fov_source_width;
+-  float norm_quality_factor;
+-  Int16 norm_quality_factor_code;
+-  Int16 storage_order;
+-  Int16 span;
+-  Int16 z_elements[64];
+-  Int16 cti_fill[123];
+-  Int16 user_fill[50];
+-
+-} Mdc_Norm_subheader7;
+-
+-#define NSH_72_SIZE   166
+-
+-typedef struct mdc_mat_attn_subheader {
+-	Int16		data_type,
+-			attenuation_type,
+-			dimension_1,
+-			dimension_2;
+-	float		scale_factor,
+-			x_origin,
+-			y_origin,
+-			x_radius,
+-			y_radius,
+-			tilt_angle,
+-			attenuation_coeff,
+-			sample_distance;
+-
+-} Mdc_Attn_subheader;
+-
+-#define ASH_64_SIZE 40
+-
+-typedef struct mdc_mat_attn_subheader7 {
+-
+-  Int16 data_type;
+-  Int16 num_dimensions;
+-  Int16 attenuation_type;
+-  Int16 num_r_elements;
+-  Int16 num_angles;
+-  Int16 num_z_elements;
+-  Int16 ring_difference;
+-  float x_resolution;
+-  float y_resolution;
+-  float z_resolution;
+-  float w_resolution;
+-  float scale_factor;
+-  float x_offset;
+-  float y_offset;
+-  float x_radius;
+-  float y_radius;
+-  float tilt_angle;
+-  float attenuation_coeff;
+-  float attenuation_min;
+-  float attenuation_max;
+-  float skull_thickness;
+-  Int16 num_xtra_atten_coeff;
+-  float xtra_atten_coeff[8];
+-  float edge_finding_threshold;
+-  Int16 storage_order;
+-  Int16 span;
+-  Int16 z_elements[64];
+-  Int16 fill_unused[86];
+-  Int16 fill_user[50];
+-
+-} Mdc_Attn_subheader7;
+-
+-#define ASH_72_SIZE   512
+-
+-typedef struct mdc_matdirnode {
+-        Int32 matnum;
+-        Int32 strtblk;
+-        Int32 endblk;
+-        Int32 matstat;
+-        struct mdc_matdirnode *next;
+-} Mdc_MatDirNode;
+-
+-typedef struct mdc_matdirlist {
+-        Int32 nmats;
+-        Mdc_MatDirNode *first;
+-        Mdc_MatDirNode *last;
+-} Mdc_MatDirList;
+-
+-typedef struct mdc_matrixdata {
+-        Int32 mat_type;
+-        Int32 matnum;
+-        Uint8 *shptr;
+-        Uint8 *data_ptr;
+-        Int32 nviews;
+-        Int32 nelements;
+-        Int32 nblks;
+-        Int32 data_type;
+-} Mdc_MatrixData;
+-
+-typedef struct mdc_matrix_file {
+-        Mdc_Main_header *mhptr;
+-        Mdc_MatDirList  *dirlist;
+-        FILE        *fptr;
+-        Int32       mode;
+-        char        *fname[80];
+-} Mdc_MatrixFile;
+-
+-typedef struct mdc_matdirblk {
+-        Int32 nfree, nextblk, prvblk, nused;
+-        struct Mdc_MatDir matdir[31];
+-} Mdc_MatDirBlk;
+-
+-#define BYTE_TYPE       1
+-#define VAX_I2          2
+-#define VAX_I4          3
+-#define VAX_R4          4
+-#define IEEE_R4         5
+-#define M68K_I2         6
+-#define M68K_I4         7
+-#define SUN_I2  M68K_I2
+-#define SUN_I4  M68K_I4
+-#define SUN_R4  IEEE_R4
+-
+-#define RAW_DATA        1
+-#define IMAGE_DATA      2
+-#define ATTN_DATA       3
+-#define NORM_DATA       4
+-#define SUN_READ        1
+-#define SUN_WRITE       2
+-#define ACS_READ        3
+-#define ACS_WRITE       4
+-#define SUN_CREATE      5
+-
+-#define ACQM_NORMAL      0  /* normal acquisition mode */
+-#define ACQM_RODTRN      1  /* rod transmission mode */
+-#define ACQM_RODTRN_KEEP 2  /* rod transmission mode keep all sinograms */
+-#define ACQM_DWIN_KEEP   3  /* dual window mode keep all sinograms */
+-#define ACQM_DWIN        4  /* dual window mode */
+-#define ACQM_SIMULT      5  /* simultaneous transmission/ emission mode */
+-
+-/* eNlf: BEGIN - unnecessary, avoid conflicts! */
+-/* #define ERROR   -1                          */
+-/* #define OK 0                                */
+-/* eNlf: END   - unnecessary, avoid conflicts! */
+-
+-/****************************************************************************
+-                            F U N C T I O N S
+-****************************************************************************/
+-Int32 MdcSWAW( Uint16 from[], Uint16 to[], Int32 length);
+-Int32 MdcSWAB( Uint8  from[], Uint8  to[], Int32 length);
+-FILE *mdc_mat_open(char *fname, char *fmode);
+-void mdc_mat_close(FILE *fptr);
+-Int32 mdc_mat_rblk(FILE *fptr, Int32 blkno, Uint8 *bufr, Int32 nblks);
+-Int32 mdc_mat_list(FILE *fptr, struct Mdc_MatDir mlist[], Int32 lmax);
+-Int32 mdc_mat_list7(FILE *fptr, struct Mdc_MatDir mlist[], Int32 lmax);
+-Int32 mdc_mat_numcod(Int32 frame, Int32 plane, Int32 gate, Int32 data, Int32 bed);
+-Int32 mdc_mat_numdoc( Int32 mdc_matnum, struct Mdc_Matval *matval);
+-Int32 mdc_mat_lookup(FILE *fptr, Int32 matnum, struct Mdc_MatDir *entry);
+-Int32 mdc_mat_lookup7(FILE *fptr, Int32 matnum, struct Mdc_MatDir *entry);
+-Int32 mdc_mat_read_main_header(FILE *fptr, Mdc_Main_header *h);
+-Int32 mdc_mat_read_main_header7(FILE *fptr, Mdc_Main_header7 *h);
+-Int32 mdc_mat_read_matrix_data(FILE *fptr, Int32 blk, Int32 nblks, Int16 bufr[]);
+-Int32 mdc_mat_read_mat_data(FILE *fptr, Int32 strtblk, Int32 nblks, Uint8 *dptr, Int32 dtype);
+-Int32 mdc_mat_read_mat_data7(FILE *fptr, Int32 strtblk, Int32 nblks, Uint8 *dptr, Int32 dtype);
+-Int32 mdc_mat_read_scan_subheader(FILE *fptr, Int32 blknum, Mdc_Scan_subheader *h);
+-Int32 mdc_mat_read_scan_subheader7(FILE *fptr, Int32 blknum, Mdc_Scan_subheader7 *h);
+-Int32 mdc_mat_read_image_subheader(FILE *fptr, Int32 blknum, Mdc_Image_subheader *h);
+-Int32 mdc_mat_read_image_subheader7(FILE *fptr, Int32 blknum, Mdc_Image_subheader7 *h);
+-float mdc_get_vax_float(Uint16 bufr[], Int32 off);
+-Int32 mdc_get_vax_long(Uint16 bufr[], Int32 off);
+-Mdc_Mat_dir mdc_mat_read_dir(FILE *fptr, Uint8 *selector);
+-Int32 mdc_mat_wblk(FILE *fptr, Int32 blkno, Uint8 *bufr, Int32 nblks);
+-FILE *mdc_mat_create(char *fname, Mdc_Main_header *mhead);
+-Int32 mdc_mat_enter(FILE *fptr, Int32 matnum, Int32 nblks);
+-Int32 mdc_mat_write_image(FILE *fptr, Int32 matnum, Mdc_Image_subheader *header, Uint16 *data, Int32 data_size);
+-Int32 mdc_mat_write_scan(FILE *fptr, Int32 matnum, Mdc_Scan_subheader *header, Uint16 *data, Int32 data_size);
+-Int32 mdc_mat_write_attn(FILE *fptr, Int32 matnum, Mdc_Attn_subheader *header, float *data, Int32 data_size);
+-Int32 mdc_mat_write_norm(FILE *fptr, Int32 matnum, Mdc_Norm_subheader *header, float *data, Int32 data_size);
+-Int32 mdc_mat_write_idata(FILE *fptr, Int32 blk, Uint8 *data, Int32 size);
+-Int32 mdc_mat_write_fdata(FILE *fptr, Int32 blk, float *data, Int32 size);
+-Int32 mdc_matrix_selector(Int32 matnum, Int32 ranges[2][5]);
+-Int32 mdc_decode_selector(char *s1, Int32 ranges[2][5]);
+-Int32 mdc_str_find(char *s1, char *s2);
+-Int32 mdc_str_replace(char *s1, char *s2, char *s3, char *s4);
+-Int32 mdc_string_replace(char *s1, char *s2, char *s3, char *s4);
+-Int32 mdc_fix_selector(char *s1, char *s2);
+-char* mdc_nex_word(char *s, char *w);
+-Int32 mdc_hostftovaxf(float f_orig, Uint16 number[]);
+-Int32 mdc_mat_write_main_header(FILE *fptr, Mdc_Main_header *header);
+-Int32 mdc_mat_write_image_subheader(FILE *fptr, Int32 blknum, Mdc_Image_subheader *header);
+-Int32 mdc_hostltovaxl(Int32 in, Uint16 out[2]);
+-Int32 mdc_mat_write_scan_subheader(FILE *fptr, Int32 blknum, Mdc_Scan_subheader *header);
+-Int32 mdc_mat_write_attn_subheader(FILE *fptr, Int32 blknum, Mdc_Attn_subheader *header);
+-Int32 mdc_mat_write_norm_subheader(FILE *fptr, Int32 blknum, Mdc_Norm_subheader *header);
+-Int32 mdc_mat_read_attn_subheader(FILE *fptr, Int32 blknum, Mdc_Attn_subheader *header);
+-Int32 mdc_mat_read_attn_subheader7(FILE *fptr, Int32 blknum, Mdc_Attn_subheader7 *h);
+-Int32 mdc_mat_read_norm_subheader(FILE *fptr, Int32 blknum, Mdc_Norm_subheader *header);
+-Int32 mdc_mat_read_norm_subheader7(FILE *fptr, Int32 blknum, Mdc_Norm_subheader7 *header);
+-Int32 mdc_write_matrix_data(FILE *fptr, Int32 strtblk, Int32 nblks, Uint8 *dptr, Int32 dtype);
+-double  mdc_mat_qs(double *X, double *Z, Int32 lod);
+-double  mdc_mat_max(double *X, Int32 lod);
+-double  mdc_mat_min(double *X, Int32 lod);
+-Int32 mdc_mat_get_spec (char *file, Int32 *num_frames, Int32 *num_planes, Int32 *num_gates, Int32 *num_bed);
+-void mdc_anatomical_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices, Mdc_Main_header *mhead, Int32 num_bed_pos);
+-void mdc_matnum_sort(struct Mdc_MatDir mlist[], Int32 num_entry);
+-void mdc_plane_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices);
+-
+ #endif
+ 




More information about the debian-med-commit mailing list