Home > bioelectromagnetism > ge_hdr_read.m

ge_hdr_read

PURPOSE ^

ge_hdr_read - Reads the header info from a GE LX2 or 5.X file

SYNOPSIS ^

function [ ge ] = ge_hdr_read(imageFileName)

DESCRIPTION ^

 ge_hdr_read - Reads the header info from a GE LX2 or 5.X file
 
 [ge,im_offset] = ge_hdr_read('imageFileName')

 ge is a struct with fields:
 
 ge.hdr.suite  - suite header
 ge.hdr.exam   - exam header
 ge.hdr.series - series header
 ge.hdr.image  - image header
 ge.hdr.pixel  - pixel header
 
 ge.img.offset  - the byte offset to the image data
 
 This function assumes the image file is big endian.  It can
 automatically determine LX2 format (SGI) and 5.X format (Sun);
 other formats fail.
 
 See also ge_vol_read

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [ ge ] = ge_hdr_read(imageFileName)
0002 
0003 % ge_hdr_read - Reads the header info from a GE LX2 or 5.X file
0004 %
0005 % [ge,im_offset] = ge_hdr_read('imageFileName')
0006 %
0007 % ge is a struct with fields:
0008 %
0009 % ge.hdr.suite  - suite header
0010 % ge.hdr.exam   - exam header
0011 % ge.hdr.series - series header
0012 % ge.hdr.image  - image header
0013 % ge.hdr.pixel  - pixel header
0014 %
0015 % ge.img.offset  - the byte offset to the image data
0016 %
0017 % This function assumes the image file is big endian.  It can
0018 % automatically determine LX2 format (SGI) and 5.X format (Sun);
0019 % other formats fail.
0020 %
0021 % See also ge_vol_read
0022 %
0023 
0024 
0025 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0026 
0027 % Souheil J. Inati  <souheil.inati@nyu.edu> at 03/2003
0028 % Dartmouth College, May 2000
0029 %
0030 % Darren.Weber_at_radiology.ucsf.edu, March 2003
0031 % - Substantially redesigned file handling and function
0032 %   call structures for integration with mri_toolbox at
0033 %   http://eeg.sf.net
0034 % - Requested permission to distribute code under GPL licence
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 
0037 
0038 % DLW, found this note in an FSL list message:
0039 %This is further confounded by the GE image format I.001 or I.MR
0040 %formats where the data following the header is inverted (top of the
0041 %image for bottom).
0042 
0043 
0044 
0045 fprintf('\nGE_HDR_READ\n'); tic
0046 
0047 fprintf('...reading %s\n',imageFileName);
0048 
0049 % Open the Image File
0050 [fid,message] = fopen(imageFileName,'r','b'); % 'b' = Big-Endian format
0051 if fid == -1, error(message); end
0052 
0053 % Check for the magic number at the first word
0054 magic = fread(fid,1,'int32');
0055 if magic == 1229801286,
0056     % This is a 5.X format image
0057     fprintf('...identified Signa 5.X format\n');
0058     byte_align = 0;
0059     ge.hdr.pixel.offset = 0;
0060     ge.hdr.suite.size   = 114;
0061     ge.hdr.exam.size    = 1024;
0062     ge.hdr.series.size  = 1020;
0063     ge.hdr.image.size   = 1022;
0064 else
0065     % Magic no. not at the 1st word, try at the LX2 position
0066     fseek(fid,3228,-1);
0067     magic = fread(fid,1,'int32');
0068     if magic == 1229801286,
0069         % This is an LX2 format image
0070         fprintf('...identified LX2 format\n');
0071         byte_align = 1;
0072         ge.hdr.pixel.offset = 3228;
0073         ge.hdr.suite.size   = 116;
0074         ge.hdr.exam.size    = 1040;
0075         ge.hdr.series.size  = 1028;
0076         ge.hdr.image.size   = 1044;
0077     else
0078         msg = 'This is not a 5.X or LX2 format image.  No Magic Number.';
0079         error(msg);
0080     end
0081 end
0082 
0083 % Load the pixel header
0084 fseek(fid,ge.hdr.pixel.offset,-1);
0085 ge = ge_readHeaderPixel(fid, byte_align, ge); % see subfunc below
0086 
0087 
0088 % Check for epirecon images
0089 if (ge.hdr.pixel.img_l_dbHdr == 0 & byte_align == 0),
0090     error('This is an epirecon image. No header!');
0091 end
0092 
0093 % Compute the offsets
0094 ge.hdr.suite.offset  = ge.hdr.pixel.img_p_dbHdr;
0095 ge.hdr.exam.offset   = ge.hdr.suite.offset  + ge.hdr.suite.size;
0096 ge.hdr.series.offset = ge.hdr.exam.offset   + ge.hdr.exam.size;
0097 ge.hdr.image.offset  = ge.hdr.series.offset + ge.hdr.series.size;
0098 ge.img.offset        = ge.hdr.pixel.offset  + ge.hdr.pixel.img_hdr_length;
0099 
0100 
0101 
0102 % Load the suite header
0103 fseek(fid,ge.hdr.suite.offset,-1);
0104 ge.hdr.suite = ge_readHeaderSuite(fid, byte_align); % see subfunc below
0105 
0106 % Load the exam header
0107 fseek(fid,ge.hdr.exam.offset,-1);
0108 ge.hdr.exam = ge_readHeaderExam(fid, byte_align); % see subfunc below
0109 
0110 % Load the series header
0111 fseek(fid,ge.hdr.series.offset,-1);
0112 ge.hdr.series = ge_readHeaderSeries(fid, byte_align); % see subfunc below
0113 
0114 % Load the image header
0115 fseek(fid,ge.hdr.image.offset,-1);
0116 ge.hdr.image = ge_readHeaderImage(fid, byte_align); % see subfunc below
0117 
0118 % Close the file
0119 fclose(fid);
0120 
0121 t=toc; fprintf('...done (%5.2f sec).\n',t);
0122 
0123 return
0124 
0125 
0126 
0127 
0128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0130 function su_hdr = ge_readHeaderSuite(fid, byte_align)
0131 
0132 % Loads the suite header from an image file (with fid)
0133 % and returns it as a structure.
0134 %
0135 % if byte_align = 1 then 32-bit alignment (SGI, LX2 format)
0136 % if byte_align = 0 then 16-bit alignment (Sun, 5.X format)
0137 
0138 % define the structure and read
0139 su_hdr = struct('su_id', fread(fid,4,'char'));                   % Suite ID
0140 su_hdr = setfield(su_hdr, 'su_uniq', fread(fid,1,'int16'));      % The Make-Unique Flag
0141 su_hdr = setfield(su_hdr, 'su_diskid', fread(fid,1,'char'));     % Disk ID
0142 su_hdr = setfield(su_hdr, 'prodid', fread(fid,13,'char'));       % Product ID
0143 su_hdr = setfield(su_hdr, 'su_verscre', fread(fid,2,'char'));    % Genesis Version
0144 su_hdr = setfield(su_hdr, 'su_verscur', fread(fid,2,'char'));    % Genesis Version
0145 su_hdr = setfield(su_hdr, 'su_checksum', fread(fid,1,'uint32')); % Suite Record Checksum
0146 su_hdr = setfield(su_hdr, 'su_padding', fread(fid,85,'char'));   % Spare Space
0147 fseek(fid,1,0); % 16-bit alignment
0148 if byte_align, fseek(fid,2,0); end % 32-bit alignment
0149 
0150 return
0151 
0152 
0153 
0154 
0155 
0156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0157 
0158 function ex_hdr = ge_readHeaderExam(fid, byte_align)
0159 
0160 % Loads the exam header from the image file
0161 % and returns it as a structure.
0162 %
0163 % if byte_align = 1 then 32-bit alignment (SGI, LX2 format)
0164 % if byte_align = 0 then 16-bit alignment (Sun, 5.X format)
0165 
0166 % define the structure and read ifseek(fid,1,0);  % byte align the data
0167 % to overcome the byte alignment problems
0168 % break up the assignment into pieces using the setfield function
0169 ex_hdr = struct('ex_suid', fread(fid,4,'uchar')); %Suite ID for this Exam%
0170 ex_hdr = setfield(ex_hdr, 'ex_uniq', fread(fid,1,'int16'));        %The Make-Unique Flag%
0171 ex_hdr = setfield(ex_hdr, 'ex_diskid', fread(fid,1,'uchar'));      %Disk ID for this Exam%
0172 fseek(fid,1,0); % 16-bit alignment
0173 ex_hdr = setfield(ex_hdr, 'ex_no', fread(fid,1,'uint16'));         %Exam Number%
0174 ex_hdr = setfield(ex_hdr, 'hospname', fread(fid,33,'uchar'));      %Hospital Name%
0175 fseek(fid,1,0); % 16-bit alignment
0176 ex_hdr = setfield(ex_hdr, 'detect', fread(fid,1,'int16'));         %Detector Type%
0177 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0178 ex_hdr = setfield(ex_hdr, 'numcells', fread(fid,1,'int32'));       %Number of cells in det%
0179 ex_hdr = setfield(ex_hdr, 'zerocell', fread(fid,1,'float32'));     %Cell number at theta%
0180 ex_hdr = setfield(ex_hdr, 'cellspace', fread(fid,1,'float32'));    %Cell spacing%
0181 ex_hdr = setfield(ex_hdr, 'srctodet', fread(fid,1,'float32'));     %Distance from source to detector%
0182 ex_hdr = setfield(ex_hdr, 'srctoiso', fread(fid,1,'float32'));     %Distance from source to iso%
0183 ex_hdr = setfield(ex_hdr, 'tubetyp', fread(fid,1,'int16'));        %Tube type%
0184 ex_hdr = setfield(ex_hdr, 'dastyp', fread(fid,1,'int16'));         %DAS type%
0185 ex_hdr = setfield(ex_hdr, 'num_dcnk', fread(fid,1,'int16'));       %Number of Decon Kernals%
0186 ex_hdr = setfield(ex_hdr, 'dcn_len', fread(fid,1,'int16'));        %Number of elements in a Decon Kernal%
0187 ex_hdr = setfield(ex_hdr, 'dcn_density', fread(fid,1,'int16'));    %Decon Kernal density%
0188 ex_hdr = setfield(ex_hdr, 'dcn_stepsize', fread(fid,1,'int16'));   %Decon Kernal stepsize%
0189 ex_hdr = setfield(ex_hdr, 'dcn_shiftcnt', fread(fid,1,'int16'));   %Decon Kernal Shift Count%
0190 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0191 ex_hdr = setfield(ex_hdr, 'magstrength', fread(fid,1,'int32'));    %Magnet strength (in gauss)%
0192 ex_hdr = setfield(ex_hdr, 'patid', fread(fid,13,'uchar'));         %Patient ID for this Exam%
0193 ex_hdr = setfield(ex_hdr, 'patname', fread(fid,25,'uchar'));       %Patientsda Name%
0194 ex_hdr = setfield(ex_hdr, 'patage', fread(fid,1,'int16'));         %Patient Age (years, months or days)%
0195 ex_hdr = setfield(ex_hdr, 'patian', fread(fid,1,'int16'));         %Patient Age Notation%
0196 ex_hdr = setfield(ex_hdr, 'patsex', fread(fid,1,'int16'));         %Patient Sex%
0197 ex_hdr = setfield(ex_hdr, 'patweight', fread(fid,1,'int32'));      %Patient Weight%
0198 ex_hdr = setfield(ex_hdr, 'trauma', fread(fid,1,'int16'));         %Trauma Flag%
0199 ex_hdr = setfield(ex_hdr, 'hist', fread(fid,61,'uchar'));          %Patient History%
0200 ex_hdr = setfield(ex_hdr, 'reqnum', fread(fid,13,'uchar'));        %Requisition Number%
0201 ex_hdr = setfield(ex_hdr, 'ex_datetime', fread(fid,1,'int32'));    %Exam date/time stamp%
0202 ex_hdr = setfield(ex_hdr, 'refphy', fread(fid,33,'uchar'));        %Referring Physician%
0203 ex_hdr = setfield(ex_hdr, 'diagrad', fread(fid,33,'uchar'));       %Diagnostician/Radiologist%
0204 ex_hdr = setfield(ex_hdr, 'op', fread(fid,4,'uchar'));             %Operator%
0205 ex_hdr = setfield(ex_hdr, 'ex_desc', fread(fid,23,'uchar'));       %Exam Description%
0206 ex_hdr = setfield(ex_hdr, 'ex_typ', fread(fid,3,'uchar'));         %Exam Type%
0207 ex_hdr = setfield(ex_hdr, 'ex_format', fread(fid,1,'int16'));      %Exam Format%
0208 if byte_align; fseek(fid,6,0); end % 32-bit alignment
0209 ex_hdr = setfield(ex_hdr, 'firstaxtime', fread(fid,1,'float64'));  %Start time(secs) of first axial in exam%
0210 ex_hdr = setfield(ex_hdr, 'ex_sysid', fread(fid,9,'uchar'));       %Creator Suite and Host%
0211 fseek(fid,1,0); % 16-bit alignment
0212 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0213 ex_hdr = setfield(ex_hdr, 'ex_lastmod', fread(fid,1,'int32'));     %Date/Time of Last Change%
0214 ex_hdr = setfield(ex_hdr, 'protocolflag', fread(fid,1,'int16'));   %Non-Zero indicates Protocol Exam%
0215 ex_hdr = setfield(ex_hdr, 'ex_alloc_key', fread(fid,13,'uchar'));  %Process that allocated this record%
0216 fseek(fid,1,0); % 16-bit alignment
0217 ex_hdr = setfield(ex_hdr, 'ex_delta_cnt', fread(fid,1,'int32'));   %Indicates number of updates to header%
0218 ex_hdr = setfield(ex_hdr, 'ex_verscre', fread(fid,2,'uchar'));     %Genesis Version - Created%
0219 ex_hdr = setfield(ex_hdr, 'ex_verscur', fread(fid,2,'uchar'));     %Genesis Version - Now%
0220 ex_hdr = setfield(ex_hdr, 'ex_checksum', fread(fid,1,'uint32'));   %Exam Record Checksum%
0221 ex_hdr = setfield(ex_hdr, 'ex_complete', fread(fid,1,'int32'));    %Exam Complete Flag%
0222 ex_hdr = setfield(ex_hdr, 'ex_seriesct', fread(fid,1,'int32'));    %Last Series Number Used%
0223 ex_hdr = setfield(ex_hdr, 'ex_numarch', fread(fid,1,'int32'));     %Number of Series Archived%
0224 ex_hdr = setfield(ex_hdr, 'ex_numseries', fread(fid,1,'int32'));   %Number of Series Existing%
0225 ex_hdr = setfield(ex_hdr, 'ex_series', struct('length', fread(fid,1,'uint32'), ...
0226     'data', fread(fid,1,'uint32')));  %Series Keys for this Exam%
0227 ex_hdr = setfield(ex_hdr, 'ex_numunser', fread(fid,1,'int32'));    %Number of Unstored Series%
0228 ex_hdr = setfield(ex_hdr, 'ex_unseries', struct('length', fread(fid,1,'uint32'), ...
0229     'data', fread(fid,1,'uint32')));    %Unstored Series Keys for this Exam%
0230 ex_hdr = setfield(ex_hdr, 'ex_toarchcnt', fread(fid,1,'int32'));   %Number of Unarchived Series%
0231 ex_hdr = setfield(ex_hdr, 'ex_toarchive', struct('length', fread(fid,1,'uint32'), ...
0232     'data', fread(fid,1,'uint32')));     %Unarchived Series Keys for this Exam%
0233 ex_hdr = setfield(ex_hdr, 'ex_prospcnt', fread(fid,1,'int32'));    %Number of Prospective/Scout Series%
0234 ex_hdr = setfield(ex_hdr, 'ex_prosp', struct('length', fread(fid,1,'uint32'), ...
0235     'data', fread(fid,1,'uint32'))); %Prospective/Scout Series Keys for this Exam%
0236 ex_hdr = setfield(ex_hdr, 'ex_modelnum', fread(fid,1,'int32'));    %Last Model Number used%
0237 ex_hdr = setfield(ex_hdr, 'ex_modelcnt', fread(fid,1,'int32'));    %Number of ThreeD Models%
0238 ex_hdr = setfield(ex_hdr, 'ex_models', struct('length', fread(fid,1,'uint32'), ...
0239     'data', fread(fid,1,'uint32')));  %ThreeD Model Keys for Exam%
0240 ex_hdr = setfield(ex_hdr, 'ex_stat', fread(fid,1,'int16'));        %Patient Status%
0241 ex_hdr = setfield(ex_hdr, 'uniq_sys_id', fread(fid,16,'uchar'));   %Unique System ID%
0242 ex_hdr = setfield(ex_hdr, 'service_id', fread(fid,16,'uchar'));    %Unique Service ID%
0243 ex_hdr = setfield(ex_hdr, 'mobile_loc', fread(fid,4,'uchar'));     %Mobile Location Number%
0244 ex_hdr = setfield(ex_hdr, 'study_uid', fread(fid,32,'uchar'));     %Study Entity Unique ID%
0245 ex_hdr = setfield(ex_hdr, 'study_status', fread(fid,1,'int16'));   %indicates if study has complete info(DICOM/genesis)%
0246 ex_hdr = setfield(ex_hdr, 'ex_padding', fread(fid,516,'uchar'));   %Spare Space%
0247 if byte_align; fseek(fid,4,0); end % byte alignment
0248 
0249 return
0250 
0251 
0252 
0253 
0254 
0255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0256 
0257 function se_hdr = ge_readHeaderSeries(fid, byte_align)
0258 
0259 % returns the series header as a structure.
0260 % if byte_align = 1 then 32-bit alignment (SGI, LX2 format)
0261 % if byte_align = 0 then 16-bit alignment (Sun, 5.X format)
0262 
0263 % define the structure and read in the data
0264 % to overcome the byte alignment problems
0265 % break up the assignment into pieces using the setfield function
0266 se_hdr = struct('se_suid', fread(fid,4,'uchar'));                       %Suite ID for this Series%
0267 se_hdr = setfield(se_hdr, 'se_uniq', fread(fid,1,'int16'));            %The Make-Unique Flag%
0268 se_hdr = setfield(se_hdr, 'se_diskid', fread(fid,1,'uchar'));          %Disk ID for this Series%
0269 fseek(fid,1,0); % 16-bit alignment
0270 se_hdr = setfield(se_hdr, 'se_exno', fread(fid,1,'uint16'));            %Exam Number%
0271 se_hdr = setfield(se_hdr, 'se_no ', fread(fid,1,'int16'));              %Series Number%
0272 se_hdr = setfield(se_hdr, 'se_datetime', fread(fid,1,'int32'));        %Allocation Series Data/Time stamp%
0273 se_hdr = setfield(se_hdr, 'se_actual_dt', fread(fid,1,'int32'));       %Actual Series Data/Time stamp%
0274 se_hdr = setfield(se_hdr, 'se_desc', fread(fid,30,'uchar'));       %Series Description%
0275 se_hdr = setfield(se_hdr, 'pr_sysid', fread(fid,9,'uchar'));       %Primary Receiver Suite and Host%
0276 se_hdr = setfield(se_hdr, 'pansysid', fread(fid,9,'uchar'));       %Archiver Suite and Host%
0277 se_hdr = setfield(se_hdr, 'se_typ ', fread(fid,1,'int16'));             %Series Type%
0278 se_hdr = setfield(se_hdr, 'se_source ', fread(fid,1,'int16'));          %Series from which prescribed%
0279 se_hdr = setfield(se_hdr, 'se_plane ', fread(fid,1,'int16'));           %Most-like Plane (for L/S)%
0280 se_hdr = setfield(se_hdr, 'scan_type ', fread(fid,1,'int16'));          %Scout or Axial (for CT)%
0281 se_hdr = setfield(se_hdr, 'position', fread(fid,1,'int32'));           %Patient Position%
0282 se_hdr = setfield(se_hdr, 'entry', fread(fid,1,'int32'));              %Patient Entry%
0283 se_hdr = setfield(se_hdr, 'anref', fread(fid,3,'uchar'));          %Anatomical reference%
0284 fseek(fid,1,0); % 16-bit alignment
0285 se_hdr = setfield(se_hdr, 'lmhor', fread(fid,1,'float32'));              %Horizontal Landmark%
0286 se_hdr = setfield(se_hdr, 'prtcl', fread(fid,25,'uchar'));         %Scan Protocol Name%
0287 fseek(fid,1,0); % 16-bit alignment
0288 se_hdr = setfield(se_hdr, 'se_contrast ', fread(fid,1,'int16'));        %Non-zero if > 0 image used contrast(L/S)%
0289 se_hdr = setfield(se_hdr, 'start_ras', fread(fid,1,'uchar'));          %RAS letter for first scan location (L/S)%
0290 fseek(fid,1,0); % 16-bit alignment
0291 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0292 se_hdr = setfield(se_hdr, 'start_loc', fread(fid,1,'float32'));          %First scan location (L/S)%
0293 se_hdr = setfield(se_hdr, 'end_ras', fread(fid,1,'uchar'));            %RAS letter for last scan location (L/S)%
0294 fseek(fid,1,0); % 16-bit alignment
0295 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0296 se_hdr = setfield(se_hdr, 'end_loc', fread(fid,1,'float32'));            %Last scan location (L/S)%
0297 se_hdr = setfield(se_hdr, 'se_pseq ', fread(fid,1,'int16'));            %Last Pulse Sequence Used (L/S)%
0298 se_hdr = setfield(se_hdr, 'se_sortorder ', fread(fid,1,'int16'));       %Image Sort Order (L/S)%
0299 se_hdr = setfield(se_hdr, 'se_lndmrkcnt', fread(fid,1,'int32'));       %Landmark Counter%
0300 se_hdr = setfield(se_hdr, 'se_nacq ', fread(fid,1,'int16'));            %Number of Acquisitions%
0301 se_hdr = setfield(se_hdr, 'xbasest ', fread(fid,1,'int16'));            %Starting number for baselines%
0302 se_hdr = setfield(se_hdr, 'xbaseend', fread(fid,1,'int16'));            %Ending number for baselines%
0303 se_hdr = setfield(se_hdr, 'xenhst', fread(fid,1,'int16'));             %Starting number for enhanced scans%
0304 se_hdr = setfield(se_hdr, 'xenhend', fread(fid,1,'int16'));            %Ending number for enhanced scans%
0305 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0306 se_hdr = setfield(se_hdr, 'se_lastmod', fread(fid,1,'int32'));         %Date/Time of Last Change%
0307 se_hdr = setfield(se_hdr, 'se_alloc_key', fread(fid,13,'uchar'));  %Process that allocated this record%
0308 fseek(fid,1,0); % 16-bit alignment
0309 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0310 se_hdr = setfield(se_hdr, 'se_delta_cnt', fread(fid,1,'int32'));       %Indicates number of updates to header%
0311 se_hdr = setfield(se_hdr, 'se_verscre', fread(fid,2,'uchar'));     %Genesis Version - Created%
0312 se_hdr = setfield(se_hdr, 'se_verscur', fread(fid,2,'uchar'));     %Genesis Version - Now%
0313 se_hdr = setfield(se_hdr, 'se_pds_a', fread(fid,1,'float32'));           %PixelData size - as stored%
0314 se_hdr = setfield(se_hdr, 'se_pds_c', fread(fid,1,'float32'));           %PixelData size - Compressed%
0315 se_hdr = setfield(se_hdr, 'se_pds_u', fread(fid,1,'float32'));           %PixelData size - UnCompressed%
0316 se_hdr = setfield(se_hdr, 'se_checksum', fread(fid,1,'uint32'));        %Series Record checksum%
0317 se_hdr = setfield(se_hdr, 'se_complete', fread(fid,1,'int32'));        %Series Complete Flag%
0318 se_hdr = setfield(se_hdr, 'se_numarch', fread(fid,1,'int32'));         %Number of Images Archived%
0319 se_hdr = setfield(se_hdr, 'se_imagect', fread(fid,1,'int32'));         %Last Image Number Used%
0320 se_hdr = setfield(se_hdr, 'se_numimages', fread(fid,1,'int32'));       %Number of Images Existing%
0321 se_hdr = setfield(se_hdr, 'se_images', struct('length', fread(fid,1,'uint32'), ...
0322     'data', fread(fid,1,'uint32'))); %Image Keys for this Series%
0323 se_hdr = setfield(se_hdr, 'se_numunimg', fread(fid,1,'int32'));        %Number of Unstored Images%
0324 se_hdr = setfield(se_hdr, 'se_unimages', struct('length', fread(fid,1,'uint32'), ...
0325     'data', fread(fid,1,'uint32'))); %Unstored Image Keys for this Series%
0326 se_hdr = setfield(se_hdr, 'se_toarchcnt', fread(fid,1,'int32'));       %Number of Unarchived Images%
0327 se_hdr = setfield(se_hdr, 'se_toarchive', struct('length', fread(fid,1,'uint32'), ...
0328     'data', fread(fid,1,'uint32'))); %Unarchived Image Keys for this Series%
0329 se_hdr = setfield(se_hdr, 'echo1_alpha', fread(fid,1,'float32'));        %Echo 1 Alpha Value%
0330 se_hdr = setfield(se_hdr, 'echo1_beta', fread(fid,1,'float32'));         %Echo 1 Beta Value%
0331 se_hdr = setfield(se_hdr, 'echo1_window', fread(fid,1,'uint16'));       %Echo 1 Window Value%
0332 se_hdr = setfield(se_hdr, 'echo1_level', fread(fid,1,'int16'));        %Echo 1 Level Value%
0333 se_hdr = setfield(se_hdr, 'echo2_alpha', fread(fid,1,'float32'));        %Echo 2 Alpha Value%
0334 se_hdr = setfield(se_hdr, 'echo2_beta', fread(fid,1,'float32'));         %Echo 2 Beta Value%
0335 se_hdr = setfield(se_hdr, 'echo2_window', fread(fid,1,'uint16'));       %Echo 2 Window Value%
0336 se_hdr = setfield(se_hdr, 'echo2_level', fread(fid,1,'int16'));        %Echo 2 Level Value%
0337 se_hdr = setfield(se_hdr, 'echo3_alpha', fread(fid,1,'float32'));        %Echo 3 Alpha Value%
0338 se_hdr = setfield(se_hdr, 'echo3_beta', fread(fid,1,'float32'));         %Echo 3 Beta Value%
0339 se_hdr = setfield(se_hdr, 'echo3_window', fread(fid,1,'uint16'));       %Echo 3 Window Value%
0340 se_hdr = setfield(se_hdr, 'echo3_level', fread(fid,1,'int16'));        %Echo 3 Level Value%
0341 se_hdr = setfield(se_hdr, 'echo4_alpha', fread(fid,1,'float32'));        %Echo 4 Alpha Value%
0342 se_hdr = setfield(se_hdr, 'echo4_beta', fread(fid,1,'float32'));         %Echo 4 Beta Value%
0343 se_hdr = setfield(se_hdr, 'echo4_window', fread(fid,1,'uint16'));       %Echo 4 Window Value%
0344 se_hdr = setfield(se_hdr, 'echo4_level', fread(fid,1,'int16'));        %Echo 4 Level Value%
0345 se_hdr = setfield(se_hdr, 'echo5_alpha', fread(fid,1,'float32'));        %Echo 5 Alpha Value%
0346 se_hdr = setfield(se_hdr, 'echo5_beta', fread(fid,1,'float32'));         %Echo 5 Beta Value%
0347 se_hdr = setfield(se_hdr, 'echo5_window', fread(fid,1,'uint16'));       %Echo 5 Window Value%
0348 se_hdr = setfield(se_hdr, 'echo5_level', fread(fid,1,'int16'));        %Echo 5 Level Value%
0349 se_hdr = setfield(se_hdr, 'echo6_alpha', fread(fid,1,'float32'));        %Echo 6 Alpha Value%
0350 se_hdr = setfield(se_hdr, 'echo6_beta', fread(fid,1,'float32'));         %Echo 6 Beta Value%
0351 se_hdr = setfield(se_hdr, 'echo6_window', fread(fid,1,'uint16'));       %Echo 6 Window Value%
0352 se_hdr = setfield(se_hdr, 'echo6_level', fread(fid,1,'int16'));        %Echo 6 Level Value%
0353 se_hdr = setfield(se_hdr, 'echo7_alpha', fread(fid,1,'float32'));        %Echo 7 Alpha Value%
0354 se_hdr = setfield(se_hdr, 'echo7_beta', fread(fid,1,'float32'));         %Echo 7 Beta Value%
0355 se_hdr = setfield(se_hdr, 'echo7_window', fread(fid,1,'uint16'));       %Echo 7 Window Value%
0356 se_hdr = setfield(se_hdr, 'echo7_level', fread(fid,1,'int16'));        %Echo 7 Level Value%
0357 se_hdr = setfield(se_hdr, 'echo8_alpha', fread(fid,1,'float32'));        %Echo 8 Alpha Value%
0358 se_hdr = setfield(se_hdr, 'echo8_beta', fread(fid,1,'float32'));         %Echo 8 Beta Value%
0359 se_hdr = setfield(se_hdr, 'echo8_window', fread(fid,1,'uint16'));       %Echo 8 Window Value%
0360 se_hdr = setfield(se_hdr, 'echo8_level', fread(fid,1,'int16'));        %Echo 8 Level Value%
0361 se_hdr = setfield(se_hdr, 'series_uid', fread(fid,32,'uchar'));    %Series Entity Unique ID%
0362 se_hdr = setfield(se_hdr, 'landmark_uid', fread(fid,32,'uchar'));  %Landmark Unique ID%
0363 se_hdr = setfield(se_hdr, 'equipmnt_uid', fread(fid,32,'uchar'));  %Equipment Unique ID%
0364 se_hdr = setfield(se_hdr, 'se_padding', fread(fid,588,'uchar'));   %Spare Space%
0365 
0366 return
0367 
0368 
0369 
0370 
0371 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0372 
0373 function im_hdr = ge_readHeaderImage(fid, byte_align)
0374 
0375 % returns the image header as a structure.
0376 % if byte_align = 1 then 32-bit alignment (SGI, LX2 format)
0377 % if byte_align = 0 then 16-bit alignment (Sun, 5.X format)
0378 
0379 % define the structure and read in the data
0380 % to overcome the byte alignment problems
0381 % break up the assignment into pieces using the setfield function
0382 
0383 im_hdr = struct('im_suid', fread(fid,4,'uchar')); %Suite id for this image
0384 im_hdr = setfield(im_hdr, 'im_uniq', fread(fid,1,'int16'));            %The Make-Unique Flag
0385 im_hdr = setfield(im_hdr, 'im_diskid', fread(fid,1,'uchar'));          %Disk ID for this Image
0386 fseek(fid, 1, 0);% 16-bit alignment
0387 im_hdr = setfield(im_hdr, 'im_exno', fread(fid,1,'uint16'));            %Exam number for this image
0388 im_hdr = setfield(im_hdr, 'im_seno', fread(fid,1,'int16'));            %Series Number for this image
0389 im_hdr = setfield(im_hdr, 'im_no', fread(fid,1,'int16'));              %Image Number
0390 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0391 im_hdr = setfield(im_hdr, 'im_datetime', fread(fid,1,'int32'));        %Allocation Image date/time stamp
0392 im_hdr = setfield(im_hdr, 'im_actual_dt', fread(fid,1,'int32'));       %Actual Image date/time stamp
0393 im_hdr = setfield(im_hdr, 'sctime', fread(fid,1,'float32'));             %Duration of scan
0394 im_hdr = setfield(im_hdr, 'slthick', fread(fid,1,'float32'));            %Slice Thickness (mm)
0395 im_hdr = setfield(im_hdr, 'imatrix_X', fread(fid,1,'int16'));          %Image matrix size - X
0396 im_hdr = setfield(im_hdr, 'imatrix_Y', fread(fid,1,'int16'));          %Image matrix size - Y
0397 im_hdr = setfield(im_hdr, 'dfov', fread(fid,1,'float32'));               %Display field of view - X (mm)
0398 im_hdr = setfield(im_hdr, 'dfov_rect', fread(fid,1,'float32'));          %Display field of view - Y (if different)
0399 im_hdr = setfield(im_hdr, 'dim_X', fread(fid,1,'float32'));              %Image dimension - X
0400 im_hdr = setfield(im_hdr, 'dim_Y', fread(fid,1,'float32'));              %Image dimension - Y
0401 im_hdr = setfield(im_hdr, 'pixsize_X', fread(fid,1,'float32'));          %Image pixel size - X
0402 im_hdr = setfield(im_hdr, 'pixsize_Y', fread(fid,1,'float32'));          %Image pixel size - Y
0403 im_hdr = setfield(im_hdr, 'pdid', fread(fid,14,'uchar'));          %Pixel Data ID
0404 im_hdr = setfield(im_hdr, 'contrastIV', fread(fid,17,'uchar'));    %IV Contrast Agent
0405 im_hdr = setfield(im_hdr, 'contrastOral', fread(fid,17,'uchar'));  %Oral Contrast Agent
0406 im_hdr = setfield(im_hdr, 'contmode', fread(fid,1,'int16'));           %Image Contrast Mode
0407 im_hdr = setfield(im_hdr, 'serrx', fread(fid,1,'int16'));              %Series from which prescribed
0408 im_hdr = setfield(im_hdr, 'imgrx', fread(fid,1,'int16'));              %Image from which prescribed
0409 im_hdr = setfield(im_hdr, 'screenformat', fread(fid,1,'int16'));       %Screen Format(8/16 bit)
0410 im_hdr = setfield(im_hdr, 'plane', fread(fid,1,'int16'));              %Plane Type
0411 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0412 im_hdr = setfield(im_hdr, 'scanspacing', fread(fid,1,'float32'));        %Spacing between scans (mm?)
0413 im_hdr = setfield(im_hdr, 'im_compress', fread(fid,1,'int16'));        %Image compression type for allocation
0414 im_hdr = setfield(im_hdr, 'im_scouttype', fread(fid,1,'int16'));       %Scout Type (AP or lateral)
0415 im_hdr = setfield(im_hdr, 'loc_ras', fread(fid,1,'uchar'));            %RAS letter of image location
0416 fseek(fid, 1, 0); % 16-bit alignment
0417 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0418 im_hdr = setfield(im_hdr, 'loc', fread(fid,1,'float32'));                %Image location
0419 im_hdr = setfield(im_hdr, 'ctr_R', fread(fid,1,'float32'));              %Center R coord of plane image
0420 im_hdr = setfield(im_hdr, 'ctr_A', fread(fid,1,'float32'));              %Center A coord of plane image
0421 im_hdr = setfield(im_hdr, 'ctr_S', fread(fid,1,'float32'));              %Center S coord of plane image
0422 im_hdr = setfield(im_hdr, 'norm_R', fread(fid,1,'float32'));             %Normal R coord
0423 im_hdr = setfield(im_hdr, 'norm_A', fread(fid,1,'float32'));             %Normal A coord
0424 im_hdr = setfield(im_hdr, 'norm_S', fread(fid,1,'float32'));             %Normal S coord
0425 im_hdr = setfield(im_hdr, 'tlhc_R', fread(fid,1,'float32'));             %R Coord of Top Left Hand Corner
0426 im_hdr = setfield(im_hdr, 'tlhc_A', fread(fid,1,'float32'));             %A Coord of Top Left Hand Corner
0427 im_hdr = setfield(im_hdr, 'tlhc_S', fread(fid,1,'float32'));             %S Coord of Top Left Hand Corner
0428 im_hdr = setfield(im_hdr, 'trhc_R', fread(fid,1,'float32'));             %R Coord of Top Right Hand Corner
0429 im_hdr = setfield(im_hdr, 'trhc_A', fread(fid,1,'float32'));             %A Coord of Top Right Hand Corner
0430 im_hdr = setfield(im_hdr, 'trhc_S', fread(fid,1,'float32'));             %S Coord of Top Right Hand Corner
0431 im_hdr = setfield(im_hdr, 'brhc_R', fread(fid,1,'float32'));             %R Coord of Bottom Right Hand Corner
0432 im_hdr = setfield(im_hdr, 'brhc_A', fread(fid,1,'float32'));             %A Coord of Bottom Right Hand Corner
0433 im_hdr = setfield(im_hdr, 'brhc_S', fread(fid,1,'float32'));             %S Coord of Bottom Right Hand Corner
0434 im_hdr = setfield(im_hdr, 'forimgrev', fread(fid,4,'uchar'));      %Foreign Image Revision
0435 im_hdr = setfield(im_hdr, 'tr', fread(fid,1,'int32'));                 %Pulse repetition time(usec)
0436 im_hdr = setfield(im_hdr, 'ti', fread(fid,1,'int32'));                 %Pulse inversion time(usec)
0437 im_hdr = setfield(im_hdr, 'te', fread(fid,1,'int32'));                 %Pulse echo time(usec)
0438 im_hdr = setfield(im_hdr, 'te2', fread(fid,1,'int32'));                %Second echo echo (usec)
0439 im_hdr = setfield(im_hdr, 'numecho', fread(fid,1,'int16'));            %Number of echoes
0440 im_hdr = setfield(im_hdr, 'echonum', fread(fid,1,'int16'));            %Echo Number
0441 im_hdr = setfield(im_hdr, 'tbldlta', fread(fid,1,'float32'));            %Table Delta
0442 im_hdr = setfield(im_hdr, 'nex', fread(fid,1,'float32'));                %Number of Excitations
0443 im_hdr = setfield(im_hdr, 'contig', fread(fid,1,'int16'));             %Continuous Slices Flag
0444 im_hdr = setfield(im_hdr, 'hrtrate', fread(fid,1,'int16'));            %Cardiac Heart Rate (bpm)
0445 im_hdr = setfield(im_hdr, 'tdel', fread(fid,1,'int32'));               %Delay time after trigger (msec)
0446 im_hdr = setfield(im_hdr, 'saravg', fread(fid,1,'float32'));             %Average SAR
0447 im_hdr = setfield(im_hdr, 'sarpeak', fread(fid,1,'float32'));            %Peak SAR
0448 im_hdr = setfield(im_hdr, 'monsar', fread(fid,1,'int16'));             %Monitor SAR flag
0449 im_hdr = setfield(im_hdr, 'trgwindow', fread(fid,1,'int16'));          %Trigger window (% of R-R interval)
0450 im_hdr = setfield(im_hdr, 'reptime', fread(fid,1,'float32'));            %Cardiac repetition time
0451 im_hdr = setfield(im_hdr, 'imgpcyc', fread(fid,1,'int16'));            %Images per cardiac cycle
0452 im_hdr = setfield(im_hdr, 'xmtgain', fread(fid,1,'int16'));            %Actual Transmit Gain (.1 db)
0453 im_hdr = setfield(im_hdr, 'rcvgain1', fread(fid,1,'int16'));           %Actual Receive Gain Analog (.1 db)
0454 im_hdr = setfield(im_hdr, 'rcvgain2', fread(fid,1,'int16'));           %Actual Receive Gain Digital (.1 db)
0455 im_hdr = setfield(im_hdr, 'mr_flip', fread(fid,1,'int16'));            %Flip Angle for GRASS scans (deg.)
0456 if byte_align; fseek(fid, 2, 0); end % byte alignment
0457 im_hdr = setfield(im_hdr, 'mindat', fread(fid,1,'int32'));             %Minimum Delay after Trigger (uSec)
0458 im_hdr = setfield(im_hdr, 'cphase', fread(fid,1,'int16'));             %Total Cardiac Phase prescribed
0459 im_hdr = setfield(im_hdr, 'swappf', fread(fid,1,'int16'));             %Swap Phase/Frequency Axis
0460 im_hdr = setfield(im_hdr, 'pauseint', fread(fid,1,'int16'));           %Pause Interval (slices)
0461 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0462 im_hdr = setfield(im_hdr, 'pausetime', fread(fid,1,'float32'));          %Pause Time
0463 im_hdr = setfield(im_hdr, 'obplane', fread(fid,1,'int32'));            %Oblique Plane
0464 im_hdr = setfield(im_hdr, 'slocfov', fread(fid,1,'int32'));            %Slice Offsets on Freq axis
0465 im_hdr = setfield(im_hdr, 'xmtfreq', fread(fid,1,'int32'));            %Center Frequency (0.1 Hz)
0466 im_hdr = setfield(im_hdr, 'autoxmtfreq', fread(fid,1,'int32'));        %Auto Center Frequency (0.1 Hz)
0467 im_hdr = setfield(im_hdr, 'autoxmtgain', fread(fid,1,'int16'));        %Auto Transmit Gain (0.1 dB)
0468 im_hdr = setfield(im_hdr, 'prescan_r1', fread(fid,1,'int16'));         %PreScan R1 - Analog
0469 im_hdr = setfield(im_hdr, 'prescan_r2', fread(fid,1,'int16'));         %PreScan R2 - Digital
0470 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0471 im_hdr = setfield(im_hdr, 'user_bitmap', fread(fid,1,'int32'));        %Bitmap defining user CVs
0472 im_hdr = setfield(im_hdr, 'cenfreq', fread(fid,1,'int16'));            %Center Frequency Method
0473 im_hdr = setfield(im_hdr, 'imode', fread(fid,1,'int16'));              %Imaging Mode
0474 im_hdr = setfield(im_hdr, 'iopt', fread(fid,1,'int32'));               %Imaging Options
0475 im_hdr = setfield(im_hdr, 'pseq', fread(fid,1,'int16'));               %Pulse Sequence
0476 im_hdr = setfield(im_hdr, 'pseqmode', fread(fid,1,'int16'));           %Pulse Sequence Mode
0477 im_hdr = setfield(im_hdr, 'psdname', fread(fid,33,'uchar'));       %Pulse Sequence Name
0478 fseek(fid,1,0); % 16-bit alignment
0479 if byte_align; fseek(fid, 2, 0); end % byte alignment
0480 im_hdr = setfield(im_hdr, 'psd_datetime', fread(fid,1,'int32'));       %PSD Creation Date and Time
0481 im_hdr = setfield(im_hdr, 'psd_iname', fread(fid,13,'uchar'));     %PSD name from inside PSD
0482 fseek(fid, 1, 0); % 16-bit alignment
0483 im_hdr = setfield(im_hdr, 'ctyp', fread(fid,1,'int16'));               %Coil Type
0484 im_hdr = setfield(im_hdr, 'cname', fread(fid,17,'uchar'));         %Coil Name
0485 fseek(fid, 1, 0); % 16-bit alignment
0486 im_hdr = setfield(im_hdr, 'surfctyp', fread(fid,1,'int16'));           %Surface Coil Type
0487 im_hdr = setfield(im_hdr, 'surfcext', fread(fid,1,'int16'));           %Extremity Coil Flag
0488 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0489 im_hdr = setfield(im_hdr, 'rawrunnum', fread(fid,1,'int32'));          %RawData Run Number
0490 im_hdr = setfield(im_hdr, 'cal_fldstr', fread(fid,1,'uint32'));         %Calibrated Field Strength (x10 uGauss)
0491 im_hdr = setfield(im_hdr, 'supp_tech', fread(fid,1,'int16'));          %SAT fat/water/none
0492 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0493 im_hdr = setfield(im_hdr, 'vbw', fread(fid,1,'float32'));                %Variable Bandwidth (Hz)
0494 im_hdr = setfield(im_hdr, 'slquant', fread(fid,1,'int16'));            %Number of slices in this scan group
0495 im_hdr = setfield(im_hdr, 'gpre', fread(fid,1,'int16'));               %Graphically prescribed
0496 im_hdr = setfield(im_hdr, 'intr_del', fread(fid,1,'int32'));           %Interimage/interloc delay (uSec)
0497 im_hdr = setfield(im_hdr, 'user0', fread(fid,1,'float32'));              %User Variable 0
0498 im_hdr = setfield(im_hdr, 'user1', fread(fid,1,'float32'));              %User Variable 1
0499 im_hdr = setfield(im_hdr, 'user2', fread(fid,1,'float32'));              %User Variable 2
0500 im_hdr = setfield(im_hdr, 'user3', fread(fid,1,'float32'));              %User Variable 3
0501 im_hdr = setfield(im_hdr, 'user4', fread(fid,1,'float32'));              %User Variable 4
0502 im_hdr = setfield(im_hdr, 'user5', fread(fid,1,'float32'));              %User Variable 5
0503 im_hdr = setfield(im_hdr, 'user6', fread(fid,1,'float32'));              %User Variable 6
0504 im_hdr = setfield(im_hdr, 'user7', fread(fid,1,'float32'));              %User Variable 7
0505 im_hdr = setfield(im_hdr, 'user8', fread(fid,1,'float32'));              %User Variable 8
0506 im_hdr = setfield(im_hdr, 'user9', fread(fid,1,'float32'));              %User Variable 9
0507 im_hdr = setfield(im_hdr, 'user10', fread(fid,1,'float32'));             %User Variable 10
0508 im_hdr = setfield(im_hdr, 'user11', fread(fid,1,'float32'));             %User Variable 11
0509 im_hdr = setfield(im_hdr, 'user12', fread(fid,1,'float32'));             %User Variable 12
0510 im_hdr = setfield(im_hdr, 'user13', fread(fid,1,'float32'));             %User Variable 13
0511 im_hdr = setfield(im_hdr, 'user14', fread(fid,1,'float32'));             %User Variable 14
0512 im_hdr = setfield(im_hdr, 'user15', fread(fid,1,'float32'));             %User Variable 15
0513 im_hdr = setfield(im_hdr, 'user16', fread(fid,1,'float32'));             %User Variable 16
0514 im_hdr = setfield(im_hdr, 'user17', fread(fid,1,'float32'));             %User Variable 17
0515 im_hdr = setfield(im_hdr, 'user18', fread(fid,1,'float32'));             %User Variable 18
0516 im_hdr = setfield(im_hdr, 'user19', fread(fid,1,'float32'));             %User Variable 19
0517 im_hdr = setfield(im_hdr, 'user20', fread(fid,1,'float32'));             %User Variable 20
0518 im_hdr = setfield(im_hdr, 'user21', fread(fid,1,'float32'));             %User Variable 21
0519 im_hdr = setfield(im_hdr, 'user22', fread(fid,1,'float32'));             %User Variable 22
0520 im_hdr = setfield(im_hdr, 'user23', fread(fid,1,'float32'));             %Projection Angle
0521 im_hdr = setfield(im_hdr, 'user24', fread(fid,1,'float32'));             %Concat Sat Type Flag
0522 im_hdr = setfield(im_hdr, 'im_alloc_key', fread(fid,13,'uchar'));
0523 fseek(fid, 1, 0); % 16-bit alignment
0524 if byte_align; fseek(fid, 2, 0); end % 32-bit alignment
0525 im_hdr = setfield(im_hdr, 'im_lastmod', fread(fid,1,'int32'));         %Date/Time of Last Change
0526 im_hdr = setfield(im_hdr, 'im_verscre', fread(fid,2,'uchar'));     %Genesis Version - Created
0527 im_hdr = setfield(im_hdr, 'im_verscur', fread(fid,2,'uchar'));     %Genesis Version - Now
0528 im_hdr = setfield(im_hdr, 'im_pds_a', fread(fid,1,'int32'));           %PixelData size - as stored
0529 im_hdr = setfield(im_hdr, 'im_pds_c', fread(fid,1,'int32'));           %PixelData size - Compressed
0530 im_hdr = setfield(im_hdr, 'im_pds_u', fread(fid,1,'int32'));           %PixelData size - UnCompressed
0531 im_hdr = setfield(im_hdr, 'im_checksum', fread(fid,1,'int32'));        %AcqRecon record checksum
0532 im_hdr = setfield(im_hdr, 'im_archived', fread(fid,1,'int32'));        %Image Archive Flag
0533 im_hdr = setfield(im_hdr, 'im_complete', fread(fid,1,'int32'));        %Image Complete Flag
0534 im_hdr = setfield(im_hdr, 'satbits', fread(fid,1,'int16'));            %Bitmap of SAT selections
0535 im_hdr = setfield(im_hdr, 'scic', fread(fid,1,'int16'));               %Surface Coil Intensity Correction Flag
0536 im_hdr = setfield(im_hdr, 'satxloc1', fread(fid,1,'int16'));           %R-side SAT pulse loc rel to lndmrk
0537 im_hdr = setfield(im_hdr, 'satxloc2', fread(fid,1,'int16'));           %L-side SAT pulse loc rel to lndmrk
0538 im_hdr = setfield(im_hdr, 'satyloc1', fread(fid,1,'int16'));           %A-side SAT pulse loc rel to lndmrk
0539 im_hdr = setfield(im_hdr, 'satyloc2', fread(fid,1,'int16'));           %P-side SAT pulse loc rel to lndmrk
0540 im_hdr = setfield(im_hdr, 'satzloc1', fread(fid,1,'int16'));           %S-side SAT pulse loc rel to lndmrk
0541 im_hdr = setfield(im_hdr, 'satzloc2', fread(fid,1,'int16'));           %I-side SAT pulse loc rel to lndmrk
0542 im_hdr = setfield(im_hdr, 'satxthick', fread(fid,1,'int16'));          %Thickness of X-axis SAT pulse
0543 im_hdr = setfield(im_hdr, 'satythick', fread(fid,1,'int16'));          %Thickness of Y-axis SAT pulse
0544 im_hdr = setfield(im_hdr, 'satzthick', fread(fid,1,'int16'));          %Thickness of Z-axis SAT pulse
0545 im_hdr = setfield(im_hdr, 'flax', fread(fid,1,'int16'));               %Phase contrast flow axis
0546 im_hdr = setfield(im_hdr, 'venc', fread(fid,1,'int16'));               %Phase contrast velocity encoding
0547 im_hdr = setfield(im_hdr, 'thk_disclmr', fread(fid,1,'int16'));        %Slice Thickness
0548 im_hdr = setfield(im_hdr, 'ps_flag', fread(fid,1,'int16'));            %Auto/Manual Prescan flag
0549 im_hdr = setfield(im_hdr, 'ps_status', fread(fid,1,'int16'));          %Bitmap of changed values
0550 im_hdr = setfield(im_hdr, 'image_type', fread(fid,1,'int16'));         %Magnitude, Phase, Imaginary, or Real
0551 im_hdr = setfield(im_hdr, 'vas_collapse', fread(fid,1,'int16'));       %Collapse Image
0552 im_hdr = setfield(im_hdr, 'user23n', fread(fid,1,'float32'));            %User Variable 23
0553 im_hdr = setfield(im_hdr, 'user24n', fread(fid,1,'float32'));            %User Variable 24
0554 im_hdr = setfield(im_hdr, 'proj_alg', fread(fid,1,'int16'));           %Projection Algorithm
0555 im_hdr = setfield(im_hdr, 'proj_name', fread(fid,13,'uchar'));     %Projection Algorithm Name
0556 fseek(fid, 1, 0); % 16-bit alignment
0557 im_hdr = setfield(im_hdr, 'x_axis_rot', fread(fid,1,'float32'));         %X Axis Rotation
0558 im_hdr = setfield(im_hdr, 'y_axis_rot', fread(fid,1,'float32'));         %Y Axis Rotation
0559 im_hdr = setfield(im_hdr, 'z_axis_rot', fread(fid,1,'float32'));         %Z Axis Rotation
0560 im_hdr = setfield(im_hdr, 'thresh_min1', fread(fid,1,'int32'));        %Lower Range of Pixels 1
0561 im_hdr = setfield(im_hdr, 'thresh_max1', fread(fid,1,'int32'));        %Upper Range of Pixels 1
0562 im_hdr = setfield(im_hdr, 'thresh_min2', fread(fid,1,'int32'));        %Lower Range of Pixels 2
0563 im_hdr = setfield(im_hdr, 'thresh_max2', fread(fid,1,'int32'));        %Upper Range of Pixels 2
0564 im_hdr = setfield(im_hdr, 'echo_trn_len', fread(fid,1,'int16'));       %Echo Train Length for Fast Spin Echo
0565 im_hdr = setfield(im_hdr, 'frac_echo', fread(fid,1,'int16'));          %Fractional Echo - Effective TE Flag
0566 im_hdr = setfield(im_hdr, 'prep_pulse', fread(fid,1,'int16'));         %Preporatory Pulse Option
0567 im_hdr = setfield(im_hdr, 'cphasenum', fread(fid,1,'int16'));          %Cardiac Phase Number
0568 im_hdr = setfield(im_hdr, 'var_echo', fread(fid,1,'int16'));           %Variable Echo Flag
0569 im_hdr = setfield(im_hdr, 'ref_img', fread(fid,1,'uchar'));            %Reference Image Field
0570 im_hdr = setfield(im_hdr, 'sum_img', fread(fid,1,'uchar'));            %Summary Image Field
0571 im_hdr = setfield(im_hdr, 'img_window', fread(fid,1,'uint16'));         %Window Value
0572 im_hdr = setfield(im_hdr, 'img_level', fread(fid,1,'int16'));          %Level Value
0573 im_hdr = setfield(im_hdr, 'slop_int_1', fread(fid,1,'int32'));         %Number of 3D Slabs
0574 im_hdr = setfield(im_hdr, 'slop_int_2', fread(fid,1,'int32'));         %Slice Locs Per 3D Slab
0575 im_hdr = setfield(im_hdr, 'slop_int_3', fread(fid,1,'int32'));         %# of Slice Locs on Each Slab Which Overlap Neighbors
0576 im_hdr = setfield(im_hdr, 'slop_int_4', fread(fid,1,'int32'));         %Image Filtering 0.5/0.2T
0577 im_hdr = setfield(im_hdr, 'slop_int_5', fread(fid,1,'int32'));         %Integer Slop Field 5
0578 im_hdr = setfield(im_hdr, 'slop_float_1', fread(fid,1,'float32'));       %Float Slop Field 1
0579 im_hdr = setfield(im_hdr, 'slop_float_2', fread(fid,1,'float32'));       %Float Slop Field 2
0580 im_hdr = setfield(im_hdr, 'slop_float_3', fread(fid,1,'float32'));       %Float Slop Field 3
0581 im_hdr = setfield(im_hdr, 'slop_float_4', fread(fid,1,'float32'));       %Float Slop Field 4
0582 im_hdr = setfield(im_hdr, 'slop_float_5', fread(fid,1,'float32'));       %Float Slop Field 5
0583 im_hdr = setfield(im_hdr, 'slop_str_1', fread(fid,16,'uchar'));    %String Slop Field 1
0584 im_hdr = setfield(im_hdr, 'slop_str_2', fread(fid,16,'uchar'));    %String Slop Field 2
0585 im_hdr = setfield(im_hdr, 'scanactno', fread(fid,1,'int16'));          %Scan Acquisition Number
0586 im_hdr = setfield(im_hdr, 'vasflags', fread(fid,1,'int16'));           %Magnitude Weighting Flag
0587 im_hdr = setfield(im_hdr, 'vencscale', fread(fid,1,'float32'));          %Scale Weighted Venc
0588 im_hdr = setfield(im_hdr, 'integrity', fread(fid,1,'int16'));          %GE Image Integrity
0589 if byte_align; fseek(fid, 2, 0); end % byte alignment
0590 im_hdr = setfield(im_hdr, 'fphase', fread(fid,1,'int32'));             %Number Of Phases
0591 im_hdr = setfield(im_hdr, 'freq_dir', fread(fid,1,'int16'));           %Frequency Direction
0592 im_hdr = setfield(im_hdr, 'vas_mode', fread(fid,1,'int16'));           %Vascular Mode
0593 im_hdr = setfield(im_hdr, 'image_uid', fread(fid,32,'uchar'));     %Image Unique ID
0594 im_hdr = setfield(im_hdr, 'sop_uid', fread(fid,32,'uchar'));       %Service Obj Class Unique ID
0595 im_hdr = setfield(im_hdr, 'dont_use_1', fread(fid,1,'int16'));         %This field is not used
0596 im_hdr = setfield(im_hdr, 'dont_use_2', fread(fid,1,'int16'));         %This field is not used
0597 im_hdr = setfield(im_hdr, 'dont_use_3', fread(fid,1,'int16'));         %This field is not used
0598 im_hdr = setfield(im_hdr, 'pscopts', fread(fid,1,'int16'));            %bitmap of prescan options
0599 im_hdr = setfield(im_hdr, 'asoffsetx', fread(fid,1,'int16'));          %gradient offset in X-direction
0600 im_hdr = setfield(im_hdr, 'asoffsety', fread(fid,1,'int16'));          %gradient offset in Y-direction
0601 im_hdr = setfield(im_hdr, 'asoffsetz', fread(fid,1,'int16'));          %gradient offset in Z-direction
0602 im_hdr = setfield(im_hdr, 'unoriginal', fread(fid,1,'int16'));         %identifies image as original or unoriginal
0603 im_hdr = setfield(im_hdr, 'interleaves', fread(fid,1,'int16'));        %number of EPI shots
0604 im_hdr = setfield(im_hdr, 'effechospace', fread(fid,1,'int16'));       %effective echo spacing for EPI
0605 im_hdr = setfield(im_hdr, 'viewsperseg', fread(fid,1,'int16'));        %views per segment
0606 im_hdr = setfield(im_hdr, 'rbpm', fread(fid,1,'int16'));               %respiratory rate, breaths per min
0607 im_hdr = setfield(im_hdr, 'rtpoint', fread(fid,1,'int16'));            %respiratory trigger point as percent of max.
0608 im_hdr = setfield(im_hdr, 'rcvrtype', fread(fid,1,'int16'));           %type of receiver used
0609 im_hdr = setfield(im_hdr, 'dbdt', fread(fid,1,'float32'));               %peak rate of change of gradient field, tesla/sec
0610 im_hdr = setfield(im_hdr, 'dbdtper', fread(fid,1,'float32'));            %limit in units of percent of theoretical curve
0611 im_hdr = setfield(im_hdr, 'estdbdtper', fread(fid,1,'float32'));         %PSD estimated limit in units of percent
0612 im_hdr = setfield(im_hdr, 'estdbdtts', fread(fid,1,'float32'));          %PSD estimated limit in Teslas/sec
0613 im_hdr = setfield(im_hdr, 'saravghead', fread(fid,1,'float32'));         %Avg head SAR
0614 im_hdr = setfield(im_hdr, 'neg_scanspacing', fread(fid,1,'float32'));    %Negative scan spacing for overlap slices
0615 im_hdr = setfield(im_hdr, 'offsetfreq', fread(fid,1,'int32'));         %Offset Frequency - Mag.Transfer
0616 im_hdr = setfield(im_hdr, 'user_usage_tag', fread(fid,1,'uint32'));     %Defines how following user CVs are to be filled in
0617 %Default value = 0x00000000
0618 %GE range = 0x00000001 - 0x7fffffff
0619 %Research = 0x80000000 - 0xffffffff
0620 im_hdr = setfield(im_hdr, 'user_fill_mapMSW', fread(fid,1,'uint32'));   %Define what process fills in the user CVs, ifcc or TIR
0621 im_hdr = setfield(im_hdr, 'user_fill_mapLSW', fread(fid,1,'uint32'));   %Define what process fills in the user CVs, ifcc or TIR
0622 im_hdr = setfield(im_hdr, 'user25', fread(fid,1,'float32'));             %User Variable 25
0623 im_hdr = setfield(im_hdr, 'user26', fread(fid,1,'float32'));             %User Variable 26
0624 im_hdr = setfield(im_hdr, 'user27', fread(fid,1,'float32'));             %User Variable 27
0625 im_hdr = setfield(im_hdr, 'user28', fread(fid,1,'float32'));             %User Variable 28
0626 im_hdr = setfield(im_hdr, 'user29', fread(fid,1,'float32'));             %User Variable 29
0627 im_hdr = setfield(im_hdr, 'user30', fread(fid,1,'float32'));             %User Variable 30
0628 im_hdr = setfield(im_hdr, 'user31', fread(fid,1,'float32'));             %User Variable 31
0629 im_hdr = setfield(im_hdr, 'user32', fread(fid,1,'float32'));             %User Variable 32
0630 im_hdr = setfield(im_hdr, 'user33', fread(fid,1,'float32'));             %User Variable 33
0631 im_hdr = setfield(im_hdr, 'user34', fread(fid,1,'float32'));             %User Variable 34
0632 im_hdr = setfield(im_hdr, 'user35', fread(fid,1,'float32'));             %User Variable 35
0633 im_hdr = setfield(im_hdr, 'user36', fread(fid,1,'float32'));             %User Variable 36
0634 im_hdr = setfield(im_hdr, 'user37', fread(fid,1,'float32'));             %User Variable 37
0635 im_hdr = setfield(im_hdr, 'user38', fread(fid,1,'float32'));             %User Variable 38
0636 im_hdr = setfield(im_hdr, 'user39', fread(fid,1,'float32'));             %User Variable 39
0637 im_hdr = setfield(im_hdr, 'user40', fread(fid,1,'float32'));             %User Variable 40
0638 im_hdr = setfield(im_hdr, 'user41', fread(fid,1,'float32'));             %User Variable 41
0639 im_hdr = setfield(im_hdr, 'user42', fread(fid,1,'float32'));             %User Variable 42
0640 im_hdr = setfield(im_hdr, 'user43', fread(fid,1,'float32'));             %User Variable 43
0641 im_hdr = setfield(im_hdr, 'user44', fread(fid,1,'float32'));             %User Variable 44
0642 im_hdr = setfield(im_hdr, 'user45', fread(fid,1,'float32'));             %User Variable 45
0643 im_hdr = setfield(im_hdr, 'user46', fread(fid,1,'float32'));             %User Variable 46
0644 im_hdr = setfield(im_hdr, 'user47', fread(fid,1,'float32'));             %User Variable 47
0645 im_hdr = setfield(im_hdr, 'user48', fread(fid,1,'float32'));             %User Variable 48
0646 im_hdr = setfield(im_hdr, 'slop_int_6', fread(fid,1,'int32'));         %Integer Slop Field 6
0647 im_hdr = setfield(im_hdr, 'slop_int_7', fread(fid,1,'int32'));         %Integer Slop Field 7
0648 im_hdr = setfield(im_hdr, 'slop_int_8', fread(fid,1,'int32'));         %Integer Slop Field 8
0649 im_hdr = setfield(im_hdr, 'slop_int_9', fread(fid,1,'int32'));         %Integer Slop Field 9
0650 im_hdr = setfield(im_hdr, 'mr_padding', fread(fid,32,'uchar'));    %Spare Space
0651 
0652 return
0653 
0654 
0655 
0656 
0657 
0658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0659 
0660 function ge = ge_readHeaderPixel(fid, byte_align, ge)
0661 
0662 % returns the pixel header as a structure.
0663 % if byte_align = 1 then 32-bit alignment (SGI, LX2 format)
0664 % if byte_align = 0 then 16-bit alignment (Sun, 5.X format)
0665 
0666 % read magic number
0667 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_magic', fread(fid,1,'int32'));
0668 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_hdr_length', fread(fid,1,'int32'));% length of total header in bytes and
0669 % a byte displacement to the 'pixel data area'
0670 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_width', fread(fid,1,'int32'));  % width (pixels) of image
0671 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_height', fread(fid,1,'int32')); % height (pixels) of image
0672 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_depth', fread(fid,1,'int32'));  % depth (1, 8, 16, or 24 bits) of pixel
0673 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_compress', fread(fid,1,'int32'));   % type of compression; see IC_* below
0674 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_dwindow', fread(fid,1,'int32'));    % default window setting
0675 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_dlevel', fread(fid,1,'int32')); % default level setting
0676 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_bgshade', fread(fid,1,'int32'));    % background shade to use for non-image
0677 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_ovrflow', fread(fid,1,'int32'));    % overflow value
0678 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_undflow', fread(fid,1,'int32'));    % underflow value
0679 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_top_offset', fread(fid,1,'int32')); % number of blank lines at image top
0680 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_bot_offset', fread(fid,1,'int32')); % number of blank lines at image bottom
0681 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_version', fread(fid,1,'int16'));    % version of the header structure
0682 if byte_align, fseek(fid,2,0); end % 32-bit alignment
0683 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_checksum', fread(fid,1,'uint16')); % 16 bit end_around_carry sum of pixels
0684 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_id', fread(fid,1,'int32'));   % a byte disp to unique image identifier
0685 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_id', fread(fid,1,'int32'));   % byte length of unique image identifier
0686 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_unpack', fread(fid,1,'int32'));   % a byte disp to 'unpack control'
0687 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_unpack', fread(fid,1,'int32'));   % byte length of 'unpack control'
0688 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_compress', fread(fid,1,'int32')); % a byte disp to 'compression control'
0689 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_compress', fread(fid,1,'int32')); % byte length of 'compression control'
0690 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_histo', fread(fid,1,'int32'));    % a byte disp to 'histogram control'
0691 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_histo', fread(fid,1,'int32'));    % byte length of 'histogram control'
0692 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_text', fread(fid,1,'int32')); % a byte disp to 'text plane data'
0693 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_text', fread(fid,1,'int32')); % byte length of 'text plane data'
0694 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_graphics', fread(fid,1,'int32')); % a byte disp to 'graphics plane data'
0695 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_graphics', fread(fid,1,'int32')); % byte length of 'graphics plane data'
0696 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_dbHdr', fread(fid,1,'int32'));    % a byte disp to 'data base header data'
0697 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_dbHdr', fread(fid,1,'int32'));    % byte length of 'data base header data'
0698 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_levelOffset', fread(fid,1,'int32'));% value to add to stored Pixel Data values
0699 % to get the correct presentation value
0700 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_p_user', fread(fid,1,'int32')); % byte displacement to user defined data
0701 ge.hdr.pixel = setfield(ge.hdr.pixel, 'img_l_user', fread(fid,1,'int32')); % byte length of user defined data
0702 
0703 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003