0001 function [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(IFileName)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 [fid,message] = fopen(IFileName,'r','b');
0012 if fid == -1
0013 error(message)
0014 end
0015
0016
0017 magic = fread(fid,1,'int32');
0018 if magic == 1229801286
0019
0020 byte_align = 0;
0021 pix_hdr_offset = 0;
0022 su_hdr_size = 114;
0023 ex_hdr_size = 1024;
0024 se_hdr_size = 1020;
0025 im_hdr_size = 1022;
0026 else
0027
0028 fseek(fid,3228,-1);
0029 magic = fread(fid,1,'int32');
0030 if magic == 1229801286
0031
0032 byte_align = 1;
0033 pix_hdr_offset = 3228;
0034 su_hdr_size = 116;
0035 ex_hdr_size = 1040;
0036 se_hdr_size = 1028;
0037 im_hdr_size = 1044;
0038 else
0039 msg = 'This is not a 5.X or LX2 format image. No Magic Number.';
0040 error(msg);
0041 end
0042 end
0043
0044
0045 fseek(fid,pix_hdr_offset,-1);
0046 pix_hdr = GE_readHeaderPixel(fid, byte_align);
0047
0048
0049 su_hdr_offset = pix_hdr.img_p_dbHdr;
0050 ex_hdr_offset = su_hdr_offset + su_hdr_size;
0051 se_hdr_offset = ex_hdr_offset + ex_hdr_size;
0052 im_hdr_offset = se_hdr_offset + se_hdr_size;
0053 im_offset = pix_hdr_offset + pix_hdr.img_hdr_length;
0054
0055
0056 if (pix_hdr.img_l_dbHdr == 0 & byte_align==0)
0057 error('This is a epirecon image. No header')
0058 end
0059
0060
0061 fseek(fid,su_hdr_offset,-1);
0062 su_hdr = GE_readHeaderSuite(fid, byte_align);
0063
0064
0065 fseek(fid,ex_hdr_offset,-1);
0066 ex_hdr = GE_readHeaderExam(fid, byte_align);
0067
0068
0069 fseek(fid,se_hdr_offset,-1);
0070 se_hdr = GE_readHeaderSeries(fid, byte_align);
0071
0072
0073 fseek(fid,im_hdr_offset,-1);
0074 im_hdr = GE_readHeaderImage(fid, byte_align);
0075
0076
0077 fclose(fid);
0078
0079 return
0080
0081
0082
0083
0084