This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/pointprocesses/exercises/pointprocesses01.tex
2017-12-04 23:14:52 +01:00

230 lines
7.6 KiB
TeX

\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}{: Solutions}
\else
\newcommand{\stitle}{}
\fi
\header{{\bfseries\large Exercise 8\stitle}}{{\bfseries\large Point processes}}{{\bfseries\large November 27th, 2017}}
\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{Statistics of interspike intervals}
Download the files \code{poisson.mat},
\code{pifou.mat}, and \code{lifadapt.mat} from Ilias.
Each of these files contains several trials of spike trains
of a specific type of neuron. The spike times are measured in seconds.
We want to compare the statistics of the interspike intervals of the
three neurons.
\begin{parts}
\part Load the spike trains from the three files.
Make sure that the data are assigned to different variables.
What is the type of the data? How can you access individual spike trains?
How do you access single spike times?
\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;
clear x;
\end{lstlisting}
\end{solution}
\newsolutionpage
\part Write a function that illustrated the spike times of the
first $t_{max}$ seconds in a raster plot. Each spike train is one
row in the raster plot. Each spike is a vertical line at the time
of the spike. When appropriate, the function should use milliseconds
for the time axis instead of seconds.
Use this function to plot the first second of the
spike rasters of the three neurons.
\begin{solution}
\lstinputlisting{../code/spikeraster.m}
\lstinputlisting{../code/plotspikeraster.m}
\mbox{}\\[-3ex]
\colorbox{white}{\includegraphics[width=1\textwidth]{spikeraster}}
\end{solution}
\part Write a function that returns a single vector containing the
interspike intervals of all trials of spike times.
\begin{solution}
\lstinputlisting{../code/isis.m}
\end{solution}
\part Write a function that computes an estimate of the
probability density of interspike intervals from a vector of
interspike intervals. The function should automatically choose a
good bin width for the histogram.
Write another function that plots the probability density of
interspike intervals given a vector of interspike intervals as
argument. The function should use the first function for computing
the probability density. The interspike intervals are given in
seconds, but the plot should mark the interspike intervals in
milliseconds. In addition, the function should compute the mean,
the standard deviation and the coefficient of variation and
display them in the plot as well.
Use this and the previous functions to compare the
interspike interval statistics of the three neurons.
\begin{solution}
\lstinputlisting{../code/isihist.m}
\lstinputlisting{../code/plotisihist.m}
\lstinputlisting{../code/plotisihs.m}
\mbox{}\\[-3ex]
\colorbox{white}{\includegraphics[width=1\textwidth]{isihist}}
\end{solution}
% XXX Add return map!!! XXX
\part Write a function that computes and plots the serial
correlations of interspike intervals for lags upto
\code{maxlag}. The serial correlations $\rho_k$ for lag $k$ of the
interspike intervals $T_i$ are the correlation coefficients
between interspike intervals $T_i$ and the intervals $T_{i+k}$
that are shifted by lag $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) \]
Use this function to compare the serial correlations of the
interspike intervals of the three neurons.
\begin{solution}
\lstinputlisting{../code/isiserialcorr.m}
\lstinputlisting{../code/plotserialcorr.m}
\colorbox{white}{\includegraphics[width=1\textwidth]{serialcorr}}
\end{solution}
\end{parts}
\continue
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\question \qt{Statistics of spike counts}
Now let's have a look at the statistics of the spike counts.
\begin{parts}
\part Write a function that counts and returns the number of
spikes in windows of a given width $W$.
Use this function to generate a histogram of spike counts for the
data of the three types of neurons. Use 100\,ms for the window
width.
\begin{solution}
\lstinputlisting{../code/spikecounts.m}
% XXX
\end{solution}
\part Write a function that computes for a range from window
widths the mean, the variance and the Fano factor of the
corresponding spike counts. The function should the generate two
plots. One showing the spike count variance in dependence on the
mean spike count. The other plot showing the Fano factor as a
function of window width.
\begin{solution}
\lstinputlisting{../code/fanoplot.m}
% XXX
\end{solution}
\end{parts}
\end{questions}
\end{document}