\documentclass[12pt,a4paper,pdftex]{exam}

\usepackage[german]{babel}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage[small]{caption}
\usepackage{sidecap}
\usepackage{pslatex}
\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\marginparwidth}{2cm}
\usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref}

%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot} \header{{\bfseries\large Exercise
    }}{{\bfseries\large Correlation of stimulus and response}}{{\bfseries\large December 19, 2017}}
\firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email:
  jan.grewe@uni-tuebingen.de} \runningfooter{}{\thepage}{}

\setlength{\baselineskip}{15pt}
\setlength{\parindent}{0.0cm}
\setlength{\parskip}{0.3cm}
\renewcommand{\baselinestretch}{1.15}

\newcommand{\code}[1]{\texttt{#1}}
\renewcommand{\solutiontitle}{\noindent\textbf{Solution:}\par\noindent}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
\begin{document}

\vspace*{-6.5ex}
\begin{center}
  \textbf{\Large Introduction to scientific computing}\\[1ex]
  {\large Jan Grewe, Jan Benda}\\[-3ex]
  Abteilung Neuroethologie \hfill --- \hfill Institut f\"ur Neurobiologie \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\
\end{center}

\begin{questions}
  \question Estimate the time-dependent firing rate of a neuron. Use
  the ``convoluion'' method to do it. The dataset \code{lifoustim.mat}
  contains three variables. 1st the spike times in different trials,
  2nd the stimulus, and 3rd the temporal resolution. The total
  duration of each trial amounts to 30 seconds.
  
  \begin{parts}
    \part{} Write a function that estimates the firing rate with the
    ``convolution'' method. This function should take four input
    arguments: (i) a vector of spike times, (ii) the temporal
    resolution of the recording, (iii) the duration of the
    trial, and (iv) the standard deviation of the applied Gaussian
    kernel. The function should return two variables: (i) the firing
    rate, and (ii) a vector representing time.
    \part{} Write a script that uses this function to estimate the
    firing rate of all trial. Plot the mean (across trials) firing
    rate as a function of time. Use two different kernel standard
    deviations (e.g. 20\,ms and 100\,ms).
    \part{} Save the figure according the style defined by the
    \emph{J. Neuroscience} (figure width 1, 1.5, or two columns, 8.5,
    11.6, or 17.6\,cm, respectively; fontsize 10 pt). Save the figure
    as pdf.
  \end{parts}

  \question In a previous exercise you were asked to estimate the
  correlation between a set of independent variables and the
  respective measurements (Chapter 6.4 in the script).  We can use
  this function to learn a few things about the relation between
  stimulus and response.

  \begin{parts}
    \part{} Estimate the firing rate of the neuronal response using one
    of the three methods. Use the same dataset as before.
    \part{} Calculate the correlation of stimulus and response.
    \part{} Calculate the correlation of stimulus and response
    while shifting the response relative to the stimulus in a range
    $\pm$ 50\,ms (1\,ms steps).
    \part{} Plot these correlations as a function of the temporal shift
    (often called lag).
    \part{} What is the maximum correlation and at which lag does it occur?
    \part{} What could this tell us about the neuronal response properties?
  \end{parts}
\end{questions}

\end{document}
