Home > eeg > egis > misc_utils > open_header_utility.m

open_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 [fname, pathname] = uigetfile('*.*','Select session file');
0011 if (fname == '')
0012    error('No filename selected. You have to click on a name');
0013 end
0014 
0015 fname = [pathname fname];
0016 
0017 [fid, message]=fopen(fname,'rb','b');
0018 if fid == -1
0019   message
0020 end
0021 
0022 offset = 6;
0023 status = fseek(fid, offset, 'bof');
0024 % read LHeader
0025 LHeader = fread(fid, 1, 'int16');
0026 LData = fread(fid, 1, 'int32');
0027 ExpName = fread(fid, 80, 'char');
0028 
0029 offset = 12;
0030 status = fseek(fid, offset, 'cof');
0031 
0032 SubjID = fread(fid, 1, 'int16');
0033 Handed = fread(fid, 1, 'int16');
0034 Sex = fread(fid, 1, 'int16');
0035 Age = fread(fid, 1, 'int16');
0036 ExperID = fread(fid, 1, 'int16');
0037 
0038 offset = 4;
0039 status = fseek(fid, offset, 'cof');
0040 
0041 NCells = fread(fid, 1, 'int16');
0042 NChan = fread(fid, 1, 'int16');
0043 
0044 offset = 8;
0045 status = fseek(fid, offset, 'cof');
0046 
0047 LCellHeader = fread(fid, NCells, 'int16');
0048 CalZero = fread(fid, NChan, 'int16');
0049 CalGain = fread(fid, NChan, 'int16');
0050 
0051 %Read in the Cell Header data for all the cells
0052 Cell_ID = zeros(1,NCells);
0053 CellName = zeros(NCells, 80);
0054 Ntrials = zeros(1, NCells);
0055 Npoints = zeros(1, NCells);
0056 SampRate = zeros(1, NCells);
0057 LSpec = zeros(1, NCells);
0058 TrialSpecs = zeros(Ntrials*64, NCells);
0059 
0060 DatumSize = 2;
0061 Cell_DataOffset = zeros(1,NCells);    % Calculate beginning of each
0062                     % cell's data
0063 
0064 cum_cell_sizes = 0;
0065 
0066 for c = 1:NCells
0067   Cell_ID(c) = fread(fid, 1, 'int16');
0068   offset = ftell(fid) + 80;
0069   CellName(c,:)= fscanf(fid, '%s', 80);
0070   fseek(fid, offset, 'bof');
0071   Ntrials(c) = fread(fid, 1, 'int16');
0072   Npoints(c) = fread(fid, 1, 'int16');
0073   SampRate(c) = fread(fid, 1, 'int16');
0074   LSpec(c) = fread(fid, 1, 'int16');
0075   LSpec(c) = LSpec(c)/2;
0076 
0077   TrialSpecs(1:LSpec(c).*Ntrials(c), c) = fread(fid, [LSpec(c).*Ntrials(c),1], 'int16');
0078 
0079   Cell_DataOffset(c) = LHeader + cum_cell_sizes;
0080   cum_cell_sizes = cum_cell_sizes + Ntrials(c)*Npoints(c)*NChan*DatumSize;
0081 end
0082 
0083 fseek(fid, LHeader, 'bof');

Generated on Sun 25-Aug-2019 04:00:39 by m2html © 2003