diff --git a/projects/project_fano_test/EdenKramer2010JNeurosciMeth-DrawingInferencesFromFanoFactorCalculations.pdf b/projects/project_fano_test/EdenKramer2010JNeurosciMeth-DrawingInferencesFromFanoFactorCalculations.pdf new file mode 100644 index 0000000..a75b342 Binary files /dev/null and b/projects/project_fano_test/EdenKramer2010JNeurosciMeth-DrawingInferencesFromFanoFactorCalculations.pdf differ diff --git a/projects/project_fano_time/solution/counthist.m b/projects/project_fano_time/solution/counthist.m new file mode 100644 index 0000000..6a51714 --- /dev/null +++ b/projects/project_fano_time/solution/counthist.m @@ -0,0 +1,11 @@ +function [counts, cbins] = counthist(spikes, tmin, tmax, T, cmax) +tbins = tmin+T/2:T:tmax; +cbins = 0.5:cmax; +counts = zeros(1, length(cbins)); +for k = 1:length(spikes) + times = spikes{k}; + n = hist(times((times>=tmin)&(times<=tmax)), tbins); + counts = counts + hist(n, cbins); +end +counts = counts / sum(counts); +end diff --git a/projects/project_fano_time/solution/discriminability.m b/projects/project_fano_time/solution/discriminability.m new file mode 100644 index 0000000..b0da789 --- /dev/null +++ b/projects/project_fano_time/solution/discriminability.m @@ -0,0 +1,23 @@ +function [d, thresholds, true1s, false1s, true2s, false2s, pratio] = discriminability(spikes1, spikes2, tmax, T, cmax) +[c1, b1] = counthist(spikes1, 0.0, tmax, T, cmax); +[c2, b2] = counthist(spikes2, 0.0, tmax, T, cmax); +thresholds = 0:cmax; +true1s = zeros(length(thresholds), 1); +true2s = zeros(length(thresholds), 1); +false1s = zeros(length(thresholds), 1); +false2s = zeros(length(thresholds), 1); +for k = 1:length(thresholds) + th = thresholds(k); + t1 = sum(c1(b1<=th)); + f1 = sum(c1(b1>th)); + t2 = sum(c2(b2>=th)); + f2 = sum(c2(b2= vthresh + v = vreset; + spiketime = i*dt; + times(j) = spiketime; + j = j + 1; + end + end + spikes{k} = times; + end +end diff --git a/projects/project_fano_time/solution/savefigpdf.m b/projects/project_fano_time/solution/savefigpdf.m new file mode 100644 index 0000000..2a11c11 --- /dev/null +++ b/projects/project_fano_time/solution/savefigpdf.m @@ -0,0 +1,28 @@ +function savefigpdf(fig, name, width, height) +% Saves figure fig in pdf file name.pdf with appropriately set page size +% and fonts + +% default width: +if nargin < 3 + width = 11.7; +end +% default height: +if nargin < 4 + height = 9.0; +end + +% paper: +set(fig, 'PaperUnits', 'centimeters'); +set(fig, 'PaperSize', [width height]); +set(fig, 'PaperPosition', [0.0 0.0 width height]); +set(fig, 'Color', 'white') + +% font: +set(findall(fig, 'type', 'axes'), 'FontSize', 12) +set(findall(fig, 'type', 'text'), 'FontSize', 12) + +% save: +saveas(fig, name, 'pdf') + +end + diff --git a/projects/project_fano_time/solution/spikeraster.m b/projects/project_fano_time/solution/spikeraster.m new file mode 100644 index 0000000..4eb1b8b --- /dev/null +++ b/projects/project_fano_time/solution/spikeraster.m @@ -0,0 +1,30 @@ +function spikeraster(spikes, tmin, tmax) +% Display a spike raster of the spike times given in spikes. +% +% spikeraster(spikes, tmax) +% spikes: a cell array of vectors of spike times in seconds +% tmin: plot spike raster starting at tmin seconds +% tmax: plot spike raster upto tmax seconds + +ntrials = length(spikes); +for k = 1:ntrials + times = spikes{k}; + times = times((times>=tmin) & (times<=tmax)); + if tmax < 1.5 + times = 1000.0*times; % conversion to ms + end + for i = 1:length( times ) + line([times(i) times(i)],[k-0.4 k+0.4], 'Color', 'k'); + end +end +if (tmax-tmin) < 1.5 + xlabel('Time [ms]'); + xlim([1000.0*tmin 1000.0*tmax]); +else + xlabel('Time [s]'); + xlim([tmin tmax]); +end +ylabel('Trials'); +ylim([0.3 ntrials+0.7 ]); +end +