Home > fmri > utils > GE2SPM > GE_readHeader.m

GE_readHeader

PURPOSE ^

SYNOPSIS ^

function [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(IFileName)

DESCRIPTION ^

 [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(IFileName)
 Reads the header info from a GE lx2 or 5.X file 


 Souheil J. Inati
 Dartmouth College
 May 2000
 souheil.inati@dartmouth.edu

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(IFileName)
0002 %
0003 % [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(IFileName)
0004 % Reads the header info from a GE lx2 or 5.X file
0005 %
0006 %
0007 % Souheil J. Inati
0008 % Dartmouth College
0009 % May 2000
0010 % souheil.inati@dartmouth.edu
0011 %
0012 
0013 %%%% Open the IFile %%%%%
0014 [fid,message] = fopen(IFileName,'r','b');         %note: 'b' = Big-Endian format
0015 if fid == -1
0016   error(message)
0017 end
0018 
0019 % Check for the magic number at the first word
0020 magic = fread(fid,1,'int32');
0021 if magic == 1229801286
0022   % This is a 5.X format image
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   % Magic no. not at the 1st word, try at the LX2 position
0031   fseek(fid,3228,-1);
0032   magic = fread(fid,1,'int32');
0033   if magic == 1229801286
0034     % This is an LX2 format image
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 % Load the pixel header
0048 fseek(fid,pix_hdr_offset,-1);
0049 pix_hdr = GE_readHeaderPixel(fid, byte_align);
0050 
0051 % Compute the offsets
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 % Check for epirecon images
0059 if (pix_hdr.img_l_dbHdr == 0 & byte_align==0)
0060   error('This is a epirecon image. No header')
0061 end
0062 
0063 % Load the suite header
0064 fseek(fid,su_hdr_offset,-1);
0065 su_hdr = GE_readHeaderSuite(fid, byte_align);
0066 
0067 % Load the exam header
0068 fseek(fid,ex_hdr_offset,-1);
0069 ex_hdr = GE_readHeaderExam(fid, byte_align);
0070 
0071 % Load the series header
0072 fseek(fid,se_hdr_offset,-1);
0073 se_hdr = GE_readHeaderSeries(fid, byte_align);
0074 
0075 % Load the image header
0076 fseek(fid,im_hdr_offset,-1);
0077 im_hdr = GE_readHeaderImage(fid, byte_align);
0078 
0079 % Close the file
0080 fclose(fid);
0081 
0082 return
0083 
0084 
0085 
0086 
0087

Generated on Sat 24-Aug-2019 04:00:39 by m2html © 2003