Home > chronux_1_15 > pointtimes > minmaxsptimes.m

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 multiple dimensions e.g. channels; channels x trials; can also accept a 1d 
               of spike times)
 Output:
 mintime       (minimum of the spike time across channels)
 maxtime       (maximum of the spike 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 multiple dimensions e.g. channels; channels x trials; can also accept a 1d
0006 %               of spike times)
0007 % Output:
0008 % mintime       (minimum of the spike time across channels)
0009 % maxtime       (maximum of the spike time across channels)
0010 %
0011 if isstruct(data)
0012    data=reshape(data,numel(data),1);
0013    C=size(data,1);
0014    fnames=fieldnames(data);
0015    mintime=zeros(1,C); maxtime=zeros(1,C);
0016    for ch=1:C
0017      eval(['dtmp=data(ch).' fnames{1} ';'])
0018      if ~isempty(dtmp)
0019         maxtime(ch)=max(dtmp);
0020         mintime(ch)=min(dtmp);
0021      else
0022         mintime(ch)=NaN;
0023         maxtime(ch)=NaN;
0024      end
0025    end;
0026    maxtime=max(maxtime); % maximum time
0027    mintime=min(mintime); % minimum time
0028 else
0029      dtmp=data;
0030      if ~isempty(dtmp)
0031         maxtime=max(dtmp);
0032         mintime=min(dtmp);
0033      else
0034         mintime=NaN;
0035         maxtime=NaN;
0036      end
0037 end
0038 if mintime < 0 
0039    error('Minimum spike time is negative'); 
0040 end

Generated on Tue 15-Aug-2006 22:51:57 by m2html © 2003