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

\newcommand{\ptitle}{Reverse reconstruction}
\input{../header.tex}
\firstpagefooter{Supervisor: Jan Grewe}{phone: 29 74588}%
{email: jan.grewe@uni-tuebingen.de}

\begin{document}

\input{../instructions.tex}

%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Reverse reconstruction of the stimulus that evoked a neuronal response.}
To analyse encoding properties of a neuron one often calculates the
Spike-Triggered-Average (STA). The STA is the average stimulus that
led to a spike in the neuron and is calculated by cutting out snippets
form the stimulus centered on the respective spike time:
\[ STA(\tau) = \frac{1}{n} \displaystyle\sum_{i=1}^{n}{s(t_i - \tau)} \],
where $n$ is the number of trials and $t_i$ is the time of the
$i_{th}$ spike. The Spike-Triggered-Average can be used to reconstruct
the stimulus from the neuronal response. The reconstructed stimulus
can then be compared to the original stimulus.

\begin{questions}
  \question In the accompanying files you find the spike responses of
  a p-type electroreceptor afferent (P-unit) and a pyramidal neurons
  recorded in the hindbrain of the weakly electric fish
  \textit{Apteronotus leptorhynchus}. The respective stimuli are
  stored in separate files. The data is sampled with 20\,kHz temporal
  resolution and spike times are given in seconds. Start with the
  P-unit and, in the end, apply the same analyzes/functions to the
  pyramidal data.
  \begin{parts}
    \part Estimate the STA and plot it.
    \part Implement a function that does the reverse reconstruction and uses the STA to recopnstruct the stimulus.
    \part Implement a function that estimates the reconstruction 
    error using the mean-square-error and express it relative to the
    variance of the original stimulus.
    \begin{equation}
      err = \frac{1}{N} \cdot \displaystyle\sum^{N}_{i=1}(x_i - \bar{x})^2,
    \end{equation}
    with $N$ the number of data points, $x_i$ the current value and
    $\bar{x}$, the average of all $x$.
    \part Analyze the robustness of the reconstruction: Estimate 
    the STA with less and less data and estimate the reconstruction
    error.
    \part Plot the reconstruction error as a function of the amount of data 
    used to estimate the STA.
    \part Repeat the above steps for the pyramidal neuron, what do you
    observe?
  \end{parts}
\end{questions}

\end{document}