[MINC-development] learning minc IO procedures

Richard Beare Richard.Beare@ieee.org
Thu, 14 Jul 2005 15:49:09 +1000


Dear minc developers,

I've recently joined Prof Reuten's group at Monash Uni, Australia, and
I'm trying to experiment with some of the low level tools in minc2.
I'm starting with the basics and trying to just query a minc2 file
starting with one of the test files from the minc2 distribution, but
I'm having trouble.

Here's what I did - I'd appreciate any pointers.

1) Installed minc-2.0.08

2) Converted a minc1 file using mincconvert

mincconvert -t /tmp/7.mnc /tmp/8.mnc

3) Confirmed that it is a version 2 file

h5dump /tmp/8.mnc | head

HDF5 "/tmp/8.mnc" {
GROUP "/" {
   GROUP "minc-2.0" {
      ATTRIBUTE "ident" {
         DATATYPE  H5T_STRING {
               STRSIZE 44;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }

4) Produced a modified version of volprops-test.c (below), compiled and ran it:

5) So the question is - should I be using the miopen_volume as per the
examples, or am I better off using some other approach.

My aim in this exercise is to produce a reader for ITK, as a way of
learning both ITK and about minc.

./volprops-test

HDF5-DIAG: Error detected in HDF5 library version: 1.6.4 thread
46912498417408.  Back trace follows.
  #000: H5D.c line 1239 in H5Dget_space(): not a dataset
    major(01): Function arguments
    minor(03): Inappropriate type
HDF5-DIAG: Error detected in HDF5 library version: 1.6.4 thread
46912498417408.  Back trace follows.
  #000: H5D.c line 1191 in H5Dclose(): not a dataset
    major(01): Function arguments
    minor(03): Inappropriate type
HDF5-DIAG: Error detected in HDF5 library version: 1.6.4 thread
46912498417408.  Back trace follows.
  #000: H5D.c line 1469 in H5Dget_create_plist(): not a dataset
    major(01): Function arguments
    minor(03): Inappropriate type
Error reported on line #31, failed: -1
Segmentation fault (core dumped)

#include <stdio.h>
#include "minc2.h"

#define TESTRPT(msg, val) (error_cnt++, fprintf(stderr, \
                                  "Error reported on line #%d, %s: %d\n", \
                                  __LINE__, msg, val))

static int error_cnt = 0;


int main(int argc, char **argv)
{
  mihandle_t vol;
  mivolumeprops_t  props;
  int r;
  micompression_t compression_type;
  BOOLEAN enable_flag;
  int zlib_level;
  int depth;
  int edge_lengths[MI2_MAX_VAR_DIMS];
  int edge_count;
  int i;

  //  fprintf(stderr, "%s\n", *++argv);
  r = miopen_volume("/tmp/8.mnc", MI2_OPEN_READ, &vol);
  if (r < 0) {
    TESTRPT("failed", r);
  }
  r = miget_volume_props(vol, &props);
  if (r < 0) {
    TESTRPT("failed", r);
  }
  r = miget_props_blocking(props, &edge_count, edge_lengths, 
			   MI2_MAX_VAR_DIMS);
  if (r < 0) {
    TESTRPT("failed", r);
  }
  printf("edge_count %d\n", edge_count);
  for (i = 0; i < edge_count; i++) {
    printf("  %d", edge_lengths[i]);
  }
  printf("\n");
  mifree_volume_props(props);
  miclose_volume(vol);

  
  if (error_cnt != 0) {
    fprintf(stderr, "%d error%s reported\n", 
	    error_cnt, (error_cnt == 1) ? "" : "s");
  }
  else {
    fprintf(stderr, "No errors\n");
  }
  return (error_cnt);
}


All advice welcome