40 lines
1.0 KiB
Matlab
40 lines
1.0 KiB
Matlab
function fano( spikes )
|
|
% computes fano factor as a function of window size
|
|
% spikes: a cell array of vectors of spike times
|
|
|
|
tmax = spikes{1}(end);
|
|
windows = 0.01:0.05:0.01*tmax;
|
|
mc = windows;
|
|
vc = windows;
|
|
ff = windows;
|
|
fs = windows;
|
|
for j = 1:length(windows)
|
|
w = windows( j );
|
|
% collect counts:
|
|
n = [];
|
|
for k = 1:length(spikes)
|
|
for tk = 0:w:tmax-w
|
|
nn = sum( ( spikes{k} >= tk ) & ( spikes{k} < tk+w ) );
|
|
%nn = length( find( ( spikes{k} >= tk ) & ( spikes{k} < tk+w ) ) );
|
|
n = [ n nn ];
|
|
end
|
|
end
|
|
% statistics for current window:
|
|
mc(j) = mean( n );
|
|
vc(j) = var( n );
|
|
ff(j) = vc( j )/mc( j );
|
|
fs(j) = sqrt(vc( j )/mc( j ));
|
|
end
|
|
|
|
subplot( 1, 2, 1 );
|
|
scatter( mc, vc, 'filled' );
|
|
xlabel( 'Mean count' );
|
|
ylabel( 'Count variance' );
|
|
|
|
subplot( 1, 2, 2 );
|
|
scatter( 1000.0*windows, fs, 'filled' );
|
|
xlabel( 'Window W [ms]' );
|
|
ylabel( 'Fano factor' );
|
|
end
|
|
|