Equations

Monday, 11 April 2011

Spikes Firing Rate

Continuing the last post, say, we would like to plot the firing rate of the spikes using non overlapping window.
I'll use the same variables as in previous post.
%window size 300ms
dt = 300;

%edges for bins
edges = 0 : dt : max(spikeTimes);
r = zeros(1, length(edges));

%we basically count the number of spikes in every bin
for i = 1 : length(spikeTimes),
   for j = 1 : length(edges) - 1,
       if edges(j) <= spikeTimes(i) && 
           spikeTimes(i) <= edges(j + 1),
          r(j) = r(j) + 1;
       end
   end
   
   if spikeTimes(i) == edges(end),
      r(end) = r(end) + 1;
   end
end

%normalizing the firing rate
r = r ./ dt;

%plot the firing rate
stairs(edges, r);


the result should be something like this:






We can now calculate the fano factor:
ff = var(r) / mean(r);

No comments:

Post a Comment