Home > fmri > utils > GE2SPM > GE_readHeaderExam.m

GE_readHeaderExam

PURPOSE ^

SYNOPSIS ^

function ex_hdr = GE_readHeaderExam(fid, byte_align)

DESCRIPTION ^

 ex_hdr = GE_readHeaderExam(fid, byte_align)

 Loads the exam header from the file with filed id fid
 and returns it as a structure. 
 if byte_align = 1 then 32-bit alignment (SGI, LX2 format)
 if byte_align = 0 then 16-bit alignment (Sun, 5.X format)


 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 ex_hdr = GE_readHeaderExam(fid, byte_align)
0002 %
0003 % ex_hdr = GE_readHeaderExam(fid, byte_align)
0004 %
0005 % Loads the exam header from the file with filed id fid
0006 % and returns it as a structure.
0007 % if byte_align = 1 then 32-bit alignment (SGI, LX2 format)
0008 % if byte_align = 0 then 16-bit alignment (Sun, 5.X format)
0009 %
0010 %
0011 % Souheil J. Inati
0012 % Dartmouth College
0013 % May 2000
0014 % souheil.inati@dartmouth.edu
0015 %
0016 
0017 
0018 % define the structure and read ifseek(fid,1,0);  % byte alignmentn the data
0019 % to overcome the byte alignment problems
0020 % break up the assignment into pieces using the setfield function
0021 ex_hdr = struct('ex_suid', fread(fid,4,'uchar')); %Suite ID for this Exam%
0022 ex_hdr = setfield(ex_hdr, 'ex_uniq', fread(fid,1,'int16'));        %The Make-Unique Flag%
0023 ex_hdr = setfield(ex_hdr, 'ex_diskid', fread(fid,1,'uchar'));      %Disk ID for this Exam%
0024 fseek(fid,1,0); % 16-bit alignment
0025 ex_hdr = setfield(ex_hdr, 'ex_no', fread(fid,1,'uint16'));         %Exam Number%
0026 ex_hdr = setfield(ex_hdr, 'hospname', fread(fid,33,'uchar'));      %Hospital Name%
0027 fseek(fid,1,0); % 16-bit alignment
0028 ex_hdr = setfield(ex_hdr, 'detect', fread(fid,1,'int16'));         %Detector Type%
0029 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0030 ex_hdr = setfield(ex_hdr, 'numcells', fread(fid,1,'int32'));       %Number of cells in det%
0031 ex_hdr = setfield(ex_hdr, 'zerocell', fread(fid,1,'float32'));     %Cell number at theta%
0032 ex_hdr = setfield(ex_hdr, 'cellspace', fread(fid,1,'float32'));    %Cell spacing%
0033 ex_hdr = setfield(ex_hdr, 'srctodet', fread(fid,1,'float32'));     %Distance from source to detector%
0034 ex_hdr = setfield(ex_hdr, 'srctoiso', fread(fid,1,'float32'));     %Distance from source to iso%
0035 ex_hdr = setfield(ex_hdr, 'tubetyp', fread(fid,1,'int16'));        %Tube type%
0036 ex_hdr = setfield(ex_hdr, 'dastyp', fread(fid,1,'int16'));         %DAS type%
0037 ex_hdr = setfield(ex_hdr, 'num_dcnk', fread(fid,1,'int16'));       %Number of Decon Kernals%
0038 ex_hdr = setfield(ex_hdr, 'dcn_len', fread(fid,1,'int16'));        %Number of elements in a Decon Kernal%
0039 ex_hdr = setfield(ex_hdr, 'dcn_density', fread(fid,1,'int16'));    %Decon Kernal density%
0040 ex_hdr = setfield(ex_hdr, 'dcn_stepsize', fread(fid,1,'int16'));   %Decon Kernal stepsize%
0041 ex_hdr = setfield(ex_hdr, 'dcn_shiftcnt', fread(fid,1,'int16'));   %Decon Kernal Shift Count%
0042 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0043 ex_hdr = setfield(ex_hdr, 'magstrength', fread(fid,1,'int32'));    %Magnet strength (in gauss)%
0044 ex_hdr = setfield(ex_hdr, 'patid', fread(fid,13,'uchar'));         %Patient ID for this Exam%
0045 ex_hdr = setfield(ex_hdr, 'patname', fread(fid,25,'uchar'));       %Patientsda Name%
0046 ex_hdr = setfield(ex_hdr, 'patage', fread(fid,1,'int16'));         %Patient Age (years, months or days)%
0047 ex_hdr = setfield(ex_hdr, 'patian', fread(fid,1,'int16'));         %Patient Age Notation%
0048 ex_hdr = setfield(ex_hdr, 'patsex', fread(fid,1,'int16'));         %Patient Sex%
0049 ex_hdr = setfield(ex_hdr, 'patweight', fread(fid,1,'int32'));      %Patient Weight%
0050 ex_hdr = setfield(ex_hdr, 'trauma', fread(fid,1,'int16'));         %Trauma Flag%
0051 ex_hdr = setfield(ex_hdr, 'hist', fread(fid,61,'uchar'));          %Patient History%
0052 ex_hdr = setfield(ex_hdr, 'reqnum', fread(fid,13,'uchar'));        %Requisition Number%
0053 ex_hdr = setfield(ex_hdr, 'ex_datetime', fread(fid,1,'int32'));    %Exam date/time stamp%
0054 ex_hdr = setfield(ex_hdr, 'refphy', fread(fid,33,'uchar'));        %Referring Physician%
0055 ex_hdr = setfield(ex_hdr, 'diagrad', fread(fid,33,'uchar'));       %Diagnostician/Radiologist%
0056 ex_hdr = setfield(ex_hdr, 'op', fread(fid,4,'uchar'));             %Operator%
0057 ex_hdr = setfield(ex_hdr, 'ex_desc', fread(fid,23,'uchar'));       %Exam Description%
0058 ex_hdr = setfield(ex_hdr, 'ex_typ', fread(fid,3,'uchar'));         %Exam Type%
0059 ex_hdr = setfield(ex_hdr, 'ex_format', fread(fid,1,'int16'));      %Exam Format%
0060 if byte_align; fseek(fid,6,0); end % 32-bit alignment
0061 ex_hdr = setfield(ex_hdr, 'firstaxtime', fread(fid,1,'float64'));  %Start time(secs) of first axial in exam%
0062 ex_hdr = setfield(ex_hdr, 'ex_sysid', fread(fid,9,'uchar'));       %Creator Suite and Host%
0063 fseek(fid,1,0); % 16-bit alignment
0064 if byte_align; fseek(fid,2,0); end % 32-bit alignment
0065 ex_hdr = setfield(ex_hdr, 'ex_lastmod', fread(fid,1,'int32'));     %Date/Time of Last Change%
0066 ex_hdr = setfield(ex_hdr, 'protocolflag', fread(fid,1,'int16'));   %Non-Zero indicates Protocol Exam%
0067 ex_hdr = setfield(ex_hdr, 'ex_alloc_key', fread(fid,13,'uchar'));  %Process that allocated this record%
0068 fseek(fid,1,0); % 16-bit alignment
0069 ex_hdr = setfield(ex_hdr, 'ex_delta_cnt', fread(fid,1,'int32'));   %Indicates number of updates to header%
0070 ex_hdr = setfield(ex_hdr, 'ex_verscre', fread(fid,2,'uchar'));     %Genesis Version - Created%
0071 ex_hdr = setfield(ex_hdr, 'ex_verscur', fread(fid,2,'uchar'));     %Genesis Version - Now%
0072 ex_hdr = setfield(ex_hdr, 'ex_checksum', fread(fid,1,'uint32'));   %Exam Record Checksum%
0073 ex_hdr = setfield(ex_hdr, 'ex_complete', fread(fid,1,'int32'));    %Exam Complete Flag%
0074 ex_hdr = setfield(ex_hdr, 'ex_seriesct', fread(fid,1,'int32'));    %Last Series Number Used%
0075 ex_hdr = setfield(ex_hdr, 'ex_numarch', fread(fid,1,'int32'));     %Number of Series Archived%
0076 ex_hdr = setfield(ex_hdr, 'ex_numseries', fread(fid,1,'int32'));   %Number of Series Existing%
0077 ex_hdr = setfield(ex_hdr, 'ex_series', struct('length', fread(fid,1,'uint32'), ...
0078                                               'data', fread(fid,1,'uint32')));  %Series Keys for this Exam%
0079 ex_hdr = setfield(ex_hdr, 'ex_numunser', fread(fid,1,'int32'));    %Number of Unstored Series%
0080 ex_hdr = setfield(ex_hdr, 'ex_unseries', struct('length', fread(fid,1,'uint32'), ...
0081                                                 'data', fread(fid,1,'uint32')));    %Unstored Series Keys for this Exam%
0082 ex_hdr = setfield(ex_hdr, 'ex_toarchcnt', fread(fid,1,'int32'));   %Number of Unarchived Series%
0083 ex_hdr = setfield(ex_hdr, 'ex_toarchive', struct('length', fread(fid,1,'uint32'), ...
0084                                                  'data', fread(fid,1,'uint32')));     %Unarchived Series Keys for this Exam%
0085 ex_hdr = setfield(ex_hdr, 'ex_prospcnt', fread(fid,1,'int32'));    %Number of Prospective/Scout Series%
0086 ex_hdr = setfield(ex_hdr, 'ex_prosp', struct('length', fread(fid,1,'uint32'), ...
0087                                              'data', fread(fid,1,'uint32'))); %Prospective/Scout Series Keys for this Exam%
0088 ex_hdr = setfield(ex_hdr, 'ex_modelnum', fread(fid,1,'int32'));    %Last Model Number used%
0089 ex_hdr = setfield(ex_hdr, 'ex_modelcnt', fread(fid,1,'int32'));    %Number of ThreeD Models%
0090 ex_hdr = setfield(ex_hdr, 'ex_models', struct('length', fread(fid,1,'uint32'), ...
0091                                               'data', fread(fid,1,'uint32')));  %ThreeD Model Keys for Exam%
0092 ex_hdr = setfield(ex_hdr, 'ex_stat', fread(fid,1,'int16'));        %Patient Status%
0093 ex_hdr = setfield(ex_hdr, 'uniq_sys_id', fread(fid,16,'uchar'));   %Unique System ID%
0094 ex_hdr = setfield(ex_hdr, 'service_id', fread(fid,16,'uchar'));    %Unique Service ID%
0095 ex_hdr = setfield(ex_hdr, 'mobile_loc', fread(fid,4,'uchar'));     %Mobile Location Number%
0096 ex_hdr = setfield(ex_hdr, 'study_uid', fread(fid,32,'uchar'));     %Study Entity Unique ID%
0097 ex_hdr = setfield(ex_hdr, 'study_status', fread(fid,1,'int16'));   %indicates if study has complete info(DICOM/genesis)%
0098 ex_hdr = setfield(ex_hdr, 'ex_padding', fread(fid,516,'uchar'));   %Spare Space%
0099 if byte_align; fseek(fid,4,0); end % byte alignment
0100 
0101 return

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003