changeset 2547:5a41267e433a

Merge remote branch 'origin/master'
author Andrew L Janke <a.janke@gmail.com>
date Wed, 07 Dec 2011 10:05:27 +1000
parents 26e3b2195783 (current diff) 8793cdffd21c (diff)
children 3f3e9cc93eee
files configure.in
diffstat 10 files changed, 158 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,67 @@
+INSTALL
+*.in
+*.o
+*.lo
+*.la
+Makefile
+.deps
+.dirstamp
+.libs
+aclocal.m4
+autom4te.cache/
+configure
+config.h
+config.log
+config.status
+dcm2mnc
+ecattominc
+epm-header
+invert_raw_image
+libtool
+minc_modify_header
+mincaverage
+minccalc
+minccmp
+mincconcat
+mincconvert
+minccopy
+mincdump
+mincexample1
+mincexample2
+mincexpand
+mincextract
+mincgen
+mincinfo
+minclookup
+mincmakescalar
+mincmakevector
+mincmath
+mincresample
+mincreshape
+mincstats
+minctoecat
+minctoraw
+mincwindow
+mnc2nii
+nii2mnc
+progs/minccomplete/minccomplete
+progs/minccomplete/minccomplete.man1
+progs/mincgen/ncgentab.c
+progs/mincgen/ncgentab.h
+progs/mincgen/ncgenyy.c
+progs/minchistory/minchistory
+progs/minchistory/minchistory.man1
+progs/xfm/xfmflip
+rawtominc
+stamp-h1
+transformtags
+upet2mnc
+vff2mnc
+volume_io/Testing/example_modify
+volume_io/Testing/example_tags
+volume_io/Testing/example_volume_io
+voxeltoworld
+worldtovoxel
+xfm2def
+xfmconcat
+xfminvert
--- a/autogen.sh
+++ b/autogen.sh
@@ -7,11 +7,14 @@
     exit 1
 fi
 
-# On Mac OS X, the GNU libtool is named 'glibtool'.
-HOSTOS=`uname`
-LIBTOOLIZE=libtoolize
-if test "$HOSTOS"x = Darwinx; then
+# some systems need libtoolize, some glibtoolize 
+echo -n "testing for glibtoolize ... "
+if glibtoolize --version >/dev/null 2>&1; then
   LIBTOOLIZE=glibtoolize
+  echo using glibtoolize 
+else
+  LIBTOOLIZE=libtoolize
+  echo using libtoolize 
 fi
 
 aclocal -I m4
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([minc],[2.1.01],[Andrew L Janke <a.janke@gmail.com>])
+AC_INIT([minc],[2.1.01],[a.janke@gmail.com])
 
 AC_CONFIG_SRCDIR([libsrc2/minc2.h])
 AC_CONFIG_AUX_DIR(ac_config_aux)
--- a/conversion/micropet/upet2mnc.c
+++ b/conversion/micropet/upet2mnc.c
@@ -548,6 +548,16 @@
     ci.frame_nbytes = 1;
     ci.frame_nvoxels = 1;
 
+    /* When we read voxels, we need COMBINED_SCALE_FACTOR() to have a sane
+     * value for all modalities. Set defaults for these in case the modality
+     * does not define one of these factors. For example, a CT (modality 2)
+     * will not define isotope_branching_fraction or calibration_factor.
+     */
+
+    ci.scale_factor = 1.0;
+    ci.calibration_factor = 1.0;
+    ci.isotope_branching_fraction = 1.0;
+
     /* Collect the headers */
     while (fgets(line_buf, sizeof(line_buf), ci.hdr_fp) != NULL) {
         if (line_buf[0] == '#') /*  */
--- a/libsrc/minc.h
+++ b/libsrc/minc.h
@@ -577,6 +577,10 @@
 MNCAPI void milog_init(const char *);
 MNCAPI int milog_set_verbosity(int);
 
+/* default voxel loop buffer size */
+#define MI2_DEF_BUFF_SIZE 4096
+#define MI2_DEF_MAX_MEM 104857
+
 #if MINC2
 
 /* New functions, not directly part of compatibility layer. */
--- a/libsrc/minc_config.h
+++ b/libsrc/minc_config.h
@@ -6,6 +6,8 @@
 #define MICFG_CHUNKING "MINC_CHUNKING"
 #define MICFG_LOGFILE  "MINC_LOGFILE"
 #define MICFG_LOGLEVEL "MINC_LOGLEVEL"
+#define MICFG_MAXBUF   "MINC_MAX_FILE_BUFFER_KB"
+#define MICFG_MAXMEM   "MINC_MAX_MEMORY_KB"
 
 extern int miget_cfg_bool(const char *);
 extern int miget_cfg_int(const char *);
--- a/libsrc/voxel_loop.c
+++ b/libsrc/voxel_loop.c
@@ -357,6 +357,8 @@
    int need_to_free_loop_options;
    int old_ncopts;
 
+   (void)fprintf(stderr, "About to loop, max_buffer is %d\n", loop_options->total_copy_space);
+   
    /* Save ncopts and set it to default value */
    old_ncopts = ncopts;
    ncopts = NC_OPTS_VAL;
@@ -2687,7 +2689,12 @@
    loop_options->convert_input_to_scalar = FALSE;
    loop_options->output_vector_size = 0;
    loop_options->input_mincid = MI_ERROR;
-   loop_options->total_copy_space = 4 * 1024 * 1024;
+   
+   loop_options->total_copy_space = miget_cfg_int(MICFG_MAXBUF) * 1024;
+   if(loop_options->total_copy_space == 0){
+      loop_options->total_copy_space = MI2_DEF_BUFF_SIZE * 1024;
+      }
+   
    loop_options->loop_dimension = NULL;
    loop_options->num_all_inputs = 0;
    loop_options->input_file_function = NULL;
--- a/libsrc2/dimension.c
+++ b/libsrc2/dimension.c
@@ -104,7 +104,8 @@
   else {
     handle->step = 0.0;
   }
-  if (dim_ptr->units == NULL) {
+  //check to make sure string is not empty or null
+  if (dim_ptr->units == NULL  || *dim_ptr->units == '\0') {
     handle->units = strdup("mm");
   }
   else {
@@ -1330,13 +1331,31 @@
   }
   
  
-  if (voxel_order == 0) {
+  if (voxel_order == MI_ORDER_FILE) {
     *start_ptr = dimension->start;
   }
-  else {
+ else { // L.B March 16/2011, Properly reflect voxel ordering
+    if (dimension->flipping_order == MI_COUNTER_FILE_ORDER) { 
+      *start_ptr = dimension->start + (dimension->step * (dimension->length-1));
+    }
+    else if (dimension->flipping_order == MI_POSITIVE) {
+      if (dimension->step > 0) {
+      *start_ptr = dimension->start;
+      }
+      else {
+	*start_ptr = dimension->start + (dimension->step * (dimension->length-1));
+      }
+    }
+    else if (dimension->flipping_order == MI_NEGATIVE) {
+      if (dimension->step < 0) {
+	*start_ptr = dimension->start;
+      }
+      else {
     
-    *start_ptr = dimension->start + (dimension->step * (dimension->length-1));
-  }
+	*start_ptr = dimension->start + (dimension->step * (dimension->length-1));
+      }
+    }
+ }
   return (MI_NOERROR);
 }
 
--- a/libsrc2/hyper.c
+++ b/libsrc2/hyper.c
@@ -729,6 +729,11 @@
     int result;
     int is_signed;
     int nctype;
+    int i;
+
+    int ndims = volume->number_of_dims;
+    midimhandle_t hdim;
+
 
     file_id = volume->hdf_id;
 
@@ -744,7 +749,30 @@
     miicv_setstr(icv, MI_ICV_SIGN, is_signed ? MI_SIGNED : MI_UNSIGNED);
     miicv_setint(icv, MI_ICV_DO_RANGE, TRUE);
     miicv_setint(icv, MI_ICV_DO_NORM, TRUE);
+    miicv_setint(icv, MI_ICV_DO_DIM_CONV, FALSE);
+    //figure out whether we need to flip image    L.B May 18/2011
+    for (i=0; i < volume->number_of_dims; i++)
+      {
+        midimhandle_t hdim;
 
+	hdim = volume->dim_handles[i];
+	switch (hdim->flipping_order) {
+	case MI_FILE_ORDER:
+	  miicv_setint(icv, MI_ICV_DO_DIM_CONV, FALSE);
+	   break;
+	case MI_COUNTER_FILE_ORDER:
+	case MI_POSITIVE:
+	  if (hdim->step < 0)
+	    miicv_setint(icv, MI_ICV_DO_DIM_CONV, TRUE);
+	  break;
+	case MI_NEGATIVE: 
+	  if (hdim->step > 0)
+	    miicv_setint(icv, MI_ICV_DO_DIM_CONV, TRUE);
+	  break;
+	default:
+	  return;
+	}
+      }
     result = miicv_attach(icv, file_id, var_id);
     if (result == MI_NOERROR) {
 	result = mirw_hyperslab_icv(MIRW_OP_READ,
--- a/progs/minccalc/minccalc.c
+++ b/progs/minccalc/minccalc.c
@@ -162,7 +162,7 @@
 static int check_dim_info = TRUE;
 static int copy_all_header = DEFAULT_BOOL;
 static int use_nan_for_illegal_values = TRUE;
-static int max_buffer_size_in_kb = 4 * 1024;
+static int max_buffer_size_in_kb = 0;
 static double valid_range[2] = {0.0, 0.0};
 double value_for_illegal_operations = DEFAULT_DBL;
 static nc_type datatype = MI_ORIGINAL_TYPE;
@@ -412,7 +412,12 @@
    set_loop_datatype(loop_options, datatype, is_signed, 
                      valid_range[0], valid_range[1]);
    set_loop_copy_all_header(loop_options, copy_all_header);
-   set_loop_buffer_size(loop_options, (long) 1024 * max_buffer_size_in_kb);
+   
+   /* only set buffer size if specified */
+   if(max_buffer_size_in_kb != 0){
+      set_loop_buffer_size(loop_options, (long) 1024 * max_buffer_size_in_kb);
+      }
+   
    set_loop_check_dim_info(loop_options, check_dim_info);
    voxel_loop(nfiles, infiles, nout, outfiles, arg_string, loop_options,
               do_math, NULL);