freq_chirp
This commit is contained in:
parent
cdcbe6123f
commit
5608851d63
39
code/eod_freq_chirp.py
Normal file
39
code/eod_freq_chirp.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
from read_chirp_data import *
|
||||||
|
import os
|
||||||
|
from IPython import embed
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
data_dir = "../data"
|
||||||
|
dataset = "2018-11-14-ak-invivo-1"
|
||||||
|
stim = read_chirp_stimulus(os.path.join(data_dir, dataset))
|
||||||
|
|
||||||
|
s = stim[(1, 675.0, 100.0)][0]
|
||||||
|
eod = s[1]
|
||||||
|
time = s[0]
|
||||||
|
|
||||||
|
eod_norm = eod - np.mean(eod)
|
||||||
|
# calculate chirp times and indices by zero crossings
|
||||||
|
threshold = 0
|
||||||
|
shift_eod = np.roll(eod_norm, 1)
|
||||||
|
eod_times = time[(eod_norm >= threshold) & (shift_eod < threshold)]
|
||||||
|
|
||||||
|
eod_freq_chirp = 1/np.diff(eod_times)
|
||||||
|
kernel = np.ones(11)/11
|
||||||
|
smooth_eod_freq_chirp = np.convolve(eod_freq_chirp, kernel, mode = 'valid')
|
||||||
|
time_axis = np.arange(len(smooth_eod_freq_chirp))
|
||||||
|
|
||||||
|
|
||||||
|
fig = plt.plot(time_axis, smooth_eod_freq_chirp)
|
||||||
|
plt.xlabel("time [ms]", fontsize = 14)
|
||||||
|
plt.xticks(fontsize = 12)
|
||||||
|
plt.ylabel("eod frequency [mV]", fontsize = 14)
|
||||||
|
plt.yticks(fontsize = 12)
|
||||||
|
plt.axis([0, len(time_axis), 0, 2000])
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user