NIFTI格式(.Nii)数据格式分析
NIFTI出现原因
- NIFTI出现的原因是原来一种图像格式是ANALYZE 7.5 format,但是这个图像格式缺少一些信息,比如没有方向信息,病人的左右方位等,如果需要包括额外的信息,就需要一个额外的文件,比如ANALYZE7.5就需要一对<.hdr, .img>文件来保存图像的完整信息。因此,解决这个问题Data Format Working Group (DFWG) 将图像格式完整的定义为NIFTI(Neuroimaging Informatics Technology Initiative)格式。
- 放射学和神经学医生使用软件和使用习惯会有一些不同,所以为了统一格式,DFWG提出NIFTI格式图像。
- NIFTI格式的读取软件,也应该可以读取<.hdr, .img>文件对。
NIFTI-1文件头信息格式
- 注:NIFTI格式中保存的信息是,一共可以保存7维数据。第1,2,3维度(0维统计使用维度个数)保留给空间维度x,y,z,而第四维度留给时间维度t。第5,6,7维度可供用户其他使用,但是第五维度也有一些预定义的用途,例如存储特定体素分布的参数或存储矢量数据。
// NIFTI version1 头文件存储信息(顺序存放)
/*
NIFTI 第一版的数据格式的头文件大小必须为348字节,这是为了兼容新,和旧的analyze格式保持一致。就是sizeof_hdr保存的数据大小。
*/
// //OFFSET SIZE Description
int sizeof_hdr; //0B 4B Size of the header.Must be 348 (bytes).
char data_type[10]; //4B 10B Not used; compatibility with analyze.
char db_name[18]; //14B 18B Not used; compatibility with analyze.
int extents; //32B 4B Not used; compatibility with analyze.
short session_error; //36B 2B Not used; compatibility with analyze.
char regular; //38B 1B Not used; compatibility with analyze.
char dim_info; //39B 1B Encoding directions(phase, frequency, slice).
short dim[8]; //40B 16B Data array dimensions.
float intent_p1; //56B 4B 1st intent parameter.
float intent_p2; //60B 4B 2nd intent parameter.
float intent_p3; //64B 4B 3rd intent parameter.
short intent_code; //68B 2B nifti intent.
short datatype; //70B 2B Data type.
short bitpix; //72B 2B Number of bits per voxel.
short slice_start; //74B 2B First slice index.
float pixdim[8]; //76B 32B Grid spacings(unit per dimension).
float vox_offset; /*108B 4B Offset into a.nii file. !Data true start point.*/
float scl_slope; //112B 4B Data scaling, slope.
float scl_inter; //116B 4B Data scaling, offset.
short slice_end; //120B 2B Last slice index.
char slice_code; //122B 1B Slice timing order.
char xyzt_units; //123B 1B Units of pixdim[1..4].
float cal_max; //124B 4B Maximum display intensity.
float cal_min; //128B 4B Minimum display intensity.
float slice_duration; //132B 4B Time for one slice.
float toffset; //136B 4B Time axis shift.
int glmax; //140B 4B Not used; compatibility with analyze.
int glmin; //144B 4B Not used; compatibility with analyze.
char descrip[80]; //148B 80B Any text.
char aux_file[24]; //228B 24B Auxiliary filename.
short qform_code; //252B 2B Use the quaternion fields.
short sform_code; //254B 2B Use of the affine fields.
float quatern_b;