changeset 1013:340c11f86adb

check_in_all
author david <david>
date Fri, 15 Nov 1996 16:09:41 +0000
parents 66c46ba73f2d
children abc2e561fd95
files volume_io/Geometry/colour_def.c volume_io/Include/volume_io/alloc.h volume_io/Include/volume_io/basic.h volume_io/Include/volume_io/system_dependent.h volume_io/Include/volume_io/volume.h volume_io/MNI_formats/gen_xf_io.c volume_io/MNI_formats/tag_points.c volume_io/Testing/copy_volume.c volume_io/Volumes/get_hyperslab.c volume_io/Volumes/input_mnc.c volume_io/Volumes/multidim_arrays.c volume_io/Volumes/output_mnc.c volume_io/Volumes/volumes.c
diffstat 13 files changed, 199 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/volume_io/Geometry/colour_def.c
+++ b/volume_io/Geometry/colour_def.c
@@ -15,7 +15,7 @@
 #include  <internal_volume_io.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Geometry/colour_def.c,v 1.5 1996-05-17 19:36:09 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Geometry/colour_def.c,v 1.6 1996-11-15 16:09:41 david Exp $";
 #endif
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -50,7 +50,7 @@
     unsigned  char  *byte_ptr;
 
     c = 0;    /* to avoid used-before-set compiler messages */
-    byte_ptr = (void *) &c;
+    ASSIGN_PTR(byte_ptr) = (void *) &c;
 
     byte_ptr[0] = (unsigned char) a;
     byte_ptr[1] = (unsigned char) b;
@@ -78,7 +78,7 @@
 {
     unsigned  char  *b;
 
-    b = (void *) &colour;
+    ASSIGN_PTR(b) = (void *) &colour;
 
     return( (int) b[3] );
 }
@@ -101,7 +101,7 @@
 {
     unsigned  char  *b;
 
-    b = (void *) &colour;
+    ASSIGN_PTR(b) = (void *) &colour;
 
     return( (int) b[2] );
 }
@@ -124,7 +124,7 @@
 {
     unsigned  char  *b;
 
-    b = (void *) &colour;
+    ASSIGN_PTR(b) = (void *) &colour;
 
     return( (int) b[1] );
 }
@@ -148,7 +148,7 @@
 {
     unsigned  char  *b;
 
-    b = (void *) &colour;
+    ASSIGN_PTR(b) = (void *) &colour;
 
     return( (int) b[0] );
 }
--- a/volume_io/Include/volume_io/alloc.h
+++ b/volume_io/Include/volume_io/alloc.h
@@ -29,7 +29,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char alloc_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/alloc.h,v 1.13 1996-05-17 19:36:12 david Exp $";
+static char alloc_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/alloc.h,v 1.14 1996-11-15 16:09:43 david Exp $";
 #endif
 
 #include  <basic.h>
@@ -63,7 +63,8 @@
 ---------------------------------------------------------------------------- */
 
 #define  ALLOC( ptr, n_items )                                                \
-             (ptr) = alloc_memory_1d( (size_t) (n_items),                     \
+             ASSIGN_PTR(ptr) =                                                \
+                     alloc_memory_1d( (size_t) (n_items),                     \
                                       sizeof(*(ptr)) _ALLOC_SOURCE_LINE )
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -139,7 +140,7 @@
 ---------------------------------------------------------------------------- */
 
 #define  ALLOC_VAR_SIZED_STRUCT( ptr, element_type, n_elements )              \
-  (ptr) = alloc_memory_in_bytes(                                              \
+  ASSIGN_PTR(ptr) = alloc_memory_in_bytes(                                    \
   (size_t) (sizeof(*(ptr))+((size_t)(n_elements)-1) * sizeof(element_type))   \
   _ALLOC_SOURCE_LINE )
 
@@ -161,7 +162,7 @@
 ---------------------------------------------------------------------------- */
 
 #define  ALLOC2D( ptr, n1, n2 )                                               \
-         (ptr) = alloc_memory_2d( (size_t) (n1), (size_t) (n2),               \
+   ASSIGN_PTR(ptr) = alloc_memory_2d( (size_t) (n1), (size_t) (n2),           \
                           sizeof(**(ptr)) _ALLOC_SOURCE_LINE )
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -197,7 +198,7 @@
 ---------------------------------------------------------------------------- */
 
 #define  ALLOC3D( ptr, n1, n2, n3 )                                           \
-         (ptr) = alloc_memory_3d( (size_t) (n1), (size_t) (n2),   \
+         ASSIGN_PTR(ptr) = alloc_memory_3d( (size_t) (n1), (size_t) (n2),     \
                           (size_t) (n3), sizeof(***(ptr)) _ALLOC_SOURCE_LINE )
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -234,7 +235,7 @@
 ---------------------------------------------------------------------------- */
 
 #define  ALLOC4D( ptr, n1, n2, n3, n4 )                                       \
-         (ptr) = alloc_memory_4d( (size_t) (n1), (size_t) (n2),  \
+       ASSIGN_PTR(ptr) = alloc_memory_4d( (size_t) (n1), (size_t) (n2),       \
                           (size_t) (n3), (size_t) (n4),                       \
                           sizeof(****(ptr)) _ALLOC_SOURCE_LINE )
 
@@ -274,7 +275,7 @@
 ---------------------------------------------------------------------------- */
 
 #define  ALLOC5D( ptr, n1, n2, n3, n4, n5 )                                   \
-         (ptr) = alloc_memory_5d( (size_t) (n1), (size_t) (n2),  \
+     ASSIGN(ptr) = alloc_memory_5d( (size_t) (n1), (size_t) (n2),             \
                           (size_t) (n3), (size_t) (n4), (size_t) (n5),        \
                           sizeof(*****(ptr)) _ALLOC_SOURCE_LINE )
 
--- a/volume_io/Include/volume_io/basic.h
+++ b/volume_io/Include/volume_io/basic.h
@@ -29,7 +29,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char basic_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/basic.h,v 1.27 1996-05-17 19:36:12 david Exp $";
+static char basic_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/basic.h,v 1.28 1996-11-15 16:09:42 david Exp $";
 #endif
 
 #include  <stdlib.h>
@@ -126,6 +126,8 @@
 
 typedef  double          Real;
 
+#define  REAL_MAX        DBL_MAX
+
 typedef  char            *STRING;
 
 /* --------------- */
--- a/volume_io/Include/volume_io/system_dependent.h
+++ b/volume_io/Include/volume_io/system_dependent.h
@@ -31,4 +31,10 @@
 #define  EXIT_SUCCESS  0
 #endif
 
+#ifdef __cplusplus
+#define  ASSIGN_PTR( ptr )  (*((void **) &(ptr)))
+#else
+#define  ASSIGN_PTR( ptr )  (ptr)
 #endif
+
+#endif
--- a/volume_io/Include/volume_io/volume.h
+++ b/volume_io/Include/volume_io/volume.h
@@ -16,7 +16,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char volume_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/volume.h,v 1.46 1996-05-17 19:36:11 david Exp $";
+static char volume_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/volume.h,v 1.47 1996-11-15 16:09:42 david Exp $";
 #endif
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -342,7 +342,7 @@
 
 typedef  struct
 {
-    BOOLEAN     promote_invalid_to_min_flag;
+    BOOLEAN     promote_invalid_to_zero_flag;
     BOOLEAN     convert_vector_to_scalar_flag;
     BOOLEAN     convert_vector_to_colour_flag;
     int         dimension_size_for_colour_data;
--- a/volume_io/MNI_formats/gen_xf_io.c
+++ b/volume_io/MNI_formats/gen_xf_io.c
@@ -15,7 +15,7 @@
 #include  <internal_volume_io.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/MNI_formats/gen_xf_io.c,v 1.18 1996-05-17 19:36:26 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/MNI_formats/gen_xf_io.c,v 1.19 1996-11-15 16:09:49 david Exp $";
 #endif
 
 /*--------------------- file format keywords ------------------------------ */
@@ -96,7 +96,7 @@
 
         for_less( i, 0, 3 )
         {
-            (void) fprintf( file, " %15.8f %15.8f %15.8f %15.8f",
+            (void) fprintf( file, " %.15g %.15g %.15g %.15g",
                                   Transform_elem(*lin_transform,i,0),
                                   Transform_elem(*lin_transform,i,1),
                                   Transform_elem(*lin_transform,i,2),
@@ -125,7 +125,7 @@
         for_less( i, 0, transform->n_points )
         {
             for_less( c, 0, transform->n_dimensions )
-                (void) fprintf( file, " %g", transform->points[i][c] );
+                (void) fprintf( file, " %.15g", transform->points[i][c] );
 
             if( i == transform->n_points-1 )
                 (void) fprintf( file, ";" );
@@ -138,7 +138,7 @@
         for_less( i, 0, transform->n_points + transform->n_dimensions + 1 )
         {
             for_less( c, 0, transform->n_dimensions )
-                (void) fprintf( file, " %g", transform->displacements[i][c] );
+                (void) fprintf( file, " %.15g", transform->displacements[i][c]);
 
             if( i == transform->n_points + transform->n_dimensions + 1 - 1 )
                 (void) fprintf( file, ";" );
--- a/volume_io/MNI_formats/tag_points.c
+++ b/volume_io/MNI_formats/tag_points.c
@@ -15,7 +15,7 @@
 #include  <internal_volume_io.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/MNI_formats/tag_points.c,v 1.21 1996-05-17 19:36:26 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/MNI_formats/tag_points.c,v 1.22 1996-11-15 16:09:49 david Exp $";
 #endif
 
 static   const char      *TAG_FILE_HEADER = "MNI Tag Point File";
@@ -132,14 +132,14 @@
 
     status = OK;
 
-    (void) fprintf( file, "\n %.8g %.8g %.8g",
+    (void) fprintf( file, "\n %.15g %.15g %.15g",
                     tag_volume1[0],
                     tag_volume1[1],
                     tag_volume1[2] );
 
     if( n_volumes >= 2 )
     {
-        (void) fprintf( file, " %.8g %.8g %.8g",
+        (void) fprintf( file, " %.15g %.15g %.15g",
                         tag_volume2[0],
                         tag_volume2[1],
                         tag_volume2[2] );
@@ -154,9 +154,9 @@
     if( aux_present )
     {
         if( weight != (Real *) NULL )
-            (void) fprintf( file, " %g", *weight );
+            (void) fprintf( file, " %.15g", *weight );
         else
-            (void) fprintf( file, " %g", 0.0 );
+            (void) fprintf( file, " %.15g", 0.0 );
 
         if( structure_id != NULL )
             (void) fprintf( file, " %d", *structure_id );
--- a/volume_io/Testing/copy_volume.c
+++ b/volume_io/Testing/copy_volume.c
@@ -7,34 +7,35 @@
     Status         status;
     int            sizes[MAX_DIMENSIONS];
     Real           separations[MAX_DIMENSIONS];
-    Real           min_value, max_value, fraction_done;
+    Real           min_value, max_value;
+    int            v1, v2, v3, v4, v5;
+    Real           value;
     Volume         volume;
-    char           *input_filename, *output_filename, *dummy;
-    char           *tmp;
+    char           *input_filename, *output_filename;
     Minc_file      file;
     static STRING  dim_names[3] = { MIzspace, MIyspace, MIxspace };
-    Real           start_time, end_time;
-
-    initialize_argument_processing( argc, argv );
+    minc_input_options   options;
 
-    if( !get_string_argument( "", &input_filename ) ||
-        !get_string_argument( "", &output_filename ) )
-    {
-        print( "Need source and destination filename.\n" );
-    }
+    input_filename = argv[1];
+    output_filename = argv[2];
 
-    if( get_string_argument( "", &dummy ) )
+    if( argc >= 4 )
     {
         (void) strcpy( dim_names[0], MIxspace );
         (void) strcpy( dim_names[1], MIyspace );
         (void) strcpy( dim_names[2], MIzspace );
     }
 
-    status = input_volume( input_filename, dim_names, FALSE, &volume );
+    set_default_minc_input_options( &options );
+
+    if( input_volume( input_filename, 3, dim_names,
+                      NC_UNSPECIFIED, FALSE, 0.0, 0.0,
+                      TRUE, &volume, &options ) != OK )
+        return( 1 );
 
     get_volume_sizes( volume, sizes );
     get_volume_separations( volume, separations );
-    get_volume_range( volume, &min_value, &max_value );
+    get_volume_real_range( volume, &min_value, &max_value );
 
     print( "Volume %s: %d by %d by %d\n",
             input_filename, sizes[X], sizes[Y], sizes[Z] );
@@ -43,14 +44,15 @@
     print( "%g %g\n", min_value, max_value );
 
     file = initialize_minc_output( output_filename, 3, dim_names, sizes,
-                                   NC_BYTE, FALSE, min_value, max_value,
-                                   &volume->voxel_to_world_transform );
+                                   NC_UNSPECIFIED, FALSE, 0.0, 0.0,
+                                   &volume->voxel_to_world_transform,
+                                   volume, NULL );
+
+    status = copy_auxiliary_data_from_minc_file( file, input_filename,
+                                                 NULL );
 
     if( status == OK )
-        status = copy_auxiliary_data_from_minc_file( file, input_filename );
-
-    if( status == OK )
-        status = output_minc_volume( file, volume );
+        status = output_minc_volume( file );
 
     if( status == OK )
         status = close_minc_output( file );
--- a/volume_io/Volumes/get_hyperslab.c
+++ b/volume_io/Volumes/get_hyperslab.c
@@ -15,7 +15,7 @@
 #include  <internal_volume_io.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/get_hyperslab.c,v 1.4 1996-08-21 15:31:30 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/get_hyperslab.c,v 1.5 1996-11-15 16:09:48 david Exp $";
 #endif
 
 public  void  convert_voxels_to_values(
@@ -275,7 +275,7 @@
     switch( data_type )
     {
     case UNSIGNED_BYTE:
-        unsigned_byte_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -302,7 +302,7 @@
         break;
 
     case SIGNED_BYTE:
-        signed_byte_ptr = void_ptr;
+        ASSIGN_PTR(signed_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -329,7 +329,7 @@
         break;
 
     case UNSIGNED_SHORT:
-        unsigned_short_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -356,7 +356,7 @@
         break;
 
     case SIGNED_SHORT:
-        signed_short_ptr = void_ptr;
+        ASSIGN_PTR(signed_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -383,7 +383,7 @@
         break;
 
     case UNSIGNED_LONG:
-        unsigned_long_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -409,7 +409,7 @@
         break;
 
     case SIGNED_LONG:
-        signed_long_ptr = void_ptr;
+        ASSIGN_PTR(signed_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -435,7 +435,7 @@
         break;
 
     case FLOAT:
-        float_ptr = void_ptr;
+        ASSIGN_PTR(float_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -461,7 +461,7 @@
         break;
 
     case DOUBLE:
-        double_ptr = void_ptr;
+        ASSIGN_PTR(double_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -523,7 +523,7 @@
     switch( data_type )
     {
     case UNSIGNED_BYTE:
-        unsigned_byte_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -546,7 +546,7 @@
         break;
 
     case SIGNED_BYTE:
-        signed_byte_ptr = void_ptr;
+        ASSIGN_PTR(signed_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -568,7 +568,7 @@
         break;
 
     case UNSIGNED_SHORT:
-        unsigned_short_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -591,7 +591,7 @@
         break;
 
     case SIGNED_SHORT:
-        signed_short_ptr = void_ptr;
+        ASSIGN_PTR(signed_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -614,7 +614,7 @@
         break;
 
     case UNSIGNED_LONG:
-        unsigned_long_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -636,7 +636,7 @@
         break;
 
     case SIGNED_LONG:
-        signed_long_ptr = void_ptr;
+        ASSIGN_PTR(signed_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -658,7 +658,7 @@
         break;
 
     case FLOAT:
-        float_ptr = void_ptr;
+        ASSIGN_PTR(float_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -680,7 +680,7 @@
         break;
 
     case DOUBLE:
-        double_ptr = void_ptr;
+        ASSIGN_PTR(double_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -735,7 +735,7 @@
     switch( data_type )
     {
     case UNSIGNED_BYTE:
-        unsigned_byte_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -753,7 +753,7 @@
         break;
 
     case SIGNED_BYTE:
-        signed_byte_ptr = void_ptr;
+        ASSIGN_PTR(signed_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -771,7 +771,7 @@
         break;
 
     case UNSIGNED_SHORT:
-        unsigned_short_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -789,7 +789,7 @@
         break;
 
     case SIGNED_SHORT:
-        signed_short_ptr = void_ptr;
+        ASSIGN_PTR(signed_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -807,7 +807,7 @@
         break;
 
     case UNSIGNED_LONG:
-        unsigned_long_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -825,7 +825,7 @@
         break;
 
     case SIGNED_LONG:
-        signed_long_ptr = void_ptr;
+        ASSIGN_PTR(signed_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -843,7 +843,7 @@
         break;
 
     case FLOAT:
-        float_ptr = void_ptr;
+        ASSIGN_PTR(float_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -861,7 +861,7 @@
         break;
 
     case DOUBLE:
-        double_ptr = void_ptr;
+        ASSIGN_PTR(double_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -909,7 +909,7 @@
     switch( data_type )
     {
     case UNSIGNED_BYTE:
-        unsigned_byte_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -923,7 +923,7 @@
         break;
 
     case SIGNED_BYTE:
-        signed_byte_ptr = void_ptr;
+        ASSIGN_PTR(signed_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -937,7 +937,7 @@
         break;
 
     case UNSIGNED_SHORT:
-        unsigned_short_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -951,7 +951,7 @@
         break;
 
     case SIGNED_SHORT:
-        signed_short_ptr = void_ptr;
+        ASSIGN_PTR(signed_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -965,7 +965,7 @@
         break;
 
     case UNSIGNED_LONG:
-        unsigned_long_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -979,7 +979,7 @@
         break;
 
     case SIGNED_LONG:
-        signed_long_ptr = void_ptr;
+        ASSIGN_PTR(signed_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -993,7 +993,7 @@
         break;
 
     case FLOAT:
-        float_ptr = void_ptr;
+        ASSIGN_PTR(float_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -1007,7 +1007,7 @@
         break;
 
     case DOUBLE:
-        double_ptr = void_ptr;
+        ASSIGN_PTR(double_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             for_less( i1, 0, n1 )
@@ -1044,7 +1044,7 @@
     switch( data_type )
     {
     case UNSIGNED_BYTE:
-        unsigned_byte_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = unsigned_byte_to_real[(long) *unsigned_byte_ptr];
@@ -1054,7 +1054,7 @@
         break;
 
     case SIGNED_BYTE:
-        signed_byte_ptr = void_ptr;
+        ASSIGN_PTR(signed_byte_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = signed_byte_to_real[(long) *signed_byte_ptr];
@@ -1064,7 +1064,7 @@
         break;
 
     case UNSIGNED_SHORT:
-        unsigned_short_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = unsigned_short_to_real[(long) *unsigned_short_ptr];
@@ -1074,7 +1074,7 @@
         break;
 
     case SIGNED_SHORT:
-        signed_short_ptr = void_ptr;
+        ASSIGN_PTR(signed_short_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = signed_short_to_real[(long) *signed_short_ptr];
@@ -1084,7 +1084,7 @@
         break;
 
     case UNSIGNED_LONG:
-        unsigned_long_ptr = void_ptr;
+        ASSIGN_PTR(unsigned_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = (Real) *unsigned_long_ptr;
@@ -1094,7 +1094,7 @@
         break;
 
     case SIGNED_LONG:
-        signed_long_ptr = void_ptr;
+        ASSIGN_PTR(signed_long_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = (Real) *signed_long_ptr;
@@ -1104,7 +1104,7 @@
         break;
 
     case FLOAT:
-        float_ptr = void_ptr;
+        ASSIGN_PTR(float_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = (Real) *float_ptr;
@@ -1114,7 +1114,7 @@
         break;
 
     case DOUBLE:
-        double_ptr = void_ptr;
+        ASSIGN_PTR(double_ptr) = void_ptr;
         for_less( i0, 0, n0 )
         {
             *values = (Real) *double_ptr;
--- a/volume_io/Volumes/input_mnc.c
+++ b/volume_io/Volumes/input_mnc.c
@@ -16,7 +16,7 @@
 #include  <minc.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/input_mnc.c,v 1.54 1996-05-17 19:36:20 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/input_mnc.c,v 1.55 1996-11-15 16:09:45 david Exp $";
 #endif
 
 #define  INVALID_AXIS   -1
@@ -116,7 +116,7 @@
     double              file_separations[MAX_VAR_DIMS];
     Real                volume_separations[MI_NUM_SPACE_DIMS];
     Real                default_voxel_min, default_voxel_max;
-    Real                world_space[N_DIMENSIONS];
+    Real                world_space[N_DIMENSIONS], voxel_zero;
     double              start_position[MAX_VAR_DIMS];
     double              dir_cosines[MAX_VAR_DIMS][MI_NUM_SPACE_DIMS];
     double              tmp_cosines[MI_NUM_SPACE_DIMS];
@@ -525,20 +525,40 @@
 
     /* --- compute the mapping to real values */
 
+    (void) miicv_inqdbl( file->minc_icv, MI_ICV_NORM_MIN, &real_min );
+    (void) miicv_inqdbl( file->minc_icv, MI_ICV_NORM_MAX, &real_max );
+
     if( !file->converting_to_colour )
+        set_volume_real_range( volume, real_min, real_max );
+
+    /* --- if promoting invalid values to zero, then we need to detach and
+           reattach in order to change the fillvalue in the icv */
+
+    if( options->promote_invalid_to_zero_flag )
     {
-         (void) miicv_inqdbl( file->minc_icv, MI_ICV_NORM_MIN, &real_min );
-         (void) miicv_inqdbl( file->minc_icv, MI_ICV_NORM_MAX, &real_max );
+        (void) miicv_detach( file->minc_icv );
 
-         set_volume_real_range( volume, real_min, real_max );
-    }
+        if( !file->converting_to_colour )
+        {
+            if( real_min == real_max )
+                voxel_zero = valid_range[0];
+            else if( real_min > 0.0 )
+                voxel_zero = valid_range[0];
+            else if( real_max < 0.0 )
+                voxel_zero = valid_range[1];
+            else
+            {
+                voxel_zero = valid_range[0] +
+                             (valid_range[1] - valid_range[0]) *
+                             (0.0 - real_min) / (real_max - real_min);
+            }
 
-    if( options->promote_invalid_to_min_flag )
-    {
-        if( !file->converting_to_colour )
-            (void) miicv_setdbl( file->minc_icv, MI_ICV_FILLVALUE, valid_range[0] );
+            (void) miicv_setdbl( file->minc_icv, MI_ICV_FILLVALUE, voxel_zero );
+        }
         else
             (void) miicv_setdbl( file->minc_icv, MI_ICV_FILLVALUE, 0.0 );
+
+        (void) miicv_attach( file->minc_icv, file->cdfid, file->img_var );
     }
 
     for_less( d, 0, file->n_file_dimensions )
@@ -1298,7 +1318,7 @@
 {
     static  int     default_rgba_indices[4] = { 0, 1, 2, 3 };
 
-    set_minc_input_promote_invalid_to_min_flag( options, TRUE );
+    set_minc_input_promote_invalid_to_zero_flag( options, TRUE );
     set_minc_input_vector_to_scalar_flag( options, TRUE );
     set_minc_input_vector_to_colour_flag( options, FALSE );
     set_minc_input_colour_dimension_size( options, 3 );
@@ -1307,7 +1327,7 @@
 }
 
 /* ----------------------------- MNI Header -----------------------------------
-@NAME       : set_minc_input_promote_invalid_to_min_flag
+@NAME       : set_minc_input_promote_invalid_to_zero_flag
 @INPUT      : flag
 @OUTPUT     : options
 @RETURNS    : 
@@ -1316,14 +1336,37 @@
 @GLOBALS    : 
 @CALLS      : 
 @CREATED    : 1993            David MacDonald
-@MODIFIED   : 
+@MODIFIED   : Oct. 25, 1996   D. MacDonald    - changed to promote to 0,
+                                                used to be min_valid
+---------------------------------------------------------------------------- */
+
+public  void  set_minc_input_promote_invalid_to_zero_flag(
+    minc_input_options  *options,
+    BOOLEAN             flag )
+{
+    options->promote_invalid_to_zero_flag = flag;
+}
+
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : set_minc_input_promote_invalid_to_zero_flag
+@INPUT      : flag
+@OUTPUT     : options
+@RETURNS    : 
+@DESCRIPTION: Sets the invalid promotion flag of the input options.  Maintained
+              for functional interface backward compatibility.  Programmers
+              should now be calling set_minc_input_promote_invalid_to_zero_flag.
+@METHOD     : 
+@GLOBALS    : 
+@CALLS      : 
+@CREATED    : 1993            David MacDonald
+@MODIFIED   : Oct. 25, 1996   D. MacDonald    - replaced with above function
 ---------------------------------------------------------------------------- */
 
 public  void  set_minc_input_promote_invalid_to_min_flag(
     minc_input_options  *options,
     BOOLEAN             flag )
 {
-    options->promote_invalid_to_min_flag = flag;
+    set_minc_input_promote_invalid_to_zero_flag( options, flag );
 }
 
 /* ----------------------------- MNI Header -----------------------------------
--- a/volume_io/Volumes/multidim_arrays.c
+++ b/volume_io/Volumes/multidim_arrays.c
@@ -17,7 +17,7 @@
 #include  <float.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/multidim_arrays.c,v 1.13 1996-08-21 15:35:33 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/multidim_arrays.c,v 1.14 1996-11-15 16:09:48 david Exp $";
 #endif
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -262,25 +262,27 @@
     switch( array->n_dimensions )
     {
     case  1:
-        p1 = alloc_memory_1d( sizes[0], type_size _ALLOC_SOURCE_LINE );
+        ASSIGN_PTR(p1) = alloc_memory_1d( sizes[0], type_size
+                                          _ALLOC_SOURCE_LINE );
         array->data = (void *) p1;
         break;
     case  2:
-        p2 = alloc_memory_2d( sizes[0], sizes[1], type_size _ALLOC_SOURCE_LINE);
+        ASSIGN_PTR(p2) = alloc_memory_2d( sizes[0], sizes[1], type_size
+                                          _ALLOC_SOURCE_LINE);
         array->data = (void *) p2;
         break;
     case  3:
-        p3 = alloc_memory_3d( sizes[0], sizes[1], sizes[2], type_size
-                             _ALLOC_SOURCE_LINE );
+        ASSIGN_PTR(p3) = alloc_memory_3d( sizes[0], sizes[1], sizes[2],
+                                          type_size _ALLOC_SOURCE_LINE );
         array->data = (void *) p3;
         break;
     case  4:
-        p4 = alloc_memory_4d( sizes[0], sizes[1],
+        ASSIGN_PTR(p4) = alloc_memory_4d( sizes[0], sizes[1],
                              sizes[2], sizes[3], type_size _ALLOC_SOURCE_LINE );
         array->data = (void *) p4;
         break;
     case  5:
-        p5 = alloc_memory_5d( sizes[0], sizes[1],
+        ASSIGN_PTR(p5) = alloc_memory_5d( sizes[0], sizes[1],
                               sizes[2], sizes[3], sizes[4], type_size
                               _ALLOC_SOURCE_LINE );
         array->data = (void *) p5;
@@ -602,6 +604,7 @@
     int       n_src_dims, n_dest_dims, type_size;
     int       src_sizes[MAX_DIMENSIONS], dest_sizes[MAX_DIMENSIONS];
     char      *dest_ptr, *src_ptr;
+    void      *void_ptr;
 
     type_size = get_type_size( get_multidim_data_type(dest) );
 
@@ -609,15 +612,17 @@
 
     n_dest_dims = get_multidim_n_dimensions( dest );
     get_multidim_sizes( dest, dest_sizes );
-    GET_MULTIDIM_PTR( dest_ptr, *dest, dest_ind[0], dest_ind[1], dest_ind[2],
+    GET_MULTIDIM_PTR( void_ptr, *dest, dest_ind[0], dest_ind[1], dest_ind[2],
                       dest_ind[3], dest_ind[4] );
+    ASSIGN_PTR( dest_ptr ) = void_ptr;
 
     /*--- initialize src */
 
     n_src_dims = get_multidim_n_dimensions( src );
     get_multidim_sizes( src, src_sizes );
-    GET_MULTIDIM_PTR( src_ptr, *src, src_ind[0], src_ind[1], src_ind[2],
+    GET_MULTIDIM_PTR( void_ptr, *src, src_ind[0], src_ind[1], src_ind[2],
                       src_ind[3], src_ind[4] );
+    ASSIGN_PTR( src_ptr ) = void_ptr;
 
     copy_multidim_data_reordered( type_size,
                                   dest_ptr, n_dest_dims, dest_sizes,
--- a/volume_io/Volumes/output_mnc.c
+++ b/volume_io/Volumes/output_mnc.c
@@ -16,7 +16,7 @@
 #include  <minc.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/output_mnc.c,v 1.46 1996-05-17 19:36:22 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/output_mnc.c,v 1.47 1996-11-15 16:09:47 david Exp $";
 #endif
 
 #define  INVALID_AXIS   -1
--- a/volume_io/Volumes/volumes.c
+++ b/volume_io/Volumes/volumes.c
@@ -17,7 +17,7 @@
 #include  <float.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/volumes.c,v 1.63 1996-05-17 19:36:21 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/volumes.c,v 1.64 1996-11-15 16:09:46 david Exp $";
 #endif
 
 STRING   XYZ_dimension_names[] = { MIxspace, MIyspace, MIzspace };
@@ -1026,6 +1026,35 @@
     recompute_world_transform( volume );
 }
 
+public  void  get_volume_direction_cosine(
+    Volume   volume,
+    int      axis,
+    Real     dir[] )
+{
+    int    d;
+
+    if( axis < 0 || axis >= get_volume_n_dimensions(volume) )
+    {
+        print_error(
+         "get_volume_direction_cosine:  cannot set dir cosine for axis %d\n",
+          axis );
+        return;
+    }
+
+    for_less( d, 0, N_DIMENSIONS )
+    {
+        if( volume->spatial_axes[d] == axis )
+            break;
+    }
+
+    if( d == N_DIMENSIONS )   /* this is not a spatial axis, ignore the dir */
+        return;
+
+    dir[X] = volume->direction_cosines[axis][X];
+    dir[Y] = volume->direction_cosines[axis][Y];
+    dir[Z] = volume->direction_cosines[axis][Z];
+}
+
 /* ----------------------------- MNI Header -----------------------------------
 @NAME       : reorder_voxel_to_xyz
 @INPUT      : volume