def auto_plot_8(data1, data2): g0 = data2.data_extra[2] g1 = data2.data_extra[3] g2 = data2.data_extra[4] g3 = data2.data_extra[5] f, axarr = plt.subplots(3, sharex=True, figsize=(8.5, 6.1)) time_a, res_a, min_a, max_a = analysis.periodo(data1.v_live) time_b, res_b, min_b, max_b = analysis.periodo(data1.v_model_scaled) res_times = [] #Recorremos elementos for i in range(len(time_a)): #Para cada elementos recorremos su entorno tmp_min = 99999 for j in range(50): if i - j >= 0 and i - j < len(time_b): tmp = abs(time_a[i] - time_b[i - j]) if tmp < tmp_min: tmp_min = tmp if i + j < len(time_b): tmp = abs(time_a[i] - time_b[i + j]) if tmp < tmp_min: tmp_min = tmp res_times.append(tmp_min) axarr[0].plot(data1.time, data1.v_model_scaled, label="Model", linewidth=0.4) axarr[0].plot(data1.time, data1.v_live, label="Live", linewidth=0.4) axarr[0].plot(time_a, res_a, 'o', linewidth=0.4) axarr[0].plot(time_b, res_b, 'o', linewidth=0.4) axarr[0].axhline(y=max_a, color='C1', linestyle='--', linewidth=0.2) axarr[0].axhline(y=min_a, color='C1', linestyle='--', linewidth=0.2) axarr[0].axhline(y=max_b, color='C2', linestyle='--', linewidth=0.2) axarr[0].axhline(y=min_b, color='C2', linestyle='--', linewidth=0.2) axarr[0].set_title("Voltage") axarr[0].legend() axarr[1].plot(data2.time, data2.data_extra[0]) axarr[1].plot(data2.time, data2.data_extra[1]) axarr[1].set_title("Conductances") axarr[1].legend() t2 = np.linspace(0, t[len(t) - 1], num=len(res_times)) axarr[2].plot(t2, res_times) axarr[2].set_title("Phase") axarr[2].legend() plt.xlabel("Time (s)") plt.tight_layout() plt.show()
def save_events(data1, data2, args): times = pa.periodo(data1.time, data1.time_ms, data1.v_model_scaled, args.freq, all_events=True)[0] pa.events_to_file(times, 'extra/' + args.file + '_1_events_model.txt') times = pa.periodo(data1.time, data1.time_ms, data1.data_in[0], args.freq, all_events=True)[0] pa.events_to_file(times, 'extra/' + args.file + '_1_events_live.txt')
def plot_regularity(data1, data2, args): t_exp = (5 + 480) * args.freq t_post = (5 + 480 + 480) * args.freq times = pa.periodo(data1.time[:t_exp], data1.time_ms[:t_exp], data1.data_in[0][:t_exp], args.freq)[0] pa.cal_coef_var(times, True) times = pa.periodo(data1.time[t_exp:t_post], data1.time_ms[t_exp:t_post], data1.data_in[0][t_exp:t_post], args.freq)[0] pa.cal_coef_var(times, True) times = pa.periodo(data1.time[t_post:], data1.time_ms[t_post:], data1.data_in[0][t_post:], args.freq)[0] pa.cal_coef_var(times, True) ############################## ############################## times = pa.periodo(data1.time, data1.time_ms, data1.v_model_scaled, args.freq)[0] times1, res1 = pa.regularity2(times) times = pa.periodo(data1.time, data1.time_ms, data1.data_in[0], args.freq)[0] times2, res2 = pa.regularity2(times) #Crete and size plt.figure(figsize=(12, 8)) #Plots ax1 = plt.subplot(2, 1, 1) plot_line_voltage(data1, data2, args) ax2 = plt.subplot(2, 1, 2, sharex=ax1) plt.plot(times1, res1, label="Model neuron period variance (%)", linewidth=0.8) plt.plot(times2, res2, label="Living neuron period variance (%)", linewidth=0.8) plt.ylim([0, 100]) plt.ylabel("Variance percentage") plt.legend(loc=1, framealpha=1.0) #Details plt.xlabel("Time (s)") plt.tight_layout() plt.show()
######## # EXTRAER EVENTOS ######## ''' data1.v_model_scaled[t_ignore:t_ignore_fin] = fil.butter_filter(data1.v_model_scaled[t_ignore:t_ignore_fin], 150, args.freq) data1.data_in[0][t_ignore:t_ignore_fin] = fil.butter_filter(data1.data_in[0][t_ignore:t_ignore_fin], 150, args.freq) fil.threshold_filter(data1.v_model_scaled[t_ignore:t_ignore_fin], 0) fil.threshold_filter(data1.data_in[0][t_ignore:t_ignore_fin], 0) ''' times, model_times_ms, events, minis, maxis = pa.periodo( data1.time[t_ignore:t_ignore_fin], data1.time_ms[t_ignore:t_ignore_fin], data1.v_model_scaled[t_ignore:t_ignore_fin], args.freq, all_events=True, plot_on=verbose) t_model_first, t_model_last = pa.clean_all_events(times, events, plot_on=verbose) times, living_times_ms, events, minis, maxis = pa.periodo( data1.time[t_ignore:t_ignore_fin], data1.time_ms[t_ignore:t_ignore_fin], data1.data_in[0][t_ignore:t_ignore_fin], args.freq, all_events=True, plot_on=verbose) t_living_first, t_living_last = pa.clean_all_events(times,