\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 12\stitle}}{{\bfseries\large Point processes}}{{\bfseries\large January 14th, 2020}} \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/rasterplot.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} \continuepage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \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 properly normalized 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} \newsolutionpage \lstinputlisting{../code/spikecountshists.m} \colorbox{white}{\includegraphics[width=1\textwidth]{spikecountshists}} \end{solution} \newsolutionpage \part Write a function that computes for a range of window widths the mean, the variance and the Fano factor of the corresponding spike counts. The function should generate two plots. One showing the spike count variance in dependence on the mean spike count (the mean spike count increases for larger window widths). The other plot showing the Fano factor as a function of window width. \begin{solution} \lstinputlisting{../code/fanoplot.m} \newsolutionpage \lstinputlisting{../code/fanoplots.m} \colorbox{white}{\includegraphics[width=1\textwidth]{fanoplotspoisson}} \colorbox{white}{\includegraphics[width=1\textwidth]{fanoplotspifou}} \colorbox{white}{\includegraphics[width=1\textwidth]{fanoplotslifadapt}} \end{solution} \end{parts} \end{questions} \end{document}