To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / utilities / UTIL_CV.m @ 33:161913b595ae

History | View | Annotate | Download (1.09 KB)

1
function [cv, cvTimes, allTimeStamps, allISIs]=  UTIL_CV(earObject, dt, timeStep)
2
% UTIL_CV computes coefficient of variation for multiple spike trains
3
% earObject must be logical 0/1.  Each row is a separate run
4
% CV is computed for successive time regions specified by timeStep
5

    
6
if ~islogical(earObject),error('UTIL_CV: input is not logical/ spikes'), end
7

    
8
[rows cols]=size(earObject);
9
totalDuration=cols*dt;
10

    
11
if nargin<3, timeStep=totalDuration/5; end
12

    
13
% identify all intervals
14
allISIs=[]; allTimeStamps=[];
15
for i=1:rows
16
    temp=find(earObject(i,:))*dt;    % find spikes
17
    isi{i}=diff(temp);                      % find ISIs
18
    timeStamps{i}=temp(2:end); % time of isi is time of second spike
19
    allISIs=[allISIs isi{i}];
20
    allTimeStamps=[allTimeStamps timeStamps{i}];
21
end
22

    
23
count=0;
24
cvTimes=0: timeStep:totalDuration-timeStep; % bin edges
25
for t= cvTimes
26
    % sort ISIs according to when they happened
27
    idx=find(allTimeStamps>t & allTimeStamps<=t+timeStep);
28
    count=count+1;
29
    if ~isempty(allISIs(idx))
30
        cv(count)=std(allISIs(idx))/mean(allISIs(idx));
31
    else
32
        cv(count)=0;
33
    end
34
end
35