import numpy as np
import matplotlib.pyplot as plt
from read_baseline_data import *
from NixFrame import *
from utility import *
from IPython import embed

# plot and data values
inch_factor = 2.54
data_dir = '../data'
dataset = '2018-11-09-ad-invivo-1'

# read spikes during baseline activity
spikes = read_baseline_spikes(os.path.join(data_dir, dataset))
# calculate interpike intervals and plot them
interspikeintervals = np.diff(spikes)*1000

fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
plt.hist(interspikeintervals, bins=np.arange(0, np.max(interspikeintervals), 0.0001), color='darkblue')
plt.xlabel("time [ms]", fontsize = 22)
plt.xticks(fontsize = 18)
plt.ylabel("Number of \n Interspikeinterval", 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('isis.pdf')





