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 #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 
85 typedef struct nifti_1_header nifti_1_header;
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 /*---------------------------------------------------------------------------*/
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 #endif
213 /*=================*/
214 
221  /*************************/ /************/
222 struct 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 
263 typedef struct nifti_2_header nifti_2_header;
264 
265 /*=================*/
266 #ifdef __cplusplus
267 }
268 #endif
269 /*=================*/
270 
271 #endif /* vtkNIFTIImagePrivate_h */
272 // VTK-HeaderTest-Exclude: vtkNIFTIImagePrivate.h
nifti_1_header::slice_code
char slice_code
Definition: vtkNIFTIImagePrivate.h:58
nifti_1_header::dim_info
char dim_info
Definition: vtkNIFTIImagePrivate.h:44
nifti_1_header::regular
char regular
Definition: vtkNIFTIImagePrivate.h:43
nifti_1_header::db_name
char db_name[18]
Definition: vtkNIFTIImagePrivate.h:40
nifti_2_header::cal_max
double cal_max
Definition: vtkNIFTIImagePrivate.h:235
nifti_1_header::magic
char magic[4]
Definition: vtkNIFTIImagePrivate.h:80
nifti_2_header::bitpix
short bitpix
Definition: vtkNIFTIImagePrivate.h:226
nifti_1_header::scl_slope
float scl_slope
Definition: vtkNIFTIImagePrivate.h:55
nifti_1_header::slice_end
short slice_end
Definition: vtkNIFTIImagePrivate.h:57
nifti_2_header::toffset
double toffset
Definition: vtkNIFTIImagePrivate.h:238
nifti_2_header::slice_duration
double slice_duration
Definition: vtkNIFTIImagePrivate.h:237
nifti_2_header::intent_p1
double intent_p1
Definition: vtkNIFTIImagePrivate.h:228
nifti_2_header::dim
long long dim[8]
Definition: vtkNIFTIImagePrivate.h:227
nifti_2_header::quatern_c
double quatern_c
Definition: vtkNIFTIImagePrivate.h:246
nifti_1_header::dim
short dim[8]
Definition: vtkNIFTIImagePrivate.h:45
nifti_2_header::descrip
char descrip[80]
Definition: vtkNIFTIImagePrivate.h:241
nifti_1_header::quatern_d
float quatern_d
Definition: vtkNIFTIImagePrivate.h:72
nifti_2_header::xyzt_units
int xyzt_units
Definition: vtkNIFTIImagePrivate.h:255
nifti_2_header::srow_y
double srow_y[4]
Definition: vtkNIFTIImagePrivate.h:252
nifti_1_header::quatern_c
float quatern_c
Definition: vtkNIFTIImagePrivate.h:71
nifti_2_header::quatern_d
double quatern_d
Definition: vtkNIFTIImagePrivate.h:247
nifti_2_header::qform_code
int qform_code
Definition: vtkNIFTIImagePrivate.h:243
nifti_1_header::intent_p2
float intent_p2
Definition: vtkNIFTIImagePrivate.h:47
nifti_1_header::vox_offset
float vox_offset
Definition: vtkNIFTIImagePrivate.h:54
nifti_1_header::srow_x
float srow_x[4]
Definition: vtkNIFTIImagePrivate.h:76
nifti_1_header::glmin
int glmin
Definition: vtkNIFTIImagePrivate.h:65
nifti_2_header::magic
char magic[8]
Definition: vtkNIFTIImagePrivate.h:224
nifti_1_header::srow_y
float srow_y[4]
Definition: vtkNIFTIImagePrivate.h:77
nifti_1_header::slice_duration
float slice_duration
Definition: vtkNIFTIImagePrivate.h:62
nifti_1_header::extents
int extents
Definition: vtkNIFTIImagePrivate.h:41
nifti_2_header::intent_code
int intent_code
Definition: vtkNIFTIImagePrivate.h:256
nifti_1_header::data_type
char data_type[10]
Definition: vtkNIFTIImagePrivate.h:39
nifti_2_header::sizeof_hdr
int sizeof_hdr
Definition: vtkNIFTIImagePrivate.h:223
nifti_1_header::glmax
int glmax
Definition: vtkNIFTIImagePrivate.h:64
nifti_1_header::cal_max
float cal_max
Definition: vtkNIFTIImagePrivate.h:60
nifti_2_header::slice_code
int slice_code
Definition: vtkNIFTIImagePrivate.h:254
nifti_1_header::aux_file
char aux_file[24]
Definition: vtkNIFTIImagePrivate.h:67
nifti_2_header::scl_inter
double scl_inter
Definition: vtkNIFTIImagePrivate.h:234
nifti_1_header::qoffset_z
float qoffset_z
Definition: vtkNIFTIImagePrivate.h:75
nifti_2_header::scl_slope
double scl_slope
Definition: vtkNIFTIImagePrivate.h:233
nifti_2_header::intent_p3
double intent_p3
Definition: vtkNIFTIImagePrivate.h:230
nifti_2_header::vox_offset
long long vox_offset
Definition: vtkNIFTIImagePrivate.h:232
nifti_1_header::cal_min
float cal_min
Definition: vtkNIFTIImagePrivate.h:61
nifti_2_header::datatype
short datatype
Definition: vtkNIFTIImagePrivate.h:225
nifti_1_header::qoffset_y
float qoffset_y
Definition: vtkNIFTIImagePrivate.h:74
nifti_1_header::descrip
char descrip[80]
Definition: vtkNIFTIImagePrivate.h:66
nifti_2_header::pixdim
double pixdim[8]
Definition: vtkNIFTIImagePrivate.h:231
nifti_1_header::qoffset_x
float qoffset_x
Definition: vtkNIFTIImagePrivate.h:73
nifti_2_header::slice_start
long long slice_start
Definition: vtkNIFTIImagePrivate.h:239
nifti_2_header::quatern_b
double quatern_b
Definition: vtkNIFTIImagePrivate.h:245
nifti_2_header::qoffset_y
double qoffset_y
Definition: vtkNIFTIImagePrivate.h:249
nifti_1_header
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Definition: vtkNIFTIImagePrivate.h:35
nifti_2_header
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...
Definition: vtkNIFTIImagePrivate.h:221
nifti_1_header::toffset
float toffset
Definition: vtkNIFTIImagePrivate.h:63
nifti_1_header::sform_code
short sform_code
Definition: vtkNIFTIImagePrivate.h:69
nifti_1_header::intent_name
char intent_name[16]
Definition: vtkNIFTIImagePrivate.h:79
nifti_2_header::aux_file
char aux_file[24]
Definition: vtkNIFTIImagePrivate.h:242
nifti_2_header::srow_x
double srow_x[4]
Definition: vtkNIFTIImagePrivate.h:251
nifti_2_header::unused_str
char unused_str[15]
Definition: vtkNIFTIImagePrivate.h:259
nifti_1_header::xyzt_units
char xyzt_units
Definition: vtkNIFTIImagePrivate.h:59
nifti_1_header::intent_p3
float intent_p3
Definition: vtkNIFTIImagePrivate.h:48
nifti_1_header::qform_code
short qform_code
Definition: vtkNIFTIImagePrivate.h:68
nifti_1_header::pixdim
float pixdim[8]
Definition: vtkNIFTIImagePrivate.h:53
nifti_1_header::slice_start
short slice_start
Definition: vtkNIFTIImagePrivate.h:52
nifti_2_header::intent_p2
double intent_p2
Definition: vtkNIFTIImagePrivate.h:229
nifti_2_header::cal_min
double cal_min
Definition: vtkNIFTIImagePrivate.h:236
nifti_1_header::datatype
short datatype
Definition: vtkNIFTIImagePrivate.h:50
nifti_1_header::scl_inter
float scl_inter
Definition: vtkNIFTIImagePrivate.h:56
nifti_1_header::intent_p1
float intent_p1
Definition: vtkNIFTIImagePrivate.h:46
nifti_1_header::sizeof_hdr
int sizeof_hdr
Definition: vtkNIFTIImagePrivate.h:38
nifti_2_header::dim_info
char dim_info
Definition: vtkNIFTIImagePrivate.h:258
nifti_1_header::quatern_b
float quatern_b
Definition: vtkNIFTIImagePrivate.h:70
nifti_1_header::bitpix
short bitpix
Definition: vtkNIFTIImagePrivate.h:51
nifti_2_header::slice_end
long long slice_end
Definition: vtkNIFTIImagePrivate.h:240
nifti_2_header::qoffset_x
double qoffset_x
Definition: vtkNIFTIImagePrivate.h:248
nifti_1_header::srow_z
float srow_z[4]
Definition: vtkNIFTIImagePrivate.h:78
nifti_2_header::qoffset_z
double qoffset_z
Definition: vtkNIFTIImagePrivate.h:250
nifti_1_header::intent_code
short intent_code
Definition: vtkNIFTIImagePrivate.h:49
nifti_2_header::sform_code
int sform_code
Definition: vtkNIFTIImagePrivate.h:244
nifti_2_header::srow_z
double srow_z[4]
Definition: vtkNIFTIImagePrivate.h:253
nifti_2_header::intent_name
char intent_name[16]
Definition: vtkNIFTIImagePrivate.h:257
nifti_1_header::session_error
short session_error
Definition: vtkNIFTIImagePrivate.h:42