12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import matplotlib.pyplot as plt
- import numpy as np
- import os
- import importlib
- from helpers import data_management as dm
- from analytics import analytics1
- from analytics import fr_analytics as fran
- importlib.reload(fran)
- import aux
- from scipy import signal
- params = aux.load_config()
- data_tot, tt, triggers_tot, ch_rec_list, file_names = dm.get_raw(n_triggers=2, exploration=False)
- ch_id = 20
- data2 = data_tot[0, 0]
- ids = np.argwhere(data2.mean(axis=0) == 0)
- data3 = np.delete(data2, ids, axis=1)
- cc = np.corrcoef(data3.T)
- # y = signal.savgol_filter(data2[:, ch_id], 41, 2)
- # ch_ids = list(range(32)) + list(range(96, 128))
- # args = {'v_thr': 10, 'ymax': 7, 'arr_id': 1}
- # an.plot_pdf(f_id=0, arr_id=args['arr_id'])
- # an.plot_pdf(f_id=1, arr_id=args['arr_id'])
- for fid in range(len(file_names)):
- an = fran.fr_analytics(data_tot, params, file_names[fid])
- args = {'v_thr': 10, 'ymax': 7, 'arr_id': 1, 'save_fig': True}
- an.plot_spectra(f_id=fid, recompute=True, **args)
- args = {'v_thr': 10, 'ymax': 7, 'arr_id': 2}
- an.plot_spectra(f_id=0, recompute=True, **args)
- # an.plot_spectra(f_id=1, recompute=True, **args)
- xx
- # plt.tight_layout()
- tt2 = np.arange(data2.shape[0]) * 0.050
- # nperseg = 100
- # fmax = 5
- # ff, tt1, Sxx1 = signal.spectrogram(y, fs=20, axis=0, nperseg=nperseg, noverlap=int(nperseg * 0.9))
- # fidx = (ff >= 0) & (ff < fmax)
- plt.figure()
- plt.clf()
- plt.subplot(211)
- # plt.plot(tt2, data2[:, ch_id])
- plt.plot(tt2, y, 'C2')
- # plt.plot(data2[:, ch_id])
- plt.xlim(0, tt2.max())
- for tr_id in range(3, 4):
- plt.vlines(triggers_tot[0, 0][0][tr_id] * 0.05, 0, 50, color='r', alpha=0.8)
- plt.vlines(triggers_tot[0, 0][1][0] * 0.05, 0, 50, color='k', alpha=0.8)
- # # plt.vlines(triggers_tot[0, 0][0][3], 0, 50, color='r', alpha=0.8)
- # plt.subplot(212)
- # plt.pcolormesh(tt1, ff[fidx], Sxx1[fidx, :])
- # plt.vlines(triggers_tot[0, 0][0][3] * 0.05, 0, fmax, color='r', alpha=0.8)
- # plt.xlim(0, tt2.max())
- # # plt.clim(0, 1)
- plt.draw()
- plt.show()
|