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
26 extern "C"
27 {
28 #endif
29  /*=================*/
30 
36  /*************************/ /************/
37  struct nifti_1_header
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 
87  typedef struct nifti_1_header nifti_1_header;
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 
111 #define NIFTI_TYPE_UINT8 2
112 
113 #define NIFTI_TYPE_INT16 4
114 
115 #define NIFTI_TYPE_INT32 8
116 
117 #define NIFTI_TYPE_FLOAT32 16
118 
119 #define NIFTI_TYPE_COMPLEX64 32
120 
121 #define NIFTI_TYPE_FLOAT64 64
122 
123 #define NIFTI_TYPE_RGB24 128
124 
125 #define NIFTI_TYPE_INT8 256
126 
127 #define NIFTI_TYPE_UINT16 512
128 
129 #define NIFTI_TYPE_UINT32 768
130 
131 #define NIFTI_TYPE_INT64 1024
132 
133 #define NIFTI_TYPE_UINT64 1280
134 
135 #define NIFTI_TYPE_FLOAT128 1536
136 
137 #define NIFTI_TYPE_COMPLEX128 1792
138 
139 #define NIFTI_TYPE_COMPLEX256 2048
140 
141 #define NIFTI_TYPE_RGBA32 2304
142  /* @} */
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
211 extern "C"
212 {
213 #endif
214  /*=================*/
215 
222  /*************************/ /************/
223  struct nifti_2_header
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 
265  typedef struct nifti_2_header nifti_2_header;
266 
267 /*=================*/
268 #ifdef __cplusplus
269 }
270 #endif
271 /*=================*/
272 
273 #endif /* vtkNIFTIImagePrivate_h */
274 // VTK-HeaderTest-Exclude: vtkNIFTIImagePrivate.h
nifti_1_header::slice_code
char slice_code
Definition: vtkNIFTIImagePrivate.h:60
nifti_1_header::dim_info
char dim_info
Definition: vtkNIFTIImagePrivate.h:46
nifti_1_header::regular
char regular
Definition: vtkNIFTIImagePrivate.h:45
nifti_1_header::db_name
char db_name[18]
Definition: vtkNIFTIImagePrivate.h:42
nifti_2_header::cal_max
double cal_max
Definition: vtkNIFTIImagePrivate.h:237
nifti_1_header::magic
char magic[4]
Definition: vtkNIFTIImagePrivate.h:82
nifti_2_header::bitpix
short bitpix
Definition: vtkNIFTIImagePrivate.h:228
nifti_1_header::scl_slope
float scl_slope
Definition: vtkNIFTIImagePrivate.h:57
nifti_1_header::slice_end
short slice_end
Definition: vtkNIFTIImagePrivate.h:59
nifti_2_header::toffset
double toffset
Definition: vtkNIFTIImagePrivate.h:240
nifti_2_header::slice_duration
double slice_duration
Definition: vtkNIFTIImagePrivate.h:239
nifti_2_header::intent_p1
double intent_p1
Definition: vtkNIFTIImagePrivate.h:230
nifti_2_header::dim
long long dim[8]
Definition: vtkNIFTIImagePrivate.h:229
nifti_2_header::quatern_c
double quatern_c
Definition: vtkNIFTIImagePrivate.h:248
nifti_1_header::dim
short dim[8]
Definition: vtkNIFTIImagePrivate.h:47
nifti_2_header::descrip
char descrip[80]
Definition: vtkNIFTIImagePrivate.h:243
nifti_1_header::quatern_d
float quatern_d
Definition: vtkNIFTIImagePrivate.h:74
nifti_2_header::xyzt_units
int xyzt_units
Definition: vtkNIFTIImagePrivate.h:257
nifti_2_header::srow_y
double srow_y[4]
Definition: vtkNIFTIImagePrivate.h:254
nifti_1_header::quatern_c
float quatern_c
Definition: vtkNIFTIImagePrivate.h:73
nifti_2_header::quatern_d
double quatern_d
Definition: vtkNIFTIImagePrivate.h:249
nifti_2_header::qform_code
int qform_code
Definition: vtkNIFTIImagePrivate.h:245
nifti_1_header::intent_p2
float intent_p2
Definition: vtkNIFTIImagePrivate.h:49
nifti_1_header::vox_offset
float vox_offset
Definition: vtkNIFTIImagePrivate.h:56
nifti_1_header::srow_x
float srow_x[4]
Definition: vtkNIFTIImagePrivate.h:78
nifti_1_header::glmin
int glmin
Definition: vtkNIFTIImagePrivate.h:67
nifti_2_header::magic
char magic[8]
Definition: vtkNIFTIImagePrivate.h:226
nifti_1_header::srow_y
float srow_y[4]
Definition: vtkNIFTIImagePrivate.h:79
nifti_1_header::slice_duration
float slice_duration
Definition: vtkNIFTIImagePrivate.h:64
nifti_1_header::extents
int extents
Definition: vtkNIFTIImagePrivate.h:43
nifti_2_header::intent_code
int intent_code
Definition: vtkNIFTIImagePrivate.h:258
nifti_1_header::data_type
char data_type[10]
Definition: vtkNIFTIImagePrivate.h:41
nifti_2_header::sizeof_hdr
int sizeof_hdr
Definition: vtkNIFTIImagePrivate.h:225
nifti_1_header::glmax
int glmax
Definition: vtkNIFTIImagePrivate.h:66
nifti_1_header::cal_max
float cal_max
Definition: vtkNIFTIImagePrivate.h:62
nifti_2_header::slice_code
int slice_code
Definition: vtkNIFTIImagePrivate.h:256
nifti_1_header::aux_file
char aux_file[24]
Definition: vtkNIFTIImagePrivate.h:69
nifti_2_header::scl_inter
double scl_inter
Definition: vtkNIFTIImagePrivate.h:236
nifti_1_header::qoffset_z
float qoffset_z
Definition: vtkNIFTIImagePrivate.h:77
nifti_2_header::scl_slope
double scl_slope
Definition: vtkNIFTIImagePrivate.h:235
nifti_2_header::intent_p3
double intent_p3
Definition: vtkNIFTIImagePrivate.h:232
nifti_2_header::vox_offset
long long vox_offset
Definition: vtkNIFTIImagePrivate.h:234
nifti_1_header::cal_min
float cal_min
Definition: vtkNIFTIImagePrivate.h:63
nifti_2_header::datatype
short datatype
Definition: vtkNIFTIImagePrivate.h:227
nifti_1_header::qoffset_y
float qoffset_y
Definition: vtkNIFTIImagePrivate.h:76
nifti_1_header::descrip
char descrip[80]
Definition: vtkNIFTIImagePrivate.h:68
nifti_2_header::pixdim
double pixdim[8]
Definition: vtkNIFTIImagePrivate.h:233
nifti_1_header::qoffset_x
float qoffset_x
Definition: vtkNIFTIImagePrivate.h:75
nifti_2_header::slice_start
long long slice_start
Definition: vtkNIFTIImagePrivate.h:241
nifti_2_header::quatern_b
double quatern_b
Definition: vtkNIFTIImagePrivate.h:247
nifti_2_header::qoffset_y
double qoffset_y
Definition: vtkNIFTIImagePrivate.h:251
nifti_1_header
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Definition: vtkNIFTIImagePrivate.h:36
nifti_2_header
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...
Definition: vtkNIFTIImagePrivate.h:222
nifti_1_header::toffset
float toffset
Definition: vtkNIFTIImagePrivate.h:65
nifti_1_header::sform_code
short sform_code
Definition: vtkNIFTIImagePrivate.h:71
nifti_1_header::intent_name
char intent_name[16]
Definition: vtkNIFTIImagePrivate.h:81
nifti_2_header::aux_file
char aux_file[24]
Definition: vtkNIFTIImagePrivate.h:244
nifti_2_header::srow_x
double srow_x[4]
Definition: vtkNIFTIImagePrivate.h:253
nifti_2_header::unused_str
char unused_str[15]
Definition: vtkNIFTIImagePrivate.h:261
nifti_1_header::xyzt_units
char xyzt_units
Definition: vtkNIFTIImagePrivate.h:61
nifti_1_header::intent_p3
float intent_p3
Definition: vtkNIFTIImagePrivate.h:50
nifti_1_header::qform_code
short qform_code
Definition: vtkNIFTIImagePrivate.h:70
nifti_1_header::pixdim
float pixdim[8]
Definition: vtkNIFTIImagePrivate.h:55
nifti_1_header::slice_start
short slice_start
Definition: vtkNIFTIImagePrivate.h:54
nifti_2_header::intent_p2
double intent_p2
Definition: vtkNIFTIImagePrivate.h:231
nifti_2_header::cal_min
double cal_min
Definition: vtkNIFTIImagePrivate.h:238
nifti_1_header::datatype
short datatype
Definition: vtkNIFTIImagePrivate.h:52
nifti_1_header::scl_inter
float scl_inter
Definition: vtkNIFTIImagePrivate.h:58
nifti_1_header::intent_p1
float intent_p1
Definition: vtkNIFTIImagePrivate.h:48
nifti_1_header::sizeof_hdr
int sizeof_hdr
Definition: vtkNIFTIImagePrivate.h:40
nifti_2_header::dim_info
char dim_info
Definition: vtkNIFTIImagePrivate.h:260
nifti_1_header::quatern_b
float quatern_b
Definition: vtkNIFTIImagePrivate.h:72
nifti_1_header::bitpix
short bitpix
Definition: vtkNIFTIImagePrivate.h:53
nifti_2_header::slice_end
long long slice_end
Definition: vtkNIFTIImagePrivate.h:242
nifti_2_header::qoffset_x
double qoffset_x
Definition: vtkNIFTIImagePrivate.h:250
nifti_1_header::srow_z
float srow_z[4]
Definition: vtkNIFTIImagePrivate.h:80
nifti_2_header::qoffset_z
double qoffset_z
Definition: vtkNIFTIImagePrivate.h:252
nifti_1_header::intent_code
short intent_code
Definition: vtkNIFTIImagePrivate.h:51
nifti_2_header::sform_code
int sform_code
Definition: vtkNIFTIImagePrivate.h:246
nifti_2_header::srow_z
double srow_z[4]
Definition: vtkNIFTIImagePrivate.h:255
nifti_2_header::intent_name
char intent_name[16]
Definition: vtkNIFTIImagePrivate.h:259
nifti_1_header::session_error
short session_error
Definition: vtkNIFTIImagePrivate.h:44