Home > bioelectromagnetism > eeg_load_ascii.m

eeg_load_ascii

PURPOSE ^

eeg_load_ascii - Load ascii EEG data matrix

SYNOPSIS ^

function [volt,var] = eeg_load_ascii(filename)

DESCRIPTION ^

 eeg_load_ascii - Load ascii EEG data matrix

 Assumes a simple matrix format of data, compatible with matlab
 'load' command, with no strings (eg, labels) in the data file.
 Looks for a voltage file and an associated .var variance file.

 Useage: [volt,var] = eeg_load_ascii(filename)

 where:    filename is the full path + fileprefix + filextension

 comment:  A very simple function, useful in other scripts.
           Could be developed further to include matrix orientation
           checks and/or reorientation options.  Currently a simple
           wrapper for the 'load' matlab function.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [volt,var] = eeg_load_ascii(filename)
0002 
0003 % eeg_load_ascii - Load ascii EEG data matrix
0004 %
0005 % Assumes a simple matrix format of data, compatible with matlab
0006 % 'load' command, with no strings (eg, labels) in the data file.
0007 % Looks for a voltage file and an associated .var variance file.
0008 %
0009 % Useage: [volt,var] = eeg_load_ascii(filename)
0010 %
0011 % where:    filename is the full path + fileprefix + filextension
0012 %
0013 % comment:  A very simple function, useful in other scripts.
0014 %           Could be developed further to include matrix orientation
0015 %           checks and/or reorientation options.  Currently a simple
0016 %           wrapper for the 'load' matlab function.
0017 %
0018 
0019 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0020 
0021 % Licence:  GNU GPL, no implied or express warranties
0022 % History:  07/2000, Darren.Weber_at_radiology.ucsf.edu
0023 %           10/2003, Darren.Weber_at_radiology.ucsf.edu
0024 %                    added variance file handling
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 
0027 eegversion = '$Revision: 1.1 $';
0028 fprintf('\nEEG_LOAD_ASCII [v %s]\n',eegversion(11:15)); tic;
0029 
0030 file = char(filename);
0031 
0032 [path,name,ext] = fileparts(filename);
0033 file = fullfile(path,[name ext]);
0034 
0035 if ~isequal(exist(file),2),
0036   lookfile = which(file);
0037   if isempty(lookfile),
0038     msg = sprintf('...cannot locate %s\n', filename);
0039     error(msg);
0040   else
0041     file = lookfile;
0042   end
0043 end
0044 
0045 fprintf('...reading %s : ', [name ext]);
0046 volt = load(file);
0047 s = size(volt);
0048 fprintf('%d rows, %d cols\n', s(1), s(2));
0049 
0050 
0051 % Attempt to load associated variance file
0052 varfile = fullfile(path,strcat(name,'.var'));
0053 if isequal(exist(varfile),2),
0054   fprintf('...reading %s : ', [name ext]);
0055   var = load(file);
0056   s = size(var);
0057   fprintf('%d rows, %d cols\n', s(1), s(2));
0058 else
0059   lookfile = which(varfile);
0060   if isempty(lookfile),
0061     fprintf('...cannot locate ASCII variance : %s\n', strcat(name,'.var'));
0062     var = [];
0063   else
0064     varfile = lookfile;
0065     fprintf('...reading %s : ', [name ext]);
0066     var = load(file);
0067     s = size(var);
0068     fprintf('%d rows, %d cols\n', s(1), s(2));
0069   end
0070 end
0071 
0072 t = toc; fprintf('...done (%6.2f sec).\n\n',t);
0073 
0074 return

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