improved indices

This commit is contained in:
Jan Benda 2019-12-10 00:09:48 +01:00
parent bf52536b7b
commit c063cc9f0e
6 changed files with 175 additions and 164 deletions

View File

@ -171,7 +171,7 @@ A good example for the application of a
assessment of \entermde[correlation]{Korrelation}{correlations}. Given assessment of \entermde[correlation]{Korrelation}{correlations}. Given
are measured pairs of data points $(x_i, y_i)$. By calculating the are measured pairs of data points $(x_i, y_i)$. By calculating the
\entermde[correlation!correlation \entermde[correlation!correlation
coefficient]{Korrelation!-skoeffizient}{correlation coefficient]{Korrelationskoeffizient}{correlation
coefficient} we can quantify how strongly $y$ depends on $x$. The coefficient} we can quantify how strongly $y$ depends on $x$. The
correlation coefficient alone, however, does not tell whether the correlation coefficient alone, however, does not tell whether the
correlation is significantly different from a random correlation. The correlation is significantly different from a random correlation. The

View File

@ -6,10 +6,10 @@
When writing a program from scratch we almost always make When writing a program from scratch we almost always make
mistakes. Accordingly, a quite substantial amount of time is invested mistakes. Accordingly, a quite substantial amount of time is invested
into finding and fixing errors. This process is called into finding and fixing errors. This process is called
\codeterm{debugging}. Don't be frustrated that a self-written program \entermde{Debugging}{debugging}. Don't be frustrated that a
does not work as intended and produces errors. It is quite exceptional self-written program does not work as intended and produces errors. It
if a program appears to be working on the first try and, in fact, is quite exceptional if a program appears to be working on the first
should leave you suspicious. try and, in fact, should leave you suspicious.
In this chapter we will talk about typical mistakes, how to read and In this chapter we will talk about typical mistakes, how to read and
understand error messages, how to actually debug your program code and understand error messages, how to actually debug your program code and
@ -20,7 +20,7 @@ some hints that help to minimize errors.
There are a number of different classes of programming errors and it There are a number of different classes of programming errors and it
is good to know the common ones. Some of your programming errors will is good to know the common ones. Some of your programming errors will
will lead to violations of the syntax or to invalid operations that will lead to violations of the syntax or to invalid operations that
will cause \matlab{} to \codeterm{throw} an error. Throwing an error will cause \matlab{} to \code{throw} an error. Throwing an error
ends the execution of a program and there will be an error messages ends the execution of a program and there will be an error messages
shown in the command window. With such messages \matlab{} tries to shown in the command window. With such messages \matlab{} tries to
explain what went wrong and to provide a hint on the possible cause. explain what went wrong and to provide a hint on the possible cause.
@ -30,8 +30,9 @@ are generally easier to find and to fix than logical errors that stay
hidden and the results of, e.g. an analysis, are seemingly correct. hidden and the results of, e.g. an analysis, are seemingly correct.
\begin{important}[Try --- catch] \begin{important}[Try --- catch]
There are ways to \codeterm{catch} errors during \codeterm{runtime} There are ways to \code{catch} errors during \enterm{runtime}
(i.e. when the program is executed) and handle them in the program. (\determ{Laufzeit}, i.e. when the program is executed) and handle
them in the program.
\begin{lstlisting}[label=trycatch, caption={Try catch clause}] \begin{lstlisting}[label=trycatch, caption={Try catch clause}]
try try
@ -43,15 +44,15 @@ hidden and the results of, e.g. an analysis, are seemingly correct.
This way of solving errors may seem rather convenient but is This way of solving errors may seem rather convenient but is
risky. Having a function throwing an error and catching it in the risky. Having a function throwing an error and catching it in the
\codeterm{catch} clause will keep your command line clean but may \code{catch} clause will keep your command line clean but may obscure
obscure logical errors! Take care when using the \codeterm{try-catch logical errors! Take care when using the \code{try}-\code{catch}
clause}. clause.
\end{important} \end{important}
\subsection{Syntax errors}\label{syntax_error} \subsection{Syntax errors}\label{syntax_error}
The most common and easiest to fix type of error. A The most common and easiest to fix type of error. A
\entermde[error!syntax]{Fehler!Syntax\~}{syntax error} violates the \entermde[error!syntax]{Fehler!Syntax@Syntax\texttildelow}{syntax error} violates the
rules (spelling and grammar) of the programming language. For example rules (spelling and grammar) of the programming language. For example
every opening parenthesis must be matched by a closing one or every every opening parenthesis must be matched by a closing one or every
\code{for} loop has to be closed by an \code{end}. Usually, the \code{for} loop has to be closed by an \code{end}. Usually, the
@ -69,7 +70,7 @@ Did you mean:
\subsection{Indexing error}\label{index_error} \subsection{Indexing error}\label{index_error}
Second on the list of common errors are the Second on the list of common errors are the
\entermde[error!indexing]{Fehler!Index\~}{indexing errors}. Usually \entermde[error!indexing]{Fehler!Index@Index\texttildelow}{indexing errors}. Usually
\matlab{} gives rather precise infromation about the cause, once you \matlab{} gives rather precise infromation about the cause, once you
know what they mean. Consider the following code. know what they mean. Consider the following code.
@ -108,21 +109,21 @@ dimensions. This indicates that we are trying to read data behind the
length of our variable \varcode{my\_array} which has 100 elements. length of our variable \varcode{my\_array} which has 100 elements.
One could have expected that the character is an invalid index, but One could have expected that the character is an invalid index, but
apparently it is valid but simply too large. The fith attempt finally apparently it is valid but simply too large. The fith attempt finally
succeeds. But why? \matlab{} implicitely converts the \codeterm{char} succeeds. But why? \matlab{} implicitely converts the character to a
to a number and uses this number to address the element in number and uses this number to address the element in
\varcode{my\_array}. The \codeterm{char} has the ASCII code 65 and \varcode{my\_array}. The character \varcode{'A'} has the ASCII code 65
thus the 65th element of \varcode{my\_array} is returned. and thus the 65th element of \varcode{my\_array} is returned.
\subsection{Assignment error} \subsection{Assignment error}
Related to the indexing error, an Related to the indexing error, an
\entermde[error!assignment]{Fehler!Zuweisungs\~}{assignment error} \entermde[error!assignment]{Fehler!Zuweisungs@Zuweisungs\texttildelow}{assignment
occurs when we want to write data into a variable, that does not fit error} occurs when we want to write data into a variable, that does
into it. Listing \ref{assignmenterror} shows the simple case for 1-d not fit into it. Listing \ref{assignmenterror} shows the simple case
data but, of course, it extents to n-dimensional data. The data that for 1-d data but, of course, it extents to n-dimensional data. The
is to be filled into a matrix hat to fit in all dimensions. The data that is to be filled into a matrix hat to fit in all
command in line 7 works due to the fact, that matlab automatically dimensions. The command in line 7 works due to the fact, that matlab
extends the matrix, if you assign values to a range outside its automatically extends the matrix, if you assign values to a range
bounds. outside its bounds.
\begin{lstlisting}[label=assignmenterror, caption={Assignment errors.}] \begin{lstlisting}[label=assignmenterror, caption={Assignment errors.}]
>> a = zeros(1, 100); >> a = zeros(1, 100);
@ -191,7 +192,7 @@ few strategies that should we can employ to solve the task.
it. Comment, but only where necessary. Correctly indent your it. Comment, but only where necessary. Correctly indent your
code. Use descriptive variable and function names. code. Use descriptive variable and function names.
\item Keep it simple. \item Keep it simple.
\item Test your code by writing \codeterm{unit tests} that test every \item Test your code by writing \entermde[unit test]{Modultest}{unit tests} that test every
aspect of your program (\ref{unittests}). aspect of your program (\ref{unittests}).
\item Use scripts and functions and call them from the command \item Use scripts and functions and call them from the command
line. \matlab{} can then provide you with more information. It will line. \matlab{} can then provide you with more information. It will
@ -264,13 +265,13 @@ The idea of unit tests to write small programs that test \emph{all}
functions of a program by testing the program's results against functions of a program by testing the program's results against
expectations. The pure lore of test-driven development requires that expectations. The pure lore of test-driven development requires that
the tests are written \textbf{before} the actual program is the tests are written \textbf{before} the actual program is
written. In parts the tests put the \codeterm{functional written. In parts the tests put the \enterm{functional
specification}, the agreement between customer and programmer, into specification}, the agreement between customer and programmer, into
code. This helps to guarantee that the delivered program works as code. This helps to guarantee that the delivered program works as
specified. In the scientific context, we tend to be a little bit more specified. In the scientific context, we tend to be a little bit more
relaxed and write unit tests, where we think them helpful and often relaxed and write unit tests, where we think them helpful and often
test only the obvious things. To write \emph{complete} test suits that test only the obvious things. To write \emph{complete} test suits that
lead to full \codeterm{test coverage} is a lot of work and is often lead to full \enterm{test coverage} is a lot of work and is often
considered a waste of time. The first claim is true, the second, considered a waste of time. The first claim is true, the second,
however, may be doubted. Consider that you change a tiny bit of a however, may be doubted. Consider that you change a tiny bit of a
standing program to adjust it to the current needs, how will you be standing program to adjust it to the current needs, how will you be
@ -446,8 +447,8 @@ that help to solve the problem.
line. Often, it is not necessary that the other person is a line. Often, it is not necessary that the other person is a
programmer or exactly understands what is going on. Rather, it is the programmer or exactly understands what is going on. Rather, it is the
own reflection on the problem and the chosen approach that helps own reflection on the problem and the chosen approach that helps
finding the bug (This strategy is also known as \codeterm{Rubber finding the bug (this strategy is also known as \enterm{Rubber
duck debugging}). ducking}).
\end{enumerate} \end{enumerate}
@ -457,11 +458,11 @@ The \matlab{} editor (figure\,\ref{editor_debugger}) supports
interactive debugging. Once you save an m-file in the editor and it interactive debugging. Once you save an m-file in the editor and it
passes the syntax check, i.e. the little box in the upper right corner passes the syntax check, i.e. the little box in the upper right corner
of the editor window is green or orange, you can set one or several of the editor window is green or orange, you can set one or several
\codeterm{break point}s. When the program is executed by calling it \entermde[break point]{Haltepunkt}{break points}. When the program is
from the command line it will be stopped at the line with the executed by calling it from the command line it will be stopped at the
breakpoint. In the editor this is indicated by a green arrow. The line with the breakpoint. In the editor this is indicated by a green
command line will change to indicate that we are now stopped in arrow. The command line will change to indicate that we are now
debug mode (listing\,\ref{debuggerlisting}). stopped in debug mode (listing\,\ref{debuggerlisting}).
\begin{figure} \begin{figure}
\centering \centering

View File

@ -280,8 +280,8 @@ the last one defines the output format (box\,\ref{graphicsformatbox}).
\begin{ibox}[t]{\label{graphicsformatbox}File formats for digital artwork.} \begin{ibox}[t]{\label{graphicsformatbox}File formats for digital artwork.}
There are two fundamentally different types of formats for digital artwork: There are two fundamentally different types of formats for digital artwork:
\begin{enumerate} \begin{enumerate}
\item \enterm{Bitmaps} \item \enterm[bitmap]{Bitmaps} (\determ{Rastergrafik})
\item \enterm{Vector graphics} \item \enterm[vector graphics]{Vector graphics} (\determ{Vektorgrafik})
\end{enumerate} \end{enumerate}
When using bitmaps a color value is given for each pixel of the When using bitmaps a color value is given for each pixel of the
stored figure. Bitmaps do have a fixed resolution (e.g.\,300\,dpi stored figure. Bitmaps do have a fixed resolution (e.g.\,300\,dpi

View File

@ -3,11 +3,12 @@
\chapter{Spiketrain analysis} \chapter{Spiketrain analysis}
\exercisechapter{Spiketrain analysis} \exercisechapter{Spiketrain analysis}
\enterm[action potential]{Action potentials} (\enterm{spikes}) are \entermde[action potential]{Aktionspotential}{Action potentials}
the carriers of information in the nervous system. Thereby it is the (\enterm[spike|seealso{action potential}]{spikes}) are the carriers of
time at which the spikes are generated that is of importance for information in the nervous system. Thereby it is the time at which the
information transmission. The waveform of the action potential is spikes are generated that is of importance for information
largely stereotyped and therefore does not carry information. transmission. The waveform of the action potential is largely
stereotyped and therefore does not carry information.
The result of the pre-processing of electrophysiological recordings are The result of the pre-processing of electrophysiological recordings are
series of spike times, which are termed \enterm{spiketrains}. If series of spike times, which are termed \enterm{spiketrains}. If
@ -15,8 +16,8 @@ measurements are repeated we get several \enterm{trials} of
spiketrains (\figref{rasterexamplesfig}). spiketrains (\figref{rasterexamplesfig}).
Spiketrains are times of events, the action potentials. The analysis Spiketrains are times of events, the action potentials. The analysis
of these leads into the realm of the so called \enterm[point of these leads into the realm of the so called \entermde[point
process]{point processes}. process]{Punktprozess}{point processes}.
\begin{figure}[ht] \begin{figure}[ht]
\includegraphics[width=1\textwidth]{rasterexamples} \includegraphics[width=1\textwidth]{rasterexamples}
@ -57,12 +58,13 @@ of these leads into the realm of the so called \enterm[point
$T_i=t_{i+1}-t_i$ and the number of events $n_i$. } $T_i=t_{i+1}-t_i$ and the number of events $n_i$. }
\end{figure} \end{figure}
A temporal \enterm{point process} is a stochastic process that A temporal \entermde{Punktprozess}{point process} is a stochastic
generates a sequence of events at times $\{t_i\}$, $t_i \in \reZ$. In process that generates a sequence of events at times $\{t_i\}$, $t_i
the neurosciences, the statistics of point processes is of importance \in \reZ$. In the neurosciences, the statistics of point processes is
since the timing of neuronal events (action potentials, post-synaptic of importance since the timing of neuronal events (action potentials,
potentials, events in EEG or local-field recordings, etc.) is crucial post-synaptic potentials, events in EEG or local-field recordings,
for information transmission and can be treated as such a process. etc.) is crucial for information transmission and can be treated as
such a process.
The events of a point process can be illustrated by means of a raster The events of a point process can be illustrated by means of a raster
plot in which each vertical line indicates the time of an event. The plot in which each vertical line indicates the time of an event. The
@ -76,7 +78,7 @@ number of observed events within a certain time window $n_i$
Implement a function \varcode{rasterplot()} that displays the times of Implement a function \varcode{rasterplot()} that displays the times of
action potentials within the first \varcode{tmax} seconds in a raster action potentials within the first \varcode{tmax} seconds in a raster
plot. The spike times (in seconds) recorded in the individual trials plot. The spike times (in seconds) recorded in the individual trials
are stored as vectors of times within a \codeterm{cell array}. are stored as vectors of times within a cell array.
\end{exercise} \end{exercise}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -84,9 +86,10 @@ number of observed events within a certain time window $n_i$
The intervals $T_i=t_{i+1}-t_i$ between successive events are real The intervals $T_i=t_{i+1}-t_i$ between successive events are real
positive numbers. In the context of action potentials they are positive numbers. In the context of action potentials they are
referred to as \enterm{interspike intervals}. The statistics of referred to as \entermde{Interspikeintervalle}{interspike
interspike intervals are described using common measures for intervals}. The statistics of interspike intervals are described
describing the statistics of stochastic real-valued variables: using common measures for describing the statistics of stochastic
real-valued variables:
\begin{figure}[t] \begin{figure}[t]
\includegraphics[width=0.96\textwidth]{isihexamples}\vspace{-2ex} \includegraphics[width=0.96\textwidth]{isihexamples}\vspace{-2ex}
@ -110,9 +113,9 @@ describing the statistics of stochastic real-valued variables:
\frac{1}{n}\sum\limits_{i=1}^n T_i$. \frac{1}{n}\sum\limits_{i=1}^n T_i$.
\item Standard deviation of the interspike intervals: $\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 \enterm[coefficient of variation]{Coefficient of variation}: $CV_{ISI} = \item \entermde[coefficient of variation]{Variationskoeffizient}{Coefficient of variation}:
\frac{\sigma_{ISI}}{\mu_{ISI}}$. $CV_{ISI} = \frac{\sigma_{ISI}}{\mu_{ISI}}$.
\item \enterm[diffusion coefficient]{Diffusion coefficient}: $D_{ISI} = \item \entermde[diffusion coefficient]{Diffusionskoeffizient}{Diffusion coefficient}: $D_{ISI} =
\frac{\sigma_{ISI}^2}{2\mu_{ISI}^3}$. \frac{\sigma_{ISI}^2}{2\mu_{ISI}^3}$.
\end{itemize} \end{itemize}
@ -133,12 +136,12 @@ describing the statistics of stochastic real-valued variables:
\end{exercise} \end{exercise}
\subsection{Interval correlations} \subsection{Interval correlations}
So called \enterm{return maps} are used to illustrate So called \entermde[return map]{return map}{return maps} are used to
interdependencies between successive interspike intervals. The return illustrate interdependencies between successive interspike
map plots the delayed interval $T_{i+k}$ against the interval intervals. The return map plots the delayed interval $T_{i+k}$ against
$T_i$. The parameter $k$ is called the \enterm{lag} $k$. Stationary the interval $T_i$. The parameter $k$ is called the \enterm{lag}
and non-stationary return maps are distinctly different (\determ{Verz\"ogerung}) $k$. Stationary and non-stationary return
\figref{returnmapfig}. maps are distinctly different \figref{returnmapfig}.
\begin{figure}[t] \begin{figure}[t]
\includegraphics[width=1\textwidth]{returnmapexamples} \includegraphics[width=1\textwidth]{returnmapexamples}
@ -149,14 +152,16 @@ and non-stationary return maps are distinctly different
lower panels the serial correlations of successive intervals lower panels the serial correlations of successive intervals
separated by lag $k$. All the interspike intervals of the separated by lag $k$. All the interspike intervals of the
stationary spike trains are independent of each other --- this is stationary spike trains are independent of each other --- this is
a so called \enterm{renewal process}. In contrast, the ones of the a so called \enterm{renewal process}
(\determ{Erneuerungsprozess}). In contrast, the ones of the
non-stationary spike trains show positive correlations that decay non-stationary spike trains show positive correlations that decay
for larger lags. The positive correlations in this example are for larger lags. The positive correlations in this example are
caused by a common stimulus that slowly increases and decreases caused by a common stimulus that slowly increases and decreases
the mean firing rate of the spike trains.} the mean firing rate of the spike trains.}
\end{figure} \end{figure}
Such dependencies can be further quantified using the \enterm{serial Such dependencies can be further quantified using the
\entermde[correlation!serial]{Korrelation!serielle}{serial
correlations} \figref{returnmapfig}. The serial correlation is the correlations} \figref{returnmapfig}. The serial correlation is the
correlation coefficient of the intervals $T_i$ and the intervals correlation coefficient of the intervals $T_i$ and the intervals
delayed by the lag $T_{i+k}$: delayed by the lag $T_{i+k}$:
@ -189,11 +194,11 @@ using the following measures:
\item Histogram of the counts $n_i$. \item Histogram of the counts $n_i$.
\item Average number of counts: $\mu_n = \langle n \rangle$. \item Average number of counts: $\mu_n = \langle n \rangle$.
\item Variance of counts: $\sigma_n^2 = \langle (n - \langle n \rangle)^2 \rangle$. \item Variance of counts: $\sigma_n^2 = \langle (n - \langle n \rangle)^2 \rangle$.
\item \determ{Fano Factor} (variance of counts divided by average count): $F = \frac{\sigma_n^2}{\mu_n}$. \item \entermde{Fano Faktor}{Fano factor} (variance of counts divided by average count): $F = \frac{\sigma_n^2}{\mu_n}$.
\end{itemize} \end{itemize}
Of particular interest is the average firing rate $r$ (spike count per Of particular interest is the \enterm[firing rate!average]{average
time interval , \determ{Feuerrate}) that is given in Hertz firing rate} $r$ (spike count per time interval, \determ{Feuerrate})
\sindex[term]{firing rate!average rate} that is given in Hertz
\begin{equation} \begin{equation}
\label{firingrate} \label{firingrate}
r = \frac{\langle n \rangle}{W} \; . r = \frac{\langle n \rangle}{W} \; .
@ -227,11 +232,12 @@ time interval , \determ{Feuerrate}) that is given in Hertz
The Gaussian distribution is, because of the central limit theorem, The Gaussian distribution is, because of the central limit theorem,
the standard distribution for continuous measures. The equivalent in the standard distribution for continuous measures. The equivalent in
the realm of point processes is the \enterm{Poisson distribution}. the realm of point processes is the
\entermde[distribution!Poisson]{Verteilung!Poisson-}{Poisson distribution}.
In a \enterm[Poisson process!homogeneous]{homogeneous Poisson process} In a \entermde[Poisson process!homogeneous]{Poissonprozess!homogener}{homogeneous Poisson
the events occur at a fixed rate $\lambda=\text{const}$ and are process} the events occur at a fixed rate $\lambda=\text{const}$ and
independent of both the time $t$ and occurrence of previous events are independent of both the time $t$ and occurrence of previous events
(\figref{hompoissonfig}). The probability of observing an event within (\figref{hompoissonfig}). The probability of observing an event within
a small time window of width $\Delta t$ is given by a small time window of width $\Delta t$ is given by
\begin{equation} \begin{equation}
@ -239,7 +245,7 @@ a small time window of width $\Delta t$ is given by
P = \lambda \cdot \Delta t \; . P = \lambda \cdot \Delta t \; .
\end{equation} \end{equation}
In an \enterm[Poisson process!inhomogeneous]{inhomogeneous Poisson In an \entermde[Poisson process!inhomogeneous]{Poissonprozess!inhomogener}{inhomogeneous Poisson
process}, however, the rate $\lambda$ depends on time: $\lambda = process}, however, the rate $\lambda$ depends on time: $\lambda =
\lambda(t)$. \lambda(t)$.
@ -281,7 +287,7 @@ The homogeneous Poisson process has the following properties:
\item Thus, the coefficient of variation is always $CV_{ISI} = 1$ . \item Thus, the coefficient of variation is always $CV_{ISI} = 1$ .
\item The serial correlation is $\rho_k =0$ for $k>0$, since the \item The serial correlation is $\rho_k =0$ for $k>0$, since the
occurrence of an event is independent of all previous events. Such a occurrence of an event is independent of all previous events. Such a
process is also called a \enterm{renewal process}. process is also called a \enterm{renewal process} (\determ{Erneuerungsprozess}).
\item The number of events $k$ within a temporal window of duration \item The number of events $k$ within a temporal window of duration
$W$ is Poisson distributed: $W$ is Poisson distributed:
\begin{equation} \begin{equation}
@ -356,10 +362,9 @@ closely.
\end{figure} \end{figure}
A very simple method for estimating the time-dependent firing rate is A very simple method for estimating the time-dependent firing rate is
the \enterm[firing rate!instantaneous]{instantaneous firing rate}. The the \entermde[firing rate!instantaneous]{Feuerrate!instantane}{instantaneous firing rate}.
firing rate can be directly estimated as the inverse of the time The firing rate can be directly estimated as the inverse of the time
between successive spikes, the interspike-interval between successive spikes, the interspike-interval (\figref{instratefig}).
(\figref{instratefig}).
\begin{equation} \begin{equation}
\label{instantaneousrateeqn} \label{instantaneousrateeqn}
@ -384,12 +389,12 @@ not fire an action potential for a long time.
\subsection{Peri-stimulus-time-histogram} \subsection{Peri-stimulus-time-histogram}
While the \emph{instantaneous firing rate} uses the interspike While the instantaneous firing rate is based on the interspike
interval, the \enterm{peri stimulus time histogram} (PSTH) uses the intervals, the \enterm{peri stimulus time histogram} (PSTH) is based on
spike count within observation windows of the duration $W$. It spike counts within observation windows of the duration $W$. It
estimates the probability of observing a spike within that observation estimates the probability of observing a spike within that observation
time. It tries to estimat the average rate in the limit of small time. It tries to estimate the average rate in the limit of small
obersvation times \eqnref{psthrate}: obersvation times:
\begin{equation} \begin{equation}
\label{psthrate} \label{psthrate}
r(t) = \lim_{W \to 0} \frac{\langle n \rangle}{W} \; , r(t) = \lim_{W \to 0} \frac{\langle n \rangle}{W} \; ,
@ -399,10 +404,11 @@ potentials observed within the interval $(t, t+W)$. Such description
matches the time-dependent firing rate $\lambda(t)$ of an matches the time-dependent firing rate $\lambda(t)$ of an
inhomogeneous Poisson process. inhomogeneous Poisson process.
The firing probability can be estimated using the \emph{binning The firing probability can be estimated using the \enterm[firing
method} or by using \emph{kernel density estimations}. Both methods rate!binning method]{binning method} or by using \enterm[firing
make an assumption about the relevant observation time-scale ($W$ in rate!kernel density estimation]{kernel density estimations}. Both
\eqnref{psthrate}). methods make an assumption about the relevant observation time-scale
($W$ in \eqnref{psthrate}).
\subsubsection{Binning-method} \subsubsection{Binning-method}
@ -416,14 +422,15 @@ make an assumption about the relevant observation time-scale ($W$ in
binwidth.}\label{binpsthfig} binwidth.}\label{binpsthfig}
\end{figure} \end{figure}
The binning method separates the time axis into regular bins of the The \entermde[firing rate!binning
bin width $W$ and counts for each bin the number of observed action method]{Feuerrate!Binningmethode}{binning method} separates the time
potentials (\figref{binpsthfig} top). The resulting histogram is then axis into regular bins of the bin width $W$ and counts for each bin
normalized with the bin width $W$ to yield the firing rate shown in the number of observed action potentials (\figref{binpsthfig}
the bottom trace of figure \ref{binpsthfig}. The above sketched top). The resulting histogram is then normalized with the bin width
process is equivalent to estimating the probability density. It is $W$ to yield the firing rate shown in the bottom trace of figure
possible to estimate the PSTH using the \code{hist()} function \ref{binpsthfig}. The above sketched process is equivalent to
\sindex[term]{Feuerrate!Binningmethode} estimating the probability density. For computing a PSTH the
\code{hist()} function can be used.
The estimated firing rate is valid for the total duration of each The estimated firing rate is valid for the total duration of each
bin. This leads to the step-like plot shown in bin. This leads to the step-like plot shown in
@ -436,7 +443,7 @@ time-scale.
\pagebreak[4] \pagebreak[4]
\begin{exercise}{binnedRate.m}{} \begin{exercise}{binnedRate.m}{}
Implement a function that estimates the firing rate using the Implement a function that estimates the firing rate using the
``binning method''. The method should take the spike-times as an binning method. The method should take the spike-times as an
input argument and returns the firing rate. Plot the PSTH. input argument and returns the firing rate. Plot the PSTH.
\end{exercise} \end{exercise}
@ -453,20 +460,22 @@ time-scale.
superposition of the kernels.}\label{convratefig} superposition of the kernels.}\label{convratefig}
\end{figure} \end{figure}
With the convolution method we avoid the sharp edges of the binning With the \entermde[firing rate!convolution
method. The spiketrain is convolved with a \enterm{convolution method]{Feuerrate!Faltungsmethode}{convolution method} we avoid the
kernel}. Technically speaking we need to first create a binary sharp edges of the binning method. The spiketrain is convolved with a
representation of the spike train. This binary representation is a \entermde{Faltungskern}{convolution kernel}. Technically speaking we
series of zeros and ones in which the ones denote the spike. Then this binary vector is convolved with a kernel of a certain width: need to first create a binary representation of the spike train. This
binary representation is a series of zeros and ones in which the ones
denote the spike. Then this binary vector is convolved with a kernel
of a certain width:
\[r(t) = \int_{-\infty}^{\infty} \omega(\tau) \, \rho(t-\tau) \, {\rm d}\tau \; , \] \[r(t) = \int_{-\infty}^{\infty} \omega(\tau) \, \rho(t-\tau) \, {\rm d}\tau \; , \]
where $\omega(\tau)$ represents the kernel and $\rho(t)$ the binary where $\omega(\tau)$ represents the kernel and $\rho(t)$ the binary
representation of the response. The process of convolution can be representation of the response. The process of convolution can be
imagined as replacing each event of the spiketrain with the kernel imagined as replacing each event of the spiketrain with the kernel
(figure \ref{convratefig} top). The superposition of the replaced (figure \ref{convratefig} top). The superposition of the replaced
kernels is then the firing rate (if the kerel is correctly normalized kernels is then the firing rate (if the kernel is correctly normalized
to an integral of one, figure \ref{convratefig} to an integral of one, figure \ref{convratefig}
bottom). \sindex[term]{Feuerrate!Faltungsmethode} bottom).
In contrast to the other methods the convolution methods leads to a In contrast to the other methods the convolution methods leads to a
continuous function which is often desirable (in particular when continuous function which is often desirable (in particular when
@ -489,8 +498,9 @@ relevate time-scale.
The graphical representation of the neuronal activity alone is not The graphical representation of the neuronal activity alone is not
sufficient tot investigate the relation between the neuronal response sufficient tot investigate the relation between the neuronal response
and a stimulus. One method to do this is the \enterm[STA|see and a stimulus. One method to do this is the \entermde{Spike-triggered
spike-triggered average]{spike-triggered average}. The STA Average}{spike-triggered average}, \enterm[STA|see{spike-triggered
average}]{STA}. The STA
\begin{equation} \begin{equation}
STA(\tau) = \langle s(t - \tau) \rangle = \frac{1}{N} \sum_{i=1}^{N} s(t_i - \tau) STA(\tau) = \langle s(t - \tau) \rangle = \frac{1}{N} \sum_{i=1}^{N} s(t_i - \tau)
\end{equation} \end{equation}
@ -504,9 +514,9 @@ snippets are then averaged (\figref{stafig}).
\includegraphics[width=\columnwidth]{sta} \includegraphics[width=\columnwidth]{sta}
\titlecaption{Spike-triggered average of a P-type electroreceptors \titlecaption{Spike-triggered average of a P-type electroreceptors
and the stimulus reconstruction.}{The neuron was driven by a and the stimulus reconstruction.}{The neuron was driven by a
``white-noise'' stimulus (blue curve, right panel). The STA (left) \enterm{white-noise} stimulus (blue curve, right panel). The STA
is the average stimulus that surrounds the times of the recorded (left) is the average stimulus that surrounds the times of the
action potentials (40\,ms before and 20\,ms after the recorded action potentials (40\,ms before and 20\,ms after the
spike). Using the STA as a convolution kernel for convolving the spike). Using the STA as a convolution kernel for convolving the
spiketrain we can reconstruct the stimulus from the neuronal spiketrain we can reconstruct the stimulus from the neuronal
response. In this way we can get an impression of the stimulus response. In this way we can get an impression of the stimulus

View File

@ -1177,11 +1177,11 @@ segment of data of a certain time span (the stimulus was on,
required. \codeterm[Timetable]{Timetables} offer specific required. \codeterm[Timetable]{Timetables} offer specific
convenience functions to work with timestamps. convenience functions to work with timestamps.
\textbf{Maps} In a \codeterm{map} a \codeterm{value} is associated \textbf{Maps} In a \code{containers.Map} a \entermde{Wert}{value} is
with an arbitrary \codeterm{key}. The \codeterm{key} is not associated with an arbitrary \entermde{Schl\"ussel}{key}. The key is
restricted to be an integer but can be almost anything. Maps are an not restricted to be an integer but can be almost anything. Maps are
alternative to structures with the additional advantage that the key an alternative to structures with the additional advantage that the
can be used during indexing: \varcode{my\_map('key')}. key can be used for indexing: \varcode{my\_map('key')}.
\textbf{Categorical arrays} are used to stored values that come from \textbf{Categorical arrays} are used to stored values that come from
a limited set of values, e.g. Months. Such categories can then be a limited set of values, e.g. Months. Such categories can then be
@ -1251,18 +1251,19 @@ used whenever the same commands have to be repeated.
\subsubsection{The \varcode{for} --- loop} \subsubsection{The \varcode{for} --- loop}
The most common type of loop is the \codeterm{for-loop}. It The most common type of loop is the
consists of a \codeterm[Loop!head]{head} and the \entermde{For-Schleife}{for-loop}. It consists of a head and the
\codeterm[Loop!body]{body}. The head defines how often the code in the body. The head defines how often the code in the body is executed. In
body is executed. In \matlab{} the head begins with the keyword \matlab{} a for-loop always operates on vectors. The head of the
\code{for} which is followed by the \codeterm{running variable}. In \varcode{for}-loop begins with the keyword \code{for} which is
\matlab{} a for-loop always operates on vectors. With each followed by the \enterm[for-loop!running variable]{running variable}
\codeterm{iteration} of the loop, the running variable assumes the to which a vector is assigned. With each
next value of this vector. In the body of the loop any code can be \entermde{Iteration}{iteration} of the loop, the running variable
executed which may or may not use the running variable for a certain assumes the next value of this vector. In the body of the loop any
purpose. The \code{for} loop is closed with the keyword code can be executed which may or may not use the running variable for
a certain purpose. The \varcode{for}-loop is closed with the keyword
\code{end}. Listing~\ref{looplisting} shows a simple version of such a \code{end}. Listing~\ref{looplisting} shows a simple version of such a
\codeterm{for-loop}. for-loop.
\begin{lstlisting}[caption={Example of a \varcode{for}-loop.}, label=looplisting] \begin{lstlisting}[caption={Example of a \varcode{for}-loop.}, label=looplisting]
>> for x = 1:3 % head >> for x = 1:3 % head
@ -1284,14 +1285,14 @@ purpose. The \code{for} loop is closed with the keyword
\subsubsection{The \varcode{while} --- loop} \subsubsection{The \varcode{while} --- loop}
The \codeterm{while-loop} is the second type of loop that is available in The \entermde{While-Schleife}{while-loop} is the second type of loop
almost all programming languages. Other, than the \codeterm{for-loop}, that is available in almost all programming languages. Other than the
that iterates with the running variable over a vector, the while loop \varcode{for}-loop, that iterates with the running variable over a
uses a Boolean expression to determine when to execute the code in vector, the while loop uses a Boolean expression to determine when to
it's body. The head of the loop starts with the keyword \code{while} execute the code in it's body. The head of the loop starts with the
that is followed by a Boolean expression. If this can be evaluated to keyword \code{while} that is followed by a Boolean expression. If this
true, the code in the body is executed. The loop is closed with an can be evaluated to true, the code in the body is executed. The loop
\code{end}. is closed with an \code{end}.
\begin{lstlisting}[caption={Basic structure of a \varcode{while} loop.}, label=whileloop] \begin{lstlisting}[caption={Basic structure of a \varcode{while} loop.}, label=whileloop]
while x == true % head with a Boolean expression while x == true % head with a Boolean expression
@ -1303,7 +1304,6 @@ end
Implement the factorial of a number \varcode{n} using a \varcode{while}-loop. Implement the factorial of a number \varcode{n} using a \varcode{while}-loop.
\end{exercise} \end{exercise}
\begin{exercise}{neverendingWhile.m}{} \begin{exercise}{neverendingWhile.m}{}
Implement a \varcode{while}-loop that is never-ending. Hint: the Implement a \varcode{while}-loop that is never-ending. Hint: the
body is executed as long as the Boolean expression in the head is body is executed as long as the Boolean expression in the head is
@ -1316,15 +1316,15 @@ end
\begin{itemize} \begin{itemize}
\item Both execute the code in the body iterative. \item Both execute the code in the body iterative.
\item When using a \code{for}-loop the body of the loop is executed \item When using a \varcode{for}-loop the body of the loop is executed
at least once (except when the vector used in the head is empty). at least once (except when the vector used in the head is empty).
\item In a \code{while}-loop, the body is not necessarily \item In a \varcode{while}-loop, the body is not necessarily
executed. It is entered only if the Boolean expression in the head executed. It is entered only if the Boolean expression in the head
yields true. yields true.
\item The \code{for}-loop is best suited for cases in which the \item The \varcode{for}-loop is best suited for cases in which the
elements of a vector have to be used for a computation or when the elements of a vector have to be used for a computation or when the
number of iterations is known. number of iterations is known.
\item The \code{while}-loop is best suited for cases when it is not \item The \varcode{while}-loop is best suited for cases when it is not
known in advance how often a certain piece of code has to be known in advance how often a certain piece of code has to be
executed. executed.
\item Any problem that can be solved with one type can also be solve \item Any problem that can be solved with one type can also be solve
@ -1334,25 +1334,24 @@ end
\subsection{Conditional expressions} \subsection{Conditional expressions}
The conditional expression are used to control that the enclosed code With a \enterm{conditional expression} (\determ{bedingte Anweisung})
is only executed under a certain condition. the enclosed code is only executed under a certain condition.
\subsubsection{The \varcode{if} -- statement} \subsubsection{The \varcode{if} -- statement}
The most prominent representative of the conditional expressions is The most prominent representative of the conditional expressions is
the \codeterm{if statement} (sometimes also called \codeterm{if - else the \code{if} statement. It constitutes a kind of branching point. It
statement}). It constitutes a kind of branching point. It allows to allows to control which branch of the code is executed.
control which branch of the code is executed.
Again, the statement consists of the head and the body. The head Again, the statement consists of the head and the body. The head
begins with the keyword \code{if} followed by a Boolean expression begins with the keyword \code{if} followed by a boolean expression
that controls whether or not the body is entered. Optionally, the body that controls whether or not the body is entered. Optionally, the body
can be either ended by the \code{end} keyword or followed by can be either ended by the \code{end} keyword or followed by
additional statements \code{elseif}, which allows to add another additional \code{elseif} statements, that allow to add further boolean
Boolean expression and to catch another condition or the \code{else} expressions and to catch other conditions, or the \code{else}
the provide a default case. The last body of the \varcode{if - elseif - expression to provide a default case. The last body of the
else} statement has to be finished with the \code{end} \varcode{if} - \varcode{elseif} - \varcode{else} statement has to be
(listing~\ref{ifelselisting}). finished with the \code{end} (listing~\ref{ifelselisting}).
\begin{lstlisting}[label=ifelselisting, caption={Structure of an \varcode{if} statement.}] \begin{lstlisting}[label=ifelselisting, caption={Structure of an \varcode{if} statement.}]
if x < y % head if x < y % head
@ -1377,17 +1376,18 @@ end
\subsubsection{The \varcode{switch} -- statement} \subsubsection{The \varcode{switch} -- statement}
The \codeterm{switch statement} is used whenever a set of conditions The \code{switch} statement is used whenever a set of conditions
requires separate treatment. The statement is initialized with the requires separate treatment. The statement is initialized with the
\code{switch} keyword that is followed by a \emph{switch expression} (a \code{switch} keyword that is followed by a \emph{switch expression}
number or string). It is followed by a set of \emph{case expressions} returning a number or string. It is followed by a set of \emph{case
which start with the keyword \code{case} followed by the condition expressions} which start with the keyword \code{case} followed by
that defines against which the \emph{switch expression} is tested. It the condition that defines against which the \emph{switch expression}
is important to note that the case expression always checks for is tested. It is important to note that the \emph{case expression}
equality! Optional the case expressions may be followed by the keyword always checks for equality! Optional the \emph{case expressions} may
\code{otherwise} which catches all cases that were not explicitly be followed by the keyword \code{otherwise} which catches all cases
stated above (listing~\ref{switchlisting}). that were not explicitly stated above (listing~\ref{switchlisting}).
As usual the \code{switch} statement needs to be closed with an
\code{end}.
\begin{lstlisting}[label=switchlisting, caption={Structure of a \varcode{switch} statement.}] \begin{lstlisting}[label=switchlisting, caption={Structure of a \varcode{switch} statement.}]
mynumber = input('Enter a number:'); mynumber = input('Enter a number:');
@ -1406,7 +1406,7 @@ end
\begin{itemize} \begin{itemize}
\item Using the \code{if} statement one can test for arbitrary cases \item Using the \code{if} statement one can test for arbitrary cases
and treat them separately. and treat them separately.
\item The \code{switch} statement does something similar but is always \item The \code{switch} statement does something similar but always
checks for the equality of \emph{switch} and \emph{case} checks for the equality of \emph{switch} and \emph{case}
expressions. expressions.
\item The \code{switch} is a little bit more compact and nicer to read \item The \code{switch} is a little bit more compact and nicer to read
@ -1610,10 +1610,10 @@ define (i) how to name the function, (ii) which information it needs
(arguments), and (iii) what it should return to the caller. (arguments), and (iii) what it should return to the caller.
\begin{enumerate} \begin{enumerate}
\item \entermde[function!name]{Funktion!-sname}{Name}: the name should be descriptive \item \entermde[function!name]{Funktionsname}{Name}: the name should be descriptive
of the function's purpose, i.e. the calculation of a sine wave. A of the function's purpose, i.e. the calculation of a sine wave. A
appropriate name might be \varcode{sinewave()}. appropriate name might be \varcode{sinewave()}.
\item \entermde[function!arguments]{Funktion!-sargument}{Arguments}: \item \entermde[function!arguments]{Funktionsargument}{Arguments}:
What information does the function need to do the calculation? There What information does the function need to do the calculation? There
are obviously the frequency as well as the amplitude. Further we may are obviously the frequency as well as the amplitude. Further we may
want to be able to define the duration of the sine wave and the want to be able to define the duration of the sine wave and the

View File

@ -468,7 +468,7 @@ data values (e.g. size and weight of elephants) we want to analyze
dependencies between the variables. dependencies between the variables.
The The
\entermde[correlation!coefficient]{Korrelation!-skoeffizient}{correlation \entermde[correlation!coefficient]{Korrelationskoeffizient}{correlation
coefficient} coefficient}
\begin{equation} \begin{equation}
\label{correlationcoefficient} \label{correlationcoefficient}