function data = erp_read_data(filename)
%function [data, nr, nc, prestim, digit_interval] = erp_read_data(filename)

%   [Npts nc TSB prestim DI digit_interval] = ...
%	textread(filename,'%s %f %s %f %s %f', 1);

   Npts = textread(filename,'%s', 1);

%   if ~isequal(Npts{1},'Npts=')
   if ~isempty(str2num(Npts{1}))
      data = load(filename);
%      [nr nc] = size(data);
%      prestim = 0;
%      digit_interval = 2;
      return;
   end

   fid = fopen(filename);

   if fid == -1
      error([filename, ': Can''t open file']);
      return;
   end

%   fgets(fid,50*nc);
   fgetl(fid);

   i = 1;
   while ~feof(fid)
%      data(i,:) = fgets(fid,50*nc);
      tmp = fgetl(fid);
      data(i,:) = str2num(tmp);
      i = i + 1;
   end

   fclose(fid);

%   nr = size(data,1);

   return;

