CiftiLib
A C++ library for CIFTI-2 and CIFTI-1 files
nifti2.h
1 #ifndef __NIFTI2_HEADER
2 #define __NIFTI2_HEADER
3 
4 /*LICENSE_START*/
5 /*
6  * Copyright (c) 2014, Washington University School of Medicine
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "nifti1.h"
32 
33 namespace cifti
34 {
35 
36 #include <stdint.h>
37 /*extended nifti intent codes*/
38 const int32_t NIFTI_INTENT_CONNECTIVITY_UNKNOWN=3000;
39 const int32_t NIFTI_INTENT_CONNECTIVITY_DENSE=3001;
40 const int32_t NIFTI_INTENT_CONNECTIVITY_DENSE_TIME=3002;//CIFTI-1 name
41 const int32_t NIFTI_INTENT_CONNECTIVITY_DENSE_SERIES=3002;//CIFTI-2 name
42 const int32_t NIFTI_INTENT_CONNECTIVITY_PARCELLATED=3003;
43 const int32_t NIFTI_INTENT_CONNECTIVITY_PARCELLATED_TIME=3004;//ditto
44 const int32_t NIFTI_INTENT_CONNECTIVITY_PARCELLATED_SERIES=3004;
45 const int32_t NIFTI_INTENT_CONNECTIVITY_CONNECTIVITY_TRAJECTORY=3005;//ditto
46 const int32_t NIFTI_INTENT_CONNECTIVITY_DENSE_TRAJECTORY=3005;
47 const int32_t NIFTI_INTENT_CONNECTIVITY_DENSE_SCALARS=3006;
48 const int32_t NIFTI_INTENT_CONNECTIVITY_DENSE_LABELS=3007;
49 const int32_t NIFTI_INTENT_CONNECTIVITY_PARCELLATED_SCALAR=3008;
50 const int32_t NIFTI_INTENT_CONNECTIVITY_PARCELLATED_DENSE=3009;
51 const int32_t NIFTI_INTENT_CONNECTIVITY_DENSE_PARCELLATED=3010;
52 const int32_t NIFTI_INTENT_CONNECTIVITY_PARCELLATED_PARCELLATED_SERIES=3011;
53 const int32_t NIFTI_INTENT_CONNECTIVITY_PARCELLATED_PARCELLATED_SCALAR=3012;
54 
55 const int32_t NIFTI_ECODE_CIFTI=32;
56 
57 #define NIFTI2_VERSION(h) \
58  (h).sizeof_hdr == 348 ? 1 : (\
59  (h).sizeof_hdr == 1543569408 ? 1 : (\
60  (h).sizeof_hdr == 540 ? 2 : (\
61  (h).sizeof_hdr == 469893120 ? 2 : 0)))
62 
63 #define NIFTI2_NEEDS_SWAP(h) \
64  (h).sizeof_hdr == 469893120 ? 1 : (\
65  (h).sizeof_hdr == 1543569408 ? 1 : 0)
66 
67 //hopefully cross-platform solution to byte padding added by some compilers
68 #pragma pack(push)
69 #pragma pack(1)
70 
76 /*************************/ /************************/ /************/
77 struct nifti_2_header { /* NIFTI-2 usage */ /* NIFTI-1 usage */ /* offset */
78  /*************************/ /************************/ /************/
79  int32_t sizeof_hdr; /* int32_t sizeof_hdr; (348) */ /* 0 */
80  char magic[8] ; /* char magic[4]; */ /* 4 */
81  int16_t datatype; /* short datatype; */ /* 12 */
82  int16_t bitpix; /* short bitpix; */ /* 14 */
83  int64_t dim[8]; /* short dim[8]; */ /* 16 */
84  double intent_p1 ; /* float intent_p1; */ /* 80 */
85  double intent_p2 ; /* float intent_p2; */ /* 88 */
86  double intent_p3 ; /* float intent_p3; */ /* 96 */
87  double pixdim[8]; /* float pixdim[8]; */ /* 104 */
88  int64_t vox_offset; /* float vox_offset; */ /* 168 */
89  double scl_slope ; /* float scl_slope; */ /* 176 */
90  double scl_inter ; /* float scl_inter; */ /* 184 */
91  double cal_max; /* float cal_max; */ /* 192 */
92  double cal_min; /* float cal_min; */ /* 200 */
93  double slice_duration; /* float slice_duration; */ /* 208 */
94  double toffset; /* float toffset; */ /* 216 */
95  int64_t slice_start; /* short slice_start; */ /* 224 */
96  int64_t slice_end; /* short slice_end; */ /* 232 */
97  char descrip[80]; /* char descrip[80]; */ /* 240 */
98  char aux_file[24]; /* char aux_file[24]; */ /* 320 */
99  int32_t qform_code ; /* short qform_code; */ /* 344 */
100  int32_t sform_code ; /* short sform_code; */ /* 348 */
101  double quatern_b ; /* float quatern_b; */ /* 352 */
102  double quatern_c ; /* float quatern_c; */ /* 360 */
103  double quatern_d ; /* float quatern_d; */ /* 368 */
104  double qoffset_x ; /* float qoffset_x; */ /* 376 */
105  double qoffset_y ; /* float qoffset_y; */ /* 384 */
106  double qoffset_z ; /* float qoffset_z; */ /* 392 */
107  double srow_x[4] ; /* float srow_x[4]; */ /* 400 */
108  double srow_y[4] ; /* float srow_y[4]; */ /* 432 */
109  double srow_z[4] ; /* float srow_z[4]; */ /* 464 */
110  int32_t slice_code ; /* char slice_code; */ /* 496 */
111  int32_t xyzt_units ; /* char xyzt_units; */ /* 500 */
112  int32_t intent_code ; /* short intent_code; */ /* 504 */
113  char intent_name[16]; /* char intent_name[16]; */ /* 508 */
114  char dim_info; /* char dim_info; */ /* 524 */
115  char unused_str[15]; /* 525 */
116 } ; /**** 540 bytes total ****/
117 typedef struct nifti_2_header nifti_2_header ;
118 
119 //and restore packing behavior
120 #pragma pack(pop)
121 
122 }//namespace
123 
124 #endif //__NIFTI2_HEADER
namespace for all CiftiLib functionality
Definition: CiftiBrainModelsMap.h:42
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...
Definition: nifti2.h:77
char unused_str[15]
Definition: nifti2.h:115
char descrip[80]
Definition: nifti2.h:97
double intent_p2
Definition: nifti2.h:85
double toffset
Definition: nifti2.h:94
double intent_p3
Definition: nifti2.h:86
double pixdim[8]
Definition: nifti2.h:87
int32_t sform_code
Definition: nifti2.h:100
int64_t dim[8]
Definition: nifti2.h:83
double scl_slope
Definition: nifti2.h:89
double intent_p1
Definition: nifti2.h:84
int16_t datatype
Definition: nifti2.h:81
int16_t bitpix
Definition: nifti2.h:82
double slice_duration
Definition: nifti2.h:93
double srow_y[4]
Definition: nifti2.h:108
double quatern_c
Definition: nifti2.h:102
double srow_z[4]
Definition: nifti2.h:109
int32_t xyzt_units
Definition: nifti2.h:111
int32_t sizeof_hdr
Definition: nifti2.h:79
int32_t slice_code
Definition: nifti2.h:110
double qoffset_z
Definition: nifti2.h:106
double qoffset_x
Definition: nifti2.h:104
int32_t intent_code
Definition: nifti2.h:112
int64_t vox_offset
Definition: nifti2.h:88
double qoffset_y
Definition: nifti2.h:105
double cal_max
Definition: nifti2.h:91
double cal_min
Definition: nifti2.h:92
double scl_inter
Definition: nifti2.h:90
char intent_name[16]
Definition: nifti2.h:113
int64_t slice_start
Definition: nifti2.h:95
char magic[8]
Definition: nifti2.h:80
int64_t slice_end
Definition: nifti2.h:96
double quatern_d
Definition: nifti2.h:103
char aux_file[24]
Definition: nifti2.h:98
double quatern_b
Definition: nifti2.h:101
char dim_info
Definition: nifti2.h:114
int32_t qform_code
Definition: nifti2.h:99
double srow_x[4]
Definition: nifti2.h:107