This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/pointprocesses/code/fanoplot.m

34 lines
899 B
Matlab

function fanoplot(spikes, titles)
% computes and plots fano factor as a function of window size
% spikes: a cell array of vectors of spike times
% titles: string that is used as a title for the plots
windows = logspace(-3.0, -0.5, 100);
mc = windows;
vc = windows;
ff = windows;
for j = 1:length(windows)
w = windows(j);
counts = spikecounts(spikes, w);
% statistics for current window:
mc(j) = mean(counts);
vc(j) = var(counts);
ff(j) = vc(j)/mc(j);
end
subplot(1, 2, 1);
scatter(mc, vc, 'filled');
title(titles);
xlabel('Mean count');
ylabel('Count variance');
subplot(1, 2, 2);
scatter(1000.0*windows, ff, 'filled');
title(titles);
xlabel('Window [ms]');
ylabel('Fano factor');
xlim(1000.0*[windows(1) windows(end)])
ylim([0.0 1.1]);
set(gca, 'XScale', 'log');
end