Code covered by the BSD License  

Highlights from
readNeuronVecAscii

readNeuronVecAscii

by

 

Reads Neuron simulator Vector object data from ascii files.

readNeuronVecAscii(filename,machineformat)
function [data, label] = readNeuronVecAscii(filename,machineformat) 

% readNeuronVecAscii - Reads Neuron simulator Vector object data from ascii files.
%
% Usage:
% [data, label] = readNeuronVecAscii(filename) 
%
% Parameters: 
%   filename: Full path to Neuron file.
%
% Returns:
%   data: Row vector with two columns of data.
%   label: String denoting Vector contents.
% 
% Description:
%   It's one line of code just to read the data: dlmread(filename, '\t', 2, 0)
%
% Example:
%   data = readNeuronVecAscii('myvec.dat');
%
% Also see: dlmread, http://www.neuron.yale.edu
%
% Author: Cengiz Gunay <cengique@users.sf.net> 2012/03/02
 
% read label
  [fid,errmsg] = fopen(filename,'r'); 
  if fid==-1 
    error(errmsg);
  end 

  label = regexprep(fgetl(fid), 'label:', '');
  count = str2num(fgetl(fid));
  
  fclose(fid);
  
  % read data
  data = dlmread(filename, '\t', 2, 0);
  
  % sanity check
  assert(size(data, 1) == count, ...
         ['Number of rows in file (' num2str(count) ') does not ' ...
          'match expected size of Vector (' num2str(size(data, 1)) ').']);

Contact us