This commit is contained in:
Jan Grewe 2018-11-02 11:08:39 +01:00
commit 696167bd39
18 changed files with 224 additions and 213 deletions

View File

@ -15,13 +15,13 @@ x = rng.randn(nsamples)
# bootstrap the mean: # bootstrap the mean:
mus = [] mus = []
for i in xrange(nresamples) : for i in range(nresamples) :
mus.append(np.mean(x[rng.randint(0, nsamples, nsamples)])) mus.append(np.mean(x[rng.randint(0, nsamples, nsamples)]))
hmus, _ = np.histogram(mus, bins, density=True) hmus, _ = np.histogram(mus, bins, density=True)
# many SRS: # many SRS:
musrs = [] musrs = []
for i in xrange(nresamples) : for i in range(nresamples) :
musrs.append(np.mean(rng.randn(nsamples))) musrs.append(np.mean(rng.randn(nsamples)))
hmusrs, _ = np.histogram(musrs, bins, density=True) hmusrs, _ = np.histogram(musrs, bins, density=True)

View File

@ -19,7 +19,7 @@ rd = np.corrcoef(x, y)[0, 1]
# permutation: # permutation:
nperm = 1000 nperm = 1000
rs = [] rs = []
for i in xrange(nperm) : for i in np.arange(nperm) :
xr=rng.permutation(x) xr=rng.permutation(x)
yr=rng.permutation(y) yr=rng.permutation(y)
rs.append( np.corrcoef(xr, yr)[0, 1] ) rs.append( np.corrcoef(xr, yr)[0, 1] )

View File

@ -8,7 +8,8 @@ PYPDFFILES=$(PYFILES:.py=.pdf)
pythonplots : $(PYPDFFILES) pythonplots : $(PYPDFFILES)
$(PYPDFFILES) : %.pdf: %.py $(PYPDFFILES) : %.pdf: %.py
python $< echo $$(which python)
python3 $<
cleanpythonplots : cleanpythonplots :
rm -f $(PYPDFFILES) rm -f $(PYPDFFILES)

View File

@ -41,7 +41,7 @@ for mu in mus :
ax.text(mu-0.1, 0.04, '?', zorder=1, ha='right') ax.text(mu-0.1, 0.04, '?', zorder=1, ha='right')
else : else :
ax.text(mu+0.1, 0.04, '?', zorder=1) ax.text(mu+0.1, 0.04, '?', zorder=1)
for k in xrange(len(mus)) : for k in np.arange(len(mus)) :
ax.plot(x, g[:,k], zorder=5) ax.plot(x, g[:,k], zorder=5)
ax.scatter(xd, 0.05*rng.rand(len(xd))+0.2, s=30, zorder=10) ax.scatter(xd, 0.05*rng.rand(len(xd))+0.2, s=30, zorder=10)

View File

@ -0,0 +1,8 @@
frequency = 5; % frequency of the sine wave in Hz
time = 0.01:0.01:1.0; % the time axis
signal = sin(2 * pi * time * frequency);
plot(time, signal);
xlabel('time [s]');
ylabel('signal');
title('5Hz sine wave')

View File

@ -146,7 +146,7 @@ additional options consult the help.
The following listing shows a simple line plot with axis labeling and a title The following listing shows a simple line plot with axis labeling and a title
\lstinputlisting[caption={A simple plot showing a sinewave.}, \lstinputlisting[caption={A simple plot showing a sinewave.},
label=niceplotlisting]{simple_plot.m} label=simpleplotlisting]{simple_plot.m}
\subsection{Changing properties of a line plot} \subsection{Changing properties of a line plot}

View File

@ -86,7 +86,7 @@ def plot_isi_rate(spike_times, max_t=30, dt=1e-4):
def get_binned_rate(times, bin_width=0.05, max_t=30., dt=1e-4): def get_binned_rate(times, bin_width=0.05, max_t=30., dt=1e-4):
time = np.arange(0., max_t, dt) time = np.arange(0., max_t, dt)
bins = np.arange(0., max_t, bin_width) bins = np.arange(0., max_t, bin_width)
bin_indices = bins / dt bin_indices = np.asarray(bins / dt, np.int)
hist, _ = sp.histogram(times, bins) hist, _ = sp.histogram(times, bins)
rate = np.zeros(time.shape) rate = np.zeros(time.shape)

View File

@ -31,7 +31,7 @@ def pifspikes(input, trials, dt, D=0.1) :
times = [] times = []
v = vreset v = vreset
noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt) noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt)
for k in xrange(len(noise)) : for k in np.arange(len(noise)) :
v += (input[k]+noise[k])*dt/tau v += (input[k]+noise[k])*dt/tau
if v >= vthresh : if v >= vthresh :
v = vreset v = vreset
@ -41,7 +41,7 @@ def pifspikes(input, trials, dt, D=0.1) :
def isis( spikes ) : def isis( spikes ) :
isi = [] isi = []
for k in xrange(len(spikes)) : for k in np.arange(len(spikes)) :
isi.extend(np.diff(spikes[k])) isi.extend(np.diff(spikes[k]))
return isi return isi
@ -76,7 +76,7 @@ rng = np.random.RandomState(54637281)
time = np.arange(0.0, duration, dt) time = np.arange(0.0, duration, dt)
x = np.zeros(time.shape)+rate x = np.zeros(time.shape)+rate
n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate
for k in xrange(1,len(x)) : for k in np.arange(1,len(x)) :
x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau
x[x<0.0] = 0.0 x[x<0.0] = 0.0

View File

@ -1,186 +1,186 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Analyse von Spiketrains} \chapter{Spiketrain analysis}
\selectlanguage{ngerman} \selectlanguage{english}
\determ[Aktionspotential]{Aktionspotentiale} (\enterm{spikes}) sind die Tr\"ager der \enterm[Actionspotentials]{Actionspotentials} (\enterm{spikes}) are
Information in Nervensystemen. Dabei ist in erster Linie nur der the carriers of information in the nervous system. Thereby it is
Zeitpunkt des Auftretens eines Aktionspotentials von Bedeutung. Die mainly the time at which the spikes are generated that is of
genaue Form des Aktionspotentials spielt keine oder nur eine importance. The waveform of the action potential is largely
untergeordnete Rolle. stereotyped and does not carry information.
Nach etwas Vorverarbeitung haben elektrophysiologische Messungen The result of the processing of electrophysiological recordings are
deshalb Listen von Spikezeitpunkten als Ergebniss --- sogenannte series of spike times, which are then termed \enterm{spiketrains}. If
\enterm{spiketrains}. Diese Messungen k\"onnen wiederholt werden und measurements are repeated we yield several \enterm{trials} of
es ergeben sich mehrere \enterm{trials} von Spiketrains spiketrains (\figref{rasterexamplesfig}).
(\figref{rasterexamplesfig}).
Spiketrains sind Zeitpunkte von Ereignissen --- den Aktionspotentialen Spiketrains are times of events, the action potentials. The analysis
--- und deren Analyse f\"allt daher in das Gebiet der Statistik von of these leads into the realm of the so called \enterm[point
sogenannten \determ[Punktprozess]{Punktprozessen}. process]{point processes}.
\begin{figure}[ht] \begin{figure}[ht]
\includegraphics[width=1\textwidth]{rasterexamples} \includegraphics[width=1\textwidth]{rasterexamples}
\titlecaption{\label{rasterexamplesfig}Raster-Plot.}{Raster-Plot von \titlecaption{\label{rasterexamplesfig}Raster-plot.}{Raster-plot of
jeweils 10 Realisierungen eines station\"arenen Punktprozesses ten realizations of a stationary point process (homogeneous point
(homogener Poisson Prozess mit Rate $\lambda=20$\;Hz, links) und process with a rate $\lambda=20$\;Hz, left) and an inhomogeneous
eines nicht-station\"aren Punktprozesses (perfect point process (perfect integrate-and-fire neuron dirven by
integrate-and-fire Neuron getrieben mit Ohrnstein-Uhlenbeck Ohrnstein-Uhlenbeck noise with a time-constant $\tau=100$\,ms,
Rauschen mit Zeitkonstante $\tau=100$\,ms, rechts). Jeder right). Each vertical dash illustrates the time at which the
vertikale Strich markiert den Zeitpunkt eines Ereignisses. action potential was observed. Each line represents the event of
Jede Zeile zeigt die Ereignisse eines trials.} each trial.}
\end{figure} \end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Punktprozesse} \section{Point processes}
Ein zeitlicher Punktprozess (\enterm{point process}) ist ein A temporal \enterm{point process} is a stochastic process that
stochastischer Prozess, der eine Abfolge von Ereignissen zu den Zeiten generates a sequence of events at times $\{t_i\}$, $t_i \in
$\{t_i\}$, $t_i \in \reZ$, generiert. \reZ$.
\begin{ibox}{Beispiele von Punktprozessen} \begin{ibox}{Examples of point processes}
Jeder Punktprozess wird durch einen sich in der Zeit kontinuierlich Every point process is generated by a temporally continuously
entwickelnden Prozess generiert. Wann immer dieser Prozess eine developing process. An event is generated whenever this process
Schwelle \"uberschreitet wird ein Ereigniss des Punktprozesses reaches a certain threshold. For example:
erzeugt. Zum Beispiel:
\begin{itemize} \begin{itemize}
\item Aktionspotentiale/Herzschlag: wird durch die Dynamik des \item Action potentials/heart beat: created by the dynamics of the
Membranpotentials eines Neurons/Herzzelle erzeugt. neuron/sinoatrial node
\item Erdbeben: wird durch die Dynamik des Druckes zwischen \item Earthquake: defined by the dynamics of the pressure between
tektonischen Platten auf beiden Seiten einer geologischen Verwerfung tectonical plates.
erzeugt. \item Evoked communication calls in crickets/frogs/birds: shaped by
\item Zeitpunkt eines Grillen/Frosch/Vogelgesangs: wird durch die the dynamics of nervous system and the muscle appartus.
Dynamik des Nervensystems und des Muskelapparates erzeugt.
\end{itemize} \end{itemize}
\end{ibox} \end{ibox}
\begin{figure}[t] \begin{figure}[t]
\texpicture{pointprocessscetch} \texpicture{pointprocessscetch}
\titlecaption{\label{pointprocessscetchfig} Statistik von \titlecaption{\label{pointprocessscetchfig} Statistics of point
Punktprozessen.}{Ein Punktprozess ist eine Abfolge von processes.}{A point process is a sequence of instances in time
Zeitpunkten $t_i$ die auch durch die Intervalle $T_i=t_{i+1}-t_i$ $t_i$ that can be characterized through the inter-event-intervals
oder die Anzahl der Ereignisse $n_i$ beschrieben werden kann. } $T_i=t_{i+1}-t_i$ and the number of events $n_i$. }
\end{figure} \end{figure}
F\"ur die Neurowissenschaften ist die Statistik der Punktprozesse In the neurosciences, the statistics of point processes is of
besonders wichtig, da die Zeitpunkte der Aktionspotentiale als importance since the timing of the neuronal events (the action
zeitlicher Punktprozess betrachtet werden k\"onnen und entscheidend potentials) is crucial for information transmission and can be treated
f\"ur die Informations\"ubertragung sind. as such a process.
Bei Punktprozessen k\"onnen wir die Zeitpunkte $t_i$ ihres Auftretens,
die Intervalle zwischen diesen Zeitpunkten $T_i=t_{i+1}-t_i$, sowie
die Anzahl der Ereignisse $n_i$ bis zu einer bestimmten Zeit betrachten
(\figref{pointprocessscetchfig}).
Zwei Punktprozesse mit verschiedenen Eigenschaften sind in Point processes can be described using the intervals between
\figref{rasterexamplesfig} als Rasterplot dargestellt, bei dem die successive events $T_i=t_{i+1}-t_i$ and the number of observed events
Zeitpunkte der Ereignisse durch senkrechte Striche markiert werden. within a certain time window $n_i$ (\figref{pointprocessscetchfig}).
The events originating from a point process can be illustrated in form
of a scatter- or raster plot in which each vertical line indicates the
time of an event. The event from two different point processes are
shown in \figref{rasterexamplesfig}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Intervallstatistik} \section{Intervalstatistics}
Die Intervalle $T_i=t_{i+1}-t_i$ zwischen aufeinanderfolgenden The intervals $T_i=t_{i+1}-t_i$ between successive events are real
Ereignissen sind reelle, positive Zahlen. Bei Aktionspotentialen positive numbers. In the context of action potentials they are
heisen die Intervalle auch \determ{Interspikeintervalle} referred to as \enterm{interspike intervals}. The statistics of these
(\enterm{interspike intervals}). Deren Statistik kann mit den are described using the common measures.
\"ublichen Gr\"o{\ss}en beschrieben werden.
\begin{figure}[t] \begin{figure}[t]
\includegraphics[width=0.96\textwidth]{isihexamples}\vspace{-2ex} \includegraphics[width=0.96\textwidth]{isihexamples}\vspace{-2ex}
\titlecaption{\label{isihexamplesfig}Interspikeintervall Histogramme}{der in \titlecaption{\label{isihexamplesfig}Interspike interval
\figref{rasterexamplesfig} gezeigten Spikes.} histogram}{of the spikes depicted in \figref{rasterexamplesfig}.}
\end{figure} \end{figure}
\begin{exercise}{isis.m}{} \begin{exercise}{isis.m}{}
Schreibe eine Funktion \code{isis()}, die aus mehreren trials von Spiketrains die Implement a function \code{isis()} that calculates the interspike
Interspikeintervalle bestimmt und diese in einem Vektor intervals from several spike trains. The function should return a
zur\"uckgibt. Jeder trial der Spiketrains ist ein Vektor mit den single vector of intervals. The action potentials recorded in the
Spikezeiten gegeben in Sekunden als Element in einem \codeterm{cell-array}. individual trials are stored as vectors of spike times within a
\codeterm{cell-array}. Spike times are given in seconds.
\end{exercise} \end{exercise}
\subsection{Intervallstatistik erster Ordnung} \subsection{First order interval statistics}
\begin{itemize} \begin{itemize}
\item Wahrscheinlichkeitsdichte $p(T)$ der Intervalle $T$ \item Probability density $p(T)$ of the intervals $T$
(\figref{isihexamplesfig}). Normiert auf $\int_0^{\infty} p(T) \; dT (\figref{isihexamplesfig}). Normalized to $\int_0^{\infty} p(T) \; dT
= 1$. = 1$.
\item Mittleres Intervall: $\mu_{ISI} = \langle T \rangle = \item Average interval: $\mu_{ISI} = \langle T \rangle =
\frac{1}{n}\sum\limits_{i=1}^n T_i$. \frac{1}{n}\sum\limits_{i=1}^n T_i$.
\item Standardabweichung der Intervalle: $\sigma_{ISI} = \sqrt{\langle (T - \langle T \item Standard deviation of the interspike intervals: $\sigma_{ISI} = \sqrt{\langle (T - \langle T
\rangle)^2 \rangle}$\vspace{1ex} \rangle)^2 \rangle}$\vspace{1ex}
\item \determ{Variationskoeffizient} (\enterm{coefficient of variation}): $CV_{ISI} = \item \enterm{Coefficient of variation}: $CV_{ISI} =
\frac{\sigma_{ISI}}{\mu_{ISI}}$. \frac{\sigma_{ISI}}{\mu_{ISI}}$.
\item \determ{Diffusionskoeffizient} (\enterm{diffusion coefficient}): $D_{ISI} = \item \enterm{Diffusion coefficient}): $D_{ISI} =
\frac{\sigma_{ISI}^2}{2\mu_{ISI}^3}$. \frac{\sigma_{ISI}^2}{2\mu_{ISI}^3}$.
\end{itemize} \end{itemize}
\begin{exercise}{isihist.m}{} \begin{exercise}{isihist.m}{}
Schreibe eine Funktion \code{isiHist()}, die einen Vektor mit Interspikeintervallen Implement a function \code{isiHist()} that calculates the normalized
entgegennimmt und daraus ein normiertes Histogramm der Interspikeintervalle interspike interval histogram. The function should take two input
berechnet. arguments; (i) a vector of interspike intervals and (ii) the width
of the bins used for the histogram. It further returns the
probability density as well as the centers of the bins.
\end{exercise} \end{exercise}
\begin{exercise}{plotisihist.m}{} \begin{exercise}{plotisihist.m}{}
Schreibe eine Funktion, die die Histogrammdaten der Funktion Implement a function that takes the return values of
\code{isiHist()} entgegennimmt, um das Histogramm zu plotten. Im \code{isiHist()} as input arguments and then plots the data. The
Plot sollen die Interspikeintervalle in Millisekunden aufgetragen plot should show the histogram with the x-axis scaled to
werden. Das Histogramm soll zus\"atzlich mit Mittelwert, milliseconds and should be annotated with the average ISI, the
Standardabweichung und Variationskoeffizient der standard deviation and the coefficient of variation.
Interspikeintervalle annotiert werden.
\end{exercise} \end{exercise}
\subsection{Korrelationen der Intervalle} \subsection{Interval correlations}
In \enterm{return maps} werden die um das \enterm{lag} $k$ verz\"ogerten So called \enterm{return maps} are used to illustrate
Intervalle $T_{i+k}$ gegen die Intervalle $T_i$ geplottet. Dies macht interdependencies between successive interspike intervals. The return
m\"ogliche Abh\"angigkeiten von aufeinanderfolgenden Intervallen map plots the delayed interval $T_{i+k}$ against the interval
sichtbar. $T_i$. The parameter $k$ is called the \enterm{lag} $k$. Stationary
and non-stationary return maps are distinctly different
\figref{returnmapfig}.
\begin{figure}[t] \begin{figure}[t]
\includegraphics[width=1\textwidth]{returnmapexamples} \includegraphics[width=1\textwidth]{returnmapexamples}
\includegraphics[width=1\textwidth]{serialcorrexamples} \includegraphics[width=1\textwidth]{serialcorrexamples}
\titlecaption{\label{returnmapfig}Interspikeintervall return maps und \titlecaption{\label{returnmapfig}Interspike interval analyses of a
serielle Korrelationen}{zwischen aufeinander folgenden Intervallen stationary and a non-stationary pointprocess.}{Upper plots show the
im Abstand des Lags $k$.} return maps and the lower panels depict the serial correlation of
successive intervals separated by the lag $k$.}
\end{figure} \end{figure}
Solche Ab\"angigkeiten werden durch die \determ{serielle Such dependencies can be further quantified using the \enterm{serial
Korrelationen} (\enterm{serial correlations}) der Intervalle correlations} \figref{returnmapfig}. The serial correlation is the
quantifiziert. Das ist der \determ{Korrelationskoeffizient} zwischen correlation coefficient of the intervals $T_i$ and the intervals
aufeinander folgenden Intervallen getrennt durch lag $k$: delayed by the lag $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)} \[ \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) \] = {\rm corr}(T_{i+k}, T_i) \] The resulting correlation coefficient
\"Ublicherweise wird die Korrelation $\rho_k$ gegen den Lag $k$ $\rho_k$ is usually plotted against the lag $k$
aufgetragen (\figref{returnmapfig}). $\rho_0=1$ (Korrelation jedes \figref{returnmapfig}. $\rho_0=1$ is the correlation of each interval
Intervalls mit sich selber). with itself and is always 1.
\begin{exercise}{isiserialcorr.m}{} \begin{exercise}{isiserialcorr.m}{}
Schreibe eine Funktion \code{isiserialcorr()}, die einen Vektor mit Interspikeintervallen Implement a function \code{isiserialcorr()} that takes a vector of
entgegennimmt und daraus die seriellen Korrelationen berechnet und plottet. interspike intervals as input argument and calculates the serial
\pagebreak[4] correlation. The function should further plot the serial
correlation. \pagebreak[4]
\end{exercise} \end{exercise}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Z\"ahlstatistik} \section{Count statistics}
% \begin{figure}[t] % \begin{figure}[t]
% \includegraphics[width=0.48\textwidth]{poissoncounthist100hz10ms}\hfill % \includegraphics[width=0.48\textwidth]{poissoncounthist100hz10ms}\hfill
% \includegraphics[width=0.48\textwidth]{poissoncounthist100hz100ms} % \includegraphics[width=0.48\textwidth]{poissoncounthist100hz100ms}
% \titlecaption{\label{countstatsfig}Count Statistik.}{} % \titlecaption{\label{countstatsfig}Count Statistik.}{}
% \end{figure} % \end{figure}
The number of events $n_i$ (counts) in a time window $i$ of the duration $W$
Die Anzahl der Ereignisse $n_i$ in Zeifenstern $i$ der yields positive integer random numbers that are commonly quantified
L\"ange $W$ ergeben ganzzahlige, positive Zufallsvariablen, die meist using the following measures:
durch folgende Sch\"atzer charakterisiert werden:
\begin{itemize} \begin{itemize}
\item Histogramm der counts $n_i$. \item Histogram of the counts $n_i$.
\item Mittlere Anzahl von Ereignissen: $\mu_N = \langle n \rangle$. \item Average number of events: $\mu_N = \langle n \rangle$.
\item Varianz der Anzahl: $\sigma_n^2 = \langle (n - \langle n \rangle)^2 \rangle$. \item Variance of the counts: $\sigma_n^2 = \langle (n - \langle n \rangle)^2 \rangle$.
\item \determ{Fano Faktor} (Varianz geteilt durch Mittelwert): $F = \frac{\sigma_n^2}{\mu_n}$. \item \determ{Fano Faktor} (The variance divided by the average): $F = \frac{\sigma_n^2}{\mu_n}$.
\end{itemize} \end{itemize}
Insbesondere ist die mittlere Rate der Ereignisse $r$ (Spikes pro And in particular the average firing rate $r$ (spike count per time interval
Zeit, \determ{Feuerrate}) gemessen in Hertz \sindex[term]{Feuerrate!mittlere Rate} , \determ{Feuerrate}) that is given in Hertz \sindex[term]{Feuerrate!mittlere Rate}
\begin{equation} \begin{equation}
\label{firingrate} \label{firingrate}
r = \frac{\langle n \rangle}{W} \; . r = \frac{\langle n \rangle}{W} \; .
@ -200,110 +200,114 @@ Zeit, \determ{Feuerrate}) gemessen in Hertz \sindex[term]{Feuerrate!mittlere Rat
% \end{figure} % \end{figure}
\begin{exercise}{counthist.m}{} \begin{exercise}{counthist.m}{}
Schreibe eine Funktion \code{counthist()}, die aus mehreren trials Implement a function \code{counthist()} that calculates and plots
von Spiketrains die Verteilung der Anzahl der Spikes in Fenstern the distribution of spike counts observed in a certain time
einer der Funktion \"ubergegebenen Breite bestimmt, das Histogramm window. The function should take two input arguments: (i) a
plottet und zur\"uckgibt. Jeder trial der Spiketrains ist ein Vektor \codeterm{cell-array} of vectors containing the spike times in
mit den Spikezeiten gegeben in Sekunden als Element in einem seconds observed in a number of trials and (ii) the duration of the
\codeterm{cell-array}. time window that is used to evaluate the counts.
\end{exercise} \end{exercise}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Homogener Poisson Prozess} \section{Homogeneous Poisson process}
F\"ur kontinuierliche Me{\ss}gr\"o{\ss}en ist die Normalverteilung
u.a. wegen dem Zentralen Grenzwertsatz die Standardverteilung. Eine The Gaussian distribution is, due to the central limit theorem, the
\"ahnliche Rolle spielt bei Punktprozessen der \determ{Poisson standard for continuous measures. The equivalent in the realm of point
Prozess}. processes is the \enterm{Poisson distribution}.
Beim \determ[Poisson Prozess!homogener]{homogenen Poisson Prozess} In a \enterm[Poisson process!homogeneous]{homogeneous Poisson process}
treten Ereignisse mit einer festen Rate $\lambda=\text{const.}$ auf the events occur at a fixed rate $\lambda=\text{const.}$ and are
und sind unabh\"angig von der Zeit $t$ und unabh\"angig von den independent of both the time $t$ and occurrence of previous events
Zeitpunkten fr\"uherer Ereignisse (\figref{hompoissonfig}). Die (\figref{hompoissonfig}). The probability of observing an even within a
Wahrscheinlichkeit zu irgendeiner Zeit ein Ereigniss in einem kleinen small time window of width $\Delta t$ is given by
Zeitfenster der Breite $\Delta t$ zu bekommen ist
\begin{equation} \begin{equation}
\label{hompoissonprob} \label{hompoissonprob}
P = \lambda \cdot \Delta t \; . P = \lambda \cdot \Delta t \; .
\end{equation} \end{equation}
Beim \determ[Poisson Prozess!inhomogener]{inhomogenen Poisson Prozess}
h\"angt die Rate $\lambda$ von der Zeit ab: $\lambda = \lambda(t)$. In an \enterm[Poisson process!inhomogeneous]{inhomogeneous Poisson
process}, however, the rate $\lambda$ depends on the time: $\lambda =
\lambda(t)$.
\begin{exercise}{poissonspikes.m}{} \begin{exercise}{poissonspikes.m}{}
Schreibe eine Funktion \code{poissonspikes()}, die die Spikezeiten Implement a function \code{poissonspikes()} that uses a homogeneous
eines homogenen Poisson-Prozesses mit gegebener Rate in Hertz f\"ur Poisson process to generate events at a given rate for a certain
eine Anzahl von trials gegebener maximaler L\"ange in Sekunden in duration and a number of trials. The rate should be given in Hertz
einem \codeterm{cell-array} zur\"uckgibt. Benutze \eqnref{hompoissonprob} and the duration of the trials is given in seconds. The function
um die Spikezeiten zu bestimmen. should return the event times in a cell-array. Each entry in this
array represents the events observed in one trial. Apply
\eqnref{hompoissonprob} to generate the event times.
\end{exercise} \end{exercise}
\begin{figure}[t] \begin{figure}[t]
\includegraphics[width=1\textwidth]{poissonraster100hz} \includegraphics[width=1\textwidth]{poissonraster100hz}
\titlecaption{\label{hompoissonfig}Rasterplot von Spikes eines homogenen \titlecaption{\label{hompoissonfig}Rasterplot of spikes of a
Poisson Prozesses mit $\lambda=100$\,Hz.}{} homogeneous Poisson process with a rate $\lambda=100$\,Hz.}{}
\end{figure} \end{figure}
\begin{figure}[t] \begin{figure}[t]
\includegraphics[width=0.45\textwidth]{poissonisihexp20hz}\hfill \includegraphics[width=0.45\textwidth]{poissonisihexp20hz}\hfill
\includegraphics[width=0.45\textwidth]{poissonisihexp100hz} \includegraphics[width=0.45\textwidth]{poissonisihexp100hz}
\titlecaption{\label{hompoissonisihfig}Interspikeintervallverteilungen \titlecaption{\label{hompoissonisihfig}Distribution of interspike intervals of two Poisson processes.}{}
zweier Poissonprozesse.}{}
\end{figure} \end{figure}
Der homogene Poissonprozess hat folgende Eigenschaften: The homogeneous Poisson process has the following properties:
\begin{itemize} \begin{itemize}
\item Die Intervalle $T$ sind exponentiell verteilt (\figref{hompoissonisihfig}): \item Intervals $T$ are exponentially distributed (\figref{hompoissonisihfig}):
\begin{equation} \begin{equation}
\label{poissonintervals} \label{poissonintervals}
p(T) = \lambda e^{-\lambda T} \; . p(T) = \lambda e^{-\lambda T} \; .
\end{equation} \end{equation}
\item Das mittlere Intervall ist $\mu_{ISI} = \frac{1}{\lambda}$ . \item The average interval is $\mu_{ISI} = \frac{1}{\lambda}$ .
\item Die Varianz der Intervalle ist $\sigma_{ISI}^2 = \frac{1}{\lambda^2}$ . \item The variance of the intervals is $\sigma_{ISI}^2 = \frac{1}{\lambda^2}$ .
\item Der Variationskoeffizient ist also immer $CV_{ISI} = 1$ . \item Thus, the coefficient of variation is always $CV_{ISI} = 1$ .
\item Die \determ[serielle Korrelationen]{seriellen Korrelationen} \item The serial correlation is $\rho_k =0$ for $k>0$, since the
$\rho_k =0$ f\"ur $k>0$, da das Auftreten der Ereignisse occurrence of an event is independent of all previous events. Such a
unabh\"angig von der Vorgeschichte ist. Ein solcher Prozess wird process is also called a \enterm{renewal process}.
auch \determ{Erneuerungsprozess} genannt (\enterm{renewal process}). \item The number of events $k$ within a temporal window of duration
\item Die Anzahl der Ereignisse $k$ innerhalb eines Fensters der $W$ is Poisson distributed:
L\"ange W ist \determ[Poisson-Verteilung]{Poissonverteilt}:
\[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \] \[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \]
(\figref{hompoissoncountfig}) (\figref{hompoissoncountfig})
\item Der \determ{Fano Faktor} ist immer $F=1$ . \item The Fano Faktor is always $F=1$ .
\end{itemize} \end{itemize}
\begin{exercise}{hompoissonspikes.m}{} \begin{exercise}{hompoissonspikes.m}{}
Schreibe eine Funktion \code{hompoissonspikes()}, die die Spikezeiten Implement a function \code{hompoissonspikes()} that uses a
eines homogenen Poisson-Prozesses mit gegebener Rate in Hertz f\"ur homogeneous Poisson process to generate spike events at a given rate
eine Anzahl von trials gegebener maximaler L\"ange in Sekunden in for a certain duration and a number of trials. The rate should be
einem \codeterm{cell-array} zur\"uckgibt. Benutze die exponentiell-verteilten given in Hertz and the duration of the trials is given in
Interspikeintervalle \eqnref{poissonintervals}, um die Spikezeiten zu erzeugen. seconds. The function should return the event times in a
cell-array. Each entry in this array represents the events observed
in one trial. Apply \eqnref{poissonintervals} to generate the event
times.
\end{exercise} \end{exercise}
\begin{figure}[t] \begin{figure}[t]
\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz10ms}\hfill \includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz10ms}\hfill
\includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz100ms} \includegraphics[width=0.48\textwidth]{poissoncounthistdist100hz100ms}
\titlecaption{\label{hompoissoncountfig}Z\"ahlstatistik von Poisson Spikes.}{} \titlecaption{\label{hompoissoncountfig}Count statistics of Poisson
spiketrains.}{}
\end{figure} \end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Zeitabh\"angige Feuerraten} \section{Time-dependent firing rate}
Bisher haben wir station\"are Spiketrains betrachtet, deren Statistik So far we discussed stationary spiketrains. The statistical properties
sich innerhalb der Analysezeit nicht ver\"andert (station\"are of these did not change within the observation time (stationary point
Punktprozesse). Meistens jedoch \"andert sich die Statistik der processes. Most commonly, however, this is not the case. A sensory
Spiketrains eines Neurons mit der Zeit. Z.B. kann ein sensorisches neuron, for example, might respond to a stimulus by modulating its
Neuron auf einen Reiz hin mit einer erh\"ohten Feuerrate antworten firing rate (non-stationary point process).
(nichtstation\"arer Punktprozess).
How the firing rate $r(t)$ changes over time is the most important
Wie die mittlere Anzahl der Spikes sich mit der Zeit ver\"andert, die measure, when analyzing non-stationary spike trains. The unit of the
\determ{Feuerrate} $r(t)$, ist die wichtigste Gr\"o{\ss}e bei firing rate is Hertz, i.e. the number of action potentials per
nicht-station\"aren Spiketrains. Die Einheit der Feuerrate ist Hertz, second. There are different ways to estimate the firing rate and three
also Anzahl Aktionspotentiale pro Sekunde. Es gibt verschiedene of these methods will are illustrated in \figref{psthfig}. All of
Methoden diese zu bestimmen. Drei solcher Methoden sind in Abbildung these have their own justifications and pros- and cons. In the
\ref{psthfig} dargestellt. Alle Methoden haben ihre Berechtigung und following we will discuss the methods shown in \figref{psthfig} more
ihre Vor- und Nachteile. Im folgenden werden die drei Methoden aus closely.
Abbildung \ref{psthfig} n\"aher erl\"autert.
\begin{figure}[tp] \begin{figure}[tp]
\includegraphics[width=\columnwidth]{firingrates} \includegraphics[width=\columnwidth]{firingrates}

View File

@ -31,7 +31,7 @@ def pifspikes(input, trials, dt, D=0.1) :
times = [] times = []
v = vreset v = vreset
noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt) noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt)
for k in xrange(len(noise)) : for k in range(len(noise)) :
v += (input[k]+noise[k])*dt/tau v += (input[k]+noise[k])*dt/tau
if v >= vthresh : if v >= vthresh :
v = vreset v = vreset
@ -55,7 +55,7 @@ rng = np.random.RandomState(54637281)
time = np.arange(0.0, duration, dt) time = np.arange(0.0, duration, dt)
x = np.zeros(time.shape)+rate x = np.zeros(time.shape)+rate
n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate
for k in xrange(1,len(x)) : for k in range(1,len(x)) :
x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau
x[x<0.0] = 0.0 x[x<0.0] = 0.0

View File

@ -31,7 +31,7 @@ def pifspikes(input, trials, dt, D=0.1) :
times = [] times = []
v = vreset v = vreset
noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt) noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt)
for k in xrange(len(noise)) : for k in range(len(noise)) :
v += (input[k]+noise[k])*dt/tau v += (input[k]+noise[k])*dt/tau
if v >= vthresh : if v >= vthresh :
v = vreset v = vreset
@ -41,7 +41,7 @@ def pifspikes(input, trials, dt, D=0.1) :
def isis( spikes ) : def isis( spikes ) :
isi = [] isi = []
for k in xrange(len(spikes)) : for k in range(len(spikes)) :
isi.extend(np.diff(spikes[k])) isi.extend(np.diff(spikes[k]))
return np.array( isi ) return np.array( isi )
@ -84,7 +84,7 @@ rng = np.random.RandomState(54637281)
time = np.arange(0.0, duration, dt) time = np.arange(0.0, duration, dt)
x = np.zeros(time.shape)+rate x = np.zeros(time.shape)+rate
n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate
for k in xrange(1,len(x)) : for k in range(1,len(x)) :
x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau
x[x<0.0] = 0.0 x[x<0.0] = 0.0

View File

@ -31,7 +31,7 @@ def pifspikes(input, trials, dt, D=0.1) :
times = [] times = []
v = vreset v = vreset
noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt) noise = np.sqrt(2.0*D)*np.random.randn(len(input))/np.sqrt(dt)
for k in xrange(len(noise)) : for k in range(len(noise)) :
v += (input[k]+noise[k])*dt/tau v += (input[k]+noise[k])*dt/tau
if v >= vthresh : if v >= vthresh :
v = vreset v = vreset
@ -41,7 +41,7 @@ def pifspikes(input, trials, dt, D=0.1) :
def isis( spikes ) : def isis( spikes ) :
isi = [] isi = []
for k in xrange(len(spikes)) : for k in range(len(spikes)) :
isi.extend(np.diff(spikes[k])) isi.extend(np.diff(spikes[k]))
return np.array( isi ) return np.array( isi )
@ -95,7 +95,7 @@ rng = np.random.RandomState(54637281)
time = np.arange(0.0, duration, dt) time = np.arange(0.0, duration, dt)
x = np.zeros(time.shape)+rate x = np.zeros(time.shape)+rate
n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate n = rng.randn(len(time))*drate*tau/np.sqrt(dt)+rate
for k in xrange(1,len(x)) : for k in range(1,len(x)) :
x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau x[k] = x[k-1] + (n[k]-x[k-1])*dt/tau
x[x<0.0] = 0.0 x[x<0.0] = 0.0

View File

@ -6,7 +6,7 @@ from IPython import embed
def plot_sta(times, stim, dt, t_min=-0.1, t_max=.1): def plot_sta(times, stim, dt, t_min=-0.1, t_max=.1):
count = 0 count = 0
sta = np.zeros((abs(t_min) + abs(t_max))/dt) sta = np.zeros(int((abs(t_min) + abs(t_max))/dt))
time = np.arange(t_min, t_max, dt) time = np.arange(t_min, t_max, dt)
if len(stim.shape) > 1 and stim.shape[1] > 1: if len(stim.shape) > 1 and stim.shape[1] > 1:
stim = stim[:,1] stim = stim[:,1]

View File

@ -40,14 +40,12 @@ variable.
\begin{figure} \begin{figure}
\centering \centering
\begin{subfigure}{.5\textwidth} \begin{subfigure}{.5\textwidth}
\includegraphics[width=0.8\textwidth]{variable} \includegraphics[width=0.8\textwidth]{variable}\label{variable:a}
\label{variable:a}
\end{subfigure}% \end{subfigure}%
\begin{subfigure}{.5\textwidth} \begin{subfigure}{.5\textwidth}
\includegraphics[width=.8\textwidth]{variableB} \includegraphics[width=.8\textwidth]{variableB}\label{variable:b}
\label{variable:b}
\end{subfigure} \end{subfigure}
\titlecaption{Variables} point to a memory \titlecaption{Variables}{ point to a memory
address. They further are described by their name and address. They further are described by their name and
data type. The variable's value is stored as a pattern of binary data type. The variable's value is stored as a pattern of binary
values (0 or 1). When reading the variable this pattern is values (0 or 1). When reading the variable this pattern is
@ -630,7 +628,7 @@ matrix). The function \code{cat()} allows to concatenate n-dimensional
matrices. matrices.
To request the length of a vector we used the function To request the length of a vector we used the function
\code{length()}. This function is \tetbf{not} suited to request \code{length()}. This function is \textbf{not} suited to request
information about the size of a matrix. As mentioned above, information about the size of a matrix. As mentioned above,
\code{length()} would return the length of the largest dimension. The \code{length()} would return the length of the largest dimension. The
function \code{size()} however, returns the length in each dimension function \code{size()} however, returns the length in each dimension

View File

@ -345,7 +345,7 @@ access (read or write) variables of the calling function. Interaction
with the local function requires to pass all required arguments and to with the local function requires to pass all required arguments and to
take care of the return values of the function. take care of the return values of the function.
\emp{Nested functions} are different in this respect. They are \emph{Nested functions} are different in this respect. They are
defined within the body of the parent function (between the keywords defined within the body of the parent function (between the keywords
\code{function} and \code{end}) and have full access to all variables \code{function} and \code{end}) and have full access to all variables
defined in the parent function. Working (in particular changing) the defined in the parent function. Working (in particular changing) the

View File

@ -86,7 +86,7 @@ large deviations.
$f_{cost}(\{(x_i, y_i)\}|\{y^{est}_i\})$ is a so called $f_{cost}(\{(x_i, y_i)\}|\{y^{est}_i\})$ is a so called
\enterm{objective function} or \enterm{cost function}. We aim to adapt \enterm{objective function} or \enterm{cost function}. We aim to adapt
the model parameters to minimize the error (mean square error) and the model parameters to minimize the error (mean square error) and
thus the \emph{objective function}. In Chapter~\ref{maximumlikelihood} thus the \emph{objective function}. In Chapter~\ref{maximumlikelihoodchapter}
we will show that the minimization of the mean square error is we will show that the minimization of the mean square error is
equivalent to maximizing the likelihood that the observations equivalent to maximizing the likelihood that the observations
originate from the model (assuming a normal distribution of the data originate from the model (assuming a normal distribution of the data
@ -270,7 +270,7 @@ The gradient is given by partial derivatives
(Box~\ref{partialderivativebox}) with respect to the parameters $m$ (Box~\ref{partialderivativebox}) with respect to the parameters $m$
and $b$ of the linear equation. There is no need to calculate it and $b$ of the linear equation. There is no need to calculate it
analytically but it can be estimated from the partial derivatives analytically but it can be estimated from the partial derivatives
using the difference quotient (Box~\ref{differentialquotient}) for using the difference quotient (Box~\ref{differentialquotientbox}) for
small steps $\Delta m$ und $\Delta b$. For example the partial small steps $\Delta m$ und $\Delta b$. For example the partial
derivative with respect to $m$: derivative with respect to $m$:

View File

@ -67,7 +67,7 @@
\lstset{inputpath=regression/code} \lstset{inputpath=regression/code}
\include{regression/lecture/regression} \include{regression/lecture/regression}
\setboolean{showexercisesolutions}{true} \setboolean{showexercisesolutions}{false}
\graphicspath{{likelihood/lecture/}{likelihood/lecture/figures/}} \graphicspath{{likelihood/lecture/}{likelihood/lecture/figures/}}
\lstset{inputpath=likelihood/code} \lstset{inputpath=likelihood/code}
\include{likelihood/lecture/likelihood} \include{likelihood/lecture/likelihood}

View File

@ -53,7 +53,7 @@ ax.annotate('mean plus\nstd. dev.',
arrowprops=dict(arrowstyle="->", relpos=(0.5,0.0), arrowprops=dict(arrowstyle="->", relpos=(0.5,0.0),
connectionstyle="angle3,angleA=-60,angleB=80") ) connectionstyle="angle3,angleA=-60,angleB=80") )
ax = fig.add_axes([xpos, ypos, width, height], axis_bgcolor='none') ax = fig.add_axes([xpos, ypos, width, height])
ax.spines['right'].set_visible(False) ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False) ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False) ax.spines['left'].set_visible(False)
@ -92,7 +92,7 @@ ax.annotate('median',
arrowprops=dict(arrowstyle="->", relpos=(0.8,0.0), arrowprops=dict(arrowstyle="->", relpos=(0.8,0.0),
connectionstyle="angle3,angleA=-60,angleB=20") ) connectionstyle="angle3,angleA=-60,angleB=20") )
ax = fig.add_axes([xpos+width+0.03, ypos, 0.98-(xpos+width+0.03), height], axis_bgcolor='none') ax = fig.add_axes([xpos+width+0.03, ypos, 0.98-(xpos+width+0.03), height])
ax.spines['right'].set_visible(False) ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False) ax.spines['top'].set_visible(False)
ax.xaxis.set_ticks_position('bottom') ax.xaxis.set_ticks_position('bottom')