Skip to content

Commit

Permalink
Switch Isilon paths to S3
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhardcastle committed Jul 9, 2024
1 parent e73b29d commit 24d1e32
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 95 deletions.
6 changes: 4 additions & 2 deletions notebooks/compute_single_unit_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"import npc_lims\n",
"from npc_sessions import DynamicRoutingSession\n",
"from dynamic_routing_analysis import spike_utils, data_utils\n",
"import dynamic_routing_analysis as dra\n",
"import os\n",
"import pickle\n",
"\n",
Expand Down Expand Up @@ -67,15 +68,16 @@
"source": [
"except_dict={}\n",
"overwrite_files=False\n",
"save_path = r\"\\\\allen\\programs\\mindscope\\workgroups\\dynamicrouting\\Ethan\\new_annotations\\single unit metrics\"\n",
"save_path = dra.SINGLE_UNIT_METRICS_PATH\n",
"\n",
"for session_info in ephys_sessions[:]:\n",
" \n",
" try:\n",
" trials=[]\n",
" units=[]\n",
" ##skip if file already exists\n",
" if overwrite_files==False and os.path.isfile(os.path.join(save_path,session_info.id+'_stim_context_modulation.pkl')):\n",
" \n",
" if overwrite_files==False and (save_path / f\"{session_info.id}_stim_context_modulation.pkl\").exists():\n",
" print('session',session_info.id,'already processed; skipping')\n",
" continue\n",
" lick_save_path=os.path.join(save_path,'lick_modulation')\n",
Expand Down
14 changes: 10 additions & 4 deletions notebooks/decode_context_linear_shift_w_repeats_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from dynamic_routing_analysis import decoding_utils, plot_utils\n",
"import dynamic_routing_analysis as dra\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
Expand All @@ -25,7 +26,7 @@
"outputs": [],
"source": [
"#set path to decoding results\n",
"loadpath=r\"\\\\allen\\programs\\mindscope\\workgroups\\templeton\\TTOC\\decoding results\\new_annotations\\linear_shift_20_units\"\n",
"loadpath=dra.DECODING_ROOTH_PATH / \"new_annotations\" / \"linear_shift_20_units\"\n",
"files=glob.glob(os.path.join(loadpath,'*_decoding_results*.pkl'))"
]
},
Expand Down Expand Up @@ -620,22 +621,27 @@
"metadata": {},
"outputs": [],
"source": [
"#load all decoding results, option to concatenate all sessions\n",
"# load all decoding results, option to concatenate all sessions\n",
"concat_session_results=False\n",
"save_table=False\n",
"return_table=False\n",
"\n",
"all_decoder_results_path=os.path.join(loadpath,'combined','all_unit_linear_shift_use_more_trials.csv')\n",
"\n",
"if save_table:\n",
" savepath=r\"\\\\allen\\programs\\mindscope\\workgroups\\templeton\\TTOC\\decoding results\\new_annotations\\linear_shift_20_units\\combined\"\n",
" savepath = (\n",
" dra.DECODING_ROOTH_PATH\n",
" / \"new_annotations\"\n",
" / \"linear_shift_20_units\"\n",
" / \"combined\"\n",
" )\n",
"else:\n",
" savepath=None\n",
"\n",
"if concat_session_results:\n",
" all_decoder_results=decoding_utils.concat_decoder_results(files,savepath=savepath,return_table=return_table)\n",
"else:\n",
" all_decoder_results=pd.read_csv(all_decoder_results_path)\n"
" all_decoder_results=pd.read_csv(all_decoder_results_path)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from dynamic_routing_analysis import decoding_utils, plot_utils\n",
"import dynamic_routing_analysis as dra\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
Expand All @@ -26,8 +27,8 @@
"metadata": {},
"outputs": [],
"source": [
"#set path to decoding results\n",
"loadpath=r\"\\\\allen\\programs\\mindscope\\workgroups\\templeton\\TTOC\\decoding results\\new_annotations\\linear_shift_20_units\"\n",
"# set path to decoding results\n",
"loadpath = dra.DECODING_ROOTH_PATH / \"new_annotations\" / \"linear_shift_20_units\"\n",
"files=glob.glob(os.path.join(loadpath,'*_decoding_results*.pkl'))"
]
},
Expand All @@ -37,11 +38,17 @@
"metadata": {},
"outputs": [],
"source": [
"#load all trialwise decoding results, option to concatenate all sessions\n",
"# load all trialwise decoding results, option to concatenate all sessions\n",
"concat_session_results=False\n",
"save_tables=False\n",
"return_table=False\n",
"loadpath=r\"\\\\allen\\programs\\mindscope\\workgroups\\templeton\\TTOC\\decoding results\\new_annotations\\linear_shift_20_units\\combined\\no_normalization\"\n",
"loadpath = (\n",
" dra.DECODING_ROOTH_PATH\n",
" / \"new_annotations\"\n",
" / \"linear_shift_20_units\"\n",
" / \"combined\" \n",
" / \"no_normalization\"\n",
")\n",
"if save_tables:\n",
" savepath=loadpath\n",
"else:\n",
Expand All @@ -60,7 +67,7 @@
" decoder_confidence_dprime_by_block=pd.read_csv(os.path.join(loadpath,'decoder_confidence_dprime_by_block.csv'))\n",
" decoder_confidence_by_switch=pd.read_csv(os.path.join(loadpath,'decoder_confidence_by_switch.csv'))\n",
" decoder_confidence_versus_trials_since_rewarded_target=pd.read_csv(os.path.join(loadpath,'decoder_confidence_versus_trials_since_rewarded_target.csv'))\n",
" decoder_confidence_before_after_target=pd.read_csv(os.path.join(loadpath,'decoder_confidence_before_after_target.csv'))\n"
" decoder_confidence_before_after_target=pd.read_csv(os.path.join(loadpath,'decoder_confidence_before_after_target.csv'))"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion notebooks/decoding_example_egm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"import npc_lims\n",
"from npc_sessions import DynamicRoutingSession\n",
"from dynamic_routing_analysis import decoding_utils\n",
"import dynamic_routing_analysis as dra\n",
"\n",
"import os\n",
"\n",
Expand Down Expand Up @@ -222,7 +223,7 @@
],
"source": [
"#2 set savepath and filename\n",
"savepath=r'\\\\allen\\programs\\mindscope\\workgroups\\templeton\\TTOC\\decoding results\\new_annotations\\linear_shift_20_units_re_run'\n",
"savepath=dra.DECODING_ROOTH_PATH / \"new_annotations\" / \"linear_shift_20_units_re_run\"\n",
"filename='decoding_results_linear_shift_20_units_re_run.pkl'\n",
"\n",
"except_list={}\n",
Expand Down
4 changes: 3 additions & 1 deletion notebooks/decoding_timebins_egm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"import npc_lims\n",
"from npc_sessions import DynamicRoutingSession\n",
"from dynamic_routing_analysis import decoding_utils\n",
"import dynamic_routing_analysis as dra\n",
"\n",
"\n",
"import os"
]
Expand Down Expand Up @@ -727,7 +729,7 @@
" if s.is_uploaded and s.is_annotated and \n",
" s.project=='DynamicRouting')\n",
"\n",
"savepath=r'C:\\Users\\ethan.mcbride\\OneDrive - Allen Institute\\DR decoding results\\by_session\\decode_timebins'\n",
"savepath= dra.DECODING_ROOTH_PATH / \"decode_timebins\"\n",
"filename='decode_timebins.pkl'\n",
"\n",
"except_list={}\n",
Expand Down
22 changes: 13 additions & 9 deletions notebooks/plot_decoder_accuracy_on_CCF.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"import numpy as np\n",
"import os\n",
"from pathlib import Path\n",
"import dynamic_routing_analysis as dra\n",
"\n",
"from allensdk.core.reference_space_cache import ReferenceSpaceCache\n",
"\n",
Expand All @@ -23,24 +24,23 @@
"metadata": {},
"outputs": [],
"source": [
"output_dir=r\"D:\\CCF\\cache\"\n",
"reference_space_key = 'annotation/ccf_2022'\n",
"output_dir = dra.ANALYSIS_ROOT_PATH / \"ccf_cache\"\n",
"reference_space_key = \"annotation/ccf_2022\"\n",
"resolution = 10\n",
"rspc = ReferenceSpaceCache(resolution, reference_space_key, manifest=Path(output_dir) / 'manifest.json')\n",
"\n",
"# get structure tree\n",
"# ID 1 is the adult mouse structure graph\n",
"tree = rspc.get_structure_tree(structure_graph_id=1) \n",
"\n",
"#get id_acronym map\n",
"# get id_acronym map\n",
"id_acronym_map = tree.get_id_acronym_map()\n",
"\n",
"#make reference space object\n",
"# make reference space object\n",
"rsp = rspc.get_reference_space()\n",
"\n",
"#get annotation volume\n",
"annotation, meta = rspc.get_annotation_volume()\n",
"\n"
"# get annotation volume\n",
"annotation, meta = rspc.get_annotation_volume()"
]
},
{
Expand Down Expand Up @@ -238,9 +238,13 @@
"metadata": {},
"outputs": [],
"source": [
"#load deocder accuracy by CCF area\n",
"# load deocder accuracy by CCF area\n",
"\n",
"ccf_coords_by_session_area=pd.read_csv(r\"\\\\allen\\programs\\mindscope\\workgroups\\templeton\\TTOC\\decoding results\\new_annotations\\linear_shift_20_units\\combined\\all_unit_linear_shift_use_more_trials.csv\")\n"
"ccf_coords_by_session_area = pd.read_csv(\n",
" dra.DECODING_ROOTH_PATH\n",
" / \"new_annotations\"\n",
" / \"linear_shift_20_units/combined/all_unit_linear_shift_use_more_trials.csv\"\n",
")"
]
},
{
Expand Down
39 changes: 20 additions & 19 deletions notebooks/single_unit_metrics_CCF_plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"from pathlib import Path\n",
"from allensdk.core.reference_space_cache import ReferenceSpaceCache\n",
"from dynamic_routing_analysis import spike_utils\n",
"import dynamic_routing_analysis as dra\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
Expand All @@ -40,7 +41,7 @@
"#load CCF\n",
"\n",
"#set this to the directory where you want the CCF to be downloaded\n",
"output_dir=r\"D:\\CCF\\cache\"\n",
"output_dir=dra.ANALYSIS_ROOT_PATH / \"ccf_cache\"\n",
"reference_space_key = 'annotation/ccf_2022'\n",
"resolution = 10\n",
"rspc = ReferenceSpaceCache(resolution, reference_space_key, manifest=Path(output_dir) / 'manifest.json')\n",
Expand All @@ -62,7 +63,7 @@
"outputs": [],
"source": [
"#load single cell metric data\n",
"all_data_path=r\"\\\\allen\\programs\\mindscope\\workgroups\\dynamicrouting\\Ethan\\new_annotations\\single unit metrics\\combined\\all_data_plus_performance.pkl\"\n",
"all_data_path=dra.SINGLE_UNIT_METRICS_PATH / \"new_annotations/single unit metrics/combined/all_data_plus_performance.pkl\"\n",
"all_data=pd.read_pickle(all_data_path)"
]
},
Expand Down Expand Up @@ -1119,7 +1120,7 @@
}
],
"source": [
"#plot histogram on successive coronal slices\n",
"# plot histogram on successive coronal slices\n",
"\n",
"# plot slices\n",
"dprime_thresh=1.0\n",
Expand All @@ -1128,7 +1129,9 @@
"\n",
"slice_size=500\n",
"slice_pos_array=np.arange(2000+slice_size/2,10500,slice_size)\n",
"savepath=r\"C:\\Users\\ethan.mcbride\\OneDrive - Allen Institute\\quick figures\\2024-05-23-single_unit_topography\"\n",
"savepath = (\n",
" dra.ANALYSIS_ROOT_PATH / \"quick-figures/2024-05-23-single_unit_topography\"\n",
")\n",
"\n",
"# plot_variable='context_roc_auc'\n",
"# plot_variable='sound1_roc_auc'\n",
Expand Down Expand Up @@ -1172,7 +1175,7 @@
"\n",
" # filesavepath=os.path.join(savepath,plot_variable+'_coronal_slice_'+str(int(slice_pos))+'.png')\n",
" # plt.savefig(filesavepath,dpi=300)\n",
" # plt.close(fig)\n"
" # plt.close(fig)"
]
},
{
Expand Down Expand Up @@ -1607,7 +1610,7 @@
}
],
"source": [
"#plot multiple unit metrics on one figure\n",
"# plot multiple unit metrics on one figure\n",
"\n",
"# plot slices\n",
"dprime_thresh=1.0\n",
Expand All @@ -1616,8 +1619,7 @@
"\n",
"slice_size=500\n",
"slice_pos_array=np.arange(2000+slice_size/2,10500,slice_size)\n",
"savepath=r\"C:\\Users\\ethan.mcbride\\OneDrive - Allen Institute\\quick figures\\2024-05-23-single_unit_topography\"\n",
"\n",
"savepath = dra.ANALYSIS_ROOT_PATH / \"quick-figures/2024-05-23-single_unit_topography\"\n",
"plot_variables=['context_roc_auc','lick_roc_auc','sound1_roc_auc','vis1_roc_auc']\n",
"\n",
"\n",
Expand Down Expand Up @@ -1670,7 +1672,7 @@
"\n",
" # filesavepath=os.path.join(savepath,'combined','combined_coronal_slice_'+str(int(slice_pos))+'.png')\n",
" # plt.savefig(filesavepath,dpi=300)\n",
" # plt.close(fig)\n"
" # plt.close(fig)"
]
},
{
Expand Down Expand Up @@ -2117,8 +2119,9 @@
"\n",
"slice_size=500\n",
"slice_pos_array=np.arange(2000+slice_size/2,10500,slice_size)\n",
"savepath=r\"C:\\Users\\ethan.mcbride\\OneDrive - Allen Institute\\quick figures\\2024-05-23-single_unit_topography\"\n",
"\n",
"savepath = (\n",
" dra.ANALYSIS_ROOT_PATH / \"quick-figures/2024-05-23-single_unit_topography\"\n",
")\n",
"plot_variables=['context','lick','sound1','vis1']\n",
"\n",
"\n",
Expand Down Expand Up @@ -2588,7 +2591,7 @@
}
],
"source": [
"#plot histogram on successive horizontal slices\n",
"# plot histogram on successive horizontal slices\n",
"\n",
"# plot slices\n",
"dprime_thresh=1.0\n",
Expand All @@ -2597,8 +2600,7 @@
"\n",
"slice_size=500\n",
"slice_pos_array=np.arange(slice_size/2,8000+slice_size/2,slice_size)\n",
"savepath=r\"C:\\Users\\ethan.mcbride\\OneDrive - Allen Institute\\quick figures\\2024-05-23-single_unit_topography\"\n",
"\n",
"savepath = dra.ANALYSIS_ROOT_PATH / \"quick-figures/2024-05-23-single_unit_topography\"\n",
"plot_variable='context_roc_auc'\n",
"# plot_variable='sound1_roc_auc'\n",
"# plot_variable='vis1_roc_auc'\n",
Expand Down Expand Up @@ -2639,7 +2641,7 @@
"\n",
" # filesavepath=os.path.join(savepath,plot_variable+'_horizontal_slice_'+str(int(slice_pos))+'.png')\n",
" # plt.savefig(filesavepath,dpi=300)\n",
" # plt.close(fig)\n"
" # plt.close(fig)"
]
},
{
Expand Down Expand Up @@ -3056,7 +3058,7 @@
}
],
"source": [
"#plot histogram on successive horizontal slices\n",
"# plot histogram on successive horizontal slices\n",
"\n",
"# plot slices\n",
"dprime_thresh=1.0\n",
Expand All @@ -3065,8 +3067,7 @@
"\n",
"slice_size=500\n",
"slice_pos_array=np.arange(slice_size/2,8000+slice_size/2,slice_size)\n",
"savepath=r\"C:\\Users\\ethan.mcbride\\OneDrive - Allen Institute\\quick figures\\2024-05-23-single_unit_topography\"\n",
"\n",
"savepath = dra.ANALYSIS_ROOT_PATH / \"quick-figures/2024-05-23-single_unit_topography\"\n",
"plot_variable='context_roc_auc'\n",
"# plot_variable='sound1_roc_auc'\n",
"# plot_variable='vis1_roc_auc'\n",
Expand Down Expand Up @@ -3106,7 +3107,7 @@
"\n",
" # filesavepath=os.path.join(savepath,plot_variable+'_sagittal_slice_'+str(int(slice_pos))+'.png')\n",
" # plt.savefig(filesavepath,dpi=300)\n",
" # plt.close(fig)\n"
" # plt.close(fig)"
]
},
{
Expand Down
13 changes: 7 additions & 6 deletions notebooks/single_unit_metrics_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from dynamic_routing_analysis import spike_utils, plot_utils\n",
"import dynamic_routing_analysis as dra\n",
"import os\n",
"\n",
"%load_ext autoreload\n",
Expand All @@ -22,19 +23,19 @@
"metadata": {},
"outputs": [],
"source": [
"#load data\n",
"# load data\n",
"regenerate_table=False\n",
"all_data_loadpath=r\"\\\\allen\\programs\\mindscope\\workgroups\\dynamicrouting\\Ethan\\new_annotations\\single unit metrics\\combined\\all_data_plus_performance.pkl\"\n",
"all_data_loadpath=dra.SINGLE_UNIT_METRICS_PATH / \"combined\" / \"all_data_plus_performance.pkl\"\n",
"\n",
"if regenerate_table:\n",
" savepath=r\"\\\\allen\\programs\\mindscope\\workgroups\\dynamicrouting\\Ethan\\new_annotations\\single unit metrics\\combined\"\n",
" stim_context_loadpath = r\"\\\\allen\\programs\\mindscope\\workgroups\\dynamicrouting\\Ethan\\new_annotations\\single unit metrics\"\n",
" lick_loadpath = r\"\\\\allen\\programs\\mindscope\\workgroups\\dynamicrouting\\Ethan\\new_annotations\\single unit metrics\\lick_modulation\"\n",
" savepath = dra.SINGLE_UNIT_METRICS_PATH / \"combined\"\n",
" stim_context_loadpath = dra.SINGLE_UNIT_METRICS_PATH\n",
" lick_loadpath = dra.SINGLE_UNIT_METRICS_PATH / \"lick_modulation\"\n",
" performance_loadpath = os.path.join(savepath,\"performance_dict.pkl\")\n",
" spike_utils.concat_single_unit_metrics_across_sessions(stim_context_loadpath=stim_context_loadpath,lick_loadpath=lick_loadpath,\n",
" performance_loadpath=None,savepath=savepath)\n",
"\n",
"all_data = pd.read_pickle(all_data_loadpath)\n"
"all_data = pd.read_pickle(all_data_loadpath)"
]
},
{
Expand Down
Loading

0 comments on commit 24d1e32

Please sign in to comment.