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