From 18efb1f3e228fea1b899f4a76397452853571ded Mon Sep 17 00:00:00 2001 From: Alex Piet Date: Thu, 23 Feb 2023 09:34:09 -0800 Subject: [PATCH] fixing limits --- visual_behavior_glm/GLM_perturbation_tools.py | 29 +++++++------------ visual_behavior_glm/GLM_strategy_tools.py | 8 ++++- .../strategy_paper_figure_script.py | 2 +- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/visual_behavior_glm/GLM_perturbation_tools.py b/visual_behavior_glm/GLM_perturbation_tools.py index 07bc210a..66c63c9b 100644 --- a/visual_behavior_glm/GLM_perturbation_tools.py +++ b/visual_behavior_glm/GLM_perturbation_tools.py @@ -303,24 +303,6 @@ def get_points(df,ellipse=True): y=y+this_y return np.array([x,y]).T -def get_ellipse_points(df): - plt.figure() - for index, row in df.iterrows(): - plt.plot(row.x,row.y,'ro') - plt.plot([row.x1,row.x2],[row.y,row.y],'r-') - plt.plot([row.x,row.x],[row.y1,row.y2],'r-') - r1 = (row.x2-row.x1)/2 - r2 = (row.y2-row.y1)/2 - n=20 - xpoints = [ - r1*np.cos(theta)+row.x - for theta in (np.pi*2 * i/n for i in range(n)) - ] - ypoints = [ - r2*np.sin(theta)+row.y - for theta in (np.pi*2 * i/n for i in range(n)) - ] - plt.plot(xpoints, ypoints, 'b-') def demonstrate_iterative_ch(Fvisual,kernel='omissions',show_steps=True, x='Slc17a7-IRES2-Cre',y='y'): ''' @@ -393,6 +375,15 @@ def plot_multiple(weights_df, run_params,savefig=False): def plot_perturbation(weights_df, run_params, kernel,experience_level="Familiar", savefig=False,lims = None,show_steps=False,ax=None,col1=False,row1=False,multi=False, x = 'Slc17a7-IRES2-Cre',y='Vip-IRES-Cre'): + + limit_list = { + 'Slc17a7-IRES2-Cre':[-.0005,0.002], + 'Sst-IRES-Cre':[-0.006,0.0125], + 'Vip-IRES-Cre':[-0.005,0.025], + 'y':[0,0.01], + } + lims=[limit_list[x], limit_list[y]] + visual, timing = get_perturbation(weights_df, run_params,kernel,experience_level) time = visual['time'] offset = 0 @@ -471,7 +462,7 @@ def plot_perturbation(weights_df, run_params, kernel,experience_level="Familiar" if savefig: filepath = run_params['figure_dir']+\ - '/strategy/'+kernel+'_strategy_perturbation_{}.svg'.format(experience_level) + '/strategy/'+kernel+'_strategy_perturbation_{}_{}_{}.svg'.format(experience_level,x,y) print('Figure saved to: '+filepath) plt.savefig(filepath) diff --git a/visual_behavior_glm/GLM_strategy_tools.py b/visual_behavior_glm/GLM_strategy_tools.py index d3e5bcbf..1856b852 100644 --- a/visual_behavior_glm/GLM_strategy_tools.py +++ b/visual_behavior_glm/GLM_strategy_tools.py @@ -95,6 +95,11 @@ def kernels_by_cre(weights_beh, run_params, kernel='omissions', savefig=False, sharey=False, depth_filter=[0,1000]): cres = ['Vip-IRES-Cre','Sst-IRES-Cre','Slc17a7-IRES2-Cre'] + limit_list = { + 'Slc17a7-IRES2-Cre':[-.0005,0.002], + 'Sst-IRES-Cre':[-.006,0.0125], + 'Vip-IRES-Cre':[-0.005,0.025], + } for dex, cre in enumerate(cres): height = 4 width=8 @@ -129,7 +134,8 @@ def kernels_by_cre(weights_beh, run_params, kernel='omissions', ax.set_title(string_mapper(cre),fontsize=16) ax.set_ylabel(kernel+' weights\n(Ca$^{2+}$ events)',fontsize=16) - ylim=ax.get_ylim() + #ylim=ax.get_ylim() + ylim = limit_list[cre] ax.set_ylim(ylim) if kernel =='omissions': out[2].plot(0,ylim[0],'co',zorder=10,clip_on=False) diff --git a/visual_behavior_glm/strategy_paper_figure_script.py b/visual_behavior_glm/strategy_paper_figure_script.py index 017b4d15..b9c3be8d 100644 --- a/visual_behavior_glm/strategy_paper_figure_script.py +++ b/visual_behavior_glm/strategy_paper_figure_script.py @@ -154,7 +154,7 @@ gst.kernels_by_cre(weights_beh, run_params, 'misses') # Plot state space plots -gpt.plot_perturbation(weights_beh, run_params. 'all-images') +gpt.plot_perturbation(weights_beh, run_params, 'all-images') gpt.plot_perturbation(weights_beh, run_params, 'omissions') gpt.plot_perturbation(weights_beh, run_params, 'hits') gpt.plot_perturbation(weights_beh, run_params, 'misses')