Home > chronux > spectral_analysis > 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 matrix 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:
• CrossSpecMatpt
• coherencypt Multi-taper coherency - point process times
• coherencysegpt Multi-taper coherency computed by segmenting two univariate point processes into chunks
• cohgrampt Multi-taper time-frequency coherence - two point processes given as times
• cohmatrixpt Multi-taper coherency matrix - point process times
• mtdspecgrampt Multi-taper derivative time-frequency spectrum - point process times
• mtdspectrumpt Multi-taper spectral derivative - point process times
• mtspecgrampt Multi-taper time-frequency spectrum - point process times
• mtspectrumpt Multi-taper spectrum - point process times
• mtspectrumsegpt Multi-taper segmented spectrum for a univariate binned point process

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

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005