huhu
This commit is contained in:
parent
68670cd9b2
commit
0d2ea250af
@ -2,38 +2,38 @@ from read_baseline_data import *
|
|||||||
from IPython import embed
|
from IPython import embed
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from IPython import embed
|
||||||
|
|
||||||
## beat
|
## beat
|
||||||
|
|
||||||
data_dir = '../data'
|
data_dir = '../data'
|
||||||
dataset = '2018-11-09-ad-invivo-1'
|
dataset = '2018-11-09-ad-invivo-1'
|
||||||
|
inch_factor = 2.54
|
||||||
|
|
||||||
time, eod = read_baseline_eod(os.path.join(data_dir, dataset))
|
time, eod = read_baseline_eod(os.path.join(data_dir, dataset))
|
||||||
eod_norm = eod - np.mean(eod)
|
eod_norm = eod - np.mean(eod)
|
||||||
|
eod_norm = eod_norm[1000:2000]
|
||||||
|
|
||||||
# calculate eod times and indices by zero crossings
|
x = np.arange(0., len(eod_norm))
|
||||||
threshold = 0
|
y = np.sin(x*2*np.pi*550)
|
||||||
shift_eod = np.roll(eod_norm, 1)
|
ampl = eod_norm + y
|
||||||
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
|
time_axis = np.arange(len(ampl))
|
||||||
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()
|
|
||||||
|
|
||||||
|
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
|
||||||
|
plt.plot(time_axis, ampl)
|
||||||
|
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()
|
||||||
|
|
||||||
#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()
|
#plt.show()
|
||||||
|
plt.savefig('beat.png')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user