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)) 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 spikes_mat = {} for deltaf in df_map.keys(): for rep in df_map[deltaf]: for phase in spikes[rep]: #print(phase) spikes_one_chirp = spikes[rep][phase] if deltaf == '-50Hz' and phase == (9, 0.54): spikes_mat[deltaf, rep, phase] = spikes_one_chirp plot_spikes = spikes[(0, '-50Hz', '20%', '100Hz')][(0, 0.789)] 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) fig, ax = plt.subplots() ax.scatter(plot_spikes, np.ones(len(plot_spikes))*10, marker='|', color='k') ax.plot(time_vec, smoothed_spikes) plt.show() #embed() #exit() #hist_data = plt.hist(plot_spikes, bins=np.arange(-200, 400, 20)) #ax.plot(hist_data[1][:-1], hist_data[0])