minmaxsptimes

PURPOSE ^

Find the minimum and maximum of the spike times in each channel

SYNOPSIS ^

function [mintime, maxtime]=minmaxsptimes(data)

DESCRIPTION ^

 Find the minimum and maximum of the spike times in each channel
 Usage: [mintime, maxtime]=minmaxsptimes(data)
 Input:
 data  (spike times as a structural array of channels/trials dimensions; can also accept a 1d 
               of spike times)
 Output:
 mintime       (minimum time across channels)
 maxtime       (maximum time across channels)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mintime, maxtime]=minmaxsptimes(data)
0002 % Find the minimum and maximum of the spike times in each channel
0003 % Usage: [mintime, maxtime]=minmaxsptimes(data)
0004 % Input:
0005 % data  (spike times as a structural array of channels/trials dimensions; can also accept a 1d
0006 %               of spike times)
0007 % Output:
0008 % mintime       (minimum time across channels)
0009 % maxtime       (maximum time across channels)
0010 %
0011 if isstruct(data)
0012    C=length(data);
0013    fnames=fieldnames(data);
0014    for ch=1:C
0015      eval(['dtmp=data(ch).' fnames{1} ';'])
0016      if ~isempty(dtmp)
0017         maxtime(ch)=max(dtmp);
0018         mintime(ch)=min(dtmp);
0019      else
0020         mintime(ch)=NaN;
0021         maxtime(ch)=NaN;
0022      end
0023    end;
0024    maxtime=max(maxtime); % maximum time
0025    mintime=min(mintime); % minimum time
0026 else
0027      dtmp=data;
0028      if ~isempty(dtmp)
0029         maxtime=max(dtmp);
0030         mintime=min(dtmp);
0031      else
0032         mintime=NaN;
0033         maxtime=NaN;
0034      end
0035 end
0036 if mintime < 0 
0037    error('Minimum spike time is negative'); 
0038 end

Generated on Fri 20-May-2005 13:10:28 by m2html © 2003