66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
from read_chirp_data import *
|
|
from utility import *
|
|
from IPython import embed
|
|
|
|
data_dir = "../data"
|
|
dataset = "2018-11-09-ad-invivo-1"
|
|
|
|
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
|
|
eod = read_chirp_eod(os.path.join(data_dir, dataset))
|
|
chirp_times = read_chirp_times(os.path.join(data_dir, dataset))
|
|
|
|
df_map = {}
|
|
for k in spikes.keys():
|
|
df = k[1]
|
|
if df in df_map.keys():
|
|
df_map[df].append(k)
|
|
else:
|
|
df_map[df] = [k]
|
|
|
|
# make phases together, 12 phases
|
|
phase_vec = np.arange(0, 1+1/12, 1/12)
|
|
phase_mat_df = {}
|
|
|
|
for deltaf in df_map.keys():
|
|
phase_df = {}
|
|
for rep in df_map[deltaf]:
|
|
for phase in spikes[rep]:
|
|
#print(phase)
|
|
for idx in range(len(phase_vec)-1):
|
|
if phase[1] > phase_vec[idx] and phase[1] < phase_vec[idx+1]:
|
|
if phase_vec[idx] in phase_df.keys():
|
|
phase_df[phase_vec[idx]].append(phase[1])
|
|
else:
|
|
phase_df[phase_vec[idx]] = [phase[1]]
|
|
|
|
#spikes_one_chirp = spikes[rep][phase]
|
|
|
|
|
|
phase_mat_df[deltaf] = phase_df
|
|
|
|
embed()
|
|
exit()
|
|
plot_spikes = spikes[(0, '-50Hz', '20%', '100Hz')][(0, 0.789)]
|
|
|
|
fig, ax = plt.subplots()
|
|
ax.scatter(plot_spikes, np.ones(len(plot_spikes))*10, marker='|', color='k')
|
|
plt.show()
|
|
|
|
#mu = 1
|
|
#sigma = 1
|
|
#time_gauss = np.arange(-4, 4, 1)
|
|
#gauss = gaussian(time_gauss, mu, sigma)
|
|
# spikes during time vec (00010000001)?
|
|
|
|
#smoothed_spikes = np.convolve(plot_spikes, gauss, 'same')
|
|
#window = np.mean(np.diff(plot_spikes))
|
|
#time_vec = np.arange(plot_spikes[0], plot_spikes[-1]+window, window)
|
|
|
|
#ax.plot(time_vec, smoothed_spikes)
|
|
|
|
#embed()
|
|
#exit()
|
|
#hist_data = plt.hist(plot_spikes, bins=np.arange(-200, 400, 20))
|
|
#ax.plot(hist_data[1][:-1], hist_data[0]) |