fiddle with figures

This commit is contained in:
a.ott 2020-09-11 17:22:39 +02:00
parent 3c06be9917
commit f5141a0760
11 changed files with 84 additions and 107 deletions

View File

@ -1,7 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from analysis import get_fit_info, get_behaviour_values, get_parameter_values, behaviour_correlations, parameter_correlations
from analysis import get_filtered_fit_info, get_behaviour_values, get_parameter_values, behaviour_correlations, parameter_correlations
from ModelFit import get_best_fit
from Baseline import BaselineModel, BaselineCellData
import Figure_constants as consts
@ -20,12 +20,12 @@ behaviour_titles = {"baseline_frequency": "base rate", "Burstiness": "Burst", "c
def main():
dir_path = "results/final_2/"
fits_info = get_fit_info(dir_path)
# cell_behaviour, model_behaviour = get_behaviour_values(fits_info)
# plot_cell_model_comp_baseline(cell_behaviour, model_behaviour)
# plot_cell_model_comp_adaption(cell_behaviour, model_behaviour)
# plot_cell_model_comp_burstiness(cell_behaviour, model_behaviour)
fits_info = get_filtered_fit_info(dir_path)
print("Cells left:", len(fits_info))
cell_behaviour, model_behaviour = get_behaviour_values(fits_info)
plot_cell_model_comp_baseline(cell_behaviour, model_behaviour)
plot_cell_model_comp_adaption(cell_behaviour, model_behaviour)
plot_cell_model_comp_burstiness(cell_behaviour, model_behaviour)
#
behaviour_correlations_plot(fits_info)
#
@ -45,8 +45,6 @@ def main():
# example_good_hist_fits(dir_path)
def create_parameter_distributions(par_values):
fig, axes = plt.subplots(4, 2)
@ -105,7 +103,7 @@ def create_correlation_plot(ax, labels, correlations, p_values, title, y_label=T
if abs(p_values[i, j]) < 0.05:
cleaned_cors[i, j] = correlations[i, j]
im = ax.imshow(cleaned_cors, vmin=-1, vmax=1)
im = ax.imshow(correlations, vmin=-1, vmax=1)
# We want to show all ticks...
ax.set_xticks(np.arange(len(labels)))
@ -126,8 +124,12 @@ def create_correlation_plot(ax, labels, correlations, p_values, title, y_label=T
# Loop over data dimensions and create text annotations.
for i in range(len(labels)):
for j in range(len(labels)):
text = ax.text(j, i, "{:.2f}".format(correlations[i, j]),
ha="center", va="center", color="w")
if p_values[i][j] < 0.0001:
text = ax.text(j, i, "***", ha="center", va="center", color="b")
elif p_values[i][j] < 0.001:
text = ax.text(j, i, "**", ha="center", va="center", color="b")
elif p_values[i][j] < 0.05:
text = ax.text(j, i, "*", ha="center", va="center", color="b")
return im

View File

@ -15,10 +15,7 @@ def get_best_fit(folder_path, use_comparable_error=False):
min_err = np.inf
min_item = ""
for item in os.listdir(folder_path):
item_path = os.path.join(folder_path, item)
if use_comparable_error:
err = ModelFit(item_path).comparable_error()
else:
item_path = os.path.join(folder_path, item + "/")
err = ModelFit(item_path).get_fit_routine_error()
if err < min_err:
min_err = err
@ -92,9 +89,6 @@ class ModelFit:
else:
raise FileNotFoundError("Isi-histogram image is missing. - " + self.path)
def get_error_value(self):
return self.path.split("_")[-1]
def get_model(self):
return LifacNoiseModel(self.get_final_parameters())
@ -124,52 +118,11 @@ class ModelFit:
return np.load(path)
def get_fit_routine_error(self):
foldername = os.path.basename(self.path)
parts = foldername.split("_")
return float(parts[-1])
def comparable_error(self):
cell_values, model_values = self.get_behaviour_values()
error = 0
bf = "baseline_frequency"
error += abs(cell_values[bf] - model_values[bf]) / 5
vs = "vector_strength"
error += abs(cell_values[vs] - model_values[vs]) / 0.1
sc = "serial_correlation"
error += abs(cell_values[sc] - model_values[sc]) / 0.1
burst = "Burstiness"
error += abs(cell_values[burst] - model_values[burst]) / 0.05
cv = "coefficient_of_variation"
error += abs(cell_values[cv] - model_values[cv]) / 0.1
f_inf_slope = "f_inf_slope"
error += abs(cell_values[f_inf_slope] - model_values[f_inf_slope]) / 5
# f_zero_sloe = "f_zero_slope"
# error += abs(cell_values[f_zero_sloe] - model_values[f_zero_sloe]) / 100
c_f_inf_values = self.get_cell_f_inf_values()
c_f_zero_values = self.get_cell_f_zero_values()
m_f_inf_values = self.get_model_f_inf_values()
m_f_zero_values = self.get_cell_f_zero_values()
error_f_inf = 0
for m_value, c_value in zip(m_f_inf_values, c_f_inf_values):
error_f_inf += abs(c_value - m_value) / 10
error_f_inf = error_f_inf / len(m_f_inf_values)
error += error_f_inf
error_f_zero = 0
for m_value, c_value in zip(m_f_zero_values, c_f_zero_values):
error_f_zero += abs(c_value - m_value) / 10
error_f_zero = error_f_zero / len(m_f_zero_values)
error += error_f_zero
return error
path_parts = self.path.split("/")
if len(path_parts[-1]) != 0:
return float(path_parts[-1].split("_")[-1])
else:
return float(path_parts[-2].split("_")[-1])
def generate_master_plot(self, save_path=None):
model = self.get_model()
@ -230,7 +183,7 @@ class ModelFit:
axes[1].set_title("cell model comparision")
axes[1].set_xlabel("Stimulus value - contrast")
axes[1].legend()
# comparision of f_zero_curve:
# comparison of f_zero_curve:
max_contrast = max(contrasts)
test_contrast = 0.5 * max_contrast
@ -278,7 +231,7 @@ class ModelFit:
axes[3].axis('tight')
axes[3].axis('off')
table = axes[3].table(cellText=clust_data, colLabels=collabel, rowLabels=("cell", "model"), loc='center')
fig.suptitle(cell.get_cell_name() + "_comp_err: {:.2f}".format(self.comparable_error()))
fig.suptitle(cell.get_cell_name() + "_err: {:.2f}".format(self.get_fit_routine_error()))
plt.tight_layout()
if save_path is None:
plt.show()

View File

@ -28,7 +28,7 @@ def main():
behaviour_keys = ["Burstiness", "coefficient_of_variation", "serial_correlation",
"vector_strength", "f_inf_slope", "f_zero_slope", "baseline_frequency"]
fits_info = get_fit_info(dir_path)
fits_info = get_filtered_fit_info(dir_path)
total_fits = len(fits_info)
cell_behaviour, model_behaviour = get_behaviour_values(fits_info)
@ -48,7 +48,7 @@ def main():
pass
def get_fit_info(folder):
def get_filtered_fit_info(folder):
fits_info = {}
for item in os.listdir(folder):
@ -56,6 +56,17 @@ def get_fit_info(folder):
results = get_best_fit(cell_folder, use_comparable_error=False)
cell_behaviour, model_behaviour = results.get_behaviour_values()
# filter:
if cell_behaviour["f_zero_slope"] > 50000:
print("cell with too high f_zero_slope. cell_folder:", cell_folder)
if model_behaviour["f_zero_slope"] > 50000 or cell_behaviour["f_zero_slope"] > 50000:
print("f_zero_slope used to filter a fit")
continue
if 1 - abs(model_behaviour["f_inf_slope"] - cell_behaviour["f_inf_slope"]) > 0.1:
print("f_inf_slope used to filter a fit")
continue
fits_info[item] = [results.get_final_parameters(), model_behaviour, cell_behaviour]
return fits_info

View File

@ -5,6 +5,11 @@ Babineau, D., Lewis, J.~E., and Longtin, A. (2007).
\newblock Spatial acuity and prey detection in weakly electric fish.
\newblock {\em PLoS Computational Biology}, 3(3):e38.
\bibitem[Bastian, 1981]{bastian1981electrolocation}
Bastian, J. (1981).
\newblock Electrolocation.
\newblock {\em Journal of comparative physiology}, 144(4):465--479.
\bibitem[Benda et~al., 2005]{benda2005spike}
Benda, J., Longtin, A., and Maler, L. (2005).
\newblock Spike-frequency adaptation separates transient communication signals
@ -45,6 +50,12 @@ Maciver, M.~A., Sharabash, N.~M., and Nelson, M.~E. (2001).
effects of water conductivity.
\newblock {\em Journal of experimental biology}, 204(3):543--557.
\bibitem[Ratnam and Nelson, 2000]{ratnam2000nonrenewal}
Ratnam, R. and Nelson, M.~E. (2000).
\newblock Nonrenewal statistics of electrosensory afferent spike trains:
implications for the detection of weak sensory signals.
\newblock {\em Journal of Neuroscience}, 20(17):6672--6683.
\bibitem[Scheich et~al., 1973]{scheich1973coding}
Scheich, H., Bullock, T.~H., and Hamstra~Jr, R. (1973).
\newblock Coding properties of two classes of afferent nerve fibers:

View File

@ -1,46 +1,46 @@
This is BibTeX, Version 0.99d (TeX Live 2017/Debian)
Capacity: max_strings=100000, hash_size=100000, hash_prime=85009
This is BibTeX, Version 0.99d (TeX Live 2015/Debian)
Capacity: max_strings=35307, hash_size=35307, hash_prime=30011
The top-level auxiliary file: Masterthesis.aux
The style file: apalike.bst
Database file #1: citations.bib
You've used 13 entries,
You've used 15 entries,
1935 wiz_defined-function locations,
566 strings with 6261 characters,
and the built_in function-call counts, 5413 in all, are:
= -- 541
> -- 218
< -- 3
+ -- 74
- -- 72
* -- 504
:= -- 943
add.period$ -- 39
call.type$ -- 13
change.case$ -- 100
chr.to.int$ -- 13
cite$ -- 13
duplicate$ -- 180
empty$ -- 379
format.name$ -- 89
if$ -- 1033
580 strings with 6551 characters,
and the built_in function-call counts, 6198 in all, are:
= -- 623
> -- 238
< -- 5
+ -- 80
- -- 78
* -- 574
:= -- 1075
add.period$ -- 45
call.type$ -- 15
change.case$ -- 113
chr.to.int$ -- 15
cite$ -- 15
duplicate$ -- 208
empty$ -- 441
format.name$ -- 99
if$ -- 1187
int.to.chr$ -- 1
int.to.str$ -- 0
missing$ -- 12
newline$ -- 68
num.names$ -- 39
pop$ -- 73
missing$ -- 14
newline$ -- 78
num.names$ -- 45
pop$ -- 80
preamble$ -- 1
purify$ -- 101
purify$ -- 114
quote$ -- 0
skip$ -- 133
skip$ -- 155
stack$ -- 0
substring$ -- 460
swap$ -- 13
substring$ -- 540
swap$ -- 15
text.length$ -- 0
text.prefix$ -- 0
top$ -- 0
type$ -- 78
type$ -- 90
warning$ -- 0
while$ -- 49
while$ -- 57
width$ -- 0
write$ -- 171
write$ -- 197

Binary file not shown.

View File

@ -95,6 +95,8 @@ Außerdem erkläre ich, dass die eingereichte Arbeit weder vollständig noch in
\item update the colors in all plots to be consistent.
\item make plot labels consistent (Units: in mV vs [mV])
\item update number of cells / fish etc
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -142,10 +144,8 @@ Außerdem erkläre ich, dass die eingereichte Arbeit weder vollständig noch in
The environment of an organism holds important information that it needs to survive. Information about predators to avoid, food to find and potential mates. That means that 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. \todo{ref} suggested already 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 perception and signal encoding is the electric fish \AptLepto
\todo{path to electric fish: good as a model system with electric sense}
The electric fish \AptLepto (Brown ghost knife fish) generate a sinusoidal electric field with the electric organ in their tail enabling them to use active electroreception which they use to find prey and communicate with each other (\cite{maciver2001prey}, \cite{zupanc2006electric}). The different use cases of this electric organ discharge (EOD) come with the necessity to detect a wide range of different amplitude modulations (AMs). Electrolocation of object 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.
One interesting model system for questions of perception and adaptive signal processing is the electric fish \AptLepto (Brown ghost knife fish).
\lepto generate a sinusoidal electric field with the electric organ in their tail enabling them to use active electroreception which they use to find prey and communicate with each other (\cite{maciver2001prey}, \cite{zupanc2006electric}). The different use cases of this electric organ discharge (EOD) come with the necessity to detect a wide range of different amplitude modulations (AMs). Electrolocation of object 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 have 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 but 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 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).
@ -167,7 +167,7 @@ When the fish's EOD is unperturbed P units fire every few EOD periods but they h
\todo{heterogeneity more}
Furthermore show P units a pronounced heterogeneity in their spiking behavior (fig.~\ref{fig:heterogeneity_isi_hist}, \cite{gussin2007limits}). This is an important aspect one needs to consider when trying to understand what and how information is encoded in the spike trains of the neuron. 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 while a single neuron only encodes a small feature space. This type of encoding is ubiquitous in the nervous system and is used in the visual sense for color vision, PLUS MORE... \todo{refs}. Even though P units were already modelled based on a simple leaky integrate-and-fire neuron \citep{chacron2001simple} and conductance based \citep{kashimori1996model} and well studied (\todo{refS}), but up to this point there 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, allow researchers gain a better picture how higher brain areas might process the information and get one step closer to the full path between sensory input and behavioural output.
Furthermore show P units a pronounced heterogeneity in their spiking behavior (fig.~\ref{fig:heterogeneity_isi_hist}, \cite{gussin2007limits}). This is an important aspect one needs to consider when trying to understand what and how information is encoded in the spike trains of the neuron. 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 used in the visual sense for color vision, PLUS MORE... \todo{refs}. Even though P units were already modelled based on a simple leaky integrate-and-fire neuron \citep{chacron2001simple} and conductance based \citep{kashimori1996model} and well studied (\cite{bastian1981electrolocation}, \cite{ratnam2000nonrenewal} \cite{benda2005spike}). There is up to this point 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, allow researchers gain a better picture how higher brain areas might process the information and get one step closer to the full path between sensory input and behavioral output.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 29 KiB