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


 Written by Souheil J. Inati
 Dartmouth College

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

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