Developer documentation
Version 3.0.3-105-gd3941f44
nifti2.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __NIFTI2_HEADER
18#define __NIFTI2_HEADER
19
20/*---------------------------------------------------------------------------*/
21/* Changes to the header from NIFTI-1 to NIFTI-2 are intended to allow for
22 larger and more accurate fields. The changes are as follows:
23
24 - short dim[8] -> int64_t dim[8]
25 - float intent_p1,2,3 -> double intent_p1,2,3 (3 fields)
26 - float pixdim[8] -> double pixdim[8]
27 - float vox_offset -> int64_t vox_offset
28 - float scl_slope -> double scl_slope
29 - float scl_inter -> double scl_inter
30 - float cal_max -> double cal_max
31 - float cal_min -> double cal_min
32 - float slice_duration -> double slice_duration
33 - float toffset -> double toffset
34 - short slice_start -> int64_t slice_start
35 - short slice_end -> int64_t slice_end
36 - char slice_code -> int32_t slice_code
37 - char xyzt_units -> int32_t xyzt_units
38 - short intent_code -> int32_t intent_code
39 - short qform_code -> int32_t qform_code
40 - short sform_code -> int32_t sform_code
41 - float quatern_b,c,d -> double quatern_b,c,d (3 fields)
42 - float srow_x,y,z[4] -> double srow_x,y,z[4] (3 fields)
43 - char magic[4] -> char magic[8]
44 - char unused_str[15] -> padding added at the end of the header
45
46 - previously unused fields have been removed:
47 data_type, db_name, extents, session_error, regular, glmax, glmin
48
49 - the field ordering has been changed
50-----------------------------------------------------------------------------*/
51
52#include <stdint.h>
53
54/*=================*/
55#ifdef __cplusplus
56extern "C" {
57#endif
58/*=================*/
59
66/* hopefully cross-platform solution to byte padding added by some compilers */
67#pragma pack(push)
68#pragma pack(1)
69
70 /***************************/ /**********************/ /************/
71struct nifti_2_header { /* NIFTI-2 usage */ /* NIFTI-1 usage */ /* offset */
72 /***************************/ /**********************/ /************/
73 int sizeof_hdr; /* int sizeof_hdr; (348) */ /* 0 */
74 char magic[8] ; /* char magic[4]; */ /* 4 */
75 int16_t datatype; /* short datatype; */ /* 12 */
76 int16_t bitpix; /* short bitpix; */ /* 14 */
77 int64_t dim[8]; /* short dim[8]; */ /* 16 */
78 double intent_p1 ; /* float intent_p1; */ /* 80 */
79 double intent_p2 ; /* float intent_p2; */ /* 88 */
80 double intent_p3 ; /* float intent_p3; */ /* 96 */
81 double pixdim[8]; /* float pixdim[8]; */ /* 104 */
82 int64_t vox_offset; /* float vox_offset; */ /* 168 */
83 double scl_slope ; /* float scl_slope; */ /* 176 */
84 double scl_inter ; /* float scl_inter; */ /* 184 */
85 double cal_max; /* float cal_max; */ /* 192 */
86 double cal_min; /* float cal_min; */ /* 200 */
87 double slice_duration; /* float slice_duration; */ /* 208 */
88 double toffset; /* float toffset; */ /* 216 */
89 int64_t slice_start; /* short slice_start; */ /* 224 */
90 int64_t slice_end; /* short slice_end; */ /* 232 */
91 char descrip[80]; /* char descrip[80]; */ /* 240 */
92 char aux_file[24]; /* char aux_file[24]; */ /* 320 */
93 int qform_code ; /* short qform_code; */ /* 344 */
94 int sform_code ; /* short sform_code; */ /* 348 */
95 double quatern_b ; /* float quatern_b; */ /* 352 */
96 double quatern_c ; /* float quatern_c; */ /* 360 */
97 double quatern_d ; /* float quatern_d; */ /* 368 */
98 double qoffset_x ; /* float qoffset_x; */ /* 376 */
99 double qoffset_y ; /* float qoffset_y; */ /* 384 */
100 double qoffset_z ; /* float qoffset_z; */ /* 392 */
101 double srow_x[4] ; /* float srow_x[4]; */ /* 400 */
102 double srow_y[4] ; /* float srow_y[4]; */ /* 432 */
103 double srow_z[4] ; /* float srow_z[4]; */ /* 464 */
104 int slice_code ; /* char slice_code; */ /* 496 */
105 int xyzt_units ; /* char xyzt_units; */ /* 500 */
106 int intent_code ; /* short intent_code; */ /* 504 */
107 char intent_name[16]; /* char intent_name[16]; */ /* 508 */
108 char dim_info; /* char dim_info; */ /* 524 */
109 char unused_str[15]; /* 525 */
110} ; /**** 540 bytes total ****/
112
113/* restore packing behavior */
114#pragma pack(pop)
115
116/*=================*/
117#ifdef __cplusplus
118}
119#endif
120/*=================*/
121
122#endif /* __NIFTI2_HEADER */
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...
Definition: nifti2.h:71
double srow_x[4]
Definition: nifti2.h:101
int sizeof_hdr
Definition: nifti2.h:73
double scl_slope
Definition: nifti2.h:83
int64_t dim[8]
Definition: nifti2.h:77
int intent_code
Definition: nifti2.h:106
int16_t datatype
Definition: nifti2.h:75
double qoffset_z
Definition: nifti2.h:100
double intent_p1
Definition: nifti2.h:78
int slice_code
Definition: nifti2.h:104
int64_t vox_offset
Definition: nifti2.h:82
char intent_name[16]
Definition: nifti2.h:107
double pixdim[8]
Definition: nifti2.h:81
char descrip[80]
Definition: nifti2.h:91
double toffset
Definition: nifti2.h:88
char magic[8]
Definition: nifti2.h:74
double intent_p3
Definition: nifti2.h:80
double quatern_c
Definition: nifti2.h:96
char unused_str[15]
Definition: nifti2.h:109
double scl_inter
Definition: nifti2.h:84
double slice_duration
Definition: nifti2.h:87
double quatern_b
Definition: nifti2.h:95
int qform_code
Definition: nifti2.h:93
double cal_max
Definition: nifti2.h:85
double srow_z[4]
Definition: nifti2.h:103
int64_t slice_start
Definition: nifti2.h:89
double cal_min
Definition: nifti2.h:86
double intent_p2
Definition: nifti2.h:79
int64_t slice_end
Definition: nifti2.h:90
int sform_code
Definition: nifti2.h:94
int16_t bitpix
Definition: nifti2.h:76
double quatern_d
Definition: nifti2.h:97
double srow_y[4]
Definition: nifti2.h:102
char dim_info
Definition: nifti2.h:108
char aux_file[24]
Definition: nifti2.h:92
double qoffset_y
Definition: nifti2.h:99
int xyzt_units
Definition: nifti2.h:105
double qoffset_x
Definition: nifti2.h:98