Home > eeg > egis > egis_file_utils > rd_ses_hdr_v.m

rd_ses_hdr_v

PURPOSE ^

[fhdr,chdr,ename,czeros,cgains,cnames,fcom,ftext]=rd_ses_hdr_v(fid)

SYNOPSIS ^

function [fhdr,chdr,ename,czeros,cgains,cnames,fcom,ftext]=rd_ses_hdr_v(fid)

DESCRIPTION ^

[fhdr,chdr,ename,czeros,cgains,cnames,fcom,ftext]=rd_ses_hdr_v(fid)

This reads the header of an EGIS session file (.ses) into two matrices.
The first is a row vector containing one element for each field of the 
description, file info, and session info sections. This vector has room 
for NCells LCellHdr variables, beggining at column 24. The second matrix
has NCells rows and a column for each field of the header. The Trial
Specifics begin in column 6. Room is left for the maximum of LSpec/2 2-byte
values per trial. The file ses_hdr_offsets.m provides index definitions 
for the columns of the matrices returned by this function. For example
the length of the data portion of a session file can be found by

    [my_fhdr, my_chdr]=rd_ses_hdr_v(my)
    L=my_fhdr(LData)

The ExptNam, Cellname, and flexible area fields are optionally read  
this function. To retrieve them add return arguments in the following
order: exp. name, zeros, gains, cell names, comment, text. Arguments
cannot be skipped, i.e. the first extra argument always returns the
exp. name.

See Also:ses_hdr_offsets_v, wt_ses_hdr_v, get_tspec_v, get_tspecs_v.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [fhdr,chdr,ename,czeros,cgains,cnames,fcom,ftext]=rd_ses_hdr_v(fid)
0002 %[fhdr,chdr,ename,czeros,cgains,cnames,fcom,ftext]=rd_ses_hdr_v(fid)
0003 %
0004 %This reads the header of an EGIS session file (.ses) into two matrices.
0005 %The first is a row vector containing one element for each field of the
0006 %description, file info, and session info sections. This vector has room
0007 %for NCells LCellHdr variables, beggining at column 24. The second matrix
0008 %has NCells rows and a column for each field of the header. The Trial
0009 %Specifics begin in column 6. Room is left for the maximum of LSpec/2 2-byte
0010 %values per trial. The file ses_hdr_offsets.m provides index definitions
0011 %for the columns of the matrices returned by this function. For example
0012 %the length of the data portion of a session file can be found by
0013 %
0014 %    [my_fhdr, my_chdr]=rd_ses_hdr_v(my)
0015 %    L=my_fhdr(LData)
0016 %
0017 %The ExptNam, Cellname, and flexible area fields are optionally read
0018 %this function. To retrieve them add return arguments in the following
0019 %order: exp. name, zeros, gains, cell names, comment, text. Arguments
0020 %cannot be skipped, i.e. the first extra argument always returns the
0021 %exp. name.
0022 %
0023 %See Also:ses_hdr_offsets_v, wt_ses_hdr_v, get_tspec_v, get_tspecs_v.
0024 
0025 %Modification History:
0026 %    Orginal Version by Brian Rakitin, 3/2/95
0027 %    Output of rest of header added by BCR, 3/12/95
0028 
0029 %Check number of arguments
0030 if nargin ~=1 | fid==-1
0031     error('Script cut_by_specs requires a valid file id as input.')
0032 end
0033 if nargout == 0 
0034     error('Script cut_by_cells requires at least two matrix output arguments.')
0035 else if nargout >= 9
0036     error('Too many output arguments for cut_by_specs.')
0037     end
0038 end
0039 
0040 %Prep file for reading
0041 fhdr=zeros(1,23);
0042 status=fseek(fid,0,'bof');
0043 %Read in fhdr fields.
0044 fhdr(1)=fread(fid,1,'int32'); %BytOrd
0045 fhdr(2)=fread(fid,1,'int16'); %HdrVer
0046 fhdr(3)=fread(fid,1,'int16'); %LHeader
0047 fhdr(4)=fread(fid,1,'int32'); %LData
0048 status=fseek(fid,80,'cof'); %Skip ExptNam
0049 fhdr(5:10)=fread(fid,6,'int16'); %RunDate and RunTime
0050 fhdr(11:23)=fread(fid,13,'int16'); %Everything else up to LCellHdr
0051 fhdr(24:(24+fhdr(18)-1))=fread(fid,fhdr(18),'int16'); %LCellHdr for each cell
0052 
0053 %Read in chdr
0054 if nargout >=2 
0055     chdr=zeros(fhdr(18),5);
0056     status=fseek(fid,(4*fhdr(19)),'cof');
0057     for loop=1:fhdr(18)
0058         chdr(loop,1)=fread(fid,1,'int16');
0059         status=fseek(fid,80,'cof');
0060         chdr(loop, 2:5)=(fread(fid,4,'int16'))';
0061         lspectot=(chdr(loop,2)*(chdr(loop,5)/2));
0062         lastcol=(6+lspectot-1);
0063         chdr(loop,lastcol)=0;
0064         chdr(loop,6:lastcol)=(fread(fid,lspectot,'int16'))';
0065     end
0066 else
0067     return
0068 end
0069 
0070 %Read experiment name if necessary
0071 if nargout >= 3 
0072     status=fseek(fid,12,'bof');
0073     tempstr=fread(fid,80,'char');
0074     ename=setstr(tempstr);
0075 else 
0076     return
0077 end
0078 
0079 %Read  zeros if necessary
0080 if nargout >= 4
0081     status=fseek(fid,(130+(2*fhdr(18))),'bof');
0082     czeros=fread(fid,(fhdr(19)),'int16');
0083 else
0084     return
0085 end
0086 
0087 %Read gains if necessary
0088 if nargout >= 5
0089     status=fseek(fid,(130+(2*fhdr(18))+(2*fhdr(19))),'bof');
0090     cgains=fread(fid,(fhdr(19)), 'int16');
0091 else
0092     return
0093 end
0094 
0095 %Read cellnames if necesaary
0096 if nargout >= 6
0097     status=fseek(fid,(130+(2*fhdr(18))+(4*fhdr(19))),'bof');
0098     status=fseek(fid,2,'cof');
0099     for loop=1:fhdr(18)
0100         cnames(loop,:)=setstr(fread(fid,80,'char')');
0101         status=fseek(fid,fhdr(24+(loop-1))-80,'cof');
0102     end
0103 else
0104     return
0105 end
0106         
0107 %Read comment if necessary
0108 if nargout >= 7
0109     status=fseek(fid,fhdr(3),'bof');
0110     status=fseek(fid,-(fhdr(22)+fhdr(21)+fhdr(20)),'cof');
0111     fcom=fread(fid,fhdr(20),'char');
0112 else
0113     return
0114 end
0115 
0116 %Read text if necessary
0117 if nargout >= 8
0118     status=fseek(fid,fhdr(3),'bof');
0119     status=fseek(fid,-(fhdr(22)+fhdr(21)),'cof');
0120     ftext=fread(fid,fhdr(21),'char');
0121 else
0122     return
0123 end
0124

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