added all my stuff
This commit is contained in:
18
pointprocesses/exercises/hompoissonisih.m
Normal file
18
pointprocesses/exercises/hompoissonisih.m
Normal file
@@ -0,0 +1,18 @@
|
||||
% generate spike times:
|
||||
rate = 20.0;
|
||||
spikes = hompoissonspikes( 10, rate, 50.0 );
|
||||
% isi histogram:
|
||||
isivec = isis( spikes );
|
||||
isihist( isivec );
|
||||
hold on
|
||||
% theoretical density:
|
||||
xmax = 5.0/rate;
|
||||
x = 0:0.0001:xmax;
|
||||
y = rate*exp(-rate*x);
|
||||
plot( 1000.0*x, y, 'r', 'LineWidth', 3 );
|
||||
% plot details:
|
||||
title( sprintf( 'Poisson spike trains, rate=%g Hz, nisi=%d', rate, length( isivec ) ) )
|
||||
xlim( [ 0.0 1000.0*xmax ] )
|
||||
ylim( [ 0.0 1.1*rate ] )
|
||||
legend( 'data', 'poisson' )
|
||||
hold off
|
||||
46
pointprocesses/exercises/hompoissonisistats.m
Normal file
46
pointprocesses/exercises/hompoissonisistats.m
Normal file
@@ -0,0 +1,46 @@
|
||||
rates = 1:1:100;
|
||||
avisi = [];
|
||||
sdisi = [];
|
||||
cvisi = [];
|
||||
|
||||
for rate = rates
|
||||
spikes = hompoissonspikes( 10, rate, 100.0 );
|
||||
isivec = isis( spikes );
|
||||
av = mean( isivec );
|
||||
sd = std( isivec );
|
||||
cv = sd/av;
|
||||
avisi = [ avisi av ];
|
||||
sdisi = [ sdisi sd ];
|
||||
cvisi = [ cvisi cv ];
|
||||
end
|
||||
|
||||
f = figure;
|
||||
subplot( 1, 3, 1 );
|
||||
scatter( rates, 1000.0*avisi, 'b', 'filled' );
|
||||
hold on;
|
||||
plot( rates, 1000.0./rates, 'r' );
|
||||
hold off;
|
||||
xlabel( 'Rate \lambda [Hz]' );
|
||||
ylim( [ 0 1000 ] );
|
||||
title( 'Mean ISI [ms]' );
|
||||
legend( 'simulation', 'theory 1/\lambda' );
|
||||
|
||||
subplot( 1, 3, 2 );
|
||||
scatter( rates, 1000.0*sdisi, 'b', 'filled' );
|
||||
hold on;
|
||||
plot( rates, 1000.0./rates, 'r' );
|
||||
hold off;
|
||||
xlabel( 'Rate \lambda [Hz]' );
|
||||
ylim( [ 0 1000 ] )
|
||||
title( 'Standard deviation ISI [ms]' );
|
||||
legend( 'simulation', 'theory 1/\lambda' );
|
||||
|
||||
subplot( 1, 3, 3 );
|
||||
scatter( rates, cvisi, 'b', 'filled' );
|
||||
hold on;
|
||||
plot( rates, ones( size( rates ) ), 'r' );
|
||||
hold off;
|
||||
xlabel( 'Rate \lambda [Hz]' );
|
||||
ylim( [ 0 2 ] )
|
||||
title( 'CV' );
|
||||
legend( 'simulation', 'theory' );
|
||||
19
pointprocesses/exercises/hompoissonspikes.m
Normal file
19
pointprocesses/exercises/hompoissonspikes.m
Normal file
@@ -0,0 +1,19 @@
|
||||
function spikes = hompoissonspikes( trials, rate, tmax )
|
||||
% Generate spike times of a homogeneous poisson process
|
||||
% trials: number of trials that should be generated
|
||||
% rate: the rate of the Poisson process in Hertz
|
||||
% tmax: the duration of each trial in seconds
|
||||
% returns a cell array of vectors of spike times
|
||||
|
||||
dt = 3.33e-5;
|
||||
p = rate*dt;
|
||||
if p > 0.2
|
||||
p = 0.2
|
||||
dt = p/rate;
|
||||
end
|
||||
x = rand( trials, ceil(tmax/dt) );
|
||||
spikes = cell( trials, 1 );
|
||||
for k=1:trials
|
||||
spikes{k} = find( x(k,:) >= 1.0-p ) * dt;
|
||||
end
|
||||
end
|
||||
BIN
pointprocesses/exercises/iafisistats-solutions.pdf
Normal file
BIN
pointprocesses/exercises/iafisistats-solutions.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/iafisistats.pdf
Normal file
BIN
pointprocesses/exercises/iafisistats.pdf
Normal file
Binary file not shown.
142
pointprocesses/exercises/iafisistats.tex
Normal file
142
pointprocesses/exercises/iafisistats.tex
Normal file
@@ -0,0 +1,142 @@
|
||||
\documentclass[addpoints,10pt]{exam}
|
||||
\usepackage{url}
|
||||
\usepackage{color}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\pagestyle{headandfoot}
|
||||
\runningheadrule
|
||||
\firstpageheadrule
|
||||
|
||||
\firstpageheader{Scientific Computing}{Integrate-and-fire models}{Oct 28, 2014}
|
||||
%\runningheader{Homework 01}{Page \thepage\ of \numpages}{23. October 2014}
|
||||
\firstpagefooter{}{}{}
|
||||
\runningfooter{}{}{}
|
||||
\pointsinmargin
|
||||
\bracketedpoints
|
||||
|
||||
%\printanswers
|
||||
\shadedsolutions
|
||||
|
||||
\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro
|
||||
|
||||
%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\usepackage{listings}
|
||||
\lstset{
|
||||
basicstyle=\ttfamily,
|
||||
numbers=left,
|
||||
showstringspaces=false,
|
||||
language=Matlab,
|
||||
breaklines=true,
|
||||
breakautoindent=true,
|
||||
columns=flexible,
|
||||
frame=single,
|
||||
captionpos=t,
|
||||
xleftmargin=2em,
|
||||
xrightmargin=1em,
|
||||
aboveskip=10pt,
|
||||
%title=\lstname,
|
||||
title={\protect\filename@parse{\lstname}\protect\filename@base.\protect\filename@ext}
|
||||
}
|
||||
|
||||
|
||||
\begin{document}
|
||||
|
||||
\sffamily
|
||||
%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
\begin{questions}
|
||||
\question \textbf{Statistics of integrate-and-fire neurons}
|
||||
For the following use different variants of the leaky integrate-and-fire models provided in \texttt{lifspikes.m},
|
||||
\texttt{lifouspikes.m}, and \texttt{lifadaptspikes.m} do generate some spike train data.
|
||||
Use the functions you wrote for the Poisson process to analyze the statistics of the spike trains.
|
||||
\begin{parts}
|
||||
\part Generate a few trials of the two models for two different inputs
|
||||
that result in qualitatively different spike trains and display
|
||||
them in a raster plot. Decide for a noise strength (good values to try are 0.001, 0.01, 0.1, 1).
|
||||
\begin{solution}
|
||||
\begin{lstlisting}
|
||||
spikes = pifspikes( 10, 1.0, 0.5, 0.01 );
|
||||
%spikes = pifspikes( 10, 10.0, 0.5, 0.01 );
|
||||
%spikes = lifspikes( 10, 11.0, 0.5, 0.001 );
|
||||
%spikes = lifspikes( 10, 15.0, 0.5, 0.001 );
|
||||
spikeraster( spikes )
|
||||
\end{lstlisting}
|
||||
\mbox{}\\[-3ex]
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{pifraster02}}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{pifraster10}}\\
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{lifraster10}}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{lifraster15}}
|
||||
\end{solution}
|
||||
|
||||
|
||||
\part The inverse Gaussian describes the interspike interval distribution of a PIF driven with white noise:
|
||||
\[ p(T) = \frac{1}{\sqrt{4\pi D T^3}}\exp\left[-\frac{(T-\langle T \rangle)^2}{4DT\langle T \rangle^2}\right] \]
|
||||
where $\langle T \rangle$ is the mean interspike interval and
|
||||
\[ D = \frac{\langle(T - \langle T \rangle)^2\rangle}{2 \langle T \rangle^3} \]
|
||||
is the diffusion coefficient (variance of the interspike intervals
|
||||
$T$ divided by two times the mean cubed). Show in two plots how
|
||||
this distribution depends on $\langle T \rangle$ and $D$.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/inversegauss.m}
|
||||
\lstinputlisting{simulations/inversegaussplot.m}
|
||||
\colorbox{white}{\includegraphics[width=0.98\textwidth]{inversegauss}}
|
||||
\end{solution}
|
||||
|
||||
\part Extent your function plotting an interspike interval histogram
|
||||
to also report the diffusion coefficient $D$.
|
||||
\begin{solution}
|
||||
\begin{lstlisting}
|
||||
...
|
||||
% annotation:
|
||||
misi = mean( isis );
|
||||
sdisi = std( isis );
|
||||
disi = sdisi^2.0/2.0/misi^3;
|
||||
text( 0.6, 0.7, sprintf( 'mean=%.1f ms', 1000.0*misi ), 'Units', 'normalized' )
|
||||
text( 0.6, 0.6, sprintf( 'std=%.1f ms', 1000.0*sdisi ), 'Units', 'normalized' )
|
||||
text( 0.6, 0.5, sprintf( 'CV=%.2f', sdisi/misi ), 'Units', 'normalized' )
|
||||
text( 0.6, 0.4, sprintf( 'D=%.1f Hz', disi ), 'Units', 'normalized' )
|
||||
...
|
||||
\end{lstlisting}
|
||||
\end{solution}
|
||||
|
||||
\part Compare intersike interval histograms obtained from the LIF and PIF models with the inverse Gaussian.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/lifisih.m}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{pifisih01}}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{pifisih10}}\\
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{lifisih08}}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{lifisih16}}
|
||||
\end{solution}
|
||||
|
||||
\part Plot the firing rate (inverse mean interspike interval),
|
||||
mean interspike interval, the corresponding standard deviation,
|
||||
CV, and diffusion coefficient as a function of the input to the LIF
|
||||
and the PIF with noise strength set to 0.01.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/lifisistats.m}
|
||||
Leaky integrate-and-fire:\\
|
||||
\colorbox{white}{\includegraphics[width=0.8\textwidth]{lifisistats}}\\
|
||||
Perfect integrate-and-fire:\\
|
||||
\colorbox{white}{\includegraphics[width=0.8\textwidth]{pifisistats}}
|
||||
\end{solution}
|
||||
|
||||
\part Plot the firing rate as a function of input of the LIF and the PIF for various values
|
||||
of the noise strength.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/lifficurves.m}
|
||||
Leaky integrate-and-fire:\\
|
||||
\colorbox{white}{\includegraphics[width=0.7\textwidth]{lifficurves}}\\
|
||||
Perfect integrate-and-fire:\\
|
||||
\colorbox{white}{\includegraphics[width=0.7\textwidth]{pifficurves}}
|
||||
\end{solution}
|
||||
|
||||
\part Use the functions for computing serial correlations, count statistics and fano factors
|
||||
to further explore the statistics of the integrate-and-fire models!
|
||||
|
||||
\end{parts}
|
||||
|
||||
\end{questions}
|
||||
|
||||
|
||||
\end{document}
|
||||
BIN
pointprocesses/exercises/inversegauss.pdf
Normal file
BIN
pointprocesses/exercises/inversegauss.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/lifficurves.pdf
Normal file
BIN
pointprocesses/exercises/lifficurves.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/lifisih08.pdf
Normal file
BIN
pointprocesses/exercises/lifisih08.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/lifisih16.pdf
Normal file
BIN
pointprocesses/exercises/lifisih16.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/lifisistats.pdf
Normal file
BIN
pointprocesses/exercises/lifisistats.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/lifraster10.pdf
Normal file
BIN
pointprocesses/exercises/lifraster10.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/lifraster15.pdf
Normal file
BIN
pointprocesses/exercises/lifraster15.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/pifficurves.pdf
Normal file
BIN
pointprocesses/exercises/pifficurves.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/pifisih01.pdf
Normal file
BIN
pointprocesses/exercises/pifisih01.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/pifisih10.pdf
Normal file
BIN
pointprocesses/exercises/pifisih10.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/pifisistats.pdf
Normal file
BIN
pointprocesses/exercises/pifisistats.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/pifraster02.pdf
Normal file
BIN
pointprocesses/exercises/pifraster02.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/pifraster10.pdf
Normal file
BIN
pointprocesses/exercises/pifraster10.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poisson-solutions.pdf
Normal file
BIN
pointprocesses/exercises/poisson-solutions.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poisson.pdf
Normal file
BIN
pointprocesses/exercises/poisson.pdf
Normal file
Binary file not shown.
160
pointprocesses/exercises/poisson.tex
Normal file
160
pointprocesses/exercises/poisson.tex
Normal file
@@ -0,0 +1,160 @@
|
||||
\documentclass[addpoints,10pt]{exam}
|
||||
\usepackage{url}
|
||||
\usepackage{color}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\pagestyle{headandfoot}
|
||||
\runningheadrule
|
||||
\firstpageheadrule
|
||||
|
||||
\firstpageheader{Scientific Computing}{Homogeneous Poisson process}{Oct 27, 2014}
|
||||
%\runningheader{Homework 01}{Page \thepage\ of \numpages}{23. October 2014}
|
||||
\firstpagefooter{}{}{}
|
||||
\runningfooter{}{}{}
|
||||
\pointsinmargin
|
||||
\bracketedpoints
|
||||
|
||||
%\printanswers
|
||||
\shadedsolutions
|
||||
|
||||
\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro
|
||||
|
||||
%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\usepackage{listings}
|
||||
\lstset{
|
||||
basicstyle=\ttfamily,
|
||||
numbers=left,
|
||||
showstringspaces=false,
|
||||
language=Matlab,
|
||||
breaklines=true,
|
||||
breakautoindent=true,
|
||||
columns=flexible,
|
||||
frame=single,
|
||||
captionpos=t,
|
||||
xleftmargin=2em,
|
||||
xrightmargin=1em,
|
||||
aboveskip=10pt,
|
||||
%title=\lstname,
|
||||
title={\protect\filename@parse{\lstname}\protect\filename@base.\protect\filename@ext}
|
||||
}
|
||||
|
||||
|
||||
\begin{document}
|
||||
|
||||
\sffamily
|
||||
%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
\begin{questions}
|
||||
\question \textbf{Homogeneous Poisson process}
|
||||
We use the Poisson process to generate spike trains on which we can test and imrpove some
|
||||
standard analysis functions.
|
||||
|
||||
A homogeneous Poisson process of rate $\lambda$ (measured in Hertz) is a point process
|
||||
where the probability of an event is independent of time $t$ and independent of previous events.
|
||||
The probability $P$ of an event within a bin of width $\Delta t$ is
|
||||
\[ P = \lambda \cdot \Delta t \]
|
||||
for sufficiently small $\Delta t$.
|
||||
\begin{parts}
|
||||
|
||||
\part Write a function that generates $n$ homogeneous Poisson spike trains of a given duration $T_{max}$
|
||||
with rate $\lambda$.
|
||||
\begin{solution}
|
||||
\lstinputlisting{hompoissonspikes.m}
|
||||
\end{solution}
|
||||
|
||||
\part Using this function, generate a few trials and display them in a raster plot.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/spikeraster.m}
|
||||
\begin{lstlisting}
|
||||
spikes = hompoissonspikes( 10, 100.0, 0.5 );
|
||||
spikeraster( spikes )
|
||||
\end{lstlisting}
|
||||
\mbox{}\\[-3ex]
|
||||
\colorbox{white}{\includegraphics[width=0.7\textwidth]{poissonraster100hz}}
|
||||
\end{solution}
|
||||
|
||||
\part Write a function that extracts a single vector of interspike intervals
|
||||
from the spike times returned by the first function.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/isis.m}
|
||||
\end{solution}
|
||||
|
||||
\part Write a function that plots the interspike-interval histogram
|
||||
from a vector of interspike intervals. The function should also
|
||||
compute the mean, the standard deviation, and the CV of the intervals
|
||||
and display the values in the plot.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/isihist.m}
|
||||
\end{solution}
|
||||
|
||||
\part Compute histograms for Poisson spike trains with rate
|
||||
$\lambda=100$\,Hz. Play around with $T_{max}$ and $n$ and the bin width
|
||||
(start with 1\,ms) of the histogram.
|
||||
How many
|
||||
interspike intervals do you approximately need to get a ``nice''
|
||||
histogram? How long do you need to record from the neuron?
|
||||
\begin{solution}
|
||||
About 5000 intervals for 25 bins. This corresponds to a $5000 / 100\,\hertz = 50\,\second$ recording
|
||||
of a neuron firing with 100\,\hertz.
|
||||
\end{solution}
|
||||
|
||||
\part Compare the histogram with the true distribution of intervals $T$ of the Poisson process
|
||||
\[ p(T) = \lambda e^{-\lambda T} \]
|
||||
for various rates $\lambda$.
|
||||
\begin{solution}
|
||||
\lstinputlisting{hompoissonisih.m}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih100hz}}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih20hz}}
|
||||
\end{solution}
|
||||
|
||||
\part What happens if you make the bin width of the histogram smaller than $\Delta t$
|
||||
used for generating the Poisson spikes?
|
||||
\begin{solution}
|
||||
The bins between the discretization have zero entries. Therefore
|
||||
the other ones become higher than they should be.
|
||||
\end{solution}
|
||||
|
||||
\part Plot the mean interspike interval, the corresponding standard deviation, and the CV
|
||||
as a function of the rate $\lambda$ of the Poisson process.
|
||||
Compare the simulations with the theoretical expectations for the dependence on $\lambda$.
|
||||
\begin{solution}
|
||||
\lstinputlisting{hompoissonisistats.m}
|
||||
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonisistats}}
|
||||
\end{solution}
|
||||
|
||||
\part Write a function that computes serial correlations for the interspike intervals
|
||||
for a range of lags.
|
||||
The serial correlations $\rho_k$ at lag $k$ are defined as
|
||||
\[ \rho_k = \frac{\langle (T_{i+k} - \langle T \rangle)(T_i - \langle T \rangle) \rangle}{\langle (T_i - \langle T \rangle)^2\rangle} = \frac{{\rm cov}(T_{i+k}, T_i)}{{\rm var}(T_i)} \]
|
||||
Use this function to show that interspike intervals of Poisson spikes are independent.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/isiserialcorr.m}
|
||||
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonserial100hz}}
|
||||
\end{solution}
|
||||
|
||||
\part Write a function that generates from spike times
|
||||
a histogram of spike counts in a count window of given duration $W$.
|
||||
The function should also plot the Poisson distribution
|
||||
\[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \]
|
||||
for the rate $\lambda$ determined from the spike trains.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/counthist.m}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz10ms}}
|
||||
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz100ms}}
|
||||
\end{solution}
|
||||
|
||||
\part Write a function that computes mean count, variance of count and the corresponding Fano factor
|
||||
for a range of count window durations. The function should generate tow plots: one plotting
|
||||
the count variance against the mean, the other one the Fano factor as a function of the window duration.
|
||||
\begin{solution}
|
||||
\lstinputlisting{simulations/fano.m}
|
||||
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonfano100hz}}
|
||||
\end{solution}
|
||||
|
||||
\end{parts}
|
||||
|
||||
\end{questions}
|
||||
|
||||
|
||||
\end{document}
|
||||
BIN
pointprocesses/exercises/poissoncounthistdist100hz100ms.pdf
Normal file
BIN
pointprocesses/exercises/poissoncounthistdist100hz100ms.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poissoncounthistdist100hz10ms.pdf
Normal file
BIN
pointprocesses/exercises/poissoncounthistdist100hz10ms.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poissonfano100hz.pdf
Normal file
BIN
pointprocesses/exercises/poissonfano100hz.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poissonisih100hz.pdf
Normal file
BIN
pointprocesses/exercises/poissonisih100hz.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poissonisih20hz.pdf
Normal file
BIN
pointprocesses/exercises/poissonisih20hz.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poissonisistats.pdf
Normal file
BIN
pointprocesses/exercises/poissonisistats.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poissonraster100hz.pdf
Normal file
BIN
pointprocesses/exercises/poissonraster100hz.pdf
Normal file
Binary file not shown.
BIN
pointprocesses/exercises/poissonserial100hz.pdf
Normal file
BIN
pointprocesses/exercises/poissonserial100hz.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user