added fano factor exercise
This commit is contained in:
parent
9abe1c43f4
commit
41379087b7
37
pointprocesses/code/fanoplot.m
Normal file
37
pointprocesses/code/fanoplot.m
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
function fanoplot( 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;
|
||||||
|
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 );
|
||||||
|
end
|
||||||
|
|
||||||
|
subplot( 1, 2, 1 );
|
||||||
|
scatter( mc, vc, 'filled' );
|
||||||
|
xlabel( 'Mean count' );
|
||||||
|
ylabel( 'Count variance' );
|
||||||
|
|
||||||
|
subplot( 1, 2, 2 );
|
||||||
|
scatter( 1000.0*windows, ff, 'filled' );
|
||||||
|
xlabel( 'Window W [ms]' );
|
||||||
|
ylabel( 'Fano factor' );
|
||||||
|
end
|
||||||
|
|
29
pointprocesses/code/spikecounts.m
Normal file
29
pointprocesses/code/spikecounts.m
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
function counts = spikecounts(spikes, w)
|
||||||
|
% Compute vector of spike counts.
|
||||||
|
%
|
||||||
|
% counts = spikecounts(spikes, w)
|
||||||
|
%
|
||||||
|
% Arguments:
|
||||||
|
% spikes: a cell array of vectors of spike times in seconds
|
||||||
|
% w: observation window duration in seconds for computing the counts
|
||||||
|
%
|
||||||
|
% Returns:
|
||||||
|
% counts: vector of spike counts
|
||||||
|
|
||||||
|
% collect spike counts:
|
||||||
|
tmax = spikes{1}(end);
|
||||||
|
counts = [];
|
||||||
|
for k = 1:length(spikes)
|
||||||
|
times = spikes{k};
|
||||||
|
% alternative 1: count the number of spikes in each window:
|
||||||
|
% for tk = 0:w:tmax-w
|
||||||
|
% nn = sum((times >= tk) & (times < tk+w));
|
||||||
|
% %nn = length(find((times >= tk) & (times < tk+w)));
|
||||||
|
% counts = [counts nn];
|
||||||
|
% end
|
||||||
|
% alternative 2: use the hist() function to do that!
|
||||||
|
tbins = 0.5*w:w:tmax-0.5*w;
|
||||||
|
nn = hist(times, tbins);
|
||||||
|
counts = [counts nn];
|
||||||
|
end
|
||||||
|
end
|
@ -173,7 +173,8 @@ jan.benda@uni-tuebingen.de}
|
|||||||
\colorbox{white}{\includegraphics[width=1\textwidth]{isihist}}
|
\colorbox{white}{\includegraphics[width=1\textwidth]{isihist}}
|
||||||
\end{solution}
|
\end{solution}
|
||||||
|
|
||||||
\part XXX Add return map!!! XXX Write a function that computes and plots the serial
|
% XXX Add return map!!! XXX
|
||||||
|
\part Write a function that computes and plots the serial
|
||||||
correlations of interspike intervals for lags upto
|
correlations of interspike intervals for lags upto
|
||||||
\code{maxlag}. The serial correlations $\rho_k$ for lag $k$ of the
|
\code{maxlag}. The serial correlations $\rho_k$ for lag $k$ of the
|
||||||
interspike intervals $T_i$ are the correlation coefficients
|
interspike intervals $T_i$ are the correlation coefficients
|
||||||
@ -192,6 +193,28 @@ jan.benda@uni-tuebingen.de}
|
|||||||
\colorbox{white}{\includegraphics[width=1\textwidth]{serialcorr}}
|
\colorbox{white}{\includegraphics[width=1\textwidth]{serialcorr}}
|
||||||
\end{solution}
|
\end{solution}
|
||||||
|
|
||||||
|
\part Write a function that counts and returns the number of
|
||||||
|
spikes in windows of a given width $W$.
|
||||||
|
|
||||||
|
Use this function to generate a histogram of spike counts for the
|
||||||
|
data of the three types of neurons. Use 100\,ms for the window
|
||||||
|
width.
|
||||||
|
\begin{solution}
|
||||||
|
\lstinputlisting{../code/spikecounts.m}
|
||||||
|
% XXX
|
||||||
|
\end{solution}
|
||||||
|
|
||||||
|
\part Write a function that computes for a range from window
|
||||||
|
widths the mean, the variance and the Fano factor of the
|
||||||
|
corresponding spike counts. The function should the generate two
|
||||||
|
plots. One showing the spike count variance in dependence on the
|
||||||
|
mean spike count. The other plot showing the Fano factor as a
|
||||||
|
function of window width.
|
||||||
|
\begin{solution}
|
||||||
|
\lstinputlisting{../code/fanoplot.m}
|
||||||
|
% XXX
|
||||||
|
\end{solution}
|
||||||
|
|
||||||
\end{parts}
|
\end{parts}
|
||||||
|
|
||||||
\end{questions}
|
\end{questions}
|
||||||
|
Reference in New Issue
Block a user