Home > bioelectromagnetism > eeg_load.m

eeg_load

PURPOSE ^

eeg_load - Load binary EEG data

SYNOPSIS ^

function [volt] = eeg_load(FILENAME,SIZE,PRECISION)

DESCRIPTION ^

 eeg_load - Load binary EEG data

 Can be used to easily load files written by 'eeg_write'.  Otherwise,
 can be used to load a binary matrix data file.

 Useage: [volt] = eeg_load(filename,SIZE,PRECISION)

 where:    'filename' is the full path + fileprefix + filextension
           'SIZE' is [M,N] rows by columns; if omitted, SIZE can
           be read from any data files written by 'eeg_write' but
           otherwise all data is read into an 1D array.
           'PRECISION' is the data type (default is 'double').
           See matlab fread command for more info on size/precision.

 comment:  A simple wrapper for 'fread' matlab function, useful in 
           other scripts. This is complementary to 'eeg_write'.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [volt] = eeg_load(FILENAME,SIZE,PRECISION)
0002 
0003 % eeg_load - Load binary EEG data
0004 %
0005 % Can be used to easily load files written by 'eeg_write'.  Otherwise,
0006 % can be used to load a binary matrix data file.
0007 %
0008 % Useage: [volt] = eeg_load(filename,SIZE,PRECISION)
0009 %
0010 % where:    'filename' is the full path + fileprefix + filextension
0011 %           'SIZE' is [M,N] rows by columns; if omitted, SIZE can
0012 %           be read from any data files written by 'eeg_write' but
0013 %           otherwise all data is read into an 1D array.
0014 %           'PRECISION' is the data type (default is 'double').
0015 %           See matlab fread command for more info on size/precision.
0016 %
0017 % comment:  A simple wrapper for 'fread' matlab function, useful in
0018 %           other scripts. This is complementary to 'eeg_write'.
0019 %
0020 
0021 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0022 
0023 % Licence:  GNU GPL, no express or implied warranties
0024 % History:  07/2000, Darren.Weber_at_radiology.ucsf.edu
0025 %           04/2002, Darren.Weber_at_radiology.ucsf.edu
0026 %                    added machineformat
0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 
0029 if ~exist('PRECISION','var'), PRECISION = 'double'; end
0030 
0031 file = char(FILENAME);    
0032 
0033 [path,name,ext] = fileparts(file);
0034 file = fullfile(path,[name ext]);
0035 
0036 if ~isequal(exist(file),2),
0037     lookfile = which(file);
0038     if isempty(lookfile),
0039         msg = sprintf('Cannot locate %s\n', file);
0040         error(msg);
0041     else
0042         file = lookfile;
0043     end
0044 end
0045 
0046 fprintf('EEG_LOAD: Reading:\n... %s : ', file);
0047 
0048 fid = fopen(file,'r','ieee-le');
0049 
0050 if ~exist('SIZE','var'),
0051     [SIZE, COUNT] = fread(fid,[1,2],'int');
0052 end
0053 
0054 [volt, COUNT] = fread(fid,SIZE,PRECISION);
0055 
0056 S = size(volt);     fprintf('%d rows, %d cols\n', S(1), S(2) );

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