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