changeset 1967:f1a50ec0e51c

Initial checkin on 1.X branch
author bert <bert>
date Tue, 15 Feb 2005 19:59:54 +0000
parents 7cae39d8a370
children 9a0adde2a4eb
files conversion/ecattominc/dump_ecat_header.c conversion/ecattominc/ecat_file.c conversion/ecattominc/ecat_file.h conversion/ecattominc/ecat_header_definition.h conversion/ecattominc/ecattominc.c conversion/ecattominc/machine_indep.c conversion/ecattominc/machine_indep.h
diffstat 7 files changed, 405 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/conversion/ecattominc/dump_ecat_header.c
+++ b/conversion/ecattominc/dump_ecat_header.c
@@ -10,7 +10,13 @@
 @CREATED    : January 10, 1996 (Peter Neelin)
 @MODIFIED   : 
  * $Log: dump_ecat_header.c,v $
- * Revision 6.1  1999-10-29 17:52:00  neelin
+ * Revision 6.2.2.1  2005-02-15 19:59:54  bert
+ * Initial checkin on 1.X branch
+ *
+ * Revision 6.2  2005/01/19 19:46:00  bert
+ * Changes from Anthonin Reilhac
+ *
+ * Revision 6.1  1999/10/29 17:52:00  neelin
  * Fixed Log keyword
  *
  * Revision 6.0  1997/09/12 13:24:22  neelin
@@ -38,14 +44,14 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[]="$Header: /private-cvsroot/minc/conversion/ecattominc/dump_ecat_header.c,v 6.1 1999-10-29 17:52:00 neelin Exp $";
+static char rcsid[]="$Header: /private-cvsroot/minc/conversion/ecattominc/dump_ecat_header.c,v 6.2.2.1 2005-02-15 19:59:54 bert Exp $";
 #endif
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-#include <ecat_file.h>
+#include "ecat_file.h"
 
 /* Main program */
 
--- a/conversion/ecattominc/ecat_file.c
+++ b/conversion/ecattominc/ecat_file.c
@@ -5,7 +5,13 @@
 @CREATED    : January 4, 1996 (Peter Neelin)
 @MODIFIED   : 
  * $Log: ecat_file.c,v $
- * Revision 6.1  1999-10-29 17:52:01  neelin
+ * Revision 6.2.2.1  2005-02-15 19:59:54  bert
+ * Initial checkin on 1.X branch
+ *
+ * Revision 6.2  2005/01/19 19:46:00  bert
+ * Changes from Anthonin Reilhac
+ *
+ * Revision 6.1  1999/10/29 17:52:01  neelin
  * Fixed Log keyword
  *
  * Revision 6.0  1997/09/12 13:24:22  neelin
@@ -33,15 +39,17 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[]="$Header: /private-cvsroot/minc/conversion/ecattominc/ecat_file.c,v 6.1 1999-10-29 17:52:01 neelin Exp $";
+static char rcsid[]="$Header: /private-cvsroot/minc/conversion/ecattominc/ecat_file.c,v 6.2.2.1 2005-02-15 19:59:54 bert Exp $";
 #endif
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <memory.h>
-#include <ecat_file.h>
-#include <vax_conversions.h>
+#include "ecat_file.h"
+#include "machine_indep.h"
+
+/*#include <vax_conversions.h>*/
 
 /* Set some standard macros */
 #ifndef SEEK_SET
@@ -51,10 +59,6 @@
 #  define TRUE 1
 #  define FALSE 0
 #endif
-#define MALLOC(size) ((void *) malloc_check(size))
-#define FREE(ptr) free(ptr)
-#define REALLOC(ptr, size) ((void *) realloc_check(ptr, size))
-#define CALLOC(nelem, elsize) ((void *) calloc(nelem, elsize))
 
 /* Constants */
 #define BLOCK_SIZE 512
@@ -99,19 +103,19 @@
 
 /* ECAT file Type */
 struct Ecat_file {
-   FILE *file_pointer;
-   Ecat_header_description_type *header_description;
-   int vax_byte_order;
-   int num_planes;
-   int num_frames;
-   int num_bed_positions;
-   int num_gates;
-   int num_volumes;
-   unsigned char *main_header;
-   long cur_subhdr_offset;
-   unsigned char *subheader;
-   int num_subhdrs;
-   long *subhdr_offsets;
+  FILE *file_pointer;
+  Ecat_header_description_type *header_description;
+  int vax_byte_order;
+  int num_planes;
+  int num_frames;
+  int num_bed_positions;
+  int num_gates;
+  int num_volumes;
+  unsigned char *main_header;
+  long cur_subhdr_offset;
+  unsigned char *subheader;
+  int num_subhdrs;
+  long *subhdr_offsets;
 };
 
 typedef enum {
@@ -146,8 +150,7 @@
 private long get_dirblock(Ecat_file *file, long *dirblock, int offset);
 private int ecat_get_subhdr_offset(Ecat_file *file, int volume, int slice, 
                                    long *offset);
-private void *malloc_check(size_t size);
-private void *realloc_check(void *ptr, size_t size);
+
 
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -169,6 +172,8 @@
 
    /* Allocate space for an ecat file structure */
    file = (void *) MALLOC(sizeof(*file));
+
+
    file->main_header = (void *) MALLOC(MAIN_HEADER_SIZE);
    file->subheader = (void *) MALLOC(SUBHEADER_SIZE);
    file->cur_subhdr_offset = -1;
@@ -216,13 +221,14 @@
    if (file->num_volumes < file->num_gates)
       file->num_volumes = file->num_gates;
 
+
    /* Read the directory structure */
    if (ecat_read_directory(file)) {
       ecat_close(file);
       return NULL;
    }
+   /* Return the file pointer */
 
-   /* Return the file pointer */
    return file;
 }
 
@@ -571,6 +577,7 @@
                                Ecat_field_name field, int index,
                                int *ivalue, double *fvalue, char *svalue)
 {
+
    return ecat_get_value(file, ECAT_MAIN_HEADER, 0, 0, field, index, 
                          ivalue, fvalue, svalue);
 }
@@ -674,29 +681,29 @@
    /* Get the value and convert it */
    switch (type) {
    case ecat_byte:
-      byte_value = header[offset];
-      if (ivalue != NULL) *ivalue = byte_value;
-      if (fvalue != NULL) *fvalue = byte_value;
-      if (svalue != NULL) (void) sprintf(svalue, "%d", (int) byte_value);
-      break;
+     byte_value = header[offset];
+     if (ivalue != NULL) *ivalue = byte_value;
+     if (fvalue != NULL) *fvalue = byte_value;
+     if (svalue != NULL) (void) sprintf(svalue, "%d", (int) byte_value);
+     break;
    case ecat_short:
-      if (file->vax_byte_order) {
-         get_vax_short(1, &header[offset], &short_value);
-      }
-      else {
-         (void) memcpy(&short_value, &header[offset], sizeof(short));
-      }
-      if (ivalue != NULL) *ivalue = short_value;
-      if (fvalue != NULL) *fvalue = short_value;
-      if (svalue != NULL) (void) sprintf(svalue, "%d", (int) short_value);
-      break;
+     if (file->vax_byte_order) {
+	get_vax_short(1, &header[offset], &short_value);
+     }
+     else {
+       get_short_value(& header[offset], &short_value);
+     }
+     if (ivalue != NULL) *ivalue = short_value;
+     if (fvalue != NULL) *fvalue = short_value;
+     if (svalue != NULL) (void) sprintf(svalue, "%d", (int) short_value);
+     break;
    case ecat_long:
-      if (file->vax_byte_order) {
-         get_vax_long(1, &header[offset], &long_value);
-      }
-      else {
-         (void) memcpy(&long_value, &header[offset], sizeof(long));
-      }
+     if (file->vax_byte_order) {
+       get_vax_long(1, &header[offset], &long_value);
+     }
+     else {
+       get_long_value(& header[offset], &long_value);
+     }
       if (ivalue != NULL) *ivalue = long_value;
       if (fvalue != NULL) *fvalue = long_value;
       if (svalue != NULL) (void) sprintf(svalue, "%d", (int) long_value);
@@ -704,10 +711,10 @@
    case ecat_float:
       offset += index * sizeof(float);
       if (file->vax_byte_order) {
-         get_vax_float(1, &header[offset], &float_value);
+	get_vax_float(1, &header[offset], &float_value);
       }
       else {
-         (void) memcpy(&float_value, &header[offset], sizeof(float));
+	get_long_value(& header[offset], &float_value);
       }
       if (ivalue != NULL) *ivalue = float_value;
       if (fvalue != NULL) *fvalue = float_value;
@@ -942,6 +949,8 @@
    file->subhdr_offsets = 
       MALLOC(num_alloc * sizeof(file->subhdr_offsets[0]));
 
+  
+
    /* Reading directory blocks until done */
    nextblock = FIRST_DIRBLOCK;
    do {
@@ -953,6 +962,7 @@
          return TRUE;
       }
 
+
       /* Get a pointer to the next block and the number of entries used */
       nextblock = get_dirblock(file, dirblock, DRBLK_NEXT);
       num_used = get_dirblock(file, dirblock, DRBLK_NUMUSED);
@@ -997,10 +1007,11 @@
    long value;
 
    if (file->header_description == ECAT_VER_PRE7) {
-      get_vax_long(1, &dirblock[offset], &value);
+     /*get_vax_long(1, &dirblock[offset], &value);*/
    }
    else if (file->header_description == ECAT_VER_7) {
-      value = dirblock[offset];
+     /* value = dirblock[offset];*/
+      get_long_value(&dirblock[offset], &value); 
    }
    else {
       return 0;
@@ -1096,7 +1107,13 @@
       break;
    case 2:
       if (file->header_description == ECAT_VER_PRE7) {
-         get_vax_short(image_npix, image, image);
+	/*get_vax_short(image_npix, image, image);*/
+      }
+      else {
+	for (ipix=0; ipix<image_npix; ipix++) {
+	  get_short_value(&bimage[ipix * bytes_per_pixel], &image[ipix]); 
+	  /*image[ipix] = bimage[array_offset+ipix];*/
+	}	
       }
       break;
    default:
@@ -1167,7 +1184,7 @@
 @CREATED    : January 4, 1996 (Peter Neelin)
 @MODIFIED   : 
 ---------------------------------------------------------------------------- */
-private void *malloc_check(size_t size)
+public void *malloc_check(size_t size)
 {
    void *ptr;
 
@@ -1193,7 +1210,7 @@
 @CREATED    : January 4, 1996 (Peter Neelin)
 @MODIFIED   : 
 ---------------------------------------------------------------------------- */
-private void *realloc_check(void *ptr, size_t size)
+public void *realloc_check(void *ptr, size_t size)
 {
    ptr = realloc(ptr, size);
    if (ptr == NULL) {
--- a/conversion/ecattominc/ecat_file.h
+++ b/conversion/ecattominc/ecat_file.h
@@ -5,7 +5,13 @@
 @CREATED    : January 4, 1996 (Peter Neelin)
 @MODIFIED   : 
  * $Log: ecat_file.h,v $
- * Revision 6.1  1999-10-29 17:52:01  neelin
+ * Revision 6.2.2.1  2005-02-15 19:59:54  bert
+ * Initial checkin on 1.X branch
+ *
+ * Revision 6.2  2005/01/19 19:46:01  bert
+ * Changes from Anthonin Reilhac
+ *
+ * Revision 6.1  1999/10/29 17:52:01  neelin
  * Fixed Log keyword
  *
  * Revision 6.0  1997/09/12 13:24:22  neelin
@@ -44,6 +50,15 @@
 
 #define ECAT_MAX_STRING_LENGTH 64
 
+
+/*memory allocation*/
+#define MALLOC(size) ((void *) malloc_check(size))
+#define FREE(ptr) free(ptr)
+#define REALLOC(ptr, size) ((void *) realloc_check(ptr, size))
+#define CALLOC(nelem, elsize) ((void *) calloc(nelem, elsize))
+public void *malloc_check(size_t size);
+public void *realloc_check(void *ptr, size_t size);
+
 typedef enum {
    ECAT_No_Field,
    ECAT_Magic_Number,
--- a/conversion/ecattominc/ecat_header_definition.h
+++ b/conversion/ecattominc/ecat_header_definition.h
@@ -5,7 +5,10 @@
 @CREATED    : January 4, 1996 (Peter Neelin)
 @MODIFIED   : 
  * $Log: ecat_header_definition.h,v $
- * Revision 6.1  1999-10-29 17:52:01  neelin
+ * Revision 6.1.2.1  2005-02-15 19:59:54  bert
+ * Initial checkin on 1.X branch
+ *
+ * Revision 6.1  1999/10/29 17:52:01  neelin
  * Fixed Log keyword
  *
  * Revision 6.0  1997/09/12 13:24:22  neelin
--- a/conversion/ecattominc/ecattominc.c
+++ b/conversion/ecattominc/ecattominc.c
@@ -10,7 +10,25 @@
 @CREATED    : January 3, 1996 (Peter Neelin)
 @MODIFIED   : 
  * $Log: ecattominc.c,v $
- * Revision 6.3  2000-09-08 18:17:15  neelin
+ * Revision 6.4.2.1  2005-02-15 19:59:54  bert
+ * Initial checkin on 1.X branch
+ *
+ * Revision 6.4  2005/01/19 19:46:01  bert
+ * Changes from Anthonin Reilhac
+ *
+ *
+ * Revision 7.0  2004/08/13           Anthonin Reilhac
+ * Portage of the code under linux environment
+ *    - little / big Indian conversion
+ *    - the vax conversion routines are now included within the distribution
+ *    - MALLOC, REALLOC and FREE macros definined within the ecat_file.h body
+ *      MALLOC and REALLOC use the malloc_check and realloc_check in ecat_file.c
+ *      which are not private(static) anymore
+ *      mni_def.h is not used anymore and 
+ * Fixed x and y flipping when y size is odd.
+ * Did not show up before since normal x and y size are even
+ *
+ * Revision 6.3  2000/09/08 18:17:15  neelin
  * Fixed swapping of x and y sizes when getting dimensions sizes from ecat file.
  * This has not previously shown up since normal ECAT images are square.
  *
@@ -53,7 +71,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[]="$Header: /private-cvsroot/minc/conversion/ecattominc/ecattominc.c,v 6.3 2000-09-08 18:17:15 neelin Exp $";
+static char rcsid[]="$Header: /private-cvsroot/minc/conversion/ecattominc/ecattominc.c,v 6.4.2.1 2005-02-15 19:59:54 bert Exp $";
 #endif
 
 #include <stdlib.h>
@@ -67,8 +85,10 @@
 #include <ParseArgv.h>
 #include <time_stamp.h>
 #include <minc.h>
-#include <minc_def.h>
-#include <ecat_file.h>
+/*#include <def_mni.h>    modif anthonin */
+#include "ecat_file.h"
+
+
 
 /* Type declarations */
 typedef struct {
@@ -186,6 +206,14 @@
 #define MINIMUM_HALFLIFE 0.1
 #define FWHM_SCALE_FOR_HANN 1.082
 
+
+/* we don't need mni_def anymore*/
+
+/*#define MALLOC(size) ((void *) malloc(size))
+#define FREE(ptr) free( (void *) ptr)
+#define REALLOC(ptr, size) ((void *) realloc(ptr, size))*/
+
+
 /* Main program */
 
 int main(int argc, char *argv[])
@@ -235,9 +263,9 @@
    };
 
    /* Other variables */
-   char *pname;
-   char *mincfile;
-   char *ecat_filename;
+   char *pname; /*name of the present command ->argv[0]*/
+   char *mincfile; /*name of the minc file = output*/
+   char *ecat_filename; /*name of the ecat7 file = input*/
    int num_frames;
    int num_bed_positions;
    int sort_over_time;
@@ -253,7 +281,7 @@
    short *image;
    Ecat_file *ecat_fp;
    int status;
-   char *tm_stamp;
+   char *tm_stamp; /******** pk for minchistory*/
    double first_z, last_z, zstep;
 
    /* Get time stamp */
@@ -306,6 +334,8 @@
       exit(EXIT_FAILURE);
    }
 
+   
+
    /* Get number of frames and bed positions to see if we are varying over
       time or interleaving slices */
    num_frames = ecat_get_num_frames(ecat_fp);
@@ -1435,7 +1465,7 @@
               general_info_type *general_info)
      /* ARGSUSED */
 {
-   long npix, ix, iy, y_offset, off1, off2;
+   long npix, in, off;
    int pmax;
    int lvalue;
    short temp;
@@ -1443,20 +1473,16 @@
 
    /* Get the image from the file */
    if (ecat_get_image(ecat_fp, frame_num, slice_num, image)) return TRUE;
-
+   
    /* Flip the image to give positive x & y axes */
    npix = frame_info->image_xsize * frame_info->image_ysize;
-   for (iy=0; iy<frame_info->image_ysize/2; iy++) {
-      y_offset = iy * frame_info->image_xsize;
-      for (ix=0; ix<frame_info->image_xsize; ix++) {
-         off1 = y_offset + ix;
-         off2 = npix - off1 - 1;
-         temp = image[off1];
-         image[off1] = image[off2];
-         image[off2] = temp;
-      }
+
+   for(in = 0; in < npix/2; in++) {
+     off = npix - in - 1;
+     temp = image[off];
+     image[off] = image[in];
+     image[in] = temp;     
    }
-
    /* Get image and pixel max */
    if (ecat_get_subhdr_value(ecat_fp, frame_num, slice_num, 
                              ECAT_Image_Max, 0, &pmax, NULL, NULL) ||
@@ -1483,7 +1509,6 @@
    return FALSE;
 }
 
-
 /* ----------------------------- MNI Header -----------------------------------
 @NAME       : write_minc_slice
 @INPUT      : scale - scale for decay correcting image
@@ -1565,7 +1590,7 @@
    return FALSE;
 }
 
-
+
 /* ----------------------------- MNI Header -----------------------------------
 @NAME       : decay_correction
 @INPUT      : scan_time - time of beginning of sample
new file mode 100644
--- /dev/null
+++ b/conversion/ecattominc/machine_indep.c
@@ -0,0 +1,195 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <netinet/in.h>
+
+void get_short_value(const void *from, void *to) {
+  short int short_value;
+
+  (void) memcpy(&short_value, from, sizeof(short int));
+  *(short int *)to = ntohs(short_value);
+}
+
+void get_long_value(const void *from, void *to) {
+  long int long_value;
+
+  (void) memcpy(&long_value, from, sizeof(long int));
+  *(long int *)to = ntohl(long_value);
+}
+/* from vax_conversion.c -Copyright 1993 Peter Neelin */
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : vax_conversions.c
+@DESCRIPTION: File containing routines to convert machine values to vax format
+              values.
+@METHOD     : 
+@CREATED    : December 10, 1992 (Peter Neelin)
+@MODIFIED   : 
+ * $Log: machine_indep.c,v $
+ * Revision 6.1.2.1  2005-02-15 19:59:54  bert
+ * Initial checkin on 1.X branch
+ *
+ * Revision 6.1  2005/01/19 19:46:28  bert
+ * Changes from Anthonin Reilhac
+ *
+ * Revision 6.2  1999/10/19 15:57:18  neelin
+ * Fixed log message containing log substitution
+ *
+ * Revision 6.1  1999/10/19 14:45:15  neelin
+ * Fixed Log subsitutions for CVS
+ *
+ * Revision 6.0  1997/09/12 13:23:41  neelin
+ * Release of minc version 0.6
+ *
+ * Revision 5.0  1997/08/21  13:24:41  neelin
+ * Release of minc version 0.5
+ *
+ * Revision 4.0  1997/05/07  20:00:50  neelin
+ * Release of minc version 0.4
+ *
+ * Revision 3.0  1995/05/15  19:31:35  neelin
+ * Release of minc version 0.3
+ *
+ * Revision 2.0  1994/09/28  10:34:32  neelin
+ * Release of minc version 0.2
+ *
+ * Revision 1.5  94/09/28  10:34:18  neelin
+ * Pre-release
+ * 
+ * Revision 1.4  93/08/04  13:04:01  neelin
+ * Added RCS Log to keep track of modifications in source
+ *
+@COPYRIGHT  :
+              Copyright 1993 Peter Neelin, McConnell Brain Imaging Centre, 
+              Montreal Neurological Institute, McGill University.
+              Permission to use, copy, modify, and distribute this
+              software and its documentation for any purpose and without
+              fee is hereby granted, provided that the above copyright
+              notice appear in all copies.  The author and McGill University
+              make no representations about the suitability of this
+              software for any purpose.  It is provided "as is" without
+              express or implied warranty.
+---------------------------------------------------------------------------- */
+
+#ifndef lint
+static char rcsid[]="$Header: /private-cvsroot/minc/conversion/ecattominc/machine_indep.c,v 6.1.2.1 2005-02-15 19:59:54 bert Exp $";
+#endif
+
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : get_vax_short
+@INPUT      : nvals - number of values to convert
+              vax_value - pointer to array of shorts in vax format
+@OUTPUT     : mach_value - pointer to array of shorts in current machine format
+@RETURNS    : (nothing)
+@DESCRIPTION: Converts vax short integers to short integers in the format of
+              the current machine.
+@METHOD     : 
+@GLOBALS    : (none)
+@CALLS      : memcpy
+@CREATED    : December 10, 1992.
+@MODIFIED   : 
+---------------------------------------------------------------------------- */
+void get_vax_short(int nvals, void *vax_value, short *mach_value)
+{
+   int i;
+   char *ptr1, *ptr2, v0, v1;
+
+#ifdef vax
+   memcpy((void *) mach_value, vax_value, nvals*sizeof(short));
+#else
+   ptr1 = (char *) vax_value;
+   ptr2 = (char *) mach_value;
+   for (i=0; i<nvals; i++) {
+      v0 = ptr1[1];
+      v1 = ptr1[0];
+      ptr2[0] = v0;
+      ptr2[1] = v1;
+      ptr1 += sizeof(mach_value[0]);
+      ptr2 += sizeof(mach_value[0]);
+   }
+#endif
+
+   return;
+}
+
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : get_vax_long
+@INPUT      : nvals - number of values to convert
+              vax_value - pointer to array of longs in vax format
+@OUTPUT     : mach_value - pointer to array of longs in current machine format
+@RETURNS    : (nothing)
+@DESCRIPTION: Converts vax long integers to long integers in the format of
+              the current machine.
+@METHOD     : 
+@GLOBALS    : (none)
+@CALLS      : memcpy
+@CREATED    : December 10, 1992.
+@MODIFIED   : 
+---------------------------------------------------------------------------- */
+void get_vax_long(int nvals, void *vax_value, long *mach_value)
+{
+   int i;
+   char *ptr1, *ptr2, v0, v1;
+
+#ifdef vax
+   memcpy((void *) mach_value, vax_value, nvals*sizeof(long));
+#else
+   ptr1 = (char *) vax_value;
+   ptr2 = (char *) mach_value;
+   for (i=0; i<nvals; i++) {
+      v0 = ptr1[3];
+      v1 = ptr1[0];
+      ptr2[0] = v0;
+      ptr2[3] = v1;
+      v0 = ptr1[2];
+      v1 = ptr1[1];
+      ptr2[1] = v0;
+      ptr2[2] = v1;
+      ptr1 += sizeof(mach_value[0]);
+      ptr2 += sizeof(mach_value[0]);
+   }
+#endif
+
+   return;
+}
+
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : get_vax_float
+@INPUT      : nvals - number of values to convert
+              vax_value - pointer to array of floats in vax format
+@OUTPUT     : mach_value - pointer to array of floats in current machine format
+@RETURNS    : (nothing)
+@DESCRIPTION: Converts vax floats to floats in the format of
+              the current machine.
+@METHOD     : 
+@GLOBALS    : (none)
+@CALLS      : memcpy
+@CREATED    : December 10, 1992.
+@MODIFIED   : 
+---------------------------------------------------------------------------- */
+void get_vax_float(int nvals, void *vax_value, float *mach_value)
+{
+   int i;
+   char *ptr1, *ptr2, v0, v1;
+
+#ifdef vax
+   memcpy((void *) mach_value, vax_value, nvals*sizeof(float));
+#else
+   ptr1 = (char *) vax_value;
+   ptr2 = (char *) mach_value;
+   for (i=0; i<nvals; i++) {
+      v0 = ptr1[1];
+      v1 = ptr1[0];
+      ptr2[0] = v0;
+      ptr2[1] = v1;
+      v0 = ptr1[3];
+      v1 = ptr1[2];
+      ptr2[2] = v0;
+      ptr2[3] = v1;
+      mach_value[i] /= 4.0;
+      ptr1 += sizeof(mach_value[0]);
+      ptr2 += sizeof(mach_value[0]);
+   }
+#endif
+
+   return;
+}
+
new file mode 100644
--- /dev/null
+++ b/conversion/ecattominc/machine_indep.h
@@ -0,0 +1,65 @@
+#ifndef _ECAT_MACHINE_INDEP_H
+#define _ECAT_MACHINE_INDEP_H	1
+
+void get_short_value(const void *from, void *to);
+void get_long_value(const void *from, void *to);
+
+/* from vax_conversions.h -Copyright 1993 Peter Neelin */
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : vax_conversions.h
+@DESCRIPTION: Header file for vax type conversion routines
+@GLOBALS    : 
+@CALLS      : 
+@CREATED    : January 8, 1993
+@MODIFIED   : 
+ * $Log: machine_indep.h,v $
+ * Revision 6.1.2.1  2005-02-15 19:59:54  bert
+ * Initial checkin on 1.X branch
+ *
+ * Revision 6.1  2005/01/19 19:46:28  bert
+ * Changes from Anthonin Reilhac
+ *
+ * Revision 6.2  1999/10/19 15:57:19  neelin
+ * Fixed log message containing log substitution
+ *
+ * Revision 6.1  1999/10/19 14:45:15  neelin
+ * Fixed Log subsitutions for CVS
+ *
+ * Revision 6.0  1997/09/12 13:23:41  neelin
+ * Release of minc version 0.6
+ *
+ * Revision 5.0  1997/08/21  13:24:41  neelin
+ * Release of minc version 0.5
+ *
+ * Revision 4.0  1997/05/07  20:00:50  neelin
+ * Release of minc version 0.4
+ *
+ * Revision 3.0  1995/05/15  19:31:35  neelin
+ * Release of minc version 0.3
+ *
+ * Revision 2.0  1994/09/28  10:34:32  neelin
+ * Release of minc version 0.2
+ *
+ * Revision 1.4  94/09/28  10:34:21  neelin
+ * Pre-release
+ * 
+ * Revision 1.3  93/08/04  13:04:03  neelin
+ * Added RCS Log to keep track of modifications in source
+ *
+@COPYRIGHT  :
+              Copyright 1993 Peter Neelin, McConnell Brain Imaging Centre, 
+              Montreal Neurological Institute, McGill University.
+              Permission to use, copy, modify, and distribute this
+              software and its documentation for any purpose and without
+              fee is hereby granted, provided that the above copyright
+              notice appear in all copies.  The author and McGill University
+              make no representations about the suitability of this
+              software for any purpose.  It is provided "as is" without
+              express or implied warranty.
+---------------------------------------------------------------------------- */
+
+void get_vax_short(int nvals, void *vax_value, short *mach_value);
+void get_vax_long(int nvals, void *vax_value, long *mach_value);
+void get_vax_float(int nvals, void *vax_value, float *mach_value);
+
+#endif /*_ECAT_MACHINE_INDEP_H*/