diff --git a/code/chirpdetection.py b/code/chirpdetection.py index 39db060..1d67e39 100755 --- a/code/chirpdetection.py +++ b/code/chirpdetection.py @@ -133,8 +133,10 @@ class ChirpPlotBuffer: data_oi, self.data.raw_rate, self.t0 - 5, - [np.min(self.frequency) - 100, np.max(self.frequency) + 200] + [np.min(self.frequency) - 300, np.max(self.frequency) + 300] ) + ax0.set_ylim(np.min(self.frequency) - 100, + np.max(self.frequency) + 200) for track_id in self.data.ids: @@ -157,27 +159,35 @@ class ChirpPlotBuffer: zorder=10, color=ps.gblue1) else: ax0.plot(t-self.t0_old, f, lw=lw, - zorder=10, color=ps.gray, alpha=0.5) - - ax0.fill_between( - np.arange(self.t0, self.t0 + self.dt, 1 / self.data.raw_rate), - q50 - self.config.minimal_bandwidth / 2, - q50 + self.config.minimal_bandwidth / 2, - color=ps.gblue1, - lw=1, - ls="dashed", - alpha=0.5, - ) + zorder=10, color=ps.black) + + # ax0.fill_between( + # np.arange(self.t0, self.t0 + self.dt, 1 / self.data.raw_rate), + # q50 - self.config.minimal_bandwidth / 2, + # q50 + self.config.minimal_bandwidth / 2, + # color=ps.gblue1, + # lw=1, + # ls="dashed", + # alpha=0.5, + # ) + + # ax0.fill_between( + # np.arange(self.t0, self.t0 + self.dt, 1 / self.data.raw_rate), + # search_lower, + # search_upper, + # color=ps.gblue2, + # lw=1, + # ls="dashed", + # alpha=0.5, + # ) + + ax0.axhline(q50 - self.config.minimal_bandwidth / 2, + color=ps.gblue1, lw=1, ls="dashed") + ax0.axhline(q50 + self.config.minimal_bandwidth / 2, + color=ps.gblue1, lw=1, ls="dashed") + ax0.axhline(search_lower, color=ps.gblue2, lw=1, ls="dashed") + ax0.axhline(search_upper, color=ps.gblue2, lw=1, ls="dashed") - ax0.fill_between( - np.arange(self.t0, self.t0 + self.dt, 1 / self.data.raw_rate), - search_lower, - search_upper, - color=ps.gblue2, - lw=1, - ls="dashed", - alpha=0.5, - ) # ax0.axhline(q50, spec_times[0], spec_times[-1], # color=ps.gblue1, lw=2, ls="dashed") # ax0.axhline(q50 + self.search_frequency, @@ -187,7 +197,11 @@ class ChirpPlotBuffer: if len(chirps) > 0: for chirp in chirps: ax0.scatter( - chirp, np.median(self.frequency) + 150, c=ps.black, marker="v" + chirp, np.median(self.frequency), c=ps.red, marker=".", + edgecolors=ps.red, + facecolors=ps.red, + zorder=10, + s=70, ) # plot waveform of filtered signal @@ -207,25 +221,31 @@ class ChirpPlotBuffer: c=ps.gblue3, lw=lw, label="baseline inst. freq.") # plot filtered and rectified envelope - ax4.plot(self.time, self.baseline_envelope, c=ps.gblue1, lw=lw) + ax4.plot(self.time, self.baseline_envelope * + waveform_scaler, c=ps.gblue1, lw=lw) ax4.scatter( (self.time)[self.baseline_peaks], - self.baseline_envelope[self.baseline_peaks], + (self.baseline_envelope*waveform_scaler)[self.baseline_peaks], edgecolors=ps.red, + facecolors=ps.red, zorder=10, - marker="o", - facecolors="none", + marker=".", + s=70, + # facecolors="none", ) # plot envelope of search signal - ax5.plot(self.time, self.search_envelope, c=ps.gblue2, lw=lw) + ax5.plot(self.time, self.search_envelope * + waveform_scaler, c=ps.gblue2, lw=lw) ax5.scatter( (self.time)[self.search_peaks], - self.search_envelope[self.search_peaks], + (self.search_envelope*waveform_scaler)[self.search_peaks], edgecolors=ps.red, + facecolors=ps.red, zorder=10, - marker="o", - facecolors="none", + marker=".", + s=70, + # facecolors="none", ) # plot filtered instantaneous frequency @@ -235,16 +255,20 @@ class ChirpPlotBuffer: self.frequency_time[self.frequency_peaks], self.frequency_filtered[self.frequency_peaks], edgecolors=ps.red, + facecolors=ps.red, zorder=10, - marker="o", - facecolors="none", + marker=".", + s=70, + # facecolors="none", ) ax0.set_ylabel("frequency [Hz]") - ax1.set_ylabel("a.u.") - ax2.set_ylabel("a.u.") + ax1.set_ylabel(r"$\mu$V") + ax2.set_ylabel(r"$\mu$V") ax3.set_ylabel("Hz") - ax5.set_ylabel("a.u.") + ax4.set_ylabel(r"$\mu$V") + ax5.set_ylabel(r"$\mu$V") + ax6.set_ylabel("Hz") ax6.set_xlabel("time [s]") plt.setp(ax0.get_xticklabels(), visible=False) @@ -323,7 +347,7 @@ def plot_spectrogram( aspect="auto", origin="lower", interpolation="gaussian", - alpha=0.6, + # alpha=0.6, ) # axis.use_sticky_edges = False return spec_times @@ -628,16 +652,16 @@ def chirpdetection(datapath: str, plot: str, debug: str = 'false') -> None: raw_time = np.arange(data.raw.shape[0]) / data.raw_rate # good chirp times for data: 2022-06-02-10_00 - # window_start_index = (3 * 60 * 60 + 6 * 60 + 43.5 + 5) * data.raw_rate - # window_duration_index = 60 * data.raw_rate + window_start_index = (3 * 60 * 60 + 6 * 60 + 43.5) * data.raw_rate + window_duration_index = 60 * data.raw_rate # t0 = 0 # dt = data.raw.shape[0] # window_start_seconds = (23495 + ((28336-23495)/3)) * data.raw_rate # window_duration_seconds = (28336 - 23495) * data.raw_rate - window_start_index = 0 - window_duration_index = data.raw.shape[0] + # window_start_index = 0 + # window_duration_index = data.raw.shape[0] # generate starting points of rolling window window_start_indices = np.arange( @@ -1097,4 +1121,4 @@ if __name__ == "__main__": datapath = "../data/2022-06-02-10_00/" # datapath = "/home/weygoldt/Data/uni/efishdata/2016-colombia/fishgrid/2016-04-09-22_25/" # datapath = "/home/weygoldt/Data/uni/chirpdetection/GP2023_chirp_detection/data/mount_data/2020-03-13-10_00/" - chirpdetection(datapath, plot="show", debug="false") + chirpdetection(datapath, plot="save", debug="false") diff --git a/code/modules/plotstyle.py b/code/modules/plotstyle.py index 2c05369..b4a8a41 100644 --- a/code/modules/plotstyle.py +++ b/code/modules/plotstyle.py @@ -23,16 +23,16 @@ def PlotStyle() -> None: sky = "#89dceb" teal = "#94e2d5" green = "#a6e3a1" - yellow = "#f9e2af" - orange = "#fab387" - maroon = "#eba0ac" - red = "#f38ba8" - purple = "#cba6f7" - pink = "#f5c2e7" + yellow = "#f9d67f" + orange = "#faa472" + maroon = "#eb8486" + red = "#f37588" + purple = "#d89bf7" + pink = "#f59edb" lavender = "#b4befe" - gblue1 = "#8cb8ff" - gblue2 = "#7cdcdc" - gblue3 = "#82e896" + gblue1 = "#89b4fa" + gblue2 = "#89dceb" + gblue3 = "#a6e3a1" @classmethod def lims(cls, track1, track2): @@ -108,6 +108,9 @@ def PlotStyle() -> None: @classmethod def set_boxplot_color(cls, bp, color): plt.setp(bp["boxes"], color=color) + plt.setp(bp["whiskers"], color=color) + plt.setp(bp["caps"], color=color) + plt.setp(bp["medians"], color=color) @classmethod def label_subplots(cls, labels, axes, fig): @@ -226,7 +229,7 @@ def PlotStyle() -> None: plt.rc("legend", fontsize=SMALL_SIZE) # legend fontsize plt.rc("figure", titlesize=BIGGER_SIZE) # fontsize of the figure title - plt.rcParams["image.cmap"] = 'cmo.haline' + plt.rcParams["image.cmap"] = "cmo.haline" plt.rcParams["axes.xmargin"] = 0.05 plt.rcParams["axes.ymargin"] = 0.1 plt.rcParams["axes.titlelocation"] = "left" @@ -247,42 +250,44 @@ def PlotStyle() -> None: # dark mode modifications plt.rcParams["boxplot.flierprops.color"] = white - plt.rcParams["boxplot.flierprops.markeredgecolor"] = white + plt.rcParams["boxplot.flierprops.markeredgecolor"] = gray plt.rcParams["boxplot.boxprops.color"] = gray - plt.rcParams["boxplot.whiskerprops.color"] = white - plt.rcParams["boxplot.capprops.color"] = white - plt.rcParams["boxplot.medianprops.color"] = white + plt.rcParams["boxplot.whiskerprops.color"] = gray + plt.rcParams["boxplot.capprops.color"] = gray + plt.rcParams["boxplot.medianprops.color"] = gray plt.rcParams["text.color"] = white plt.rcParams["axes.facecolor"] = black # axes background color plt.rcParams["axes.edgecolor"] = gray # axes edge color # plt.rcParams["axes.grid"] = True # display grid or not # plt.rcParams["axes.grid.axis"] = "y" # which axis the grid is applied to plt.rcParams["axes.labelcolor"] = white - plt.rcParams["axes.axisbelow"] = True # draw axis gridlines and ticks: + plt.rcParams["axes.axisbelow"] = True # draw axis gridlines and ticks: plt.rcParams["axes.spines.left"] = True # display axis spines plt.rcParams["axes.spines.bottom"] = True plt.rcParams["axes.spines.top"] = False plt.rcParams["axes.spines.right"] = False plt.rcParams["axes.prop_cycle"] = cycler( - 'color', [ - '#b4befe', - '#89b4fa', - '#74c7ec', - '#89dceb', - '#94e2d5', - '#a6e3a1', - '#f9e2af', - '#fab387', - '#eba0ac', - '#f38ba8', - '#cba6f7', - '#f5c2e7', - ]) + "color", + [ + "#b4befe", + "#89b4fa", + "#74c7ec", + "#89dceb", + "#94e2d5", + "#a6e3a1", + "#f9e2af", + "#fab387", + "#eba0ac", + "#f38ba8", + "#cba6f7", + "#f5c2e7", + ], + ) plt.rcParams["xtick.color"] = gray # color of the ticks plt.rcParams["ytick.color"] = gray # color of the ticks plt.rcParams["grid.color"] = dark_gray # grid color - plt.rcParams["figure.facecolor"] = black # figure face color - plt.rcParams["figure.edgecolor"] = black # figure edge color + plt.rcParams["figure.facecolor"] = black # figure face color + plt.rcParams["figure.edgecolor"] = black # figure edge color plt.rcParams["savefig.facecolor"] = black # figure face color when saving return style @@ -292,12 +297,11 @@ if __name__ == "__main__": s = PlotStyle() - import matplotlib.pyplot as plt + import matplotlib.cbook as cbook import matplotlib.cm as cm import matplotlib.pyplot as plt - import matplotlib.cbook as cbook - from matplotlib.path import Path from matplotlib.patches import PathPatch + from matplotlib.path import Path # Fixing random state for reproducibility np.random.seed(19680801) @@ -305,14 +309,20 @@ if __name__ == "__main__": delta = 0.025 x = y = np.arange(-3.0, 3.0, delta) X, Y = np.meshgrid(x, y) - Z1 = np.exp(-X**2 - Y**2) - Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2) + Z1 = np.exp(-(X**2) - Y**2) + Z2 = np.exp(-((X - 1) ** 2) - (Y - 1) ** 2) Z = (Z1 - Z2) * 2 fig1, ax = plt.subplots() - im = ax.imshow(Z, interpolation='bilinear', cmap=cm.RdYlGn, - origin='lower', extent=[-3, 3, -3, 3], - vmax=abs(Z).max(), vmin=-abs(Z).max()) + im = ax.imshow( + Z, + interpolation="bilinear", + cmap=cm.RdYlGn, + origin="lower", + extent=[-3, 3, -3, 3], + vmax=abs(Z).max(), + vmin=-abs(Z).max(), + ) plt.show() @@ -325,22 +335,21 @@ if __name__ == "__main__": all_data = [np.random.normal(0, std, 100) for std in range(6, 10)] # plot violin plot - axs[0].violinplot(all_data, - showmeans=False, - showmedians=True) - axs[0].set_title('Violin plot') + axs[0].violinplot(all_data, showmeans=False, showmedians=True) + axs[0].set_title("Violin plot") # plot box plot axs[1].boxplot(all_data) - axs[1].set_title('Box plot') + axs[1].set_title("Box plot") # adding horizontal grid lines for ax in axs: ax.yaxis.grid(True) - ax.set_xticks([y + 1 for y in range(len(all_data))], - labels=['x1', 'x2', 'x3', 'x4']) - ax.set_xlabel('Four separate samples') - ax.set_ylabel('Observed values') + ax.set_xticks( + [y + 1 for y in range(len(all_data))], labels=["x1", "x2", "x3", "x4"] + ) + ax.set_xlabel("Four separate samples") + ax.set_ylabel("Observed values") plt.show() @@ -352,24 +361,42 @@ if __name__ == "__main__": theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False) radii = 10 * np.random.rand(N) width = np.pi / 4 * np.random.rand(N) - colors = cmo.cm.haline(radii / 10.) + colors = cmo.cm.haline(radii / 10.0) - ax = plt.subplot(projection='polar') + ax = plt.subplot(projection="polar") ax.bar(theta, radii, width=width, bottom=0.0, color=colors, alpha=0.5) plt.show() - methods = [None, 'none', 'nearest', 'bilinear', 'bicubic', 'spline16', - 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', - 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos'] + methods = [ + None, + "none", + "nearest", + "bilinear", + "bicubic", + "spline16", + "spline36", + "hanning", + "hamming", + "hermite", + "kaiser", + "quadric", + "catrom", + "gaussian", + "bessel", + "mitchell", + "sinc", + "lanczos", + ] # Fixing random state for reproducibility np.random.seed(19680801) grid = np.random.rand(4, 4) - fig, axs = plt.subplots(nrows=3, ncols=6, figsize=(9, 6), - subplot_kw={'xticks': [], 'yticks': []}) + fig, axs = plt.subplots( + nrows=3, ncols=6, figsize=(9, 6), subplot_kw={"xticks": [], "yticks": []} + ) for ax, interp_method in zip(axs.flat, methods): ax.imshow(grid, interpolation=interp_method) diff --git a/code/plot_introduction_specs.py b/code/plot_introduction_specs.py index 3f8395e..20fb562 100644 --- a/code/plot_introduction_specs.py +++ b/code/plot_introduction_specs.py @@ -41,9 +41,9 @@ def main(): freqtime2, freq2 = instantaneous_frequency( filtered2, data.raw_rate, smoothing_window=3) - ax1.plot(freqtime1*timescaler, freq1, color=ps.gblue1, + ax1.plot(freqtime1*timescaler, freq1, color=ps.red, lw=2, label=f"fish 1, {np.median(freq1):.0f} Hz") - ax1.plot(freqtime2*timescaler, freq2, color=ps.gblue3, + ax1.plot(freqtime2*timescaler, freq2, color=ps.orange, lw=2, label=f"fish 2, {np.median(freq2):.0f} Hz") ax1.legend(bbox_to_anchor=(0, 1.02, 1, 0.2), loc="lower center", mode="normal", borderaxespad=0, ncol=2) diff --git a/poster/figs/algorithm.pdf b/poster/figs/algorithm.pdf new file mode 100644 index 0000000..359d7e6 Binary files /dev/null and b/poster/figs/algorithm.pdf differ diff --git a/poster/figs/introplot.pdf b/poster/figs/introplot.pdf new file mode 100644 index 0000000..7fef6fa Binary files /dev/null and b/poster/figs/introplot.pdf differ diff --git a/poster/main.pdf b/poster/main.pdf index cc12208..92b0871 100644 Binary files a/poster/main.pdf and b/poster/main.pdf differ diff --git a/poster/main.tex b/poster/main.tex index e01ba65..1738024 100644 --- a/poster/main.tex +++ b/poster/main.tex @@ -7,7 +7,7 @@ blockverticalspace=2mm, colspace=20mm, subcolspace=0mm]{tikzposter} %Default val \begin{document} \renewcommand{\baselinestretch}{1} -\title{\parbox{1500pt}{Poster}} +\title{\parbox{1500pt}{Detection of transient communication signals in weakly electric fish}} \author{Sina Prause, Alexander Wendt, and Patrick Weygoldt} \institute{Supervised by Till Raab \& Jan Benda, Neuroethology Lab, University of Tuebingen} \usetitlestyle[]{sampletitle} @@ -21,17 +21,15 @@ blockverticalspace=2mm, colspace=20mm, subcolspace=0mm]{tikzposter} %Default val sender identification of freely interacting individuals impossible. This profoundly limits our current understanding of chirps to experiments with single - or physically separated - individuals. - \vspace{0.6cm} - \begin{tikzfigure}[] - \label{griddrawing} - \includegraphics[width=0.5\linewidth]{example-image-a} - \end{tikzfigure} + % \begin{tikzfigure}[] + % \label{griddrawing} + % \includegraphics[width=1\linewidth]{figs/introplot} + % \end{tikzfigure} } - \myblock[TranspBlock]{Chirp detection}{ \begin{tikzfigure}[] \label{fig:example_a} - \includegraphics[width=0.5\linewidth]{example-image-a} + \includegraphics[width=1\linewidth]{figs/algorithm} \end{tikzfigure} \vspace{0cm} } @@ -67,7 +65,7 @@ blockverticalspace=2mm, colspace=20mm, subcolspace=0mm]{tikzposter} %Default val \vspace{-1cm} } -\myblock[TranspBlock]{Conclusion}{ +\myblock[GrayBlock]{Conclusion}{ \begin{itemize} \setlength\itemsep{0.5em} \item Our analysis is the first to indicate that \textit{A. leptorhynchus} uses long, diffuse and synchronized EOD$f$ signals to communicate in addition to chirps and rises. diff --git a/poster/style.tex b/poster/style.tex index d627e22..0397831 100644 --- a/poster/style.tex +++ b/poster/style.tex @@ -1,9 +1,9 @@ \tikzposterlatexaffectionproofoff \usetheme{Default} -\definecolor{text}{HTML}{ffffff} -\definecolor{background}{HTML}{080808} -\definecolor{boxes}{HTML}{1E1E1E} +\definecolor{text}{HTML}{e0e4f7} +\definecolor{background}{HTML}{111116} +\definecolor{boxes}{HTML}{2a2a32} \definecolor{unired}{HTML}{a51e37} \colorlet{blocktitlefgcolor}{text}