\documentclass[12pt,a4paper,pdftex]{article}
\usepackage[left=25mm, right=25mm, top=20mm, bottom=25mm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{natbib}
\usepackage{comment}
\usepackage{xcolor}
\usepackage[breaklinks=true,colorlinks=true,citecolor=blue!30!black,urlcolor=blue!30!black,linkcolor=blue!30!black]{hyperref}


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

\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{Abstract}
%Einleitung + Ergebnisse der Diskussion in kurz
The environment contains vital information for the survival of an organism. Thus it is critical for the senses of an organism to encode this information. This encoding process needs to be efficient to gather the most information possible while at the same time filtering and removing noise and irrelevant information.
The active electric sense used by the electric fish \AptLepto is a well defined model system for adaptive signal processing. The population of P-Unit neurons, the electro sensory afferents, display strong heterogeneity. The proposed model is able to reproduce this heterogeneic population allow further research into the encoding of such heterogeneous neuron populations.

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

The environment of an organism holds important information needed to survive. Information about predators to avoid, food to find and potential mates. The ability to sense and process this information is of vital importance for any organism. At the same time the environment also contains a lot of information that is irrelevant to an organism. \cite{barlow1961possible} already suggested that the sensory systems of an organism should be specialized to extract the information it needs while filtering out the noise and irrelevant information, to efficiently use the limited coding capacity of the sensory systems.

One interesting model system for questions of adaptive signal processing is the electric fish \AptLepto (brown ghost knifefish).
\lepto generates a sinusoidal electric field through discharges of its electric organ in their tail (electric organ discharge, EOD) enabling them to use active electroreception. They use their EOD to find prey and communicate with each other (\cite{maciver2001prey}, \cite{zupanc2006electric}). The different use cases of this EOD come with the necessity to detect a wide range of different amplitude modulations (AMs). Electrolocation of objects in the surrounding water - like small prey or rocks - cause small low frequency AMs \citep{babineau2007spatial}. At the same time other electric fish can cause stronger and higher frequency AMs through interference between the electric fields and their communication signals like chirps, short increases in their EOD frequency \citep{zupanc2006electric}. This means that the electroreceptors need to be able to encode a wide range of changes in EOD amplitude, in speed as well as strength.

The EOD and its AMs are encoded by electroreceptor organs in the skin. \lepto posses two kinds of tuberous electrosensory organs: the T and P type units \citep{scheich1973coding}. The T-units (time coder) are strongly phase locked to the EOD and fire regularly once every EOD period. They encode the phase of the EOD in their spike timing. The P-units (probability coders) on the other hand do not fire every EOD period. Instead, they fire irregularly with a certain probability that depends on the EOD amplitude. That way they encode information about the EOD amplitude in their firing probability \citep{scheich1973coding}. An example of the firing behavior of a P-unit is shown in figure~\ref{fig:p_unit_example}. 
When the fish's EOD is unperturbed, P-units fire every few EOD periods. Still they have a certain variability in their firing (fig. \ref{fig:p_unit_example} B) and show negative correlation between successive interspike intervals (ISIs)(fig. \ref{fig:p_unit_example} C). When presented with a step increase in EOD amplitude P-units show strong adaption behavior. After a strong increase in the firing rate reacting to the onset of the step, the firing rate quickly decays back to a steady state (fig. \ref{fig:p_unit_example} D). When using different sizes of steps both the onset and the steady state response scale with its size and direction of the step (fig. \ref{fig:p_unit_example} E). 


\begin{figure}[H]
{\caption{\label{fig:p_unit_example} Example behavior of a P-unit with a high baseline firing rate and an EOD frequency of 744\,Hz. \textbf{A}: 100\,ms voltage trace of the baseline recording with spikes marked by the black strokes. \textbf{B}: ISI histogram showing the phase locking of the P-unit firing to the EOD period. \textbf{C}: The serial correlation of the ISIs showing the negative correlation at lag one of most P-units. \textbf{D}: The response of the P-unit to a step increase in EOD amplitude. The averaged firing frequency (1/ISI) averaged over 10 trials. The P-unit strongly reacts to the onset of the stimulus but very quickly adapts to the new stimulus and then shows a reduced steady state response. \textbf{E}: The onset (red) and steady-state (dark blue) f-I curves of the neuron display the dependence of both responses on the stimulus contrast. The lines are fits with a Boltzmann function (eq. \ref{eq:Boltzmann}) and a rectified linear fit (eq. \ref{eq:rectified_line}) for the onset and steady state f-I curve respectively.}}
{\includegraphics{figures/p_unit_example.pdf}}
\end{figure}
\newpage



\begin{figure}[H]
{\caption{\label{fig:heterogeneity_isi_hist} Variability in spiking behavior between P-units under baseline conditions. \textbf{A--C}: 100\,ms of cell membrane voltage and \textbf{D--F}: interspike interval histograms, each for three different cells. \textbf{A} and \textbf{D}: A non-bursting cell with a baseline firing rate of 133\,Hz (EODf: 806\,Hz), \textbf{B} and \textbf{E}: A cell with some bursts and a baseline firing rate of 235\,Hz (EODf: 682\,Hz) and \textbf{C} and \textbf{F}: A strongly bursting cell with longer pauses between bursts (baseline rate of  153\,Hz and EOD frequency of 670\,Hz). }}
{\includegraphics{figures/isi_hist_heterogeneity.pdf}}
\end{figure}

Furthermore show P-units a pronounced heterogeneity in their spiking behavior (fig.~\ref{fig:heterogeneity_isi_hist}, \cite{gussin2007limits}). Currently the spiking behavior of P-units is often split into two distinct categories of bursting and non-bursting  cells (\cite{xu1996logarithmic}, \cite{chacron2004burst}) or the bursting behavior is not considered at all \citep{walz2013Phd}. But when one is trying to understand how information is encoded in the spike trains and populations of neurons the bursts (review: \cite{zeldenrust2018neural}) and general heterogeneity (\cite{padmanabhan2010intrinsic}, \cite{tripathy2013intermediate}) are important aspects to consider.
 A single neuron might be an independent unit from all other neurons but through different tuning curves a full picture of the stimulus can be encoded in the population even when a single neuron only encodes a small feature space. This type of encoding is ubiquitous in the nervous system and is, for example in form of a labeled line code, used in the visual sense for color vision. Even though P-units were already modelled based on a simple leaky integrate-and-fire neuron (\cite{chacron2001simple}, \cite{walz2013Phd}) and conductance based \citep{kashimori1996model} and also well studied (\cite{bastian1981electrolocation}, \cite{ratnam2000nonrenewal} \cite{benda2005spike}), up to this point there is no model that tries to cover the full breadth of heterogeneity of the P-unit population. Having such a model could help shed light into the population code used in the electric sense, but also of heterogeneous neuron populations in general as there are currently few model systems that have well defined heterogeneous populations.
Further it could allow researchers gain a better picture how higher brain areas might process the information and get closer to the full path between sensory input and behavioral output. 



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

\subsection{Cell Recordings}

The cell recordings for this master thesis were collected as part of other previous studies like \cite{walz2013Phd} and \cite{walz2014static}. The recordings of altogether 457 P-units were inspected. 88 of the recordings fulfilled the basic necessary requirements: including a measurement of at least 30 seconds of baseline behavior and containing at least 7 different contrasts with a minimum of 7 trials each for the f-I curve (see below fig. \ref{fig:f_point_detection} B). After pre-analysis of those cells 15 cells additional were excluded because of spike detection difficulties.

The 67 used cells came from 32 \AptLepto (brown ghost knifefish). The fish were between 11--25\,cm long (15.8 $\pm$ 3.5\,cm) and their electric organ discharge (EOD) frequencies (EODf) ranged between 601 and 928\,Hz (753 $\pm$ 82\,Hz). The sex of the fish was not determined.

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. The water had a conductivity of about 300$\mu$\,S/cm and the temperature was around 28°C. 
All experimental protocols 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).
For the recordings a standard glass mircoelectrode (borosilicate; 1.5 mm outer diameter; GB150F-8P, Science Products, Hofheim, Germany) was used. They were pulled to a resistance of 50--100\,M$\Omega$ using Model P-97 from Sutter Instrument Co. (Novato, CA, USA) and filled with 1\,M 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 low-pass 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 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 iso-potential 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 20--100\,kHz (54 cells at 20\,kHz, 20 at 100\,kHz and 1 at 40\,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 two types of recordings were made with all cells: baseline recordings and amplitude step recordings for the frequency-intensity curve (f-I curve). 
The 'stimulus' for the baseline recording is purely the EOD field the fish produces itself with no external stimulus.

The amplitude step stimulus here is a step in EOD amplitude. The amplitude modulation (AM) is measured as a contrast. The contrast is calculated by dividing the EOD amplitude during the step by the normal EOD amplitude. To be able to cause a given AM in the fish's EOD, the EOD was recorded and multiplied with the modulation (see fig. \ref{fig:stim_examples}). This modified EOD can then be presented at the right phase with the stimulus electrodes, causing constructive interference and adding the used amplitude modulation to the EOD (Fig. \ref{fig:stim_examples}). This stimuli construction as seen in equation~\ref{eq:am_generation} works for any AM as long as the EOD of the fish is stable. 

\begin{equation}
V_{Stim}(t) = EOD(t)(1 + AM(t)) 
\label{eq:am_generation}
\end{equation}


\begin{figure}[H]
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={left, center}, capbesidewidth=0.33\textwidth}}]{figure}[\FBwidth]
{\caption{\label{fig:stim_examples} Example of the stimulus construction. \hfill \break \textbf{A}: Recording of the fish's EOD. \textbf{B}: EOD recording multiplied with the AM, with a step between 0 and 50\,ms to a contrast of 30\,\% (marked in orange).\textbf{C}: The resulting stimulus trace when the AM is added to the EOD. }}
{\includegraphics{figures/amGeneration.pdf}}
\end{figure}


All step stimuli consisted of a delay of 0.2\,s followed by a 0.4\,s (n=68) or 1\,s (n=7) long step and a 0.8\,s long recovery time. The contrast range measured  was for the most cells 80--120\% of EOD amplitude. Some cells were measured in a larger range up to 20--180\%. In the range at least 7 contrasts were measured with at least 7 trials, but again many cells were measured with more contrasts and trials. The additionally measured contrasts were used for the model if they had at least 3 trials.


\subsection{Cell Characteristics}

The cells were characterized by ten parameters: 6 for the baseline and 4 for the f-I curve.
For the baseline the mean firing rate was calculated by dividing the number of spikes in the recording by the recording time. Then the set of all interspike intervals (ISI) $T$ was computed and further parameters were calculated from it. 

The coefficient of variation
\begin{equation}
CV = \frac{STD(T)}{\langle T \rangle}
\label{eq:CV}
\end{equation}
is defined as the standard deviation (STD) of $T$ divided by the mean ISI, see equation \ref{eq:CV} with angled brackets as the averaging operator. 


The vector strength (VS) is a measure of how strong the cell locks to a phase of the EOD. It was calculated as seen in equation \ref{eq:VS}, by placing each spike on a unit circle depending on the relative spike time $t_i$ of how much time has passed since the start of the current EOD period in relation to the EOD period length. This set of vectors is then averaged and the absolute value of this average vector describes the VS. If the VS is zero the spikes happen equally in all phases of the EOD while if it is one all spikes happen at the exact same phase of the EOD. 

\begin{equation}
vs = |\frac{1}{n} \sum_n e^{iwt_i}|
\label{eq:VS}
\end{equation}


The serial correlation with lag k ($SC_k$) of $T$ is a measure how the ISI $T_i$ (the $i$-th ISI) influences the $T_{i+k}$ the ISI with a lag of k intervals. This is calculated as,  
 
\begin{equation}
SC_k = \frac{\langle (T_{i} - \langle T \rangle)(T_{i+k} - \langle T \rangle) \rangle}{\sqrt{\langle (T_i - \langle T \rangle)^2 \rangle}\sqrt{\langle (T_{i+k} - \langle T \rangle)^2 \rangle}}
\label{eq:SC}
\end{equation}
with the angled brackets again the averaging operator.


Finally the ISI-histogram was calculated within a range of 0--50\,ms and a bin size of 0.1\,ms. The burstiness was calculated as the percentage of ISI smaller than 2.5 EOD periods multiplied by the average ISI. This gives a rough measure of how often a cell fires in the immediately following EOD periods compared to its average firing frequency.   


%burstiness: \todo{how to write as equation, ignore and don't show an equation?}
% \begin{equation}
% 	b = (T < 1/2EODf)/ N * \langle T \rangle
% \end{equation}

\begin{figure}[H]
\centering
% trim={<left> <lower> <right> <upper>}
%\parbox[c][0mm][t]{80mm}{\hspace{-10.5mm}\large\sffamily A\hspace{50.5mm} \large\sffamily B} 
%\raisebox{70mm}[10]{\large\sffamily A)}
\includegraphics[trim={10mm 5mm 10mm 5mm}]{figures/f_point_detection.pdf}

\caption{\label{fig:f_point_detection} \textbf{A}: The averaged response of a cell to a step in EOD amplitude. The step of the stimulus is marked by the back bar. The detected values for the onset ($f_0$) and steady-state ($f_{\infty}$) response are marked in dark blue. $f_0$ is detected as the highest deviation from the mean frequency before the stimulus while $f_{\infty}$ is the average frequency in the 0.1\,s time window, 25\,ms before the end of the stimulus. \textbf{B}: The fi-curve visualizes the onset and steady-state response of the neuron for different stimuli contrasts. In red the detected onset responses and the fitted Boltzmann, in dark blue the detected steady-state response and the linear fit.}
\end{figure}


As already mentioned in the introduction, P-units react to a step in EOD amplitude with a strong onset response decaying back to a steady state response (fig.~\ref{fig:f_point_detection}~A). This adaption behavior of the cell was characterized by the f-I curve measurements. First the ISI frequency trace for each stimulus was calculated. The ISI frequency of a time point t is defined as $1/T_i$ with $T_i$ the ISI the time point t falls into. This gives a frequency trace starting with the first spike and ending at the last spike. For further analysis, all trials of a specific contrast were averaged over the trials with the resolution of the sampling rate. This results in a trial-averaged step response for each contrast as illustrated in figure \ref{fig:f_point_detection}~A. 
In this firing frequency trace the baseline frequency, the onset $f_0$ and steady-state $f_{\infty}$ response were detected. The baseline frequency was measured as the mean of the firing frequency 25\,ms after recording start up to 25\,ms before the stimulus start. $f_0$ was then defined as the largest deviation from the baseline frequency, within the first 25\,ms after stimulus onset. If there was no deviation farther than the minimum or maximum before the stimulus start, then the average frequency in that 25\,ms time window was used. This approximation made the detection of $f_0$ more stable for small contrasts and trials with high variation in their firing rates.   
The $f_{\infty}$ response was estimated as the average firing frequency in the 100\,ms time window ending 25\,ms before the end of the stimulus (fig. \ref{fig:f_point_detection} A). 
Afterwards a Boltzmann function:
\begin{equation}
f_{0}(I) = (f_{max}-f_{min}) (1 / (1 + e^{-k * (I - I_0)})) + f_{min}
\label{eq:Boltzmann}
\end{equation}
was fitted to the onset response and a rectified line:
\begin{equation}
f_{\infty}(I) = \lfloor mI+c \rfloor_0
\label{eq:rectified_line}
\end{equation} 
(with $\lfloor x \rfloor_0$ the rectify operator) was fitted to the steady-state responses (fig.~\ref{fig:f_point_detection}~B).




\subsection{Leaky Integrate-and-Fire Model}

% add info about simulation by euler integration and which time steps!
% show voltage dynamics with resistance : 

The above described cell characteristics need to be reproduced by a simple and efficient model to be able to simulate bigger populations in a reasonable time. The model used in this thesis follows these equations:

\begin{align}
	\tau_m \frac{dV}{dt} &= -V+I_{Bias} +\alpha V_{dend} - I_{A} + \sqrt{2D}\frac{\xi}{\sqrt{\Delta t}} \label{eq:full_model_dynamics_voltage} \\	
	\tau_A \frac{dI_A}{dt} &= -I_A + \Delta_A \sum \delta (t) \label{eq:full_model_dynamics_adaption} \\
	\tau_{dend} \frac{dV_{dend}}{dt} &= -V_{dend} + \lfloor V_{stim} \rfloor_0 \label{eq:full_model_dynamics_dendrite} 
\end{align}

Equation \ref{eq:full_model_dynamics_voltage} describes the leaky dynamics of the membrane voltage with $\tau_m$ the membrane time constant, $I_{Bias}$ a bias current, $\alpha$ the cell specific gain factor for $V_{dend}$ the input voltage coming from the dendrite. $\sqrt{2D}$ is the strength of the normal distributed noise $\xi$. $I_A$ is an adaption current with the dynamics of equation~\ref{eq:full_model_dynamics_adaption}. $\tau_A$ is the time constant of the adaption, $\Delta_A$ its strength and $\delta (t)$ is the spike train of the cell. Equation~\ref{eq:full_model_dynamics_dendrite} shows the dynamics of the synapse and dendrite with $\tau_{dend}$ the time constant of the dendrite and $\lfloor V_{stim} \rfloor_0$ the rectified stimulus given. Finally the model also includes a refractory period $t_{ref}$, not shown in above equations, that keeps the membrane voltage $V$ at zero for its duration.

To arrive at this proposed model the perfect integrate-and-fire (PIF) model was stepwise extended. The PIF is the simplest commonly used neuron model. Its voltage can be described in one equation: $\tau_m \frac{dV}{dt} = \frac{I}{R_m}$ with $I$ the stimulus current, $R_m$ the membrane resistance and a voltage threshold $V_\theta$. In this model $I$ is integrated and when this threshold $\theta$ is reached the voltage is reset to zero and a spike is recorded (see fig. \ref{fig:model_comparison} PIF). The model is useful for basic simulations but cannot reproduce the richer behavior of the P-units, as it has no memory of previous spikes so it cannot show any adaption behavior. It is also very strongly locked to its limit cycle producing very constant ISI, not allowing the firing flexibility of the P-units. 

The next slightly more complex model is the leaky integrate-and-fire (LIF) model:
\begin{equation}
	\tau_m \frac{dV}{dt} = -V + IR_m
	\label{eq:basic_voltage_dynamics}
\end{equation}
As the name suggests it adds a leakage current to the PIF (fig.~\ref{fig:model_comparison} LIF). The leakage current adds sub threshold behavior to the model and allows for some more flexibility in suprathresold firing but it is still not flexible enough and cannot reproduce the adaption.

To reproduce the adaption behavior the model needs some form of memory of previous spikes. There are two main ways this can be added to the model as an adaptive current or a dynamic threshold. The biophysical mechanism of the adaption in P-units is unknown because the cell bodies are not accessible for intra-cellular recordings. Following the results of \cite{benda2010linear} a negative adaptive current was chosen, because the dynamic threshold causes divisive adaption instead of the subtractive adaption of P-units seen in \cite{benda2005spike}. This results in an leaky integrate-and-fire model with adaption current (LIFAC) (fig.~\ref{fig:model_comparison} LIFAC). The added adaptive current follows the dynamics:

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

and gets subtracted from the input current $I$ of the voltage dynamics in equation~\ref{eq:basic_voltage_dynamics}. It is modelled as an exponential decay with the time constant $\tau_A$ and an adaption strength $\Delta_A$. $\Delta_A$ is multiplied with the sum of spikes $t_i$ in the spike train ($\delta (t_i)$) of the model cell. For the simulation using the Euler integration this results in an increase of $I_A$ by $\frac{\Delta_A}{\tau_A}$ at every time step where a spike is recorded. The input current $I$ from equation \ref{eq:basic_voltage_dynamics} is a sum of those two currents and an additional bias current $I_{Bias}$ that is needed to adjust the cells spontaneous spiking:

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

Note that in this P-unit model all currents are measured in mV because, as mentioned above, the cell body is not accessible for intra-cellular recordings and as such the membrane resistance $R_m$ is unknown. The input current $I_{Input}$ is the current of the stimulus, an amplitude modulated sine wave mimicking the frequency EOD. This stimulus is then rectified to model the receptor synapse and low-pass filtered with a time constant of $\tau_{dend}$ to simulate the low-pass filter properties of the dendrite (fig. \ref{fig:stim_development}) according to:
\begin{equation}
\tau_{dend} \frac{dV_{dend}}{dt} = -V_{dend} + \lfloor I_{Input} \rfloor_0
\end{equation}

Afterwards it is multiplied with $\alpha$ a cell specific gain factor. This gain factor has the unit of cm because the $I_{Input}$ stimulus represents the EOD with a unit of mV/cm.

Finally, noise and an absolute refractory period were added to the model. The noise $\xi$ is drawn from a Gaussian noise distribution and divided by $\sqrt{\Delta t}$ to get a noise which autocorrelation function is independent of the simulation step size $\Delta t$.  The implemented form of the absolute refractory period $t_{ref}$ keeps the model voltage at zero for the duration of $t_{ref}$ after a spike. This gives us the full model described in equations \ref{eq:full_model_dynamics_voltage}--\ref{eq:full_model_dynamics_dendrite}.

\begin{figure}[H]
\includegraphics{figures/model_comparison.pdf}
\caption{\label{fig:model_comparison} Comparison of different simple models normed to a spontaneous firing rate of ~10 Hz stimulated with a step stimulus. 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 but 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{figures/stimulus_development.pdf}
\caption{\label{fig:stim_development} The stimulus modification in the model. The fish's EOD is simulated with a sine wave. It is rectified at the synapse and then low-pass filtered in the dendrite.}
\end{figure}


\begin{table}[H]
\begin{tabular}{c|l|c}

 parameter & explanation & unit \\
 \hline
  $\alpha$   	&	stimulus scaling factor & [cm] \\
 $\tau_m$    	&	membrane time constant & [ms]\\
 $I_{Bias}$ 	& 	bias current & [mV] \\
 $\sqrt{2D}$ 	&	noise strength & [mV$\sqrt{\text{s}}$]\\
 $\tau_A$ 		&	adaption time constant & [ms] \\
 $\Delta_A$ 	&	adaption strength & [mVms]\\
 $\tau_{dend}$ 	& 	time constant of dendritic low-pass filter & [ms] \\
 $t_{ref}$ 		&	absolute refractory period & [ms]
\end{tabular}
\caption{\label{tab:parameter_explanation} Overview about all parameters of the model that are fitted.}
\end{table}



\subsection{Fitting of the Model}
%überleitung!
The full model has, as described above, eight parameters that need to be fit so it can reproduce the behavior of the cell. During the fitting and the analysis all models were integrated with at time step of 0.05\,ms.
The stimuli described in the stimulus protocols section above were recreated for the stimulation of the model during the fitting process. The pure fish EOD was approximated by a simple sine wave of the appropriate frequency, but it was decided to keep the amplitude of the sine wave at one to make the models more comparable. Changes in the amplitude can be compensated for by changing the input scaling factor so there is no qualitative difference.

During the fitting the baseline stimulus was simulated 3 times with 30\,s each and the step stimuli were simulated with a delay, step duration and recovery time of each 0.5\,s. The contrasts were the same as in the cell recordings. The step stimuli for the different contrasts were each repeated 8 times. The simulated data was analyzed in the same way as the cells (see above).

The error function was constructed from both the baseline characteristics: VS, CV, SC, ISI-histogram and burstiness and the f-I curve: the detections of $f_{inf}$ and $f_0$ responses for each contrast, the slope of the linear fit into the $f_{inf}$ and the frequency trace of one step response. 

The error of the VS, CV, SC, and burstiness was calculated as the scaled absolute difference:

\begin{equation}
err_i = c_i |x^M_i - x^C_i|
\end{equation}
with $x^M_i$ the model value for the characteristic $i$, $x^C_i$ the corresponding cell value and $c_i$ a scaling factor that is the same for all cells but different between characteristics. The scaling factor was used to make all errors a similar size. They are listed in table \ref{tab:scaling_factors}.

The error for the slope of the $f_{inf}$ fit was the scaled relative difference:

\begin{equation}
err_i = c_i|1 - ((x^M_i - x^C_i) / x^C_i)| 
\end{equation}

For the $f_{inf}$ and $f_0$ responses the average scaled difference of all contrasts was taken and finally the error for the ISI-histogram and the step-response was calculated with a mean-square error. For the histogram over all bins but for the step response only the first 50\,ms after stimulus onset as an error for the adaption time constant.  

\begin{equation}
err_i = c_i (\langle (x^M_i - x^C_i)²\rangle)
\end{equation}

\begin{table}[H]
\begin{tabular}{c|c}

 firing property & scaling factor \\
 \hline
 vector strength 	  		& 100 	\\
 coefficient of variation  	& 20  	\\
 serial correlation 		& 10  	\\
 ISI-histogram				& 1/600	\\
 $f_0$ detections 			& 0.1 	\\
 $f_{\infty}$ detections 	& 1	  	\\
 $f_\infty$ slope 			& 20  	\\
 $f_0$ step response		& 0.001
\end{tabular}
\caption{\label{tab:scaling_factors} Scaling factors for fitting errors.}
\end{table}

All errors were then summed up for the full error. The fits were done with the simplex algorithm from \cite{nelder1965simplex} implemented in the python package Scipy according to \cite{gao2012implementing}. All model variables listed above in table \ref{tab:parameter_explanation} were fit at the same time except for $I_{Bias}$. $I_{Bias}$ was determined before each fitting iteration and set to a value giving the correct baseline firing frequency within 2\,Hz. 

The parameters were constrained during fitting to reduce the search space and limit impossible values. The time constants $\tau_m$,  $\tau_A$, $\tau_{dend}$ were constrained to be larger than 1\,ms to keep the simulation stable with the integration step size of 0.05\,ms. $\alpha$, $\sqrt{2D}$, $\Delta_A$, $t_{ref}$ were constrained to be larger than 0 and $t_{ref}$ was also limited to be smaller than 1.05 times the EOD period.

The model was fit to each in vivo recording of a single P-unit with 12 different start parameters (tab. \ref{tab:start_parameter}). Of the resulting 12 fitted models the best was chosen for further analysis.  The resulting 67 fitted models were then filtered for $f_0$ slope above 50000 and a CV more than 33\% different from the cell value. This filtering removed 13 cell-model pairs. 11 were filtered by the CV requirement and 2 by the $f_0$ slope requirement. This left 54 fitted models for further analysis. 


\begin{table}[H]
\begin{tabular}{c|c|c}

 parameter & values & unit \\
 \hline
  $\alpha$   	&  80 & [cm] \\
 $\tau_m$    	&   1 & [ms]\\
 $\sqrt{2D}$ 	& 0.01 & [mV$\sqrt{\text{s}}$]\\
 $\tau_A$ 		&	20, 40  & [ms] \\
 $\Delta_A$ 		&	10, 30, 65 & [mVms]\\
 $\tau_{dend}$ 	&  2	 &[ms] \\
 $t_{ref}$ 		&	0.65, 1.2 & [ms]
\end{tabular}
\caption{\label{tab:start_parameter} Model parameter values used as start parameters during the fitting. Every combination was used resulting in a total of twelve parameter sets. $I_{Bias}$ has no start parameter as it is set during the fit iterations to match the baseline firing rate.}
\end{table}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RESULTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Results}

\subsection{Model Examples}

First the effect of the dendritic low-pass filter and the refractory period was investigated. This was done by fitting the model to three cells representing the continuously firing, weakly and strongly bursting cells, while removing the parameter to be investigated e.g. once without the low-pass filter and once without a refractory period (fig. \ref{fig:dend_ref_effect}). 

The model without the dendritic low-pass filter was able to fit the shape of the ISI histogram even for the strongly bursting cell but was not able to correctly match the height of the distribution. It has very thin peaks which show that this model locks very strongly to the phase of the EOD and cannot match the weaker locking of the cells (fig. \ref{fig:dend_ref_effect} A). 

When the refractory period of the model is disabled it can still match the ISI histogram of the continuously firing cell perfectly, but is not able to match the ISI histogram shape for the two bursting cells. These cells have more than one local maximum in their histogram: One at the first EOD period caused by the bursts and a second at a latter EOD period showing the times between bursts. The model without $t_{ref}$ is only able to produce a single maximum in their ISI histogram and cannot match the high firing probability at the first EOD period (fig. \ref{fig:dend_ref_effect} B).

The full model with both parameters can match both the shape and the height of the full ISI histogram for all three cells shown in figure \ref{fig:dend_ref_effect} C, but there are also cases in which the model fails to reproduce the ISI histogram of the cell (fig. \ref{fig:example_bad_isi_fits}). The cell A in figure \ref{fig:example_bad_isi_fits} shows a very strongly bursting cell. This cell has a very high peak at the first EOD period and there is some distance to the rest of the ISI distribution. This means that the cell has a few EOD periods in which it does not fire after a burst (compare fig. \ref{fig:heterogeneity_isi_hist} C). The fitted model fails at reproducing the long pauses between the bursts and in this case also shows a too low phase locking. In figure \ref{fig:example_bad_isi_fits} B the cell shows a high firing probability for the first two EOD periods after a spike and showing only afterwards the Gaussian-like firing probability distribution over multiple EOD periods of a continously firing cell. The fitted model does not show the high probability for the first two EOD periods. Instead it has only a high firing probability at the first EOD and a very low probability at the second EOD. 
The last cell shown in figure \ref{fig:example_bad_isi_fits} has a higher order structure in its ISI histogram. It has high firing probabilities only at every second EOD period starting at the fourth EOD. This higher order structure is not matched by the model. Instead it shows a continuously increasing firing probability for each EOD period up to the maximum and then decreases again - without being reduced every second EOD.

When comparing the f-I curves of the same three cells as (fig. \ref{fig:dend_ref_effect}) with the f-I curves of their fits shows good agreement for all three (fig. \ref{fig:example_good_fi_fits}), except the steady-state response of cell C, where the model shows a steeper slope. Note the miss-detections of the $f_0$ response in the negative contrasts of cell C influencing the fit of the Boltzmann function. The cells also demonstrate the variability of the cells in the strength of their response to the step stimuli.

All fitted models were again examined and representative failure cases are shown in figure \ref{fig:example_bad_fi_fits}. The fitted model in A overestimates the slope of the steady-state response and underestimates the frequency in the lower half of the onset response.
The second example of the problematic cases (fig. \ref{fig:example_bad_fi_fits} B) is a cell with a very high baseline firing rate where the model does not manage to reproduce the plateau the cell quickly reaches for positive contrasts. Instead the frequency of its onset response continues to increase above the possible range of one spike per EOD period.


\begin{figure}[H]
\centering
\includegraphics[trim={5mm 0mm 0mm 0mm}]{figures/dend_ref_effect.pdf}
\caption{\label{fig:dend_ref_effect} Effect of the dendritic filter and the refractory period on baseline firing. In each row data (blue) and model fits (orange) to three example cells are shown. These cells differ in their burstiness as indicated on the left. Top: cell 2012-12-21-am, r=135\,Hz, b=0.02\,\%ms; center: cell 2014-03-19-ad-invivo-1, r=237\,Hz b=1.69\,\%ms; bottom:  cell 2014-03-25-aa r=204\,Hz, b=1.9\,\%ms
\textbf{A}: Without dendritic filter ($\tau_{dend}$) the spikes are too strongly locked to the EOD, resulting in very high vector strength and too narrow peaks in the baseline ISI histogram. \textbf{B}: Without refractory period ($t_{ref}$) the model cannot capture the burstiness. While this is no problem for the non-bursting cell (top),  the peak in the ISI histogram at one EOD period cannot be reproduced without refractory period. \textbf{C}: With both the dendritic filter and the refractory period ISI histograms can be faithfully reproduced  for all three cells.}
\end{figure}


\begin{figure}[H]
\includegraphics{figures/example_bad_isi_hist_fits.pdf}
\caption{\label{fig:example_bad_isi_fits} Problem cases in which the model ISI histogram was not fitted correctly. \textbf{A}: (cell 2014-06-06-ag r=117\,Hz , b=3.9) Strongly bursting cell with large pauses between bursts, where the model does not manage to reproduce the long pauses. \textbf{B}: (cell 2018-05-08-ab r=112\,Hz , b=2.8) Bursting cell with a high probability of firing in the first and second following EOD period. Here the model can not reproduce the high probability on the second following EOD period. \textbf{C}: (cell 2014-12-11-ad rate=50\,Hz, b=0) Cell with a higher order structure in its ISI histogram. It only has a high firing probability every second EOD period which is not represented in the model.}
\end{figure}


\begin{figure}[H]
\includegraphics{figures/example_good_fi_fits.pdf}
\caption{\label{fig:example_good_fi_fits} Good fit examples of the f-I curves. The red line the fitted Boltzmann function and blue line the linear fit for the cell's $f_0$ and $f_\infty$ response respectively. \textbf{A}: cell 2012-12-21-am r=135\,Hz, EODf=806\,Hz; \textbf{B}: cell 2014-03-19-ad-invivo-1 r=237\,Hz, EODf=658\,Hz; \textbf{C}: cell 2014-03-25-aa r=204\,Hz, EODf=870\,Hz. The cells show different response strengths to the contrasts. Which are all well matched by their models.}
\end{figure}

\begin{figure}[H]
\includegraphics{figures/example_bad_fi_fits.pdf}
\caption{\label{fig:example_bad_fi_fits} Examples of bad fits of the f-I curves. The red line the fitted Boltzmann function and blue line the linear fit for the cell's $f_0$ and $f_\infty$ response respectively. \textbf{A}: (cell 2012-12-13-ao r=146\,Hz, EODf=657\,Hz) Model that did not fit the negative contrast responses of the $f_0$ response well but was successful in the positive half. It also was not successful in the $f_\infty$ response and shows a too steep slope. \textbf{B}: (cell 2014-01-23-ab r=431\,Hz, EODf=775\,Hz) A fit that was successful for the lower $f_0$ response but overshoots the limit of one spike per EOD period. It also has a slightly too steep $f_\infty$ response slope.}
\end{figure}


\subsection{Population Comparison}

The general fitting quality was inspected by comparing the distributions in firing behavior between cells and fitted models as well as directly comparing each cell and its respective model. The baseline rate was matched perfectly (fig. \ref{fig:comp_baseline} A) because it was set to be equal within 2\,Hz during the fitting procedure by adjusting the bias current $I_{Bias}$ appropriately. Its approximately log-normal distribution was in the expected range of around 50--400\,Hz of the literature \citep{gussin2007limits}. 

The vector strength (VS) was matched quiet well. Many cells have a VS of around 0.85 and with a few cells having a VS as low as 0.5. The fitted models show the same range of VSs but for cells with a VS above 0.8, the models are often underestimating the true VS.

The models failed to fit the full breadth of the serial correlation (SC) shown by the cells, that have serial correlations between -0.8-- -0.1. The fits fail to match the strong negative SCs, reducing the range on the lower end to -0.7. The fits of the SC also show a high variability. 

\begin{figure}[H]
\makebox[\textwidth][c]{\includegraphics{figures/fit_baseline_comparison.pdf}}
\caption{\label{fig:comp_baseline} Comparison of baseline firing properties between cells and their corresponding fits. The histograms on top compare the distributions of the n= 54 cells in blue and their respective models in orange. The scatter plot at the bottom directly compares them. Points on the identity line (grey) indicate perfect model predictions. \textbf{A}: The baseline firing rate of the cell and the model. The base rate agrees near perfectly as it is set to be equal within a margin of 2\,Hz during the fitting process. \textbf{B}: The vector strength agrees well for most cells but for some cells with a VS above 0.8 the models to show a weaker VS than the cell. \textbf{C}: The models fail to show the same strong negative SC at lag 1. This effect gets stronger the more the SC deviates from -0.4.}
\end{figure}


The last two baseline firing behaviors are the burstiness and the coefficient of variation (CV) and both were fit quite similar, because both are correlated as shown below in figure \ref{fig:behavior_correlations} and by the color coding by the computed cell burstiness of the scatter plot (fig. \ref{fig:comp_burstiness}). The model fits lower half of them well but does not manage to match the high values, where it consistently underestimates the corresponding value.
The cells' burstiness distribution has two peaks: the continuously firing cells around 0 and the bursting cells around 2. These two main peaks are still fit quite well but the rare very strongly bursting cell is not matched by the model. But this may be an artifact of how burstiness was defined here, as the ISI histograms seem to contain a full continuum between regular firing as seen in fig. \ref{fig:heterogeneity_isi_hist} A and the strongly bursting cells as in C. The covariance is distributed more evenly but still shows the two peaks seen in the burstiness measure.

\begin{figure}[H]
\includegraphics{figures/fit_burstiness_comparison.pdf}
\caption{\label{fig:comp_burstiness}  Comparison of baseline firing properties between cells and their corresponding fits. The histograms on top compare the distributions of the n= 54 cells in blue and their respective models in orange. The scatter plot at the bottom directly compares them. Points on the identity line (grey) indicate perfect model predictions. The points are colored by the cell's burstiness. \textbf{A}: The model values for the burstiness agree well with the values of the model but again show a tendency that the higher the value of the cell the more the model value is below it. \textbf{B}: The CV also shows the problem of the burstiness but the values drift apart more slowly starting around 0.6. The colouring of the points indicates the correlation between burstiness and CV (shown below).}
\end{figure}


The models were able to fit the steady-state response of the cells very well (\ref{fig:comp_adaption} A), with some fluctuations but no strong bias in one direction. Most cells react to a 10\% increase in EOD amplitude with around an increase of their firing frequency of around 40\,Hz.
The fit of the onset response characterized by the slope of the Boltzmann function shows very strong fluctuations which make an accurate judgment difficult, as even with these large differences the quality of the model is still often decent.

\begin{figure}[H]
\includegraphics{figures/fit_adaption_comparison.pdf}
\caption{\label{fig:comp_adaption}  Comparison of adaption properties between cells and their corresponding fits. The histograms on top compare the distributions of the n=54 cells in blue and their respective models in orange. The scatter plot at the bottom directly compares them. Points on the identity line (grey) indicate perfect model predictions. \textbf{A}: The $f_\infty$ slope pairs show good agreement with mostly low scattering in both direction. \textbf{B}: The $f_0$ values show a higher spread and for steeper slopes the models have more often too flat slopes.}
\end{figure}

Given the differences between the cell firing properties and the ones of the model the correlations were calculated and show differences (fig. \ref{fig:behavior_correlations}). Of the seven correlations found in the data set the fitted models show a correlation for all but the correlation between the VS and baseline firing rate, but the models also show four additional correlations. These are between the base rate and the $f_0$ slope, base rate and burstiness, base rate and SC and finally between SC and $f_\infty$ slope.  

Before the parameter distributions (fig. \ref{fig:parameter_distributions}) and correlations (fig. \ref{fig:parameter_correlations}) of the model parameters were closer investigated, the potential influence of the different EOD frequencies was removed by scaling the time dependent parameters for all models. This was done by calculating the factor between the fish's EOD frequency and the chosen EOD frequency of 800\,Hz and then multiplying all time parameters appropriately to their dependence with the factor. These scaled parameter distributions are shown in figure \ref{fig:parameter_distributions}. With these scaled distributions the correlations between the parameters were computed giving the matrix in figure \ref{fig:parameter_correlations}, it shows extensive correlations between most parameters. The correlations indicate that the parameter can compensate for each other and that the model can produce similar firing properties for different parameter sets. A notable exception is the refractory period $t_{ref}$ which is independent of all other parameters and could as such be the only variable influencing the burstiness in this model. 




\begin{figure}[H]
\includegraphics{figures/behaviour_correlations.pdf}
\caption{\label{fig:behavior_correlations} Significant correlations between the firing properties in the data and the fitted models (Significance $p < 0.05$ Bonferroni corrected). The models contain all the same correlations as the data except for the correlation between the baseline firing rate and the VS, but they also show four additional correlations not seen within the cells: bursting - base rate, SC - $f_\infty$ slope, $f_0$ slope - base rate, SC - base rate.}
\end{figure}



\begin{figure}[H]
\includegraphics{figures/scaled_to_800_parameter_distributions.pdf}
\caption{\label{fig:parameter_distributions} Distributions of all eight model parameters with the time scaled for all models so their driving EOD frequency has 800\,Hz. \textbf{A}: input scaling $\alpha$, \textbf{B}: Bias current $I_{Bias}$, \textbf{C}: membrane time constant $\tau_m$, \textbf{D}: noise strength $\sqrt{2D}$, \textbf{E}: adaption time constant $\tau_A$, \textbf{F}: adaption strength $\Delta_A$, \textbf{G}: time constant of the dendritic low pass filter $\tau_{dend}$, \textbf{H}: refractory period $t_{ref}$}
\end{figure}

\begin{figure}[H]
\includegraphics{figures/parameter_correlations.pdf}
\caption{\label{fig:parameter_correlations} Correlations between model parameters (Significance $p < 0.05$ Bonferroni corrected). The model parameters show many correlations between each other indicating strong compensatory effects where multiple parameter sets can lead to the same firing properties. The only parameter without correlations to any other is $t_{ref}$ showing a certain independence compared to the other parameters.}
\end{figure}


\subsection{Random Model Population}

Finally the scaled parameter distributions of the fitted models were used to compute a representative multivariate normal space out of which random parameter sets for the model could be drawn. 
Each parameter distribution was fit by Gaussian function and then tweaked by hand to remove overly wide Gaussian fits that would produce many parameters outside of the observed distributions (fig. \ref{fig:parameter_dist_with_gauss_fits}). The standard deviation of the fits and the calculated correlations between the parameters were used to compute the covariances. The covariances and the means of the Gaussian fits were then used to compute the multivariate normal space. 

\begin{figure}[H]
\includegraphics{figures/parameter_distribution_with_gauss_fits.pdf}
\caption{\label{fig:parameter_dist_with_gauss_fits} Gaussian fits (black) used as approximations for the parameter distributions. All parameters except for $t_{ref}$ and $I_{Bias}$ were log transformed to get a more Gaussian-like distribution. \textbf{A}: Logarithmic input scaling $\alpha$, \textbf{B}: bias current $I_{Bias}$, \textbf{C}: Logarithmic membrane time constant $\tau_m$, \textbf{D}: Logarithmic noise strength $\sqrt{2D}$, \textbf{E}: Logarithmic adaption time constant $\tau_A$, \textbf{F}: Logarithmic adaption strength $\Delta_A$, \textbf{G}: Logarithmic time constant of the dendritic low-pass filter $\tau_{dend}$, \textbf{H}: refractory period $t_{ref}$.}
\end{figure}
\newpage

100 parameter sets were drawn and their distribution and correlation compared to the parameters of fitted models to verify the drawing. The distributions depicted in figure \ref{fig:drawn_parameter_dist} are for most parameters in good agreement. The distributions of the input scaling $\alpha$ and the adaption strength $\Delta_A$ are a bit shifted from the reference distribution and the distribution of the bias current $I_{Bias}$ does not show the tail towards negative values. The correlations also show differences even though they are part of the computation of the multivariate normal space. The drawn parameter sets have three missing and one additional correlation. The missing correlations are between $\tau_{dend}$ and $\sqrt{2D}$, $\tau_{dend}$ and $\Delta_A$ and $\tau_A$ and $\alpha$, while the correlation between $\alpha$ and $\tau_m$  was only found in the drawn parameter sets. This calculation was repeated a few times during the analysis and these four correlations were inconsistent in the drawn models indicating they may not be well defined in the calculated covariances.

Even with these differences the firing property distributions (fig. \ref{fig:drawn_behavior_dist}) shown by the random models show large overlaps. The baseline firing rate distribution of the random models show that there are too few models with low firing rates and the distribution also has a long tail up too 800\,Hz which does not match the cells. The serial correlation distribution is shifted towards weaker negative correlations. The worst fit distribution is the VS where the random models have a nearly distinct distribution compared to the cells with lower VS.  

\begin{figure}[H]
\includegraphics{figures/rand_parameter_correlations_comparison.pdf}
\caption{\label{fig:drawn_parameter_corr} Parameter correlation comparison between the fitted parameters and the ones drawn from the multivariate normal distribution. There are four correlations that do not agree between the two, but those are inconsistent in the drawn models (see discussion).}
\end{figure}


\begin{figure}[H]
\includegraphics{figures/compare_parameter_dist_random_models.pdf}
\caption{\label{fig:drawn_parameter_dist} Parameter distribution between randomly drawn models (gray) and the fitted ones (orange).  \textbf{A}: input scaling $\alpha$, randomly drawn parameters are shifted to higher values. \textbf{B}: Bias current $I_{Bias}$ doesn't match the long tail into the negative. \textbf{C}: membrane time constant $\tau_m$, \textbf{D}: noise strength $\sqrt{2D}$, \textbf{E}: adaption time constant $\tau_A$, \textbf{F}: adaption strength $\Delta_A$, \textbf{G}: time constant of the dendritic low-pass filter $\tau_{dend}$, \textbf{H}: refractory period $t_{ref}$.}
\end{figure}



\begin{figure}[H]
\includegraphics{figures/random_models_behaviour_dist.pdf}
\caption{\label{fig:drawn_behavior_dist} Distribution of firing properties from randomly drawn models (orange) and the original cells (blue). The distribution of the seven firing properties agree well, but especially the vector strength (VS) in \textbf{C} is offset to the distribution seen in the cells and shows manly lower values and the burstiness and SC are also slightly offset.}
\end{figure}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%DISCUSSION   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\newpage
\section{Discussion}

In this thesis a simple model based on the leaky integrate-and-fire (LIF) model was developed to allow the simulation of a neuron population that correctly represents the heterogeneity of P-units in the electrosensory pathway of the electric fish \textit{A. leptorhynchus}. The LIF model was extended by an adaption current, a refractory period and simulated the input synapses by rectifying and low-pass filtering the input current, building on the model proposed by \cite{walz2013Phd}. This model was then fit to in vivo recordings of single P-units characterized by seven firing properties and the resulting models were compared to their respective reference cell. Additionally estimates of the distributions and covariances of the model parameters were used to draw random parameter sets. Simulations of these generated populations were compared with the data.
The previously proposed model by \cite{walz2013Phd} was limited to only non bursting P-units, but the extension allows now also the simulation of bursting neurons. The model proposed by \cite{chacron2001simple} also models the P-units with a extended LIF neuron but uses a dynamic threshold to add the negative ISI correlation, instead of an adaption current as used here. This causes the the neuron to display divisive adaption \citep{benda2010linear} instead of the substractive adaption shown in P-units \citep{benda2005spike}. Their model was also only shown for one representative neuron of bursting non-bursting cells. 

\subsection{Model fit}

The dendritic low-pass filter and the refractory period were necessary for the model to match the firing behavior of the P-units (fig. \ref{fig:dend_ref_effect}). As \cite{walz2013Phd} demonstrated a model without the low-pass filter is not able to match the VS and locks too strongly to the EOD. A refractory period $t_{ref}$ is necessary for the model to deviate from the ISI histogram shown by continuously firing P-units (fig. \ref{fig:heterogeneity_isi_hist} D) and show bursting behavior and is flexible enough to match different strengths of burstiness.

With these additions the behavior of the cells was generally matched well by the models with very similar final distributions of the firing properties but there were some limitations. The model failed to reproduce cells with a very high burstiness (long bursts with long pauses between) and as such a high coefficient of variation could not fully be matched by the model (fig.~\ref{fig:comp_burstiness}). The example of fig. \ref{fig:example_bad_isi_fits} A is a case where the model can show this type of firing behavior (long bursts and pauses) yet it seems difficult to reach the parameter configuration needed with the fitting approach used. In contrast to this, the firing behavior of the cells in fig. \ref{fig:example_bad_isi_fits} B and C are not possible for the model in its current form. The addition of the refractory period $t_{ref}$ does not also allow for an increased firing probability at the 2nd EOD period and the cell C shows a higher order structure in its ISI histogram on a comparatively long timescale which the proposed simple model cannot reproduce. These kind of cells showing higher order structure in their ISI histogram are rare but might provide interesting insights in the physiological properties of P-units when further studied.

Two firing properties had a high spread in the fitted models. In the serial correlation the models had some tendency to underestimate the cell's SC. The second property was the slope of the $f_0$ response. Here one possible source is that the fitted Boltzmann function and its slope are quite sensitive to miss-detections of spikes. A wrong estimate of the firing frequency for a single contrast can strongly influence the slope of the fitted Boltzmann function. Unlike the baseline firing properties there do not seem to be cases in which the model cannot fit the f-I curves. The problematic cases shown in figure \ref{fig:example_bad_fi_fits} are both generally possible (fig. \ref{fig:example_good_fi_fits}) so improvements in the cost function and fitting routine should also further improve the model consistency for the adaption responses. 

Comparing the correlation between the firing properties of the data and the models clear discrepancies could be seen, (fig. \ref{fig:behavior_correlations}) with four additional and one missing significant correlation. The added correlation between bursts and baseline firing rate could be a result of the slightly stronger correlations between CV and base rate and between bursts and CV. The difficulties of the model to fit strongly bursting cells with a long pause between bursts could also have introduced this correlation as these cells would show high burstiness and a low firing rate. The correlation between $f_0$ slope and base rate might also be caused by a slight increase in the correlations between $f_\infty$ slope and base rate and $f_\infty$ slope and $f_0$ slope. The other two added correlations are between the SC and the base rate as well as the $f_\infty$ slope, where the former may again have caused the latter because of the correlation between $f_\infty$ and base rate.
Finally the one missing correlation in the models is the one between base rate and VS, which is an unexpected correlation.  
This was also looked at in \cite{walz2013Phd}, but only 23 exclusively non bursting cells were used, which makes a direct comparison difficult. The data there shows the correlation between SC and base rate which is shown by the models in this work. This might indicate that the highest bursting cells that are not fitted well remove this correlation from the population in the data or that there is not enough data to robustly define the correlation.

The parameters of the fitted models also show extensive correlations between each other. This is an indication of strong compensation effects between them \citep{olypher2007using}. Which is especially clear for the input gain $\alpha$ and the bias current $I_{Bias}$ that have a nearly perfect correlation and control the models baseline firing rate together. Note that the refractory period $t_{ref}$ is the only completely independent variable. This might show a certain independence between the strength of the burstiness and the other firing characteristics, which could be more closely investigated by looking at the sensitivity of models firing properties to changes in $t_{ref}$.

\subsection{Heterogeneous Population}

The correlations and the estimated parameter distributions were used in form of their covariances to draw random parameter sets from a multivariate normal distribution. The drawn parameters show the expected distributions but different correlations. That could mean that the 54 models used to calculate them were to few to give enough statistical power for the correct estimation of all correlations. Drawing more models and compensating for the increase in power showed that the involved correlations stay inconsistent, which points to an uncertainty already in the measured covariance matrix of the data. This could be further investigated with a robustness analysis estimating the reliability of the computed covariances. 

The firing behavior shown by the drawn models on the other hand fits the ones of the data quite well except for the VS, where it is consistently underestimating the VS of the data.

\subsection{Conclusion}

In general the model is the first that takes the burstiness as a continuum into account and is able to accurately describe the firing behavior in a large part of the behavior space of the P-units. But further testing is required to get a clearer picture where and why discrepancies exist. An important next step is the verification of the models with a different type of stimulus. For this a stimulus with random or sinusoidal amplitude modulations could be used. The correlations also need further investigation. As a first step a robustness test could be done to estimate if there are correlations that are not well characterized in both the cells and the models. 

The coding properties of bursting and non-bursting neurons differ as well as their means of decoding \citep{chacron2004burst}. That means the full breadth of neuron types is important to get a accurate image of what and how information is encoded in a heterogeneous population. But this type of research is not possible in vivo because it is not possible to record intracellularly from so many neurons at once. The proposed model allows the simulation of such a heterogenic population, allowing researchers to investigate whether or why heterogenic population are necessary to encode behaviorally relevant stimuli and which type of cells encode for which parts of them. 


\newpage
\bibliography{citations} 
\bibliographystyle{apalike}


\end{document}