-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import glob\n", | ||
"import numpy as np\n", | ||
"import scipy.stats as stats\n", | ||
"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", | ||
"import matplotlib\n", | ||
"import matplotlib.font_manager as fm\n", | ||
"\n", | ||
"matplotlib.rcParams['font.size'] = 8\n", | ||
"matplotlib.rcParams['pdf.fonttype'] = 42\n", | ||
"matplotlib.rcParams['ps.fonttype'] = 42\n", | ||
"fm.FontProperties().set_family('arial')\n", | ||
"\n", | ||
"%load_ext autoreload\n", | ||
"%autoreload 2\n", | ||
"%matplotlib inline\n", | ||
"# %matplotlib widget" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"loadpath={}\n", | ||
"\n", | ||
"# loadpath['no_unit_criteria']=r\"D:\\decoding_results_from_CO\\n_units_test_2024-11-06\"\n", | ||
"loadpath['svc_medium_unit_criteria']=r\"D:\\decoding_results_from_CO\\n_units_test_medium_unit_criteria_2024-11-07\"\n", | ||
"loadpath['lda_medium_criteria']=r\"D:\\decoding_results_from_CO\\lda_test_2024-11-11\"\n", | ||
"loadpath['logreg_medium_criteria']=r\"D:\\decoding_results_from_CO\\logreg_test_2024-11-13\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"decoder_results={}\n", | ||
"session_list={}\n", | ||
"for ll in loadpath.keys():\n", | ||
" all_decoder_results_path=os.path.join(loadpath[ll],'decoder_results_summary.csv')\n", | ||
" decoder_results[ll]=pd.read_csv(all_decoder_results_path)\n", | ||
" session_list[ll]=decoder_results[ll]['session_id'].unique()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"array(['620264_2022-08-02', '626791_2022-08-15', '626791_2022-08-16',\n", | ||
" '626791_2022-08-17', '628801_2022-09-19', '628801_2022-09-20',\n", | ||
" '636397_2022-09-26', '636397_2022-09-27', '636766_2023-01-23',\n", | ||
" '636766_2023-01-24', '636766_2023-01-25', '636766_2023-01-26',\n", | ||
" '644547_2022-12-05', '644547_2022-12-06', '644864_2023-01-30',\n", | ||
" '644864_2023-01-31', '644864_2023-02-02', '644866_2023-02-07',\n", | ||
" '644866_2023-02-08', '644866_2023-02-09', '644866_2023-02-10',\n", | ||
" '644867_2023-02-20', '644867_2023-02-22', '644867_2023-02-23',\n", | ||
" '646318_2023-01-17', '649943_2023-02-13', '649943_2023-02-14',\n", | ||
" '649943_2023-02-15', '649943_2023-02-16', '649944_2023-02-27',\n", | ||
" '649944_2023-02-28', '660023_2023-08-09', '662892_2023-08-21',\n", | ||
" '662892_2023-08-22', '662892_2023-08-23', '662892_2023-08-24',\n", | ||
" '662983_2023-05-15', '662983_2023-05-16', '664851_2023-11-13',\n", | ||
" '664851_2023-11-14', '664851_2023-11-15', '664851_2023-11-16',\n", | ||
" '666986_2023-08-14', '666986_2023-08-15', '666986_2023-08-16',\n", | ||
" '666986_2023-08-17', '667252_2023-09-26', '667252_2023-09-27',\n", | ||
" '667252_2023-09-28', '668755_2023-08-29', '668755_2023-08-30',\n", | ||
" '668755_2023-08-31', '668759_2023-07-11', '668759_2023-07-12',\n", | ||
" '670180_2023-07-27', '670181_2023-07-18', '670248_2023-08-01',\n", | ||
" '670248_2023-08-03', '681532_2023-10-16', '681532_2023-10-17',\n", | ||
" '681532_2023-10-18', '681532_2023-10-19', '686176_2023-12-04',\n", | ||
" '686176_2023-12-05', '686176_2023-12-06', '686176_2023-12-07',\n", | ||
" '686740_2023-10-23', '686740_2023-10-25', '686740_2023-10-26',\n", | ||
" '690706_2023-11-27', '690706_2023-11-28', '690706_2023-11-29',\n", | ||
" '690706_2023-11-30', '699847_2024-04-15', '699847_2024-04-16',\n", | ||
" '699847_2024-04-17', '699847_2024-04-18', '702131_2024-02-26',\n", | ||
" '703333_2024-04-08', '703333_2024-04-09', '703333_2024-04-10',\n", | ||
" '703333_2024-04-11', '703880_2024-04-15', '703880_2024-04-16',\n", | ||
" '703880_2024-04-17', '703880_2024-04-18', '703882_2024-04-22',\n", | ||
" '703882_2024-04-23', '703882_2024-04-24', '703882_2024-04-25',\n", | ||
" '706401_2024-04-23', '706401_2024-04-24', '708016_2024-04-29',\n", | ||
" '708016_2024-04-30', '708016_2024-05-01', '708016_2024-05-02',\n", | ||
" '712815_2024-05-21', '712815_2024-05-22', '713655_2024-08-05',\n", | ||
" '713655_2024-08-06', '713655_2024-08-07', '713655_2024-08-08',\n", | ||
" '713655_2024-08-09', '714748_2024-06-24', '714748_2024-06-25',\n", | ||
" '714748_2024-06-26', '714748_2024-06-27', '714753_2024-07-01',\n", | ||
" '714753_2024-07-02', '715710_2024-07-15', '715710_2024-07-16',\n", | ||
" '715710_2024-07-17', '715710_2024-07-18', '715710_2024-07-19',\n", | ||
" '726088_2024-06-17', '726088_2024-06-18', '726088_2024-06-20',\n", | ||
" '726088_2024-06-21', '733780_2024-08-26', '733780_2024-08-29',\n", | ||
" '733780_2024-08-30', '733780_2024-09-03', '733780_2024-09-05',\n", | ||
" '733780_2024-09-06'], dtype=object)" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"#need to match sessions\n", | ||
"# shared_sessions=np.intersect1d(np.intersect1d(np.intersect1d(\n", | ||
"# session_list['no_unit_criteria'],session_list['svc_medium_unit_criteria']),\n", | ||
"# session_list['lda_medium_criteria']),session_list['logreg_medium_criteria'])\n", | ||
"\n", | ||
"shared_sessions=np.intersect1d(np.intersect1d(\n", | ||
" session_list['logreg_medium_criteria'],session_list['svc_medium_unit_criteria']),\n", | ||
" session_list['lda_medium_criteria'])\n", | ||
"shared_sessions" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"area='CP'\n", | ||
"savepath=r\"C:\\Users\\ethan.mcbride\\OneDrive - Allen Institute\\quick figures\\2024-11-13-compare_decoder_models\"\n", | ||
"plot_n_units=[10,20,40]\n", | ||
"\n", | ||
"fig,ax=plt.subplots(1,1,figsize=(4,3))\n", | ||
"\n", | ||
"for ll in list(loadpath.keys())[:]:\n", | ||
" all_decoder_results=decoder_results[ll].query('area==@area and session_id in @shared_sessions and project==\"DynamicRouting\"')\n", | ||
" #compute fraction significant, difference from null for DynamicRouting and Templeton projects\n", | ||
" all_frac_sig_df,all_diff_from_null_df=decoding_utils.compute_significant_decoding_by_area(all_decoder_results)\n", | ||
"\n", | ||
" unique_areas=all_decoder_results['area'].unique()\n", | ||
" n_units=[]\n", | ||
" n_units_int=[]\n", | ||
" for col in all_frac_sig_df.filter(like='frac_sig_DR').columns.values:\n", | ||
" if len(col.split('_'))==4:\n", | ||
" if col.split('_')[3]=='all':\n", | ||
" continue\n", | ||
"\n", | ||
" n_units.append('_'+col.split('_')[3])\n", | ||
" n_units_int.append(int(col.split('_')[3]))\n", | ||
" \n", | ||
" else:\n", | ||
" n_units.append('')\n", | ||
" n_units_int.append(None)\n", | ||
"\n", | ||
" n_units_int=np.array(n_units_int)\n", | ||
"\n", | ||
" # for area in unique_areas[:]:\n", | ||
"\n", | ||
" area_df=all_diff_from_null_df.query('area==@area')\n", | ||
"\n", | ||
" temp_accuracy=[]\n", | ||
" temp_sem=[]\n", | ||
"\n", | ||
" for nu in n_units:\n", | ||
" if nu=='all':\n", | ||
" continue\n", | ||
" if len(area_df['diff_from_null_median_DR'+nu].values)==0:\n", | ||
" continue\n", | ||
" temp_accuracy.append(area_df['diff_from_null_median_DR'+nu].values[0])\n", | ||
" temp_sem.append(area_df['diff_from_null_sem_DR'+nu].values[0])\n", | ||
"\n", | ||
" # if len(temp_accuracy)==0:\n", | ||
" # continue\n", | ||
"\n", | ||
" temp_accuracy=np.array(temp_accuracy)\n", | ||
" temp_sem=np.array(temp_sem)\n", | ||
"\n", | ||
" n_units_incl=[]\n", | ||
" for ii,nui in enumerate(n_units_int):\n", | ||
" if nui in plot_n_units:\n", | ||
" n_units_incl.append(ii)\n", | ||
" n_units_incl=np.array(n_units_incl)\n", | ||
"\n", | ||
" # ax.axhline(y=0,color='k',linestyle='--',alpha=0.5)\n", | ||
" ax.errorbar(n_units_int[n_units_incl],temp_accuracy[n_units_incl],\n", | ||
" yerr=temp_sem[n_units_incl],marker='.',linestyle='-',label=ll)\n", | ||
" ax.set_xlabel('number of units')\n", | ||
" ax.set_ylabel('decoder accuracy above null')\n", | ||
" ax.set_title(area)\n", | ||
" # ax.set_ylim([-0.05,0.25])\n", | ||
"\n", | ||
"ax.legend()\n", | ||
"# fig.savefig(os.path.join(savepath,area+'_decoder_acc_by_n_units_comp.png'),format='png',bbox_inches='tight')\n", | ||
"# plt.close(fig)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#correlation between decoder models\n", | ||
"\n", | ||
"area_wise_decoder_model_comp={}\n", | ||
"\n", | ||
"#loop through areas\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "dr_analysis", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Large diffs are not rendered by default.