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