from read_baseline_data import *
#import nix_helpers as nh 
import matplotlib.pyplot as plt
import numpy as np
from IPython import embed #Funktionen importieren

data_dir = "../data"
dataset = "2018-11-09-aa-invivo-1"
#data = ("2018-11-09-aa-invivo-1", "2018-11-09-ab-invivo-1", "2018-11-09-ac-invivo-1", "2018-11-09-ad-invivo-1", "2018-11-13-aa-invivo-1", "2018-11-13-ab-invivo-1", "2018-11-13-ad-invivo-1", "2018-11-09-af-invivo-1", "2018-11-09-ag-invivo-1", "2018-11-13-ah-invivo-1", "2018-11-13-ai-invivo-1", "2018-11-13-aj-invivo-1", "2018-11-13-ak-invivo-1", "2018-11-13-al-invivo-1", "2018-11-14-aa-invivo-1", "2018-11-14-ab-invivo-1", "2018-11-14-ac-invivo-1", "2018-11-14-ad-invivo-1", "2018-11-14-ae-invivo-1", "2018-11-14-af-invivo-1", "2018-11-14-ag-invivo-1", "2018-11-14-aa-invivo-1", "2018-11-14-aj-invivo-1", "2018-11-14-ak-invivo-1", "2018-11-14-al-invivo-1", "2018-11-14-am-invivo-1", "2018-11-14-an-invivo-1")
spike_times = read_baseline_spikes(os.path.join(data_dir, dataset))


#spike_frequency = len(spike_times) / spike_times[-1]
#inst_frequency = 1. / np.diff(spike_times)
spike_rate = np.diff(spike_times)


x = np.arange(0.001, 0.01, 0.0001)
plt.hist(spike_rate,x)

mu = np.mean(spike_rate)
sigma = np.std(spike_rate)
cv = sigma/mu
print(cv)

plt.title('A.lepto ISI Histogramm', fontsize = 14)
plt.xlabel('duration ISI[ms]', fontsize = 12)
plt.ylabel('number of ISI', fontsize = 12)

plt.xticks(fontsize = 12)
plt.yticks(fontsize = 12)
plt.show()


