Home > FMAToolbox > Analyses > CountSpikesPerCycle.m

CountSpikesPerCycle

PURPOSE ^

CountSpikesPerCycle - Count number of spikes per LFP cycle.

SYNOPSIS ^

function [count,cycles] = CountSpikesPerCycle(spikes,phases)

DESCRIPTION ^

CountSpikesPerCycle - Count number of spikes per LFP cycle.

 Count the number of spikes per cycle in the ongoing oscillatory LFP
 (e.g. during theta).

  USAGE

    [count,cycles] = CountSpikesPerCycle(spikes,phases)

    spikes         list of spike timestamps
    phases         phase <a href="matlab:help samples">samples</a> in radians (see <a href="matlab:help Phase">Phase</a>)

  OUTPUT

    count          spike count in each cycle
    cycles         list of [start,stop] times for each cycle

  SEE

    See also Phase.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [count,cycles] = CountSpikesPerCycle(spikes,phases)
0002 
0003 %CountSpikesPerCycle - Count number of spikes per LFP cycle.
0004 %
0005 % Count the number of spikes per cycle in the ongoing oscillatory LFP
0006 % (e.g. during theta).
0007 %
0008 %  USAGE
0009 %
0010 %    [count,cycles] = CountSpikesPerCycle(spikes,phases)
0011 %
0012 %    spikes         list of spike timestamps
0013 %    phases         phase <a href="matlab:help samples">samples</a> in radians (see <a href="matlab:help Phase">Phase</a>)
0014 %
0015 %  OUTPUT
0016 %
0017 %    count          spike count in each cycle
0018 %    cycles         list of [start,stop] times for each cycle
0019 %
0020 %  SEE
0021 %
0022 %    See also Phase.
0023 
0024 % Copyright (C) 2004-2011 by Michaƫl Zugaro
0025 %
0026 % This program is free software; you can redistribute it and/or modify
0027 % it under the terms of the GNU General Public License as published by
0028 % the Free Software Foundation; either version 3 of the License, or
0029 % (at your option) any later version.
0030 
0031 % Check number of parameters
0032 if nargin < 2,
0033     error('Incorrect number of parameters (type ''help <a href="matlab:help CountSpikesPerCycle">CountSpikesPerCycle</a>'' for details).');
0034 end
0035 
0036 % Check parameter sizes
0037 if ~isdvector(spikes),
0038     error('Parameter ''spikes'' is not a vector (type ''help <a href="matlab:help CountSpikesPerCycle">CountSpikesPerCycle</a>'' for details).');
0039 end
0040 if ~isdmatrix(phases) | size(phases,2) ~= 2,
0041     error('Parameter ''phases'' is not an Nx2 matrix (type ''help <a href="matlab:help CountSpikesPerCycle">CountSpikesPerCycle</a>'' for details).');
0042 end
0043 isradians(phases(:,2));
0044 
0045 % Find theta peaks
0046 p = phases(:,2);
0047 p(p>pi) = p(p>pi) - 2*pi;
0048 [up,~] = ZeroCrossings([phases(:,1) p]);
0049 start = find(up);
0050 cycles = [phases(start(1:end-1),1) phases(start(2:end),1)];
0051 
0052 % Intervals between successive theta peaks
0053 [~,interval] = InIntervals(spikes,cycles);
0054 
0055 % Count
0056 used = interval ~= 0;
0057 count = Accumulate(interval(used));
0058 %  count = count(interval(used));
0059

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005