metadata analysis and fi_curve testing

This commit is contained in:
a.ott 2020-08-22 15:53:00 +02:00
parent cb74838326
commit 96e9d744bb
9 changed files with 146 additions and 50 deletions

View File

@ -111,6 +111,16 @@ class DatParser(AbstractParser):
type = metadata["Cell"]["CellType"]
return type
def get_fish_size(self):
size = ""
for metadata in Dl.load(self.info_file):
if "Species" in metadata.keys():
size = metadata["Size"]
elif "Subject" in metadata.keys():
if isinstance(metadata["Subject"], dict) and "Species" in metadata["Subject"].keys():
size = metadata["Subject"]["Size"]
return size[:-2]
def get_fi_curve_contrasts(self):
"""
@ -329,6 +339,12 @@ class DatParser(AbstractParser):
return traces
def __iget_traces__(self, repro):
for info, key, time, x in Dl.iload_traces(self.base_path, repro=repro):
# time, v1, eod, local_eod, stimulus
yield time, x[0], x[1], x[2], x[3]
def __read_fi_recording_times__(self):
delays = []

View File

@ -2,6 +2,7 @@
from CellData import icelldata_of_dir, CellData
from Baseline import BaselineCellData
from FiCurve import FICurveCellData
from DataParserFactory import DatParser
import os
import numpy as np
@ -11,7 +12,46 @@ def main():
# plot_visualizations("cells/")
# full_overview("cells/master_table.csv", "cells/")
recalculate_saved_preanalysis("data/final/")
# recalculate_saved_preanalysis("data/final/")
metadata_analysis("data/final/")
pass
def metadata_analysis(data_folder):
species = {}
sampling_interval = {}
eod_freqs = []
sizes = []
dates = {}
for cell in os.listdir(data_folder):
if cell[:10] in dates.keys():
continue
dates[cell[:10]] = 1
cell_path = data_folder + cell
parser = DatParser(cell_path)
cell_data = CellData(cell_path)
species = count_with_dict(species, parser.get_species())
sampling_interval = count_with_dict(sampling_interval, parser.get_sampling_interval())
sizes.append(float(parser.get_fish_size()))
eod_freqs.append(cell_data.get_eod_frequency())
for k in sampling_interval.keys():
print("sampling:", np.rint(1.0/float(k)), "count:", sampling_interval[k])
print("# of Fish (by dates):", len(dates.keys()))
print("EOD-freq: min {:.2f}, mean {:.2f}, max {:.2f}, std {:.2f}".format(min(eod_freqs), np.mean(eod_freqs), max(eod_freqs), np.std(eod_freqs)))
print("Sizes: min {:.2f}, mean {:.2f}, max {:.2f}, std {:.2f}".format(min(sizes), np.mean(sizes), max(sizes), np.std(sizes)))
print("done")
def count_with_dict(dictionary, key):
if key not in dictionary:
dictionary[key] = 0
dictionary[key] += 1
return dictionary
def recalculate_saved_preanalysis(data_folder):

View File

@ -0,0 +1,32 @@
import numpy as np
from CellData import CellData
from DataParserFactory import DatParser
import matplotlib.pyplot as plt
test_cell = "data/final/2010-11-08-al-invivo-1/"
def main():
parser = DatParser(test_cell)
fi_trans_amplitudes, fi_intensities, fi_spiketimes = parser.get_fi_curve_spiketimes()
for time, v1, eod, local_eod, stim in parser.__iget_traces__("FICurve"):
del eod
del local_eod
del stim
for i in range(len(fi_spiketimes)):
for j, spikes in enumerate(fi_spiketimes[i]):
offset = max(v1)+j
plt.eventplot(np.array(spikes)+2*j, colors="black", lineoffsets=offset) # , linelengths=0.5, lineoffsets=1+i*1+max(v1))
plt.plot(np.array(time), v1)
plt.show()
pass
if __name__ == '__main__':
main()

View File

@ -19,8 +19,8 @@ def main():
# test_cells()
# read_test_cells_tsv()
inspect_fi_curve()
read_test_cells_tsv()
# inspect_fi_curve()
def inspect_fi_curve():
@ -64,8 +64,6 @@ def read_test_cells_tsv():
else:
print("already thrown:", cell_name)
else:
count_rejected += 1

View File

@ -28,8 +28,8 @@
\@writefile{toc}{\contentsline {section}{\numberline {3}Introduction}{3}{section.3}}
\@writefile{toc}{\contentsline {section}{\numberline {4}Materials and Methods}{3}{section.4}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}Cell recordings}{3}{subsection.4.1}}
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces use real EOD data?}}{4}{figure.1}}
\newlabel{fig:stim_examples}{{1}{4}{use real EOD data?}{figure.1}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces use real EOD data? A) B) }}{4}{figure.1}}
\newlabel{fig:stim_examples}{{1}{4}{use real EOD data? A) B)}{figure.1}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Stimulus Protocols}{4}{subsection.4.2}}
\newlabel{eq:am_generation}{{1}{4}{Stimulus Protocols}{equation.4.1}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Cell Characteristics}{4}{subsection.4.3}}
@ -37,7 +37,7 @@
\newlabel{basic_voltage_dynamics}{{5}{5}{Leaky Integrate and Fire Model}{equation.4.5}{}}
\newlabel{currents_lifac}{{6}{5}{Leaky Integrate and Fire Model}{equation.4.6}{}}
\newlabel{Adaption_dynamics}{{7}{5}{Leaky Integrate and Fire Model}{equation.4.7}{}}
\newlabel{full_voltage_dynamics}{{8}{5}{Leaky Integrate and Fire Model}{equation.4.8}{}}
\newlabel{full_voltage_dynamics}{{8}{6}{Leaky Integrate and Fire Model}{equation.4.8}{}}
\newlabel{fig:model_comparison}{{4.4}{6}{Leaky Integrate and Fire Model}{equation.4.8}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces 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. {\color {red}(TODO: how to deal with the parameters)} }}{6}{figure.2}}
\bibdata{citations}

View File

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2018.11.12) 20 AUG 2020 16:57
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2018.11.12) 22 AUG 2020 15:47
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
@ -506,63 +506,59 @@ File: uni-32.def 2013/05/13 UCS: Unicode data U+2000..U+20FF
(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-34.def
File: uni-34.def 2013/05/13 UCS: Unicode data U+2200..U+22FF
) [3]
LaTeX Warning: Reference `fig:am_generation' on page 4 undefined on input line
140.
<figures/amGeneration.pdf, id=95, 433.62pt x 433.62pt>
<figures/amGeneration.pdf, id=96, 433.62pt x 433.62pt>
File: figures/amGeneration.pdf Graphic file (type pdf)
<use figures/amGeneration.pdf>
Package pdftex.def Info: figures/amGeneration.pdf used on input line 155.
(pdftex.def) Requested size: 216.24025pt x 216.24045pt.
Package pdftex.def Info: figures/amGeneration.pdf used on input line 170.
(pdftex.def) Requested size: 211.91782pt x 211.91988pt.
<figures/stimuliExamples.pdf, id=96, 433.62pt x 433.62pt>
Overfull \hbox (0.77333pt too wide) in paragraph at lines 169--171
[][] []
[]
<figures/stimuliExamples.pdf, id=97, 433.62pt x 433.62pt>
File: figures/stimuliExamples.pdf Graphic file (type pdf)
<use figures/stimuliExamples.pdf>
Package pdftex.def Info: figures/stimuliExamples.pdf used on input line 158.
(pdftex.def) Requested size: 227.62206pt x 227.62082pt.
Package pdftex.def Info: figures/stimuliExamples.pdf used on input line 173.
(pdftex.def) Requested size: 223.07211pt x 223.07529pt.
[4 <./figures/amGeneration.pdf> <./figures/stimuliExamples.pdf
pdfTeX warning: pdflatex (file ./figures/stimuliExamples.pdf): PDF inclusion: m
ultiple pdfs with page group included in a single page
>] <figures/model_comparison.pdf, id=181, 578.16pt x 578.16pt>
>] [5] <figures/model_comparison.pdf, id=194, 578.16pt x 578.16pt>
File: figures/model_comparison.pdf Graphic file (type pdf)
<use figures/model_comparison.pdf>
Package pdftex.def Info: figures/model_comparison.pdf used on input line 241.
Package pdftex.def Info: figures/model_comparison.pdf used on input line 255.
(pdftex.def) Requested size: 346.89867pt x 346.89867pt.
[5]
<figures/stimulus_development.pdf, id=195, 433.62pt x 433.62pt>
File: figures/stimulus_development.pdf Graphic file (type pdf)
<use figures/stimulus_development.pdf>
Package pdftex.def Info: figures/stimulus_development.pdf used on input line 25
0.
Package pdftex.def Info: figures/stimulus_development.pdf used on input line 26
4.
(pdftex.def) Requested size: 260.17401pt x 260.17401pt.
[6 <./figures/model_comparison.pdf>]
(./Masterthesis.bbl)
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 273.
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 287.
[7 <./figures/stimulus_development.pdf>]
Package atveryend Info: Empty hook `AfterLastShipout' on input line 273.
Package atveryend Info: Empty hook `AfterLastShipout' on input line 287.
(./Masterthesis.aux)
Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 273.
Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 273.
Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 287.
Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 287.
Package rerunfilecheck Info: File `Masterthesis.out' has not changed.
(rerunfilecheck) Checksum: 7A3ACD7CD7DC89195072057BF8EFCD4A;622.
LaTeX Warning: There were undefined references.
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 273.
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 287.
)
Here is how much of TeX's memory you used:
11012 strings out of 493029
156838 string characters out of 6136233
263888 words of memory out of 5000000
14391 multiletter control sequences out of 15000+600000
11011 strings out of 493029
156819 string characters out of 6136233
259306 words of memory out of 5000000
14390 multiletter control sequences out of 15000+600000
9521 words of font info for 34 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
37i,11n,38p,1008b,551s stack positions out of 5000i,500n,10000p,200000b,80000s
@ -577,10 +573,10 @@ blic/amsfonts/cm/cmss12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/a
msfonts/cm/cmsy10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfont
s/cm/cmsy8.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cm
ti12.pfb>
Output written on Masterthesis.pdf (8 pages, 263547 bytes).
Output written on Masterthesis.pdf (8 pages, 263393 bytes).
PDF statistics:
331 PDF objects out of 1000 (max. 8388607)
177 compressed objects within 2 object streams
327 PDF objects out of 1000 (max. 8388607)
178 compressed objects within 2 object streams
36 named destinations out of 1000 (max. 500000)
109 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

Binary file not shown.

View File

@ -114,15 +114,30 @@ Außerdem erkläre ich, dass die eingereichte Arbeit weder vollständig noch in
\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 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 . There were recordings of 457 p-units were inspected. Of those 88 fulfilled the basic necessary requirements of including a measurement of at least 30 seconds of the baseline behavior and containing at least 7 different contrasts with each at least 7 trials for the FI-Curve (see below \todo{ref}). After preanalysis of those cells an additional 13 cells were excluded because of analysis difficulties.
The 75 used cells came from 32 \AptLepto (brown ghost knifefish). \todo{sizes range, EOD range, number of cells}
%# of fish = 32
%sampling: 100000.0 count: 20
%sampling: 20000.0 count: 54
%sampling: 40000.0 count: 1
% with counting fish doubled
%EOD-freq: min 597.94, mean 732.96, max 928.45, std 76.64
%Sizes: min 11.00, mean 15.16, max 25.00, std 2.91
% each fish only once in calculation (as determined with max one fish per day)
%EOD-freq: min 601.09, mean 753.09, max 928.45, std 82.30
%Sizes: min 11.00, mean 15.78, max 25.00, std 3.48
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, 2550 $\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-
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-100\,M$\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 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 20-100\,kHz (54 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.
@ -137,9 +152,9 @@ The stimuli used during the recordings were presented from two vertical carbon r
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}).
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:stim_examples} B).
This system as seen in equation \ref{eq:am_generation} works for any AM. In the
This construction as seen in equation \ref{eq:am_generation} works for any AM. In the
\todo{contrast ranges, presentation windows/durations, changing stimulus parameters}
@ -150,21 +165,20 @@ Stimulus = EOD(t) * AM(t) + EOD(t) \todo{acceptable?}
\begin{figure}
\centering
\begin{minipage}{0.5\textwidth}
\raisebox{50mm}{\large\sffamily A}\hspace{-2ex}
\begin{minipage}{0.49\textwidth}
\raisebox{50mm}{\large\sffamily A}
\includegraphics[width=0.95\textwidth]{figures/amGeneration.pdf}
\end{minipage}\hfill
\begin{minipage}{0.5\textwidth}
\begin{minipage}{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/stimuliExamples.pdf}
%\caption{second}
\end{minipage}
\caption{use real EOD data?\label{fig:stim_examples}}
\caption{use real EOD data? A) B) \label{fig:stim_examples}}
\end{figure}
\subsection{Cell Characteristics}
Baseline