\documentclass[12pt,a4paper,pdftex]{article}
\usepackage[left=25mm, right=25mm, top=20mm, bottom=25mm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{natbib}
\usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=false,citecolor=blue]{hyperref}

\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
%\usepackage{float}
\usepackage{floatrow}

\usepackage{listings} % für den code am Ende



\newcommand{\todo}[1]{{\color{red}(TODO: #1)}}
\newcommand{\AptLepto}{{\textit{Apteronotus leptorhynchus \:}}}
\newcommand{\lepto}{{\textit{A. leptorhynchus}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ab hier beginnt der eigentliche Text:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Titelseite
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{titlepage}
		\begin{center}
		{\Huge Modeling the Heterogeneity of Electrosensory Afferents in Electric Fish \par}
		\vspace{0.75cm}
		{\Large Masterthesis \par}
		\vspace{0.25cm}
		{der Mathematisch-Naturwissenschaftlichen Fakultät \par} {der Eberhard Karls Universität Tübingen \par}
		\vspace{0.75cm}
		{Erstkorrektor: Prof.~Dr.~Philipp Berens\\
		Zweitkorrektor: Prof.~Dr.~Jan Benda \par}
		\vspace{0.25cm}
		{Lehrbereich für Neuroethologie}
		
		\vfill
		\large vorgelegt von \par
		\large Alexander Mathias Ott \par
		Abgabedatum: 21.09.2020
	\end{center}
\end{titlepage}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Erklärung
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Eigenständigkeitserklärung}

\vspace{0.5cm}

Hiermit erkläre ich, dass ich die vorgelegte Arbeit selbstständig verfasst habe und keine anderen als die angegebenen Quellen und Hilfsmittel benutzt habe. 

\vspace{2mm}
\noindent
Außerdem erkläre ich, dass die eingereichte Arbeit weder vollständig noch in wesentlichen Teilen Gegenstand eines anderen Prüfungsverfahrens gewesen ist.






\vfill

\begin{tabular}{ll}
	$\overline{\text{Unterschrift}\hspace{6cm}}$ & $\overline{\text{Ort, Datum}\hspace{4cm}}$ \\
\end{tabular}
\newpage\newpage



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inhalsverzeichnis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

{
 \hypersetup{linkcolor=black}
 \tableofcontents
}

\newpage



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zusammenfassung
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Zusammenfassung}
% Abstract in deutsch


\section{Abstract}
%Einleitung + Ergebnisse der Diskussion in kurz



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Einleitung
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Methoden
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Materials and Methods}


\subsection{Cell recordings}

The cell recordings for this master thesis were collected as part of other previous studies (\cite{walz2013Phd}, \citep{walz2014static})\todo{ref other studies} and is described there but will also be repeated below . The data of \todo{how many} \AptLepto were used. \todo{sizes range, EOD range, number of cells}

The in vivo intracellular recordings of P-unit electroreceptors were done in the lateral line nerve . The fish were anesthetized with MS-222 (100-130 mg/l; PharmaQ; Fordingbridge, UK) and the part of the skin covering the lateral line just behind the skull was removed, while the area was anesthetized with Lidocaine (2\%; bela-pharm; Vechta, Germany). The fish were immobilized for the recordings with Tubocurarine (Sigma-Aldrich; Steinheim, Germany, 25–50 $\mu l$ of 5\. mg/ml solution) and placed in the experimental tank (47 $\times$ 42 $\times$ 12\,cm) filled with water from the fish's home tank with a conductivity of about 300$\mu$\,S/cm and the temperature was around 28°C. 
All experimental protocels were approved and complied with national and regional laws (files: no. 55.2-1-54-2531-135-09 and Regierungspräsidium Tübingen no. ZP 1/13 and no. ZP 1/16 \todo{andere antrags nummern so richtig ?})
For the recordings a standard glass mircoelectrode (borosilicate; 1.5 mm outer diameter; GB150F-8P, Science Products, Hofheim, Germany) was used, pulled to a resistance of 50-100M$\Omega$ using Model P-97 from Sutter Instrument Co. (No-
vato, CA, USA). They were filled with 1M KCl solution. The electrodes were controlled using microdrives (Luigs-Neumann; Ratingen, Germany) and the potentials recorded with the bridge mode of the SEC-05 amplifier (npi-electronics GmbH, Tamm, Germany) and lowpass filtered at 10 kHz.

During the recording spikes were detected online using the peak detection algorithm from \cite{todd1999identification}. It uses a dynamically adjusted threshold value above the previously detected trough. To detect spikes through changes in amplitude the threshold was set to 50\% of the amplitude of a detected spike while keeping the threshold above a minimum set to be higher than the noise level based on a histogram of all peak amplitudes. Trials with bad spike detection were removed from further analysis.
The fish's EOD was recorded using using two vertical carbon rods (11\,cm long, 8\,mm diameter) positioned in front of the head and behind its tail.. the signal was amplified 200 to 500 times and band-pass filtered (3 − 1500 Hz passband, DPA2-FX, npi-electronics, Tamm, Germany). The electrodes were placed on isopotential lines of the stimulus field to reduce the interference of the stimulus in the recording. All signals were digitized using a data acquisition board (PCI-6229; National Instruments, Austin TX, USA) at a sampling rate of \todo{Hz range} kHz

The recording and stimulation was done using the ephys, efield, and efish plugins of the software RELACS (\href{www.relacs.net}{www.relacs.net}). It allowed the online spike and EOD detection, pre-analysis and visualization and ran on a Debian computer.



\subsection{Stimulus Protocols}
% image of Baseline stimulus as baseline doesn't mean no stimulus here
% image of Fi curve stimulus sinusoidal step
% image of SAM stimulus

The stimuli used during the recordings were presented from two vertical carbon rods (30 cm long, 8 mm diameter) as stimulus electrodes. They were positioned at either side of the fish parallel to its longitudinal axis. The stimuli were computer generated, attenuated and isolated  (Attenuator: ATN-01M, Isolator: ISO-02V, npi-electronics, Tamm, Germany) and then send to the stimulus electrodes.
For this work three types of recordings were made baseline, frequency-Intensity curve (FI-Curve) and sinusoidal amplitude modulation (SAM). 
The 'stimulus' for the baseline recording is purely the field the fish produces itself. So the situation with no outside influence. 

For the other two stimuli a certain kind of amplitude modulation (AM) of the fish's EOD was the goal. The recordings for the FI-Curve used a step change in the EOD amplitude. This step change was produced by recording the EOD of the fish multiplying this trace with the wanted step change (the amplitude modulation) and then playing the modified EOD back through the stimulus electrodes in the right phase. This causes constructive interference between the fish's EOD and the AM signal and results in the stimulus carrying the wanted AM (see Figure \ref{fig:am_generation}).

This system as seen in equation \ref{eq:am_generation} works for any AM. In the 

\todo{contrast ranges, presentation windows/durations, changing stimulus parameters}

\begin{equation}
Stimulus = EOD(t) * AM(t) + EOD(t) \todo{acceptable?}
\label{eq:am_generation}
\end{equation}

\begin{figure}
    \centering
    \begin{minipage}{0.5\textwidth}
    	\raisebox{50mm}{\large\sffamily A}\hspace{-2ex}
        \includegraphics[width=0.95\textwidth]{figures/amGeneration.pdf}
    \end{minipage}\hfill
    \begin{minipage}{0.5\textwidth}
        \includegraphics[width=\textwidth]{figures/stimuliExamples.pdf}
		%\caption{second}
    \end{minipage}
		\caption{use real EOD data?\label{fig:stim_examples}}
\end{figure}





\subsection{Cell Characteristics}

Baseline

p-Value:

\begin{equation}
p = \frac{neuron frequency}{EOD frequency}
\end{equation}

coefficient of variation:

\begin{equation}
CV = \frac{STD(ISI)}{\langle ISI \rangle}
\end{equation}

serial correlation: \todo{check!}

\begin{equation}
sc_i = \frac{\langle ISI_{k+j} ISI_k \rangle - \langle ISI_k \rangle^2}{VAR(ISI)}
\end{equation}

burstiness: \todo{what definition? still use it? }


vector strength:


FI-Curve:

explain detection of f-points


\subsection{Leaky Integrate and Fire Model}

% add info about simulation by euler integration and which time steps!
% show voltage dynamics with resistance : 
also show function with membrane resistance before explaining that is unknown and left out: $ \tau_m \frac{dV}{dt} = -V + I$
% explain subthreshold behaviour first then add V_{th} and adaption etc
% explain modeling of the adaption current see Benda2010
% table with explanation of variables ?
\todo{restructure and rewrite sounds horrible}

The P-units were modeled with an noisy leaky integrate-and-fire neuron with an adaption current (LIFAC). The basic voltage dynamics in this model follows equation \ref{basic_voltage_dynamics}. The voltage is integrated over time while also exponentially decaying back to zero. When a voltage threshold is reached the voltage is set back to zero and a spike is recorded. The currents in this model carry the unit mV as the the cell bodies of p-units are inaccessible during the recordings and as such the resistance of the cell membrane is unknown \todo{ref mem res p-units}. 

The current can be split into three parts: the adaption current, the input current and the bias current (Eq. \ref{currents_lifac}). The input current is the stimulus from outside the cell, the bias current models the general activity of the cell and the adaption current models a combination of the M-type, mAHP-type and sodium adaption currents \todo{ref Benda 2005}.

The adaption current is modeled as an exponential decay with the time constant $\tau_A$ and a strength called $\Delta_A$ (Eq. \ref{Adaption_dynamics}). $\Delta_A$ is multiplied with the sum of events in the spike train ($\delta (t)$) of the model cell itself. For the simulation using the Euler integration this results in an increase of $I_A$ by $\Delta_A$ in every time step where a spike is recorded. \todo{image of model simulation with voltage adaption and spikes?}

Finally a noise current and an absolute refractory period where added to the model. The noise $\xi$ is drawn in from a Gaussian noise with values between 0 and 1 and divided by $\sqrt{\Delta t}$ to get a noise which autocorrelation function is independent of the integration step size $\Delta t$.  After an excitation of the model the voltage is kept at zero for the duration of the refractory period.


\begin{equation}
	\tau_m \frac{dV}{dt} = -V + I
	\label{basic_voltage_dynamics}
\end{equation}

\begin{equation}
	I = \alpha I_{Input} - I_A + I_{Bias}
	\label{currents_lifac}
\end{equation}

\begin{equation}
	\tau_A \frac{dI_A}{dt} = -I_A + \Delta_A \sum \delta (t)
	\label{Adaption_dynamics}
\end{equation}

\begin{equation}
	\tau_m \frac{dV}{dt} = -V+I_{Bias} +\alpha I_{Input} - I_{A} + \sqrt{2D}\frac{\xi}{\sqrt{\Delta t}}
	\label{full_voltage_dynamics}
\end{equation}

\begin{figure}[H]
\includegraphics[scale=0.6]{figures/model_comparison.pdf}
\label{fig:model_comparison}
\caption{Comparison of different simple models normed to a baseline fire rate of ~10 Hz stimulated with a step stimulus. In the left column y-axis in mV in the right column the y-axis shows the frequency in Hz.  PIF: Shows a continuously increasing membrane voltage with a fixed slope and as such constant frequency for a given stimulus strength. LIF: Approaches a stimulus dependent membrane voltage steady state exponentially Also has constant frequency for a fixed stimulus value. LIFAC: Exponentially approaches its new membrane voltage value but also shows adaption after changes in the stimulus the frequency takes some time to adapt and arrive at the new stable value. LIFAC + ref: Very similar to LIFAC the added absolute refractory period keeps the voltage constant for a short time after the spike and limits high fire rates. \todo{how to deal with the parameters} }

\end{figure}



\begin{figure}[H]
\includegraphics[scale=0.6]{figures/stimulus_development.pdf}
\label{fig:stim_development}
\caption{}
\end{figure}


\subsection{Fitting of the Model}



\section{Results}



\section{Discussion}




\bibliography{citations} 
\bibliographystyle{apalike}


\end{document}