1 #ifndef  MINC_STRUCTURES_HEADER_FILE
2 #define  MINC_STRUCTURES_HEADER_FILE
3 
4 /* ----------------------------- MNI Header -----------------------------------
5 @NAME       : minc_structures.h
6 @INPUT      :
7 @OUTPUT     :
8 @RETURNS    :
9 @DESCRIPTION: Defines structures for use by MINC routines
10 @METHOD     :
11 @GLOBALS    :
12 @CALLS      :
13 @CREATED    : August 28, 1992 (Peter Neelin)
14 @MODIFIED   :
15  * $Log: minc_structures.h,v $
16  * Revision 6.1  1999-10-19 14:45:10  neelin
17  * Fixed Log subsitutions for CVS
18  *
19  * Revision 6.0  1997/09/12 13:24:54  neelin
20  * Release of minc version 0.6
21  *
22  * Revision 5.0  1997/08/21  13:25:53  neelin
23  * Release of minc version 0.5
24  *
25  * Revision 4.0  1997/05/07  20:07:52  neelin
26  * Release of minc version 0.4
27  *
28  * Revision 3.1  1997/04/10  18:14:50  neelin
29  * Fixed handling of invalid data when icv scale is zero.
30  *
31  * Revision 3.0  1995/05/15  19:33:12  neelin
32  * Release of minc version 0.3
33  *
34  * Revision 2.0  1994/09/28  10:38:09  neelin
35  * Release of minc version 0.2
36  *
37  * Revision 1.10  94/09/28  10:37:30  neelin
38  * Pre-release
39  *
40  * Revision 1.9  93/08/11  12:06:42  neelin
41  * Added RCS logging in source.
42  *
43 @COPYRIGHT  :
44               Copyright 1993 Peter Neelin, McConnell Brain Imaging Centre,
45               Montreal Neurological Institute, McGill University.
46               Permission to use, copy, modify, and distribute this
47               software and its documentation for any purpose and without
48               fee is hereby granted, provided that the above copyright
49               notice appear in all copies.  The author and McGill University
50               make no representations about the suitability of this
51               software for any purpose.  It is provided "as is" without
52               express or implied warranty.
53 @RCSID      : $Header: /private-cvsroot/minc/libsrc/minc_structures.h,v 6.1 1999-10-19 14:45:10 neelin Exp $ MINC (MNI)
54 ---------------------------------------------------------------------------- */
55 
56 /* Image conversion variable structure type */
57 
58 typedef struct mi_icv_struct mi_icv_type;
59 
60 struct mi_icv_struct {
61 
62    /* semiprivate : fields available to the package */
63 
64    int     do_scale;       /* Indicates to MI_convert_type that scaling should
65                               be done */
66    double  scale;          /* For scaling in MI_convert_type */
67    double  offset;
68    int     do_dimconvert;  /* Indicates that dimensional conversion function
69                               should be given */
70    int   (*dimconvert_func) (int operation, mi_icv_type *icvp,
71                              long start[], long count[], void *values,
72                              long bufstart[], long bufcount[], void *buffer);
73    int     do_fillvalue;   /* Indicates to MI_convert_type that fillvalue
74                               checking should be done */
75    double  fill_valid_min; /* Range limits for fillvalue checking */
76    double  fill_valid_max;
77 
78    /* private : fields available only to icv routines */
79 
80    /* Fields that hold values passed by user */
81    nc_type user_type;      /* Type to that user wants */
82    int     user_typelen;   /* Length of type in bytes */
83    int     user_sign;      /* Sign that user wants */
84    int     user_do_range;  /* Does the user want range scaling? */
85    double  user_vmax;      /* Range of values that user wants */
86    double  user_vmin;
87    int     user_do_norm;   /* Indicates that user wants value normalization */
88    int     user_user_norm; /* If TRUE, user specifies range for norm, otherwise
89                                  norm is taken from variable range */
90    char    *user_maxvar;   /* Name of MIimagemax variable */
91    char    *user_minvar;   /* Name of MIimagemin variable */
92    double  user_imgmax;    /* Range for normalization */
93    double  user_imgmin;
94    int     user_do_dimconv; /* Indicates that user wants to do dimension
95                                conversion stuff */
96    int     user_do_scalar; /* Indicates that user wants scalar fields */
97    int     user_xdim_dir;  /* Direction for x, y and z dimensions */
98    int     user_ydim_dir;
99    int     user_zdim_dir;
100    int     user_num_imgdims; /* Number of image (fastest varying) dimensions */
101    long    user_dim_size[MI_MAX_IMGDIMS]; /* Size of fastest varying
102                                               dimensions for user */
103    int     user_keep_aspect; /* Indicates that user wants to preserve the
104                                 aspect ratio when resizing images */
105    int     user_do_fillvalue; /* Indicates that user wants fillvalue checking
106                                  to be done */
107    double  user_fillvalue;    /* Fillvalue that user wants */
108 
109    /* Fields that hold values from real variable */
110    int     cdfid;          /* Id of cdf */
111    int     varid;          /* Id of variable */
112    int     imgmaxid;       /* Id of MIimagemax */
113    int     imgminid;       /* Id of Miimagemin */
114    int     var_ndims;      /* Number of dimensions of variable */
115    int     var_dim[MAX_VAR_DIMS]; /* Dimensions of variable */
116    nc_type var_type;       /* Variable type */
117    int     var_typelen;    /* Length of type in bytes */
118    int     var_sign;       /* Variable sign */
119    double  var_vmax;       /* Range of values in variable */
120    double  var_vmin;
121    int     var_is_vector;  /* Is this variable a vector field */
122    long    var_vector_size; /* Size of vector dimension */
123    long    var_dim_size[MI_MAX_IMGDIMS]; /* Size of image dimensions in
124                                              variable */
125 
126    /* Fields derived from user values and variable values */
127    int     derv_usr_float; /* Are user or variable values floating point? */
128    int     derv_var_float;
129    double  derv_imgmax;    /* Range for normalization */
130    double  derv_imgmin;
131    int     derv_firstdim;  /* First dimension (counting from fastest, ie.
132                                  backwards) over which MIimagemax or
133                                  MIimagemin vary */
134    int     derv_do_zero;   /* Indicates if we should zero user's buffer
135                               on GETs */
136    int     derv_do_bufsize_step; /* Indicates if we need to worry about
137                                     bufsize_step */
138    int     derv_bufsize_step[MAX_VAR_DIMS];  /* Array of convenient multiples
139                                                 for buffer allocation */
140    int     derv_var_compress; /* Indicate need for compressing variable or */
141    int     derv_usr_compress;    /* user buffer */
142    int     derv_dimconv_fastdim;  /* Fastest varying dimensions for dimension
143                                      conversion */
144    long    derv_var_pix_num; /* Number of pixels to compress/expand for */
145    long   *derv_var_pix_off;    /* variable and user buffers, as well as */
146    long    derv_usr_pix_num;    /* pointers to arrays of offsets */
147    long   *derv_usr_pix_off;
148    long    derv_icv_start[MAX_VAR_DIMS]; /* Space for storing parameters to */
149    long    derv_icv_count[MAX_VAR_DIMS]; /* MI_icv_access */
150 
151                            /* Stuff that affects first user_num_imgdims
152                               (excluding any vector dimension) as image
153                               dimensions */
154    int     derv_dim_flip[MI_MAX_IMGDIMS];   /* Flip dimension? */
155    int     derv_dim_grow[MI_MAX_IMGDIMS];   /* Expand variable to fit user's
156                                                 array? */
157    int     derv_dim_scale[MI_MAX_IMGDIMS];  /* Grow/shrink scale factor */
158    int     derv_dim_off[MI_MAX_IMGDIMS];    /* Pixels to skip in user's
159                                                 image */
160    double  derv_dim_step[MI_MAX_IMGDIMS];   /* Step, start for user's image
161                                                 (analogous to MIstep,
162                                                 MIstart) for first
163                                                 user_num_imgdims dims */
164    double  derv_dim_start[MI_MAX_IMGDIMS];
165 };
166 
167 /* Structure for passing values for MI_varaccess */
168 typedef struct {
169    int operation;
170    int cdfid;
171    int varid;
172    nc_type var_type, call_type;
173    int var_sign, call_sign;
174    int var_value_size, call_value_size;
175    mi_icv_type *icvp;
176    int do_scale;
177    int do_dimconvert;
178    int do_fillvalue;
179    long *start, *count;
180    void *values;
181 } mi_varaccess_type;
182 
183 /* Structure for passing values for micopy_var_values */
184 typedef struct {
185    int value_size;            /* Size of each value */
186    int incdfid, outcdfid;     /* Input and output cdf files */
187    int invarid, outvarid;     /* Input and output variables */
188 } mi_vcopy_type;
189 
190 /* Structure for passing values for MI_icv_dimconvert */
191 typedef struct {
192    int do_compress, do_expand;
193    long end[MAX_VAR_DIMS];
194    long in_pix_num,     out_pix_num; /* Variables for compressing/expanding */
195    long *in_pix_off,   *out_pix_off;
196    void *in_pix_first, *out_pix_first;
197    void *in_pix_last,  *out_pix_last;
198    nc_type intype, outtype;     /* Variable types and signs */
199    int insign, outsign;
200    long buf_step[MAX_VAR_DIMS];    /* Step sizes for pointers */
201    long usr_step[MAX_VAR_DIMS];
202    long *istep, *ostep;
203    void *istart, *ostart;       /* Beginning of buffers */
204 } mi_icv_dimconv_type;
205 
206 #endif
207