next up previous contents
Next: Multiresolution, blocking and compression Up: MINC 2.0 User's Guide Previous: Hyperslab, real data functions   Contents

Volume creation

After all the required dimension handles are defined/assigned with their appropriate class and attribute, the MINC 2.0 file can be created by calling the following:
      micreate_volume(const char *filename, 
                      int number_of_dimensions,
                      midimhandle_t dimensions[], 
                      mitype_t volume_type,
                      miclass_t volume_class, 
                      mivolumeprops_t create_props,
                      mihandle_t *volume)
where filename, number of dimensions, an array of dimension handles, volume type, volume class and finally volume properties are the given parameters and the file handle will be the retrieved parameter after the file is successfully created. micreate_volume creates the file template (i.e, all the information about the actual image, its dimensions etc) but not the actual image file itself. To Create the actual image for the file, after the file template is created use the following
         micreate_volume_image(mihandle_t volume)
where the handle is the one retrieved by calling the previous function. Here is an example showing the use of these two functions:

#include <minc2.h>

main() {

    int result;
    mihandle_t hvol;
    midimhandle_t dim[3];
    mivolumeprops_t props;

    result = minew_volume_props(&props);
    result = miset_props_compression_type(props, 
                                     MI_COMPRESS_ZLIB);
    result = miset_props_zlib_compression(props, 3);
    result = miset_props_multi_resolution(props, 1, 3);
    
    if (result < 0) {
      TESTRPT("failed", result);
    }
  
    result = micreate_dimension("xspace",MI_DIMCLASS_SPATIAL,
                                MI_DIMATTR_REGULARLY_SAMPLED, 
                                10,&dim[0]);
    if (result < 0) {
      TESTRPT("failed", result);
    }
    result = micreate_dimension("yspace",MI_DIMCLASS_SPATIAL,
                                MI_DIMATTR_REGULARLY_SAMPLED, 
                                10,&dim[1]);
    if (result < 0) {
      TESTRPT("failed", result);
    }
    result = micreate_dimension("zspace",MI_DIMCLASS_SPATIAL,
                                MI_DIMATTR_REGULARLY_SAMPLED, 
                                6,&dim[2]);
    if (result < 0) {
      TESTRPT("failed", result);
    }

    result = micreate_volume("test_multi_h5.mnc", 3, dim, 
                             MI_TYPE_UINT, MI_CLASS_REAL,
                             props,&hvol);
    if (result < 0) {
      TESTRPT("failed", result);
    }

    result = micreate_volume_image(hvol);
    if (result < 0) {
    TESTRPT("failed", result);
    }
   
}



Robert VINCENT 2004-05-28