📄 analyzeformat.txt
字号:
ANALYZE IMAGE FILE FORMAT
ANALYZE image file sets consist of at least 2 files:
- an image file
- a header file
- a color lookup file * optional
For the Analyze image file set "foo" there are two files:
foo.img & foo.hdr (optionally foo.lkup)
The ANALYZE programs refer to this file set as a single entity.
The Image File (foo.img)
The format of the image file is very simple; containing usually
uncompressed voxel data for the images in one of the several
possible voxel formats:
- 1 bit packed binary (slices begin on byte boundaries)
- 8 bit (unsigned char) gray scale (unless .lkup file present)
- 16 bit signed short
- 32 bit signed integers or float
- 24 bit RGB, 8 bits per channel
The header file is a 'C' structure which describes the dimensions
and properties of the voxel data. This structure follows:
/*
*
* (c) Copyright, 1986-1995
* Biomedical Imaging Resource
* Mayo Foundation
*
* dbh.h
*
*
* database sub-definitions
*/
struct header_key /* header_key */
{ /* off + size*/
int sizeof_hdr; /* 0 + 4 */
char data_type[10]; /* 4 + 10 */
char db_name[18]; /* 14 + 18 */
int extents; /* 32 + 4 */
short int session_error; /* 36 + 2 */
char regular; /* 38 + 1 */
char hkey_un0; /* 39 + 1 */
}; /* total=40 */
struct image_dimension /* image_dimension */
{ /* off + size*/
short int dim[8]; /* 0 + 16 */
char vox_units[4]; /* 16 + 4 */
char cal_units[8]; /* 20 + 4 */
short int unused1; /* 24 + 2 */
short int datatype; /* 30 + 2 */
short int bitpix; /* 32 + 2 */
short int dim_un0; /* 34 + 2 */
float pixdim[8]; /* 36 + 32 */
/*
pixdim[] specifies the voxel dimensions:
pixdim[1] - voxel width
pixdim[2] - voxel height
pixdim[3] - interslice distance
..etc
*/
float vox_offset; /* 68 + 4 */
float funused1; /* 72 + 4 */
float funused2; /* 76 + 4 */
float funused3; /* 80 + 4 */
float cal_max; /* 84 + 4 */
float cal_min; /* 88 + 4 */
int compressed; /* 92 + 4 */
int verified; /* 96 + 4 */
int glmax, glmin; /* 100 + 8 */
}; /* total=108 */
struct data_history /* data_history */
{ /* off + size*/
char descrip[80]; /* 0 + 80 */
char aux_file[24]; /* 80 + 24 */
char orient; /* 104 + 1 */
char originator[10]; /* 105 + 10 */
char generated[10]; /* 115 + 10 */
char scannum[10]; /* 125 + 10 */
char patient_id[10]; /* 135 + 10 */
char exp_date[10]; /* 145 + 10 */
char exp_time[10]; /* 155 + 10 */
char hist_un0[3]; /* 165 + 3 */
int views; /* 168 + 4 */
int vols_added; /* 172 + 4 */
int start_field; /* 176 + 4 */
int field_skip; /* 180 + 4 */
int omax,omin; /* 184 + 8 */
int smax,smin; /* 192 + 8 */
}; /* total=200 */
struct dsr /* dsr */
{ /* off + size*/
struct header_key hk; /* 0 + 40 */
struct image_dimension dime; /* 40 + 108 */
struct data_history hist; /* 148 + 200 */
}; /* total=348 */
Comments:
struct header_key
int sizeof_header /* must indicate size of header file */
int extants; /* should be 16384 */
char regular; /* 'r' */
struct image_dimension struct decribes the organization and
side of images. These elements enable IO routines to reference
images by volume and slice number.
short int dim[] /* array of image dimensions */
dim[0] /* number of dimensions; usually 4 */
dim[1] /* image width */
dim[2] /* image height */
dim[3] /* volume depth */
dim[4] /* volumes in file */
char vox_units[4] /* labels voxel spatial unit */
char cal_units[4] /* labels voxel calibration unit */
short int datatype /* Acceptable values are */
#define DT_NONE 0
#define DT_UNKNOWN 0
#define DT_BINARY 1
#define DT_UNSIGNED_CHAR 2
#define DT_SIGNED_SHORT 4
#define DT_SIGNED_INT 8
#define DT_FLOAT 16
#define DT_COMPLEX 32
#define DT_DOUBLE 64
#define DT_RGB 128
#define DT_ALL 255
short int bitpix /* bits per pixel */
float pixdim[] /* parallel array to dim giving voxel dimensions
in each dimension */
pixdim[1] /* voxel width */
pixdim[2] /* voxel height */
pixdim[3] /* voxel depth or slice thickness */
float vox_offset; /* byte offset in the .img file at which
voxels start. If value is negative
specifies that the absolute value
is applied for every image in the file. */
float calibrated Max & Min /* specify range of calibration values */
int glmax, glmin /* the max and min values for entire data set */
The data_history substructure is not required, but the 'orient' element
is used to indicate individual slice orientation and determines whether
the ANALYZE 'Movie' program will attempt to flip the images before
displaying a movie sequence.
orient:
0 - transverse unflipped
1 - coronal unflipped
2 - sagittal unflipped
3 - transverse flipped
4 - coronal flipped
5 - sagittal flipped
The following 'C' program creates an Analyze .hdr file.
/*
* (c) Copyright, 1986-1994
* Biomedical Imaging Resource
* Mayo Foundation
*
*
*/
#include <stdio.h>
#include "dbh.h"
main(argc,argv) /* file x y z t datatype max min */
int argc;
char **argv;
{
int i;
struct dsr hdr;
FILE *fp;
static char DataTypes[9][12] = {"UNKNOWN", "BINARY", "CHAR", "SHORT", "INT",
"FLOAT", "COMPLEX", "DOUBLE", "RGB"};
static int DataTypeSizes[9] = {0,1,8,16,32,32,64,64,24};
if(argc != 9)
{
usage();
exit(0);
}
memset(&hdr,0, sizeof(struct dsr));
for(i=0;i<8;i++)
hdr.dime.pixdim[i]=0.0;
hdr.dime.vox_offset = 0.0;
hdr.dime.roi_scale = 1.0;
hdr.dime.funused1 = 0.0;
hdr.dime.funused2 = 0.0;
hdr.dime.cal_max = 0.0;
hdr.dime.cal_min = 0.0;
hdr.dime.datatype = -1;
for(i=1;i<=8;i++)
if(!strcmp(argv[6],DataTypes[i]))
{
hdr.dime.datatype = (1<<(i-1));
hdr.dime.bitpix = DataTypeSizes[i];
break;
}
if(hdr.dime.datatype <= 0)
{
printf("<%s> is an unacceptable datatype \n\n", argv[6]);
usage();
exit(0);
}
if((fp=fopen(argv[1],"w"))==0)
{
printf("unable to create: %s\n",argv[1]);
exit(0);
}
hdr.dime.dim[0] = 4; /* all Analyze images are taken as 4 dimensional */
hdr.hk.regular = 'r';
hdr.hk.sizeof_hdr = sizeof(struct dsr);
hdr.dime.dim[1] = atoi(argv[2]); /* slice width in pixels */
hdr.dime.dim[2] = atoi(argv[3]); /* slice height in pixels */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -