VTK  9.1.0
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{
28#endif
29 /*=================*/
30
36 /*************************/ /************/
38 { /* NIFTI-1 usage */ /* offset */
39 /*************************/ /************/
40
41 int sizeof_hdr; /* 0 */
42 char data_type[10]; /* 4 */
43 char db_name[18]; /* 14 */
44 int extents; /* 32 */
45 short session_error; /* 36 */
46 char regular; /* 38 */
47 char dim_info; /* 39 */
48 short dim[8]; /* 40 */
49 float intent_p1; /* 56 */
50 float intent_p2; /* 60 */
51 float intent_p3; /* 64 */
52 short intent_code; /* 68 */
53 short datatype; /* 70 */
54 short bitpix; /* 72 */
55 short slice_start; /* 74 */
56 float pixdim[8]; /* 76 */
57 float vox_offset; /* 108 */
58 float scl_slope; /* 112 */
59 float scl_inter; /* 116 */
60 short slice_end; /* 120 */
61 char slice_code; /* 122 */
62 char xyzt_units; /* 123 */
63 float cal_max; /* 124 */
64 float cal_min; /* 128 */
65 float slice_duration; /* 132 */
66 float toffset; /* 136 */
67 int glmax; /* 140 */
68 int glmin; /* 144 */
69 char descrip[80]; /* 148 */
70 char aux_file[24]; /* 228 */
71 short qform_code; /* 252 */
72 short sform_code; /* 254 */
73 float quatern_b; /* 256 */
74 float quatern_c; /* 260 */
75 float quatern_d; /* 264 */
76 float qoffset_x; /* 268 */
77 float qoffset_y; /* 272 */
78 float qoffset_z; /* 276 */
79 float srow_x[4]; /* 280 */
80 float srow_y[4]; /* 296 */
81 float srow_z[4]; /* 312 */
82 char intent_name[16]; /* 328 */
83 char magic[4]; /* 344 */
84
85 }; /**** 348 bytes total ****/
86
88
89 /*---------------------------------------------------------------------------*/
90 /* TYPE OF DATA (acceptable values for datatype field):
91 ---------------------------------------------------
92 Values of datatype smaller than 256 are ANALYZE 7.5 compatible.
93 Larger values are NIFTI-1 additions. These are all multiples of 256, so
94 that no bits below position 8 are set in datatype. But there is no need
95 to use only powers-of-2, as the original ANALYZE 7.5 datatype codes do.
96
97 The additional codes are intended to include a complete list of basic
98 scalar types, including signed and unsigned integers from 8 to 64 bits,
99 floats from 32 to 128 bits, and complex (float pairs) from 64 to 256 bits.
100
101 Note that most programs will support only a few of these datatypes!
102 A NIFTI-1 program should fail gracefully (e.g., print a warning message)
103 when it encounters a dataset with a type it doesn't like.
104 -----------------------------------------------------------------------------*/
105
107
111#define NIFTI_TYPE_UINT8 2
113#define NIFTI_TYPE_INT16 4
115#define NIFTI_TYPE_INT32 8
117#define NIFTI_TYPE_FLOAT32 16
119#define NIFTI_TYPE_COMPLEX64 32
121#define NIFTI_TYPE_FLOAT64 64
123#define NIFTI_TYPE_RGB24 128
125#define NIFTI_TYPE_INT8 256
127#define NIFTI_TYPE_UINT16 512
129#define NIFTI_TYPE_UINT32 768
131#define NIFTI_TYPE_INT64 1024
133#define NIFTI_TYPE_UINT64 1280
135#define NIFTI_TYPE_FLOAT128 1536
137#define NIFTI_TYPE_COMPLEX128 1792
139#define NIFTI_TYPE_COMPLEX256 2048
141#define NIFTI_TYPE_RGBA32 2304
143
144 /*---------------------------------------------------------------------------*/
145 /* MISCELLANEOUS C MACROS
146 -----------------------------------------------------------------------------*/
147
148 /*.................*/
152#define NIFTI_VERSION(h) \
153 (((h).magic[0] == 'n' && (h).magic[3] == '\0' && ((h).magic[1] == 'i' || (h).magic[1] == '+') && \
154 ((h).magic[2] >= '1' && (h).magic[2] <= '9')) \
155 ? (h).magic[2] - '0' \
156 : 0)
157
158 /*.................*/
163#define NIFTI_ONEFILE(h) ((h).magic[1] == '+')
164
165 /*.................*/
169#define NIFTI_NEEDS_SWAP(h) ((h).dim[0] < 0 || (h).dim[0] > 7)
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{
213#endif
214 /*=================*/
215
222 /*************************/ /************/
224 { /* NIFTI-2 usage */ /* offset */
225 /*************************/ /************/
226 int sizeof_hdr; /* 0 */
227 char magic[8]; /* 4 */
228 short datatype; /* 12 */
229 short bitpix; /* 14 */
230 long long dim[8]; /* 16 */
231 double intent_p1; /* 80 */
232 double intent_p2; /* 88 */
233 double intent_p3; /* 96 */
234 double pixdim[8]; /* 104 */
235 long long vox_offset; /* 168 */
236 double scl_slope; /* 176 */
237 double scl_inter; /* 184 */
238 double cal_max; /* 192 */
239 double cal_min; /* 200 */
240 double slice_duration; /* 208 */
241 double toffset; /* 216 */
242 long long slice_start; /* 224 */
243 long long slice_end; /* 232 */
244 char descrip[80]; /* 240 */
245 char aux_file[24]; /* 320 */
246 int qform_code; /* 344 */
247 int sform_code; /* 348 */
248 double quatern_b; /* 352 */
249 double quatern_c; /* 360 */
250 double quatern_d; /* 368 */
251 double qoffset_x; /* 376 */
252 double qoffset_y; /* 384 */
253 double qoffset_z; /* 392 */
254 double srow_x[4]; /* 400 */
255 double srow_y[4]; /* 432 */
256 double srow_z[4]; /* 464 */
257 int slice_code; /* 496 */
258 int xyzt_units; /* 500 */
259 int intent_code; /* 504 */
260 char intent_name[16]; /* 508 */
261 char dim_info; /* 524 */
262 char unused_str[15]; /* 525 */
263 }; /**** 540 bytes total ****/
264
266
267/*=================*/
268#ifdef __cplusplus
269}
270#endif
271/*=================*/
272
273#endif /* vtkNIFTIImagePrivate_h */
274// 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...