Home > bioelectromagnetism > emse_read_avg.m

emse_read_avg

PURPOSE ^

emse_read_avg - Load EMSE .avg data (actually ascii format)

SYNOPSIS ^

function [EMSE] = emse_read_avg(filename)

DESCRIPTION ^

 emse_read_avg - Load EMSE .avg data (actually ascii format)
 
 Useage: [EMSE] = emse_read_avg(filename)

 where 'filename' is the full path + fileprefix + filextension

 The returned struct has the following fields:
 
 EMSE.channels
 EMSE.pnts
 EMSE.rate       - sample rate (msec)
 EMSE.xmin       - prestim baseline period (msec)
 EMSE.volt       - potential floating point matrix, 
                   size [points,channels]
 
 No variance data is yet read or returned

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [EMSE] = emse_read_avg(filename)
0002 
0003 % emse_read_avg - Load EMSE .avg data (actually ascii format)
0004 %
0005 % Useage: [EMSE] = emse_read_avg(filename)
0006 %
0007 % where 'filename' is the full path + fileprefix + filextension
0008 %
0009 % The returned struct has the following fields:
0010 %
0011 % EMSE.channels
0012 % EMSE.pnts
0013 % EMSE.rate       - sample rate (msec)
0014 % EMSE.xmin       - prestim baseline period (msec)
0015 % EMSE.volt       - potential floating point matrix,
0016 %                   size [points,channels]
0017 %
0018 % No variance data is yet read or returned
0019 %
0020 
0021 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:34 $
0022 
0023 % Licence:  GNU GPL, no implied or express warranties
0024 % History:  08/2000, Darren.Weber_at_radiology.ucsf.edu
0025 %
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 
0028 ver = '$Revision: 1.1 $';
0029 fprintf('EMSE_READ_AVG [v %s]\n',ver(11:15));
0030 
0031 [path,name,ext] = fileparts(filename);
0032 file = fullfile(path,[name ext]);
0033 
0034 if exist(file) ~= 2,
0035   lookfile = which(file);
0036   if isempty(lookfile),
0037     msg = sprintf('Cannot locate %s\n', filename);
0038     error(msg);
0039   else
0040     file = lookfile;
0041   end
0042 end
0043 
0044 fprintf('...reading: %s\n', file);
0045 
0046 fid = fopen(file);
0047 
0048 version   = fscanf(fid,'%d',1);
0049 file_type = fscanf(fid,'%d',1);
0050 minor_rev = fscanf(fid,'%d',1);
0051 
0052 if isempty(version),
0053   EMSE.channels = [];
0054   EMSE.pnts = [];
0055   EMSE.rate = [];
0056   EMSE.xmin = [];
0057   EMSE.volt = [];
0058   fprintf('...this is not an EMSE file.\n...it might be a Neuroscan file.\n');
0059   return
0060 end
0061 
0062 fprintf('...Version = %d, File-Type = %d, Minor_Revision = %d\n',...
0063   version,file_type,minor_rev);
0064 
0065 unknown  = fscanf(fid,'%d',1);
0066 channels = fscanf(fid,'%d',1);
0067 points   = fscanf(fid,'%d',1);
0068 samples  = fscanf(fid,'%f',1) * 1000; % msec sample rate
0069 unknown  = fscanf(fid,'%f',1);
0070 baseline = fscanf(fid,'%f',1) * -1000; % msec baseline
0071 unknown  = fscanf(fid,'%d',1);
0072 unknown  = fscanf(fid,'%d',1);
0073 
0074 
0075 fprintf('...Sample Rate (msec) = %6.3f, Baseline (msec) = %6.3f\n',...
0076   samples,baseline);
0077 
0078 for i = 1:channels,
0079   discard = fscanf(fid,'%d',2)';
0080 end
0081 
0082 volt = zeros(points,channels);
0083 
0084 for i = 1:points,
0085   volt(i,:) = fscanf(fid,'%f',channels)';
0086 end
0087 
0088 fclose(fid);
0089 
0090 fprintf('...Points (rows) = %d, Channels (cols) = %d\n',points,channels);
0091 
0092 EMSE.channels = channels;
0093 EMSE.pnts = points;
0094 EMSE.rate = samples;
0095 EMSE.xmin = baseline;
0096 EMSE.volt = volt;
0097 
0098 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003