VTK
vtkNIFTIImagePrivate.h
Go to the documentation of this file.
1 #ifndef _NIFTI_HEADER_
2 #define _NIFTI_HEADER_
3 
4 /*****************************************************************************
5  ** This file defines the "NIFTI-1" header format. **
6  ** It is derived from 2 meetings at the NIH (31 Mar 2003 and **
7  ** 02 Sep 2003) of the Data Format Working Group (DFWG), **
8  ** chartered by the NIfTI (Neuroimaging Informatics Technology **
9  ** Initiative) at the National Institutes of Health (NIH). **
10  **--------------------------------------------------------------**
11  ** Neither the National Institutes of Health (NIH), the DFWG, **
12  ** nor any of the members or employees of these institutions **
13  ** imply any warranty of usefulness of this material for any **
14  ** purpose, and do not assume any liability for damages, **
15  ** incidental or otherwise, caused by any use of this document. **
16  ** If these conditions are not acceptable, do not use this! **
17  **--------------------------------------------------------------**
18  ** Author: Robert W Cox (NIMH, Bethesda) **
19  ** Advisors: John Ashburner (FIL, London), **
20  ** Stephen Smith (FMRIB, Oxford), **
21  ** Mark Jenkinson (FMRIB, Oxford) **
22 ******************************************************************************/
23 
24 /*=================*/
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 /*=================*/
29 
35  /*************************/ /************/
36 struct nifti_1_header { /* NIFTI-1 usage */ /* offset */
37  /*************************/ /************/
38 
39  int sizeof_hdr; /* 0 */
40  char data_type[10]; /* 4 */
41  char db_name[18]; /* 14 */
42  int extents; /* 32 */
43  short session_error; /* 36 */
44  char regular; /* 38 */
45  char dim_info; /* 39 */
46  short dim[8]; /* 40 */
47  float intent_p1; /* 56 */
48  float intent_p2; /* 60 */
49  float intent_p3; /* 64 */
50  short intent_code; /* 68 */
51  short datatype; /* 70 */
52  short bitpix; /* 72 */
53  short slice_start; /* 74 */
54  float pixdim[8]; /* 76 */
55  float vox_offset; /* 108 */
56  float scl_slope; /* 112 */
57  float scl_inter; /* 116 */
58  short slice_end; /* 120 */
59  char slice_code; /* 122 */
60  char xyzt_units; /* 123 */
61  float cal_max; /* 124 */
62  float cal_min; /* 128 */
63  float slice_duration; /* 132 */
64  float toffset; /* 136 */
65  int glmax; /* 140 */
66  int glmin; /* 144 */
67  char descrip[80]; /* 148 */
68  char aux_file[24]; /* 228 */
69  short qform_code; /* 252 */
70  short sform_code; /* 254 */
71  float quatern_b; /* 256 */
72  float quatern_c; /* 260 */
73  float quatern_d; /* 264 */
74  float qoffset_x; /* 268 */
75  float qoffset_y; /* 272 */
76  float qoffset_z; /* 276 */
77  float srow_x[4]; /* 280 */
78  float srow_y[4]; /* 296 */
79  float srow_z[4]; /* 312 */
80  char intent_name[16]; /* 328 */
81  char magic[4]; /* 344 */
82 
83 }; /**** 348 bytes total ****/
84 
86 
87 /*---------------------------------------------------------------------------*/
88 /* TYPE OF DATA (acceptable values for datatype field):
89  ---------------------------------------------------
90  Values of datatype smaller than 256 are ANALYZE 7.5 compatible.
91  Larger values are NIFTI-1 additions. These are all multiples of 256, so
92  that no bits below position 8 are set in datatype. But there is no need
93  to use only powers-of-2, as the original ANALYZE 7.5 datatype codes do.
94 
95  The additional codes are intended to include a complete list of basic
96  scalar types, including signed and unsigned integers from 8 to 64 bits,
97  floats from 32 to 128 bits, and complex (float pairs) from 64 to 256 bits.
98 
99  Note that most programs will support only a few of these datatypes!
100  A NIFTI-1 program should fail gracefully (e.g., print a warning message)
101  when it encounters a dataset with a type it doesn't like.
102 -----------------------------------------------------------------------------*/
103 
109 #define NIFTI_TYPE_UINT8 2
110 
111 #define NIFTI_TYPE_INT16 4
112 
113 #define NIFTI_TYPE_INT32 8
114 
115 #define NIFTI_TYPE_FLOAT32 16
116 
117 #define NIFTI_TYPE_COMPLEX64 32
118 
119 #define NIFTI_TYPE_FLOAT64 64
120 
121 #define NIFTI_TYPE_RGB24 128
122 
123 #define NIFTI_TYPE_INT8 256
124 
125 #define NIFTI_TYPE_UINT16 512
126 
127 #define NIFTI_TYPE_UINT32 768
128 
129 #define NIFTI_TYPE_INT64 1024
130 
131 #define NIFTI_TYPE_UINT64 1280
132 
133 #define NIFTI_TYPE_FLOAT128 1536
134 
135 #define NIFTI_TYPE_COMPLEX128 1792
136 
137 #define NIFTI_TYPE_COMPLEX256 2048
138 
139 #define NIFTI_TYPE_RGBA32 2304
140 /* @} */
141 
142 
143 /*---------------------------------------------------------------------------*/
144 /* MISCELLANEOUS C MACROS
145 -----------------------------------------------------------------------------*/
146 
147 /*.................*/
151 #define NIFTI_VERSION(h) \
152  ( ( (h).magic[0]=='n' && (h).magic[3]=='\0' && \
153  ( (h).magic[1]=='i' || (h).magic[1]=='+' ) && \
154  ( (h).magic[2]>='1' && (h).magic[2]<='9' ) ) \
155  ? (h).magic[2]-'0' : 0 )
156 
157 /*.................*/
162 #define NIFTI_ONEFILE(h) ( (h).magic[1] == '+' )
163 
164 /*.................*/
168 #define NIFTI_NEEDS_SWAP(h) ( (h).dim[0] < 0 || (h).dim[0] > 7 )
169 
170 
171 /*=================*/
172 #ifdef __cplusplus
173 }
174 #endif
175 /*=================*/
176 
177 #endif /* _NIFTI_HEADER_ */
178 
179 #ifndef __NIFTI2_HEADER
180 #define __NIFTI2_HEADER
181 
182 /*---------------------------------------------------------------------------*/
183 /* Changes to the header from NIFTI-1 to NIFTI-2 are intended to allow for
184  larger and more accurate fields. The changes are as follows:
185 
186  - short dim[8] -> int64_t dim[8]
187  - float intent_p1,2,3 -> double intent_p1,2,3 (3 fields)
188  - float pixdim[8] -> double pixdim[8]
189  - float vox_offset -> int64_t vox_offset
190  - float scl_slope -> double scl_slope
191  - float scl_inter -> double scl_inter
192  - float cal_max -> double cal_max
193  - float cal_min -> double cal_min
194  - float slice_duration -> double slice_duration
195  - float toffset -> double toffset
196  - short slice_start -> int64_t slice_start
197  - short slice_end -> int64_t slice_end
198  - char slice_code -> int32_t slice_code
199  - char xyzt_units -> int32_t xyzt_units
200  - short intent_code -> int32_t intent_code
201  - short qform_code -> int32_t qform_code
202  - short sform_code -> int32_t sform_code
203  - float quatern_b,c,d -> double quatern_b,c,d (3 fields)
204  - float srow_x,y,z[4] -> double srow_x,y,z[4] (3 fields)
205  - char magic[4] -> char magic[8]
206  - char unused_str[15] -> padding added at the end of the header
207 
208  - previously unused fields have been removed:
209  data_type, db_name, extents, session_error, regular, glmax, glmin
210 
211  - the field ordering has been changed
212 -----------------------------------------------------------------------------*/
213 
214 /*=================*/
215 #ifdef __cplusplus
216 extern "C" {
217 #endif
218 /*=================*/
219 
226  /*************************/ /************/
227 struct nifti_2_header { /* NIFTI-2 usage */ /* offset */
228  /*************************/ /************/
229  int sizeof_hdr; /* 0 */
230  char magic[8]; /* 4 */
231  short datatype; /* 12 */
232  short bitpix; /* 14 */
233  long long dim[8]; /* 16 */
234  double intent_p1; /* 80 */
235  double intent_p2; /* 88 */
236  double intent_p3; /* 96 */
237  double pixdim[8]; /* 104 */
238  long long vox_offset; /* 168 */
239  double scl_slope; /* 176 */
240  double scl_inter; /* 184 */
241  double cal_max; /* 192 */
242  double cal_min; /* 200 */
243  double slice_duration; /* 208 */
244  double toffset; /* 216 */
245  long long slice_start; /* 224 */
246  long long slice_end; /* 232 */
247  char descrip[80]; /* 240 */
248  char aux_file[24]; /* 320 */
249  int qform_code; /* 344 */
250  int sform_code; /* 348 */
251  double quatern_b; /* 352 */
252  double quatern_c; /* 360 */
253  double quatern_d; /* 368 */
254  double qoffset_x; /* 376 */
255  double qoffset_y; /* 384 */
256  double qoffset_z; /* 392 */
257  double srow_x[4]; /* 400 */
258  double srow_y[4]; /* 432 */
259  double srow_z[4]; /* 464 */
260  int slice_code; /* 496 */
261  int xyzt_units; /* 500 */
262  int intent_code; /* 504 */
263  char intent_name[16]; /* 508 */
264  char dim_info; /* 524 */
265  char unused_str[15]; /* 525 */
266 }; /**** 540 bytes total ****/
267 
269 
270 /*=================*/
271 #ifdef __cplusplus
272 }
273 #endif
274 /*=================*/
275 
276 #endif /* __NIFTI2_HEADER */
277 // VTK-HeaderTest-Exclude: vtkNIFTIImagePrivate.h
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...