VTK
vtkNIFTIImagePrivate.h
Go to the documentation of this file.
1#ifndef vtkNIFTIImagePrivate_h
2#define vtkNIFTIImagePrivate_h
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
26extern "C" {
27#endif
28/*=================*/
29
35 /*************************/ /************/
36struct 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
111#define NIFTI_TYPE_INT16 4
113#define NIFTI_TYPE_INT32 8
115#define NIFTI_TYPE_FLOAT32 16
117#define NIFTI_TYPE_COMPLEX64 32
119#define NIFTI_TYPE_FLOAT64 64
121#define NIFTI_TYPE_RGB24 128
123#define NIFTI_TYPE_INT8 256
125#define NIFTI_TYPE_UINT16 512
127#define NIFTI_TYPE_UINT32 768
129#define NIFTI_TYPE_INT64 1024
131#define NIFTI_TYPE_UINT64 1280
133#define NIFTI_TYPE_FLOAT128 1536
135#define NIFTI_TYPE_COMPLEX128 1792
137#define NIFTI_TYPE_COMPLEX256 2048
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/*---------------------------------------------------------------------------*/
178/* Changes to the header from NIFTI-1 to NIFTI-2 are intended to allow for
179 larger and more accurate fields. The changes are as follows:
180
181 - short dim[8] -> int64_t dim[8]
182 - float intent_p1,2,3 -> double intent_p1,2,3 (3 fields)
183 - float pixdim[8] -> double pixdim[8]
184 - float vox_offset -> int64_t vox_offset
185 - float scl_slope -> double scl_slope
186 - float scl_inter -> double scl_inter
187 - float cal_max -> double cal_max
188 - float cal_min -> double cal_min
189 - float slice_duration -> double slice_duration
190 - float toffset -> double toffset
191 - short slice_start -> int64_t slice_start
192 - short slice_end -> int64_t slice_end
193 - char slice_code -> int32_t slice_code
194 - char xyzt_units -> int32_t xyzt_units
195 - short intent_code -> int32_t intent_code
196 - short qform_code -> int32_t qform_code
197 - short sform_code -> int32_t sform_code
198 - float quatern_b,c,d -> double quatern_b,c,d (3 fields)
199 - float srow_x,y,z[4] -> double srow_x,y,z[4] (3 fields)
200 - char magic[4] -> char magic[8]
201 - char unused_str[15] -> padding added at the end of the header
202
203 - previously unused fields have been removed:
204 data_type, db_name, extents, session_error, regular, glmax, glmin
205
206 - the field ordering has been changed
207-----------------------------------------------------------------------------*/
208
209/*=================*/
210#ifdef __cplusplus
211extern "C" {
212#endif
213/*=================*/
214
221 /*************************/ /************/
222struct nifti_2_header { /* NIFTI-2 usage */ /* offset */
223 /*************************/ /************/
224 int sizeof_hdr; /* 0 */
225 char magic[8]; /* 4 */
226 short datatype; /* 12 */
227 short bitpix; /* 14 */
228 long long dim[8]; /* 16 */
229 double intent_p1; /* 80 */
230 double intent_p2; /* 88 */
231 double intent_p3; /* 96 */
232 double pixdim[8]; /* 104 */
233 long long vox_offset; /* 168 */
234 double scl_slope; /* 176 */
235 double scl_inter; /* 184 */
236 double cal_max; /* 192 */
237 double cal_min; /* 200 */
238 double slice_duration; /* 208 */
239 double toffset; /* 216 */
240 long long slice_start; /* 224 */
241 long long slice_end; /* 232 */
242 char descrip[80]; /* 240 */
243 char aux_file[24]; /* 320 */
244 int qform_code; /* 344 */
245 int sform_code; /* 348 */
246 double quatern_b; /* 352 */
247 double quatern_c; /* 360 */
248 double quatern_d; /* 368 */
249 double qoffset_x; /* 376 */
250 double qoffset_y; /* 384 */
251 double qoffset_z; /* 392 */
252 double srow_x[4]; /* 400 */
253 double srow_y[4]; /* 432 */
254 double srow_z[4]; /* 464 */
255 int slice_code; /* 496 */
256 int xyzt_units; /* 500 */
257 int intent_code; /* 504 */
258 char intent_name[16]; /* 508 */
259 char dim_info; /* 524 */
260 char unused_str[15]; /* 525 */
261}; /**** 540 bytes total ****/
262
264
265/*=================*/
266#ifdef __cplusplus
267}
268#endif
269/*=================*/
270
271#endif /* vtkNIFTIImagePrivate_h */
272// 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...