From d1139b65df40eae84f9c6cf272cb9d681784f6a1 Mon Sep 17 00:00:00 2001 From: efish Date: Thu, 22 Nov 2018 15:12:20 +0100 Subject: [PATCH] hallo --- code/eod_freq_beat.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 code/eod_freq_beat.py diff --git a/code/eod_freq_beat.py b/code/eod_freq_beat.py new file mode 100644 index 0000000..8dab8e7 --- /dev/null +++ b/code/eod_freq_beat.py @@ -0,0 +1,39 @@ +from read_baseline_data import * +from IPython import embed +import matplotlib.pyplot as plt +import numpy as np + +## beat + +data_dir = '../data' +dataset = '2018-11-09-ad-invivo-1' + +time, eod = read_baseline_eod(os.path.join(data_dir, dataset)) +eod_norm = eod - np.mean(eod) + +# calculate eod times and indices by zero crossings +threshold = 0 +shift_eod = np.roll(eod_norm, 1) +eod_times = time[(eod_norm >= threshold) & (shift_eod < threshold)] + +#x = eod_times*40000 +x = np.arange(0., len(eod_times)-1) +y = np.sin(x*2*np.pi*600) +eod_freq_beat = 1/(np.diff(eod_times) + y) + +# glätten +kernel = np.ones(7)/7 +smooth_eod_freq_beat = np.convolve(eod_freq_beat, kernel, mode = 'valid') +time_axis = np.arange(len(smooth_eod_freq_beat)) + +plt.plot(time_axis, smooth_eod_freq_beat) +plt.show() + + +#eod_freq_beat = eod_freq_normal + y +#smooth_eod_freq_beat = np.convolve(eod_freq_beat, kernel, mode = 'valid') +#fig = plt.plot(time_axis,smooth_eod_freq_beat) +#plt.xlabel("time [ms]") +#plt.ylabel("eod frequency [mV]") +#plt.show() +