import numpy as np
import matplotlib.pyplot as plt
import glob
import os
import NixFrame as nf
from IPython import embed

if __name__ == '__main__':
    data_dir = '/home/lisa/data/'
    os.chdir(data_dir)
    data_sets = glob.glob('2019-*')
    for data_set in data_sets:
        print(data_set)
        df = nf.load_data(data_dir + data_set + '/' + data_set + '_dataframe.pickle')
        embed()
        exit()
        for i in range(len(df)):

            stim_type = df['tag_meta']['RePro'][i]
            smpl_rt = df['samplingrate'][i]
            # t = df['time'][i+1]
            voltage = df['V-1'][i]
            t = np.arange(0, len(voltage)*1./smpl_rt, 1./smpl_rt)
            print(len(t))
            spiketimes = df['Spikes-1'][i]
            stim_onset = df['onset_times'][i]
            stim_dur = df['durations'][i]

            plt.plot(t, voltage, color='#BA2D22')
            plt.plot([stim_onset, stim_dur], [np.max(voltage)+0.75, np.max(voltage)+0.75], color='#53379B')
            plt.plot([spiketimes, spiketimes], [np.max(voltage)+1, np.max(voltage)+1.5], color='black')
            plt.show()