From fadef774d4dc33e680f4f207f41b5409d041e3d2 Mon Sep 17 00:00:00 2001 From: Diana Date: Thu, 24 Oct 2024 13:49:57 +0200 Subject: [PATCH 1/2] changed highlight function --- code/plot_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/plot_functions.py b/code/plot_functions.py index 7bf001f..5fb4c17 100644 --- a/code/plot_functions.py +++ b/code/plot_functions.py @@ -136,7 +136,7 @@ def plot_highlighted_integrals(frequency, power, points, color_mapping, points_c ax.set_title('Power Spectrum with Highlighted Integrals') ax.legend() - return fig + return fig, ax From edc8d832e10a9b5f369704d6096320ed8ae5ed95 Mon Sep 17 00:00:00 2001 From: mbergmann Date: Thu, 24 Oct 2024 15:14:57 +0200 Subject: [PATCH 2/2] [useful_functions.py] added true_eodf function --- code/useful_functions.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/code/useful_functions.py b/code/useful_functions.py index 6c17064..ed94b8e 100644 --- a/code/useful_functions.py +++ b/code/useful_functions.py @@ -1,9 +1,5 @@ -import glob -import pathlib import numpy as np -import matplotlib.pyplot as plt import rlxnix as rlx -from IPython import embed from scipy.signal import welch def all_coming_together(freq_array, power_array, points_list, categories, num_harmonics_list, colors, delta=2.5, threshold=0.5): @@ -513,6 +509,29 @@ def spike_times(stim): dt = ti.sampling_interval return spikes, stim_dur, dt # se changed spike_times to spikes so its not the same as name of function +def true_eodf(eodf_file): + ''' + Calculates the Eodf of the fish when it was awake from a nix file. + + Parameters + ---------- + eodf_file : str + path to the file with nix-file for the eodf. + + Returns + ------- + orig_eodf : int + The original eodf. + + ''' + eod_data = rlx.Dataset(eodf_file)#load eodf file + baseline = eod_data.repro_runs('baseline')[0] + eod, time = baseline.trace_data('EOD') # get time and eod + dt = baseline.trace_info('EOD').sampling_interval + eod_freq, eod_power = welch(eod, fs = 1/dt, nperseg = 2**16, noverlap = 2**15) + orig_eodf = round(eod_freq[np.argmax(eod_power)]) + return orig_eodf + def valid_integrals(integral, local_mean, point, threshold = 0.1): """ Check if the integral exceeds the threshold compared to the local mean and