Home > eeg > egis > misc_utils > opened_header_utility.m

opened_header_utility

PURPOSE ^

rd_ses_hdr.m

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 rd_ses_hdr.m

 Reads the header information in EGIS session (.ses) files

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % rd_ses_hdr.m
0002 %
0003 % Reads the header information in EGIS session (.ses) files
0004 
0005 % Modification history:
0006 %
0007 %  2/15/95 PJ  Created this m-file from the original egis.m file
0008 %
0009 
0010 [fid, message]=fopen(fname,'rb','b');
0011 if fid == -1
0012   message
0013 end
0014 
0015 offset = 6;
0016 status = fseek(fid, offset, 'bof');
0017 % read LHeader
0018 LHeader = fread(fid, 1, 'int16');
0019 LData = fread(fid, 1, 'int32');
0020 ExpName = fread(fid, 80, 'char');
0021 
0022 offset = 12;
0023 status = fseek(fid, offset, 'cof');
0024 
0025 SubjID = fread(fid, 1, 'int16');
0026 Handed = fread(fid, 1, 'int16');
0027 Sex = fread(fid, 1, 'int16');
0028 Age = fread(fid, 1, 'int16');
0029 ExperID = fread(fid, 1, 'int16');
0030 
0031 offset = 4;
0032 status = fseek(fid, offset, 'cof');
0033 
0034 NCells = fread(fid, 1, 'int16');
0035 NChan = fread(fid, 1, 'int16');
0036 
0037 offset = 8;
0038 status = fseek(fid, offset, 'cof');
0039 
0040 LCellHeader = fread(fid, NCells, 'int16');
0041 CalZero = fread(fid, NChan, 'int16');
0042 CalGain = fread(fid, NChan, 'int16');
0043 
0044 %Read in the Cell Header data for all the cells
0045 Cell_ID = zeros(1,NCells);
0046 CellName = zeros(NCells, 80);
0047 Ntrials = zeros(1, NCells);
0048 Npoints = zeros(1, NCells);
0049 SampRate = zeros(1, NCells);
0050 LSpec = zeros(1, NCells);
0051 TrialSpecs = zeros(Ntrials(1)*64, NCells);
0052 
0053 DatumSize = 2;
0054 Cell_DataOffset = zeros(1,NCells);    % Calculate beginning of each
0055                     % cell's data
0056 
0057 cum_cell_sizes = 0;
0058 
0059 for c = 1:NCells
0060   Cell_ID(c) = fread(fid, 1, 'int16');
0061   offset = ftell(fid) + 80;
0062   fscanf(fid, '%s', 80);
0063   fseek(fid, offset, 'bof');
0064   Ntrials(c) = fread(fid, 1, 'int16');
0065   Npoints(c) = fread(fid, 1, 'int16');
0066   SampRate(c) = fread(fid, 1, 'int16');
0067   LSpec(c) = fread(fid, 1, 'int16');
0068   LSpec(c) = LSpec(c)/2;
0069 
0070   TrialSpecs(1:LSpec(c).*Ntrials(c), c) = fread(fid, [LSpec(c).*Ntrials(c),1], 'int16');
0071 
0072   Cell_DataOffset(c) = LHeader + cum_cell_sizes;
0073   cum_cell_sizes = cum_cell_sizes + Ntrials(c)*Npoints(c)*NChan*DatumSize;
0074 end
0075 
0076 fseek(fid, LHeader, 'bof');
0077 
0078 
0079 
0080 
0081 
0082 
0083 
0084 
0085 
0086 
0087

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