Doxygen Source Code Documentation
GE_readHeader.m
Go to the documentation of this file.00001 function [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(IFileName)
00002 %
00003 % [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(IFileName)
00004 % Reads the header info from a GE lx2 or 5.X file
00005 %
00006 %
00007 % Souheil J. Inati
00008 % Dartmouth College
00009 % May 2000
00010 % souheil.inati@dartmouth.edu
00011 %
00012
00013 %%%% Open the IFile %%%%%
00014 [fid,message] = fopen(IFileName,'r','b'); %note: 'b' = Big-Endian format
00015 if fid == -1
00016 error(message)
00017 end
00018
00019 % Check for the magic number at the first word
00020 magic = fread(fid,1,'int32');
00021 if magic == 1229801286
00022 % This is a 5.X format image
00023 byte_align = 0;
00024 pix_hdr_offset = 0;
00025 su_hdr_size = 114;
00026 ex_hdr_size = 1024;
00027 se_hdr_size = 1020;
00028 im_hdr_size = 1022;
00029 else
00030 % Magic no. not at the 1st word, try at the LX2 position
00031 fseek(fid,3228,-1);
00032 magic = fread(fid,1,'int32');
00033 if magic == 1229801286
00034 % This is an LX2 format image
00035 byte_align = 1;
00036 pix_hdr_offset = 3228;
00037 su_hdr_size = 116;
00038 ex_hdr_size = 1040;
00039 se_hdr_size = 1028;
00040 im_hdr_size = 1044;
00041 else
00042 msg = 'This is not a 5.X or LX2 format image. No Magic Number.';
00043 error(msg);
00044 end
00045 end
00046
00047 % Load the pixel header
00048 fseek(fid,pix_hdr_offset,-1);
00049 pix_hdr = GE_readHeaderPixel(fid, byte_align);
00050
00051 % Compute the offsets
00052 su_hdr_offset = pix_hdr.img_p_dbHdr;
00053 ex_hdr_offset = su_hdr_offset + su_hdr_size;
00054 se_hdr_offset = ex_hdr_offset + ex_hdr_size;
00055 im_hdr_offset = se_hdr_offset + se_hdr_size;
00056 im_offset = pix_hdr_offset + pix_hdr.img_hdr_length;
00057
00058 % Check for epirecon images
00059 if (pix_hdr.img_l_dbHdr == 0 & byte_align==0)
00060 error('This is a epirecon image. No header')
00061 end
00062
00063 % Load the suite header
00064 fseek(fid,su_hdr_offset,-1);
00065 su_hdr = GE_readHeaderSuite(fid, byte_align);
00066
00067 % Load the exam header
00068 fseek(fid,ex_hdr_offset,-1);
00069 ex_hdr = GE_readHeaderExam(fid, byte_align);
00070
00071 % Load the series header
00072 fseek(fid,se_hdr_offset,-1);
00073 se_hdr = GE_readHeaderSeries(fid, byte_align);
00074
00075 % Load the image header
00076 fseek(fid,im_hdr_offset,-1);
00077 im_hdr = GE_readHeaderImage(fid, byte_align);
00078
00079 % Close the file
00080 fclose(fid);
00081
00082 return
00083
00084
00085
00086
00087