VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/IO/Image/vtkNIFTIImagePrivate.h
Go to the documentation of this file.
00001 #ifndef _NIFTI_HEADER_
00002 #define _NIFTI_HEADER_
00003 
00004 /*****************************************************************************
00005       ** This file defines the "NIFTI-1" header format.               **
00006       ** It is derived from 2 meetings at the NIH (31 Mar 2003 and    **
00007       ** 02 Sep 2003) of the Data Format Working Group (DFWG),        **
00008       ** chartered by the NIfTI (Neuroimaging Informatics Technology  **
00009       ** Initiative) at the National Institutes of Health (NIH).      **
00010       **--------------------------------------------------------------**
00011       ** Neither the National Institutes of Health (NIH), the DFWG,   **
00012       ** nor any of the members or employees of these institutions    **
00013       ** imply any warranty of usefulness of this material for any    **
00014       ** purpose, and do not assume any liability for damages,        **
00015       ** incidental or otherwise, caused by any use of this document. **
00016       ** If these conditions are not acceptable, do not use this!     **
00017       **--------------------------------------------------------------**
00018       ** Author:   Robert W Cox (NIMH, Bethesda)                      **
00019       ** Advisors: John Ashburner (FIL, London),                      **
00020       **           Stephen Smith (FMRIB, Oxford),                     **
00021       **           Mark Jenkinson (FMRIB, Oxford)                     **
00022 ******************************************************************************/
00023 
00024 /*=================*/
00025 #ifdef  __cplusplus
00026 extern "C" {
00027 #endif
00028 /*=================*/
00029 
00035                         /*************************/  /************/
00036 struct nifti_1_header { /* NIFTI-1 usage         */  /*  offset  */
00037                         /*************************/  /************/
00038 
00039   int   sizeof_hdr;      /*   0 */
00040   char  data_type[10];   /*   4 */
00041   char  db_name[18];     /*  14 */
00042   int   extents;         /*  32 */
00043   short session_error;   /*  36 */
00044   char  regular;         /*  38 */
00045   char  dim_info;        /*  39 */
00046   short dim[8];          /*  40 */
00047   float intent_p1;       /*  56 */
00048   float intent_p2;       /*  60 */
00049   float intent_p3;       /*  64 */
00050   short intent_code;     /*  68 */
00051   short datatype;        /*  70 */
00052   short bitpix;          /*  72 */
00053   short slice_start;     /*  74 */
00054   float pixdim[8];       /*  76 */
00055   float vox_offset;      /* 108 */
00056   float scl_slope;       /* 112 */
00057   float scl_inter;       /* 116 */
00058   short slice_end;       /* 120 */
00059   char  slice_code;      /* 122 */
00060   char  xyzt_units;      /* 123 */
00061   float cal_max;         /* 124 */
00062   float cal_min;         /* 128 */
00063   float slice_duration;  /* 132 */
00064   float toffset;         /* 136 */
00065   int   glmax;           /* 140 */
00066   int   glmin;           /* 144 */
00067   char  descrip[80];     /* 148 */
00068   char  aux_file[24];    /* 228 */
00069   short qform_code;      /* 252 */
00070   short sform_code;      /* 254 */
00071   float quatern_b;       /* 256 */
00072   float quatern_c;       /* 260 */
00073   float quatern_d;       /* 264 */
00074   float qoffset_x;       /* 268 */
00075   float qoffset_y;       /* 272 */
00076   float qoffset_z;       /* 276 */
00077   float srow_x[4];       /* 280 */
00078   float srow_y[4];       /* 296 */
00079   float srow_z[4];       /* 312 */
00080   char intent_name[16];  /* 328 */
00081   char magic[4];         /* 344 */
00082 
00083 };                    /**** 348 bytes total ****/
00084 
00085 typedef struct nifti_1_header nifti_1_header;
00086 
00087 /*---------------------------------------------------------------------------*/
00088 /* TYPE OF DATA (acceptable values for datatype field):
00089    ---------------------------------------------------
00090    Values of datatype smaller than 256 are ANALYZE 7.5 compatible.
00091    Larger values are NIFTI-1 additions.  These are all multiples of 256, so
00092    that no bits below position 8 are set in datatype.  But there is no need
00093    to use only powers-of-2, as the original ANALYZE 7.5 datatype codes do.
00094 
00095    The additional codes are intended to include a complete list of basic
00096    scalar types, including signed and unsigned integers from 8 to 64 bits,
00097    floats from 32 to 128 bits, and complex (float pairs) from 64 to 256 bits.
00098 
00099    Note that most programs will support only a few of these datatypes!
00100    A NIFTI-1 program should fail gracefully (e.g., print a warning message)
00101    when it encounters a dataset with a type it doesn't like.
00102 -----------------------------------------------------------------------------*/
00103 
00109 #define NIFTI_TYPE_UINT8           2
00110 
00111 #define NIFTI_TYPE_INT16           4
00112 
00113 #define NIFTI_TYPE_INT32           8
00114 
00115 #define NIFTI_TYPE_FLOAT32        16
00116 
00117 #define NIFTI_TYPE_COMPLEX64      32
00118 
00119 #define NIFTI_TYPE_FLOAT64        64
00120 
00121 #define NIFTI_TYPE_RGB24         128
00122 
00123 #define NIFTI_TYPE_INT8          256
00124 
00125 #define NIFTI_TYPE_UINT16        512
00126 
00127 #define NIFTI_TYPE_UINT32        768
00128 
00129 #define NIFTI_TYPE_INT64        1024
00130 
00131 #define NIFTI_TYPE_UINT64       1280
00132 
00133 #define NIFTI_TYPE_FLOAT128     1536
00134 
00135 #define NIFTI_TYPE_COMPLEX128   1792
00136 
00137 #define NIFTI_TYPE_COMPLEX256   2048
00138 
00139 #define NIFTI_TYPE_RGBA32       2304
00140 /* @} */
00141 
00142 
00143 /*---------------------------------------------------------------------------*/
00144 /* MISCELLANEOUS C MACROS
00145 -----------------------------------------------------------------------------*/
00146 
00147 /*.................*/
00151 #define NIFTI_VERSION(h)                               \
00152  ( ( (h).magic[0]=='n' && (h).magic[3]=='\0'    &&     \
00153      ( (h).magic[1]=='i' || (h).magic[1]=='+' ) &&     \
00154      ( (h).magic[2]>='1' && (h).magic[2]<='9' )   )    \
00155  ? (h).magic[2]-'0' : 0 )
00156 
00157 /*.................*/
00162 #define NIFTI_ONEFILE(h) ( (h).magic[1] == '+' )
00163 
00164 /*.................*/
00168 #define NIFTI_NEEDS_SWAP(h) ( (h).dim[0] < 0 || (h).dim[0] > 7 )
00169 
00170 
00171 /*=================*/
00172 #ifdef  __cplusplus
00173 }
00174 #endif
00175 /*=================*/
00176 
00177 #endif /* _NIFTI_HEADER_ */
00178 
00179 #ifndef __NIFTI2_HEADER
00180 #define __NIFTI2_HEADER
00181 
00182 /*---------------------------------------------------------------------------*/
00183 /* Changes to the header from NIFTI-1 to NIFTI-2 are intended to allow for
00184    larger and more accurate fields.  The changes are as follows:
00185 
00186       - short dim[8]         -> int64_t dim[8]
00187       - float intent_p1,2,3  -> double intent_p1,2,3    (3 fields)
00188       - float pixdim[8]      -> double pixdim[8]
00189       - float vox_offset     -> int64_t vox_offset
00190       - float scl_slope      -> double scl_slope
00191       - float scl_inter      -> double scl_inter
00192       - float cal_max        -> double cal_max
00193       - float cal_min        -> double cal_min
00194       - float slice_duration -> double slice_duration
00195       - float toffset        -> double toffset
00196       - short slice_start    -> int64_t slice_start
00197       - short slice_end      -> int64_t slice_end
00198       - char slice_code      -> int32_t slice_code
00199       - char xyzt_units      -> int32_t xyzt_units
00200       - short intent_code    -> int32_t intent_code
00201       - short qform_code     -> int32_t qform_code
00202       - short sform_code     -> int32_t sform_code
00203       - float quatern_b,c,d  -> double quatern_b,c,d    (3 fields)
00204       - float srow_x,y,z[4]  -> double srow_x,y,z[4]    (3 fields)
00205       - char magic[4]        -> char magic[8]
00206       - char unused_str[15]  -> padding added at the end of the header
00207 
00208       - previously unused fields have been removed:
00209            data_type, db_name, extents, session_error, regular, glmax, glmin
00210 
00211       - the field ordering has been changed
00212 -----------------------------------------------------------------------------*/
00213 
00214 /*=================*/
00215 #ifdef  __cplusplus
00216 extern "C" {
00217 #endif
00218 /*=================*/
00219 
00226                         /*************************/  /************/
00227 struct nifti_2_header { /* NIFTI-2 usage         */  /*  offset  */
00228                         /*************************/  /************/
00229   int   sizeof_hdr;        /*   0 */
00230   char  magic[8];        /*   4 */
00231   short datatype;          /*  12 */
00232   short bitpix;            /*  14 */
00233   long long dim[8];        /*  16 */
00234   double intent_p1;        /*  80 */
00235   double intent_p2;        /*  88 */
00236   double intent_p3;        /*  96 */
00237   double pixdim[8];        /* 104 */
00238   long long vox_offset;    /* 168 */
00239   double scl_slope;        /* 176 */
00240   double scl_inter;        /* 184 */
00241   double cal_max;          /* 192 */
00242   double cal_min;          /* 200 */
00243   double slice_duration;   /* 208 */
00244   double toffset;          /* 216 */
00245   long long slice_start;   /* 224 */
00246   long long slice_end;     /* 232 */
00247   char descrip[80];        /* 240 */
00248   char aux_file[24];       /* 320 */
00249   int qform_code;          /* 344 */
00250   int sform_code;          /* 348 */
00251   double quatern_b;        /* 352 */
00252   double quatern_c;        /* 360 */
00253   double quatern_d;        /* 368 */
00254   double qoffset_x;        /* 376 */
00255   double qoffset_y;        /* 384 */
00256   double qoffset_z;        /* 392 */
00257   double srow_x[4];      /* 400 */
00258   double srow_y[4];      /* 432 */
00259   double srow_z[4];      /* 464 */
00260   int slice_code;          /* 496 */
00261   int xyzt_units;          /* 500 */
00262   int intent_code;         /* 504 */
00263   char intent_name[16];   /* 508 */
00264   char dim_info;           /* 524 */
00265   char unused_str[15];    /* 525 */
00266 };                    /**** 540 bytes total ****/
00267 
00268 typedef struct nifti_2_header nifti_2_header;
00269 
00270 /*=================*/
00271 #ifdef  __cplusplus
00272 }
00273 #endif
00274 /*=================*/
00275 
00276 #endif /* __NIFTI2_HEADER */
00277 // VTK-HeaderTest-Exclude: vtkNIFTIImagePrivate.h