def plot_speed(prm, speed_light, speed_nolight, param): print('plotting speed...') #plot continuous data fig = plt.figure(figsize=(14, 8)) ax = fig.add_subplot(111) ax.plot(np.arange(0, 20, 1), speed_light, label='light') ax.plot(np.arange(0, 20, 1), speed_nolight, label='nolight') vr_plot_utility.makelegend(fig, ax, 0.4) ax.tick_params(axis='x', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.tick_params(axis='y', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.locator_params(axis='x', nbins=7) # set number of ticks on x axis ax.locator_params(axis='y', nbins=7) # set number of ticks on y axis ax.set_xlabel('Location (cm)', fontsize=18, labelpad=20) ax.set_ylabel('Speed (cm/s)', fontsize=18, labelpad=20) vr_plot_utility.adjust_spines(ax, ['left', 'bottom']) vr_plot_utility.adjust_spine_thickness(ax) plt.subplots_adjust(hspace=.35, wspace=.35, bottom=0.15, left=0.15, right=0.92, top=0.92) if param == 1: fig.savefig(prm.get_filepath() + 'Behaviour/Analysis/Speed/' + 'Speed_light.png', dpi=200) plt.close() if param == 2: fig.savefig(prm.get_filepath() + 'Behaviour/Analysis/Speed/' + 'Speed_nolight.png', dpi=200) plt.close()
def plot_continuous_filtered_data(prm, channel_data_all, channel): start_time = 0 # in ms end_time = (np.array((25,50,100,500,1000,5000)))+ start_time # in ms for t, times in enumerate(end_time): end_time = times #plot continuous data fig = plt.figure(figsize = (14,8)) ax = fig.add_subplot(111) ax.plot(np.arange(start_time,end_time,(1/30)),channel_data_all[0,(start_time*30):(end_time*30)]) ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 8,labelsize =18) ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 8, labelsize =18) ax.locator_params(axis = 'x', nbins=7) # set number of ticks on x axis ax.locator_params(axis = 'y', nbins=7) # set number of ticks on y axis ax.set_xlabel('Time (ms)', fontsize=18, labelpad = 20) ax.set_ylabel('Amplitude (uV)', fontsize=18, labelpad = 20) vr_plot_utility.adjust_spines(ax, ['left','bottom']) vr_plot_utility.adjust_spine_thickness(ax) plt.subplots_adjust(hspace = .35, wspace = .35, bottom = 0.15, left = 0.15, right = 0.92, top = 0.92) fig.savefig(prm.get_filepath() + 'Electrophysiology/continuous/raw/CH' + str(channel) + '_' + str(end_time) + 'ms_filtered.png', dpi=200) plt.close()
def plot_continuous_opto_data(prm, data, channel, param): print('plotting continuous data...') data = data[data[:, 3] > 3, :] # remove all data in black box trials = np.unique(data[:, 1]) for tcount, trial in enumerate(trials[:20]): array = data[data[:, 1] == trial, :] trial_type = array[1, 2] print(trial_type) start_time = 900 # in ms try: end_time = (np.array((100, 500, 1000, 5000))) + start_time # in ms for t, times in enumerate(end_time): end_time = times fig = plt.figure(figsize=(7.5, 12)) ax = fig.add_subplot(511) ax.tick_params(axis='y', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.locator_params(axis='y', nbins=3) # set number of ticks on y axis ax.set_ylabel('Amplitude (uV)', fontsize=18, labelpad=20) array_min = np.min(array[(start_time * 30):(end_time * 30), 5]) opto_ch = (array[(start_time * 30):(end_time * 30), 0]) + (array_min - 5) ax.set_ylim(array_min - 10, array_min + 10) ax.plot(np.arange(0, end_time - start_time, (1 / 30)), opto_ch, 'k') vr_plot_utility.adjust_spines(ax, ['left']) vr_plot_utility.adjust_spine_thickness(ax) ax = fig.add_subplot(512) ax.plot(np.arange(0, end_time - start_time, (1 / 30)), array[(start_time * 30):(end_time * 30), 5]) ax.tick_params(axis='y', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.locator_params(axis='y', nbins=3) # set number of ticks on y axis ax.set_ylabel('Amplitude (uV)', fontsize=18, labelpad=20) array_min = np.min(array[(start_time * 30):(end_time * 30), 5]) #opto_ch = (array[(start_time*30):(end_time*30),0])+(array_min-5) ax.set_ylim(array_min - 10, ) vr_plot_utility.adjust_spines(ax, ['left']) vr_plot_utility.adjust_spine_thickness(ax) ax = fig.add_subplot(513) ax.plot(np.arange(0, end_time - start_time, (1 / 30)), array[(start_time * 30):(end_time * 30), 7]) ax.tick_params(axis='y', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.locator_params(axis='y', nbins=3) # set number of ticks on y axis ax.set_ylabel('Amplitude (uV)', fontsize=18, labelpad=20) array_min = np.min(array[(start_time * 30):(end_time * 30), 6]) ax.set_ylim(-200, 200) vr_plot_utility.adjust_spines(ax, ['left']) vr_plot_utility.adjust_spine_thickness(ax) ax = fig.add_subplot(514) ax.plot(np.arange(0, end_time - start_time, (1 / 30)), array[(start_time * 30):(end_time * 30), 9]) ax.plot(np.arange(0, end_time - start_time, (1 / 30)), array[(start_time * 30):(end_time * 30), 8]) ax.tick_params(axis='y', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.locator_params(axis='y', nbins=3) # set number of ticks on y axis ax.set_ylabel('Amplitude (uV)', fontsize=18, labelpad=20) array_min = np.min(array[(start_time * 30):(end_time * 30), 8]) opto_ch = (array[(start_time * 30):(end_time * 30), 0]) + (array_min - 5) ax.set_ylim(-270, 270) vr_plot_utility.adjust_spines(ax, ['left']) vr_plot_utility.adjust_spine_thickness(ax) ax = fig.add_subplot(515) ax.plot(np.arange(0, end_time - start_time, (1 / 30)), array[(start_time * 30):(end_time * 30), 3]) ax.tick_params(axis='x', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.tick_params(axis='y', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.locator_params(axis='x', nbins=7) # set number of ticks on x axis ax.locator_params(axis='y', nbins=3) # set number of ticks on y axis ax.set_xlabel('Time (ms)', fontsize=18, labelpad=20) ax.set_ylabel('Location (cm)', fontsize=18, labelpad=20) array_min = np.min(array[(start_time * 30):(end_time * 30), 4]) array_max = np.min(array[(start_time * 30):(end_time * 30), 4]) #ax.set_ylim(0,20) vr_plot_utility.adjust_spines(ax, ['left', 'bottom']) vr_plot_utility.adjust_spine_thickness(ax) plt.subplots_adjust(hspace=.35, wspace=.35, bottom=0.15, left=0.2, right=0.92, top=0.92) if param == 1: if trial_type == 0: fig.savefig( prm.get_filepath() + 'Electrophysiology/opto_stimulation/continuous/filtered/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_light.png', dpi=200) plt.close() if trial_type == 1: fig.savefig( prm.get_filepath() + 'Electrophysiology/opto_stimulation/continuous/filtered/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_light.png', dpi=200) plt.close() if trial_type == 2: fig.savefig( prm.get_filepath() + 'Electrophysiology/opto_stimulation/continuous/filtered/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_light.png', dpi=200) plt.close() if param == 2: if trial_type == 0: fig.savefig( prm.get_filepath() + 'Electrophysiology/opto_stimulation/continuous/filtered/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_nolight.png', dpi=200) plt.close() if trial_type == 1: fig.savefig( prm.get_filepath() + 'Electrophysiology/opto_stimulation/continuous/filtered/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_nonbeaconed_nolight.png', dpi=200) plt.close() if trial_type == 2: fig.savefig( prm.get_filepath() + 'Electrophysiology/opto_stimulation/continuous/filtered/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_probe_nolight.png', dpi=200) plt.close() except ValueError: continue
def plot_continuous_theta_opto_data(prm, theta, gamma, channel, param): print('plotting continuous data...') theta = theta[theta[:, 3] > 3, :] # remove all data in black box trials = np.unique(theta[:, 1]) for tcount, trial in enumerate(trials[:10]): theta = theta[theta[:, 1] == trial, :] gamma = gamma[gamma[:, 1] == trial, :] start_time = 0 # in ms end_time = (np.array( (25, 50, 100, 500, 1000, 5000))) + start_time # in ms for t, times in enumerate(end_time): end_time = times #plot continuous data fig = plt.figure(figsize=(14, 8)) ax = fig.add_subplot(111) ax.plot(np.arange(start_time, end_time, (1 / 30)), theta[(start_time * 30):(end_time * 30), 5]) ax.plot(np.arange(start_time, end_time, (1 / 30)), gamma[(start_time * 30):(end_time * 30), 5], 'r') array_min = np.min(theta[(start_time * 30):(end_time * 30), 5]) opto_ch = (theta[(start_time * 30):(end_time * 30), 0]) + (array_min - 5) ax.set_ylim(array_min - 10, ) ax.plot(np.arange(start_time, end_time, (1 / 30)), opto_ch, 'k') ax.tick_params(axis='x', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.tick_params(axis='y', pad=10, top='off', right='off', direction='out', width=2, length=8, labelsize=18) ax.locator_params(axis='x', nbins=7) # set number of ticks on x axis ax.locator_params(axis='y', nbins=7) # set number of ticks on y axis ax.set_xlabel('Time (ms)', fontsize=18, labelpad=20) ax.set_ylabel('Amplitude (uV)', fontsize=18, labelpad=20) vr_plot_utility.adjust_spines(ax, ['left', 'bottom']) vr_plot_utility.adjust_spine_thickness(ax) plt.subplots_adjust(hspace=.35, wspace=.35, bottom=0.15, left=0.15, right=0.92, top=0.92) if param == 1: fig.savefig(prm.get_filepath() + 'Electrophysiology/opto_stimulation/theta/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_light.png', dpi=200) plt.close() if param == 2: fig.savefig(prm.get_filepath() + 'Electrophysiology/opto_stimulation/theta/CH' + str(channel) + '_' + str(trial) + '_' + str(end_time - start_time) + 'ms_nolight.png', dpi=200) plt.close()