next up previous contents
Next: Dimension and voxel ordering Up: Dimensions and coordinate systems Previous: Voxel and World Coordinate   Contents

Coding Examples

MINC 2 files can define any number of dimensions. In MINC 2 library, a dimension is represented by an opaque datatype called a dimension handle, which is defined by the ``C'' typedef midimhandle_t. Through the use of the dimension handle, the user can access and modify all dimension properties.

Only four essential properties must be specified prior to creating a new dimension. Other properties will be set to default values which can be changed individually after the dimension is created.

 micreate_dimension(const char *name, midimclass_t class, 
                    midimattr_t attr,unsigned long length, 
                    midimhandle_t *new_dim_ptr);
Accessing or modifying any of the dimension properties is done by using

miget_dimension_ property()
miset_dimension_ property()
where ``property'' can be replaced with any of the dimension properties. For Example,

miget_dimension_units(midimhandle_t dimension, 
                      char **units_ptr);
miset_dimension_units(midimhandle_t dimension, 
                      const char *units);

you can retrieve the dimensions associated with an open MINC file using the function:

miget_volume_dimensions(mihandle_t hvol, midimclass_t class,
                        midimattr_t attr, miorder_t order,
                        int max_dims, midimhandle_t dims[]);

where miorder_t is an enumerated type flag which determines whether the dimension order is determined by the file (i.e., the order the dimensions were created) or by the apparent order (i.e., any order other than the file order) which must be set by the user.

Finally, to release the memory associated with a dimension, the dimension handle must be passed to mifree_dimension_handle().
Note that calling mifree_dimension_handle() on a dimension that is associated with a volume will result in an error.

      mifree_dimension_handle(midimhandle_t dim_ptr)

next up previous contents
Next: Dimension and voxel ordering Up: Dimensions and coordinate systems Previous: Voxel and World Coordinate   Contents
Robert VINCENT 2004-05-28