Jan Bs projects

This commit is contained in:
2014-11-02 13:35:52 +01:00
parent 123442932f
commit 896c6d858e
29 changed files with 922 additions and 7 deletions

View File

@@ -0,0 +1,10 @@
latex:
pdflatex *.tex > /dev/null
pdflatex *.tex > /dev/null
clean:
rm -rf *.log *.aux *.zip *.out auto
rm -f `basename *.tex .tex`.pdf
zip: latex
zip `basename *.tex .tex`.zip *.pdf *.dat *.mat *.m

View File

@@ -0,0 +1,140 @@
\documentclass[addpoints,10pt]{exam}
\usepackage{url}
\usepackage{color}
\usepackage{hyperref}
\pagestyle{headandfoot}
\runningheadrule
\firstpageheadrule
\firstpageheader{Scientific Computing}{Project Assignment}{11/05/2014
-- 11/06/2014}
%\runningheader{Homework 01}{Page \thepage\ of \numpages}{23. October 2014}
\firstpagefooter{}{}{}
\runningfooter{}{}{}
\pointsinmargin
\bracketedpoints
%\printanswers
%\shadedsolutions
%%%%% 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}
%%%%%%%%%%%%%%%%%%%%% Submission instructions %%%%%%%%%%%%%%%%%%%%%%%%%
\sffamily
% \begin{flushright}
% \gradetable[h][questions]
% \end{flushright}
\begin{center}
\input{../disclaimer.tex}
\end{center}
%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
\begin{questions}
\question You are recording the activity of two neurons in response to
a constant stimulus $I$ (think of it, for example,
of a sound wave with intensity $I$).
For different inputs $I$ the interspike interval ($T$) distribution looks
quite different. You want to compare these distributions to
the following three standard distributions.
The first is the exponential distribution of a Poisson spike train:
\begin{equation}
\label{exppdf}
p_{exp}(T) = \lambda e^{-\lambda T}
\end{equation}
where $\lambda$ is the mean firing rate of the response.
The second distribution is the inverse Gaussian:
\begin{equation}
\label{invgauss}
p_\mathrm{ig}(T) = \frac{1}{\sqrt{4 \pi D T^{3}}} \exp \left[ - \frac{(T - \mu)^{2} }{4 D T \mu^{2}} \right]
\end{equation}
where $\mu$ is the mean interspike interval and
$D=\textrm{var}(T)/(2\mu^3)$ is the so called diffusion coefficient.
The third one was derived for neurons driven with colored noise:
\begin{equation}\label{pcn}
p_\mathrm{cn}(T)=\frac{1}{2\tau\sqrt{4\pi\epsilon\gamma_1^3}}\exp\left[-\frac{(T-\mu)^2}{4\epsilon\tau^2\gamma_1}\right]\left\{\frac{[(\mu-T)\gamma_2+2\gamma_1\tau]^2}{2\gamma_1\tau^2}-\epsilon(\gamma_2^2-2\gamma_1e^{-T/\tau})\right\}
\end{equation}
with $\gamma_1(T)=T/\tau+e^{-T/\tau}-1$, $\gamma_2(T)=1-e^{-T/\tau}$
and correlation time of the colored noise $\tau$.
Eq.~(\ref{pcn}) thus has the three parameter $\mu$, $\epsilon>0$, and $\tau$.
The squared coefficient of variation (standard deviation of the
interspike intervals divided by their mean) of the density
eq.~(\ref{pcn}) is given by
\begin{equation}
\label{cvpcn}
C_V^2=\frac{2}{\delta}\left[\epsilon\left(1-\frac{1-e^{-\delta}}{\delta}\right)+\epsilon^2\left(e^{-\delta}+\frac{(1-e^{-\delta})(1-2e^{-\delta})}{\delta}\right)\right]
\end{equation}
with $\delta=\mu/\tau$.
\begin{parts}
\part The two neurons are implemented in the files \texttt{pifouspikes.m}
and \texttt{lifouspikes.m}.
Call them with the following parameters:
\begin{lstlisting}
trials = 10;
tmax = 50.0;
input = 10.0; % the input I
Dnoise = 1.0; % noise strength
outau = 1.0; % correlation time of the noise in seconds
spikes = pifouspikes( trials, input, tmax, Dnoise, outau );
\end{lstlisting}
The returned \texttt{spikes} is a cell array with \texttt{trials} elements, each being a vector
of spike times (in seconds) computed for a duration of \texttt{tmax} seconds.
The input is set via the \texttt{input} variable.
\part Find for both model neurons the inputs $I_i$ required to make the fire with a mean rate
of 10, 20, 50, and 100\,Hz.
\part Compute interspike interval distributions of the two model neurons for these inputs $I_i$.
\part Compare the interspike interval distributions with the exponential
distribution eq.~(\ref{exppdf}) and the inverse Gaussian
eq.~(\ref{invgauss}) by measuring their parameters from the
interspike intervals. How well do theu describe the real
distributions for the different conditions?
\part Also fit eq.~(\ref{pcn}) to the data. Here you need to apply a non-linear fit algorithm.
How well does this function describe the data?
Compare the fitted value for $\tau$ with the one used for the model (\texttt{outau}).
\uplevel{If you still have time you can continue with the following question:}
\part Compare the measured coefficient of variation with eq.~(\ref{cvpcn}).
\part Repeat your analysis for different values of the intrinsic noise strengh of the neurons
\texttt{Dnoise}. Increase or decrease it in factors of ten.
\end{parts}
\end{questions}
\end{document}

View File

@@ -0,0 +1,44 @@
function spikes = lifouspikes( trials, input, tmaxdt, D, outau )
% Generate spike times of a leaky integrate-and-fire neuron
% trials: the number of trials to be generated
% input: the stimulus either as a single value or as a vector
% tmaxdt: in case of a single value stimulus the duration of a trial
% in case of a vector as a stimulus the time step
% D: the strength of additive white noise
% outau: time constant of the colored noise
tau = 0.01;
if nargin < 4
D = 1e0;
end
if nargin < 5
outau = 1.0;
end
vreset = 0.0;
vthresh = 10.0;
dt = 1e-4;
if length( input ) == 1
input = input * ones( ceil( tmaxdt/dt ), 1 );
else
dt = tmaxdt;
end
spikes = cell( trials, 1 );
for k=1:trials
times = [];
j = 1;
n = 0.0;
v = vreset;
noise = sqrt(2.0*D)*randn( length( input ), 1 )/sqrt(dt);
for i=1:length( noise )
n = n + ( - n + noise(i))*dt/outau;
v = v + ( - v + n + input(i))*dt/tau;
if v >= vthresh
v = vreset;
times(j) = i*dt;
j = j + 1;
end
end
spikes{k} = times;
end
end

View File

@@ -0,0 +1,44 @@
function spikes = pifouspikes( trials, input, tmaxdt, D, outau )
% Generate spike times of a perfect integrate-and-fire neuron
% trials: the number of trials to be generated
% input: the stimulus either as a single value or as a vector
% tmaxdt: in case of a single value stimulus the duration of a trial
% in case of a vector as a stimulus the time step
% D: the strength of additive white noise
% outau: time constant of the colored noise
tau = 0.01;
if nargin < 4
D = 1e0;
end
if nargin < 5
outau = 1.0;
end
vreset = 0.0;
vthresh = 10.0;
dt = 1e-4;
if length( input ) == 1
input = input * ones( ceil( tmaxdt/dt ), 1 );
else
dt = tmaxdt;
end
spikes = cell( trials, 1 );
for k=1:trials
times = [];
j = 1;
n = 0.0;
v = vreset;
noise = sqrt(2.0*D)*randn( length( input ), 1 )/sqrt(dt);
for i=1:length( noise )
n = n + ( - n + noise(i))*dt/outau;
v = v + ( n + input(i))*dt/tau;
if v >= vthresh
v = vreset;
times(j) = i*dt;
j = j + 1;
end
end
spikes{k} = times;
end
end