Home > fmri > utils > old > GE2SPM.orig > 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 


 Written by Souheil J. Inati
 Dartmouth College 2000

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 % Written by Souheil J. Inati
0008 % Dartmouth College 2000
0009 
0010 %%%% Open the IFile %%%%%
0011 [fid,message] = fopen(IFileName,'r','b');         %note: 'b' = Big-Endian format
0012 if fid == -1
0013   error(message)
0014 end
0015 
0016 % Check for the magic number at the first word
0017 magic = fread(fid,1,'int32');
0018 if magic == 1229801286
0019   % This is a 5.X format image
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   % Magic no. not at the 1st word, try at the LX2 position
0028   fseek(fid,3228,-1);
0029   magic = fread(fid,1,'int32');
0030   if magic == 1229801286
0031     % This is an LX2 format image
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 % Load the pixel header
0045 fseek(fid,pix_hdr_offset,-1);
0046 pix_hdr = GE_readHeaderPixel(fid, byte_align);
0047 
0048 % Compute the offsets
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 % Check for epirecon images
0056 if (pix_hdr.img_l_dbHdr == 0 & byte_align==0)
0057   error('This is a epirecon image. No header')
0058 end
0059 
0060 % Load the suite header
0061 fseek(fid,su_hdr_offset,-1);
0062 su_hdr = GE_readHeaderSuite(fid, byte_align);
0063 
0064 % Load the exam header
0065 fseek(fid,ex_hdr_offset,-1);
0066 ex_hdr = GE_readHeaderExam(fid, byte_align);
0067 
0068 % Load the series header
0069 fseek(fid,se_hdr_offset,-1);
0070 se_hdr = GE_readHeaderSeries(fid, byte_align);
0071 
0072 % Load the image header
0073 fseek(fid,im_hdr_offset,-1);
0074 im_hdr = GE_readHeaderImage(fid, byte_align);
0075 
0076 % Close the file
0077 fclose(fid);
0078 
0079 return
0080 
0081 
0082 
0083 
0084

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003