gp_neurobio/code/eod_freq_beat.py
2018-11-29 16:40:52 +01:00

45 lines
1.0 KiB
Python

from read_baseline_data import *
from IPython import embed
import matplotlib.pyplot as plt
import numpy as np
import thunderfish.peakdetection as pd
from IPython import embed
## beat
data_dir = '../data'
dataset = '2018-11-09-ad-invivo-1'
inch_factor = 2.54
time, eod = read_baseline_eod(os.path.join(data_dir, dataset))
eod_norm = eod - np.mean(eod)
eod_norm = eod_norm[10000:20000]
x = np.arange(0., len(eod_norm))
y = np.sin(time[10000:20000]*2*np.pi*600)*0.5
ampl = eod_norm + y
p, t = pd.detect_peaks(ampl, 0.1)
time_axis = np.arange(len(ampl))
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
plt.plot(time[10000:20000], ampl)
plt.plot(time[10000:20000][p], ampl[p], lw=2, color='k')
plt.plot(time[10000:20000][t], ampl[t], lw=2, color='k')
ax.set_xlabel("time [ms]", fontsize = 22)
plt.xticks(fontsize = 18)
ax.set_ylabel("eod amplitude [mV]", fontsize = 22)
plt.yticks(fontsize = 18)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
fig.tight_layout()
plt.show()
#plt.savefig('beat.png')