[pointprocesses] cleaned up m and pdf files

This commit is contained in:
Jan Benda 2021-01-19 13:28:51 +01:00
parent 73c6d35536
commit 77b6666347
25 changed files with 106 additions and 730 deletions

View File

@ -1,3 +1,3 @@
TEXFILES=$(wildcard pointprocesses-?.tex)
TEXFILES=$(wildcard pointprocesses-?.tex) psth.tex
include ../../exercises.mk

View File

@ -1,18 +0,0 @@
% 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

View File

@ -1,46 +0,0 @@
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' );

View File

@ -1,19 +0,0 @@
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,:) < p ) * dt;
end
end

View File

@ -1,142 +0,0 @@
\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}

View File

@ -1,12 +1,12 @@
\documentclass[12pt,a4paper,pdftex]{exam}
\newcommand{\exercisetopic}{Point Processes}
\newcommand{\exercisenum}{X2}
\newcommand{\exercisetopic}{Integrate-and-fire models}
\newcommand{\exercisenum}{13}
\newcommand{\exercisedate}{January 19th, 2021}
\input{../../exercisesheader}
\firstpagefooter{Prof. Dr. Jan Benda}{}{jan.benda@uni-tuebingen.de}
\firstpagefooter{Dr. Jan Benda}{}{jan.benda@uni-tuebingen.de}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
@ -14,113 +14,97 @@
\input{../../exercisestitle}
\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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\question \qt{Homogener Poisson Prozess}
Wir wollen den homogenen Poisson Prozess benutzen um Spikes zu generieren,
mit denen wir die Analysfunktionen des vorherigen \"Ubungszettel \"uberpr\"ufen k\"onnen.
Ein homogener Poisson Prozess mit der Rate $\lambda$ (gemessen in Hertz) ist ein Punktprozess,
bei dem die Wahrschienlichkeit eines Ereignisses unabh\"angig von der Zeit $t$ und
unabh\"angig von vorherigen Ereignissen ist.
Die Wahrscheinlichkeit $P$ eines Ereignisses innerhalb eines Bins der Breite $\Delta t$ ist
\[ P = \lambda \cdot \Delta t \]
f\"ur gen\"ugend kleine $\Delta t$.
\begin{parts}
\part Schreibe eine Funktion die $n$ homogene Poisson Spiketrains
einer gegebenen Dauer $T_{max}$ mit Rate $\lambda$ erzeugt.
\begin{solution}
\lstinputlisting{hompoissonspikes.m}
\end{solution}
\part Benutze diese Funktion um einige Trials von Spikes zu erzeugen
und plotte diese als Spikeraster.
\begin{solution}
\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 Berechne Histogramme aus den Interspikeintervallen von $n$
Poisson Spiketrains mit der Rate $\lambda=100$\,Hz. Ver\"andere
\"uber die Dauer $T_{max}$ der Spiketrains und die Anzahl $n$ der
Trials die Anzahl der Intervalle und ver\"andere auch die Binbreite
des Histograms (fang mit 1\,ms an). Wieviele Interspikeintervalle
werden ben\"otigt, um ein ``sch\"ones'' Histogramm zu erhalten? Wie
lange m\"usste man also von dem Neuron ableiten?
\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 Vergleiche Interspike-Intervall Histogramme von Poisson-Spikes
verschiedener Raten $\lambda$ mit der theoretisch zu erwartenden Verteilung
der Intervalle $T$ des Poisson Prozesses
\[ p(T) = \lambda e^{-\lambda T} \; .\]
\begin{solution}
\lstinputlisting{hompoissonisih.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih100hz}}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih20hz}}
\end{solution}
\part \extra Was pasiert mit den Histogrammen, wenn die Binbreite
der Histogramme kleiner als das bei der Erzeugung der Poisson
Spiketrains verwendete $\Delta t$ ist?
\begin{solution}
Die Bins zwischen der durch $\Delta t$ vorgegebenen
Diskretisierung haben den Wert 0. Dadurch werden aber die anderen
durch die Normierung h\"oher als sie sein sollten.
\end{solution}
\part Plotte den Mittelwert der Interspikeintervalle, die
dazugeh\"orige Standardabweichung und den Variationskoeffizienten
als Funktion der Rate $\lambda$ des Poisson Prozesses. Vergleiche
die Ergebnisse mit den theoretischen Erwartungen (siehe Vorlesungsskript).
\begin{solution}
\lstinputlisting{hompoissonisistats.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonisistats}}
\end{solution}
\part Plotte die seriellen Korrelationen von Poisson-Spiketrains und
erkl\"are kurz das Ergebniss.
\begin{solution}
\mbox{}\\[-2ex]\hspace*{2cm}
\colorbox{white}{\includegraphics[width=0.8\textwidth]{poissonserial100hz}}\\
Alle Korrelationen zwischen Interspikeintervallen sind Null, da
beim Poisson Prozess das Auftreten jedes Spikes unabh\"angig von
den vorherigen Spikes ist.
\end{solution}
\part Vergleiche Histogramme von Spikecounts gez\"ahlt in Fenstern
der Breite $W$ mit der Poisson Verteilung
\[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \; , \]
wobei die Rate $\lambda$ aus den Daten bestimmt werden
soll. Hinweis: es gibt eine \code{matlab} Funktion, die die
Fakult\"at $n!$ berechnet.
\begin{solution}
%\lstinputlisting{counthist.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz10ms}}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz100ms}}
\end{solution}
\part Schreibe eine Funktion, die die mittlere Anzahl, die Varianz
und den Fano-Faktor der Anzahl der Spikes in einem Fenster der
Breite $W$ bestimmt. Benutze die Funktion, um diese Parameter f\"ur
verschiedene Fensterbreiten $W$ zu bestimmen. Zwei Plots sollen aus
den Ergebnissen angefertigt werden: (i) Varianz gegen Mittelwert der counts.
(ii) Fano Faktor als Funktion der Fensterbreite.
\begin{solution}
\lstinputlisting{fanoplot.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonfano100hz}}
\end{solution}
\end{parts}
\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{inversegauss.m}
\lstinputlisting{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{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{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{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}

View File

@ -1,163 +0,0 @@
\documentclass[12pt,a4paper,pdftex]{exam}
\newcommand{\exercisetopic}{Point Processes}
\newcommand{\exercisenum}{X3}
\newcommand{\exercisedate}{January 19th, 2021}
\input{../../exercisesheader}
\firstpagefooter{Prof. Dr. Jan Benda}{}{jan.benda@uni-tuebingen.de}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\input{../../exercisestitle}
\begin{questions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\question \qt{Statistik von Spiketrains 2}
In Ilias findet ihr die Dateien \code{poisson.mat},
\code{pifou.mat}, und \code{lifadapt.mat}. Jede dieser Dateien
enth\"alt mehrere Trials von Spiketrains von einer bestimmten Art
von Neuron. Die Spikezeiten sind in Sekunden gemessen.
Mit den folgenden Aufgaben wollen wir die Statistik der Spiketrains
der drei Neurone miteinander vergleichen.
Bereits im letzten \"Ubungszettel erstellte Funktionen d\"urfen (sollen!)
wiederverwendet werden.
\begin{parts}
\part Lade die Spiketrains aus den drei Dateien. Stelle sie in Rasterplots dar.
\part Plotte die Interspike-Intervall Verteilungen.
Annotiere die Plots mit dem Mittelwert, der
Standardabweichung, und dem Variationskoeffizienten der
Interspikeintervalle, sowie der mittleren Feuerrate.
\part Vergleiche die ISI-Histogramme mit der ISI Verteilung eines Poisson Prozesses
der Rate $\lambda$:
\[ p(T) = \lambda e^{-\lambda T} \; .\]
\part Erstelle Return-Maps f\"ur die drei Spiketrains, also jedes
Interspike-Intervall $T_{i+1}$ gegen das vorherige Intervall $T_i$
geplottet.
\part Schreibe eine Funktion, die die seriellen Korrelationen der
Interspikeintervalle f\"ur Lags bis zu \code{maxlag} berechnet und
plottet. Die Seriellen Korrelationen $\rho_k$ f\"ur Lag $k$ der
Interspikeintervalle $T_i$ sind die Korrelationskoeffizienten
zwischen den Interspikeintervallen $T_i$ und den um das Lag $k$
verschobenen Intervallen $T_{i+k}$:
\[ \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)} = {\rm corr}(T_{i+k}, T_i) \]
Benutze diese Funktion, um die Interspikeintervall-Korrelationen
der drei Neurone zu vergleichen.
\begin{solution}
\lstinputlisting{../code/isiserialcorr.m}
\lstinputlisting{../code/plotserialcorr.m}
\colorbox{white}{\includegraphics[width=1\textwidth]{serialcorr}}
\end{solution}
\end{parts}
\continue
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\question \qt{Homogener Poisson Prozess}
Wir wollen den homogenen Poisson Prozess benutzen um Spikes zu
generieren, mit denen wir die Analysfunktionen des vorherigen
Aufgaben \"uberpr\"ufen k\"onnen.
Ein homogener Poisson Prozess mit der Rate $\lambda$ (gemessen in
Hertz) ist ein Punktprozess, bei dem die Wahrscheinlichkeit eines
Ereignisses unabh\"angig von der Zeit $t$ und unabh\"angig von
vorherigen Ereignissen ist. Wenn wir die Zeitachse in kleine Bins
der Breite $\Delta t$ einteilen, dann ist
\[ P = \lambda \cdot \Delta t \]
die Wahrscheinlichkeit innerhalb eines Bins ein Ereignis (``spike'')
zu erhalten. $\Delta t$ muss daf\"ur klein genug sein, so dass $P<0.1$.
\begin{parts}
\part Schreibe eine Funktion die $n$ homogene Poisson Spiketrains
einer gegebenen Dauer $T_{max}$ mit Rate $\lambda$ erzeugt.
Falls das nicht gelingt, benutze f\"ur die folgenden Aufgaben
soweit m\"oglich spikes aus der Datei \code{poisson.mat}.
\begin{solution}
\lstinputlisting{hompoissonspikes.m}
\end{solution}
\part Benutze diese Funktion um einige Trials von Spikes zu erzeugen
und plotte diese als Spikeraster.
\begin{solution}
\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 Berechne Histogramme aus den Interspikeintervallen von $n$
Poisson Spiketrains mit der Rate $\lambda=100$\,Hz. Wie viele bins
werden f\"ur ein ``sch\"ones'' ISI-Histogramm ungef\"ahr ben\"otigt?
Ver\"andere \"uber die Dauer $T_{max}$ der Spiketrains und die
Anzahl $n$ der Trials die Anzahl der Intervalle. Wieviele
Interspikeintervalle werden ben\"otigt, um ein ``sch\"ones''
Histogramm zu erhalten? Wie lange m\"usste man also von dem Neuron
ableiten?
\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 Vergleiche Interspike-Intervall Histogramme von Poisson-Spikes
verschiedener Raten $\lambda$ mit der theoretisch zu erwartenden Verteilung
der Intervalle $T$ des Poisson Prozesses
\[ p(T) = \lambda e^{-\lambda T} \; .\]
Achte darauf, dass die Bins des Histograms nicht kleiner als $\Delta t$ sind!
\begin{solution}
\lstinputlisting{hompoissonisih.m}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih100hz}}
\colorbox{white}{\includegraphics[width=0.48\textwidth]{poissonisih20hz}}
\end{solution}
\part \extra Was passiert mit den Histogrammen, wenn die Binbreite
der Histogramme kleiner als das bei der Erzeugung der Poisson
Spiketrains verwendete $\Delta t$ ist?
\begin{solution}
Die Bins zwischen der durch $\Delta t$ vorgegebenen
Diskretisierung haben den Wert 0. Dadurch werden aber die anderen
durch die Normierung h\"oher als sie sein sollten.
\end{solution}
\part Plotte den Mittelwert der Interspikeintervalle, die
dazugeh\"orige Standardabweichung und den Variationskoeffizienten
als Funktion der Rate $\lambda$ des Poisson Prozesses. Vergleiche
die Ergebnisse mit den theoretischen Erwartungen (siehe Vorlesungsskript).
\begin{solution}
\lstinputlisting{hompoissonisistats.m}
\colorbox{white}{\includegraphics[width=0.98\textwidth]{poissonisistats}}
\end{solution}
\part Plotte die seriellen Korrelationen von Poisson-Spiketrains und
erkl\"are kurz das Ergebniss.
\begin{solution}
\mbox{}\\[-2ex]\hspace*{2cm}
\colorbox{white}{\includegraphics[width=0.8\textwidth]{poissonserial100hz}}\\
Alle Korrelationen zwischen Interspikeintervallen sind Null, da
beim Poisson Prozess das Auftreten jedes Spikes unabh\"angig von
den vorherigen Spikes ist.
\end{solution}
\end{parts}
\end{questions}
\end{document}

View File

@ -1,198 +0,0 @@
\documentclass[12pt,a4paper,pdftex]{exam}
\usepackage[german]{babel}
\usepackage{pslatex}
\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref}
%%%%% layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot}
\ifprintanswers
\newcommand{\stitle}{L\"osungen}
\else
\newcommand{\stitle}{\"Ubung}
\fi
\header{{\bfseries\large \stitle}}{{\bfseries\large Punktprozesse}}{{\bfseries\large 27. Oktober, 2015}}
\firstpagefooter{Prof. Dr. Jan Benda}{Phone: 29 74573}{Email:
jan.benda@uni-tuebingen.de}
\runningfooter{}{\thepage}{}
\setlength{\baselineskip}{15pt}
\setlength{\parindent}{0.0cm}
\setlength{\parskip}{0.3cm}
\renewcommand{\baselinestretch}{1.15}
%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\lstset{
language=Matlab,
basicstyle=\ttfamily\footnotesize,
numbers=left,
numberstyle=\tiny,
title=\lstname,
showstringspaces=false,
commentstyle=\itshape\color{darkgray},
breaklines=true,
breakautoindent=true,
columns=flexible,
frame=single,
xleftmargin=1em,
xrightmargin=1em,
aboveskip=10pt
}
%%%%% math stuff: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{dsfont}
\newcommand{\naZ}{\mathds{N}}
\newcommand{\gaZ}{\mathds{Z}}
\newcommand{\raZ}{\mathds{Q}}
\newcommand{\reZ}{\mathds{R}}
\newcommand{\reZp}{\mathds{R^+}}
\newcommand{\reZpN}{\mathds{R^+_0}}
\newcommand{\koZ}{\mathds{C}}
%%%%% page breaks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\continue}{\ifprintanswers%
\else
\vfill\hspace*{\fill}$\rightarrow$\newpage%
\fi}
\newcommand{\continuepage}{\ifprintanswers%
\newpage
\else
\vfill\hspace*{\fill}$\rightarrow$\newpage%
\fi}
\newcommand{\newsolutionpage}{\ifprintanswers%
\newpage%
\else
\fi}
%%%%% new commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\qt}[1]{\textbf{#1}\\}
\newcommand{\pref}[1]{(\ref{#1})}
\newcommand{\extra}{--- Zusatzaufgabe ---\ \mbox{}}
\newcommand{\code}[1]{\texttt{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\input{instructions}
\begin{questions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\question \qt{Statistik von Spiketrains}
In Ilias findet ihr die Dateien \code{poisson.mat},
\code{pifou.mat}, und \code{lifadapt.mat}. Jede dieser Dateien
enth\"alt mehrere Trials von Spiketrains von einer bestimmten Art
von Neuron. Die Spikezeiten sind in Sekunden gemessen.
Mit den folgenden Aufgaben wollen wir die Statistik der Spiketrains
der drei Neurone miteinander vergleichen.
\begin{parts}
\part Lade die Spiketrains aus den drei Dateien. Achte darauf,
dass sie verschiedene Variablen\-namen bekommen.
\begin{solution}
\begin{lstlisting}
clear all
% not so good:
load poisson.mat
whos
poissonspikes = spikes;
load pifou.mat;
pifouspikes = spikes;
load lifadapt.mat;
lifadaptspikes = spikes;
clear spikes;
% better:
clear all
x = load( 'poisson.mat' );
poissonspikes = x.spikes;
x = load( pifou.mat' );
pifouspikes = x.spikes;
x = load( 'lifadapt.mat' );
lifadaptspikes = x.spikes;
\end{lstlisting}
\end{solution}
\part Schreibe eine Funktion, die die Spikezeiten der ersten
$t_{max}$ Sekunden in einem Rasterplot visualisiert. In jeder
Zeile des Rasterplots wird ein Spiketrain dargestellt. Jeder
einzelne Spike wird als senkrechte Linie zu der Zeit des
Auftretens des Spikes geplottet. Benutze die Funktion, um die
Spikeraster der ersten 1\,s der drei Neurone nebeneinander zu plotten.
\begin{solution}
\lstinputlisting{../code/spikeraster.m}
\lstinputlisting{../code/plotspikeraster.m}
\mbox{}\\[-3ex]
\colorbox{white}{\includegraphics[width=1\textwidth]{spikeraster}}
\end{solution}
\part Schreibe eine Funktion, die einen einzigen Vektor mit den
Interspikeintervallen aller Trials von Spikezeiten zur\"uckgibt.
\begin{solution}
\lstinputlisting{../code/isis.m}
\end{solution}
\part Schreibe eine Funktion, die ein normiertes Histogramm aus
einem Vektor von Interspikeintervallen, gegeben in Sekunden,
berechnet und dieses mit richtiger Achsenbeschriftung plottet.
Die Interspikeintervalle sollen dabei in Millisekunden angegeben
werden. Die Funktion soll zus\"atzlich den Mittelwert, die
Standardabweichung, und den Variationskoeffizienten der
Interspikeintervalle berechnen und diese im Plot mit angeben.
Benutze die vorherige und diese Funktion, um die
Interspikeintervall Verteilung der drei Neurone zu vergleichen.
\begin{solution}
\lstinputlisting{../code/isihist.m}
\lstinputlisting{../code/plotisih.m}
\mbox{}\\[-3ex]
\colorbox{white}{\includegraphics[width=1\textwidth]{isihist}}
\end{solution}
\part Schreibe eine Funktion, die die seriellen Korrelationen der
Interspikeintervalle f\"ur Lags bis zu \code{maxlag} berechnet und
plottet. Die Seriellen Korrelationen $\rho_k$ f\"ur Lag $k$ der
Interspikeintervalle $T_i$ sind die Korrelationskoeffizienten
zwischen den Interspikeintervallen $T_i$ und den um das Lag $k$
verschobenen Intervallen $T_{i+k}$:
\[ \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)} = {\rm corr}(T_{i+k}, T_i) \]
Benutze diese Funktion, um die Interspikeintervall-Korrelationen
der drei Neurone zu vergleichen.
\begin{solution}
\lstinputlisting{../code/isiserialcorr.m}
\lstinputlisting{../code/plotserialcorr.m}
\colorbox{white}{\includegraphics[width=1\textwidth]{serialcorr}}
\end{solution}
\part Schreibe eine Funktion, die aus Spikezeiten
Histogramme aus der Anzahl von Spikes, die in Fenstern gegebener L\"ange $W$
gez\"ahlt werden, erzeugt und plottet.
Wende diese Funktion auf die drei
Datens\"atze an. Probiere verschiedene Fenstergr\"o{\ss}en $W$ aus.
\begin{solution}
\lstinputlisting{../code/counthist.m}
\lstinputlisting{../code/plotcounthist.m}
\colorbox{white}{\includegraphics[width=1\textwidth]{counthist}}
\end{solution}
\end{parts}
\end{questions}
\end{document}

Binary file not shown.

View File

@ -1,42 +1,20 @@
\documentclass[12pt,a4paper,pdftex]{exam}
\usepackage[german]{babel}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage[small]{caption}
\usepackage{sidecap}
\usepackage{pslatex}
\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\marginparwidth}{2cm}
\usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref}
\newcommand{\exercisetopic}{Time-dependent firing rates}
\newcommand{\exercisenum}{12}
\newcommand{\exercisedate}{January 19th, 2021}
%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot} \header{{\bfseries\large Exercise
}}{{\bfseries\large Time-dependent firing rate}}{{\bfseries\large January, 14, 2020}}
\firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email:
jan.grewe@uni-tuebingen.de} \runningfooter{}{\thepage}{}
\input{../../exercisesheader}
\setlength{\baselineskip}{15pt}
\setlength{\parindent}{0.0cm}
\setlength{\parskip}{0.3cm}
\renewcommand{\baselinestretch}{1.15}
\firstpagefooter{Dr. Jan Grewe}{}{jan.grewe@uni-tuebingen.de}
\newcommand{\code}[1]{\texttt{#1}}
\renewcommand{\solutiontitle}{\noindent\textbf{Solution}\par\noindent}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\vspace*{-6.5ex}
\begin{center}
\textbf{\Large Introduction to scientific computing.}\\[1ex]
{\large Jan Grewe, Jan Benda}\\[-3ex]
Abteilung Neuroethologie \hfill --- \hfill Institut f\"ur Neurobiologie \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\
\end{center}
\input{../../exercisestitle}
\begin{questions}
\question Plot the time-dependent firing rate of a neuron. Calculate
the firing rate from the \emph{instantaneous firing rate} (based on the
interspike interval). Use the \code{lifoustim.mat}. The dataset
@ -45,14 +23,14 @@
duration of each trial is 30 seconds.
\begin{parts}
\part{} Write a function that takes three arguments: the spike
\part Write a function that takes three arguments: the spike
times of a single trial, the trial duration and the temporal
resolution. The function should return two variables: the time axis and the
time-dependent firing rate.
\part{} Write a script that applies the above function to estimate
\part Write a script that applies the above function to estimate
the time-dependent firing rate of each trial. Plot the firing rates of the individual responses
and the average response as a function of time into the same graph.
\part{} Extend your program that it saves the figure with the width and height of 8.5\,cm using a fontsize of 10\,pt for labels.
\part Extend your program that it saves the figure with the width and height of 8.5\,cm using a fontsize of 10\,pt for labels.
See Chapter 3 in the script, or browse the Matlab help for more
information. Store the figure in pdf format.
\end{parts}
@ -65,10 +43,10 @@
\question{} Some trials are different than the others.
\begin{parts}
\part{} Use a rasterplot to identify them. In which sense
\part Use a rasterplot to identify them. In which sense
are they different? Save the rasterplot in pdf
format. Use the same figure specifications as above and make sure it is properly labeled.
\part{} Identify those trials in which the spike count
\part Identify those trials in which the spike count
deviates more than $2\sigma$ (twice the standard deviation) from the average.
\end{parts}
\end{questions}