Skip to content

Commit 0535ff3

Browse files
committed
replace print with logger
1 parent 7adcd7a commit 0535ff3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/dynamic_routing_analysis/decoding_utils.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,25 +1298,25 @@ def concat_decoder_results(files,savepath=None,return_table=True,single_session=
12981298
session_id=str(list(decoder_results.keys())[0])
12991299
session_info=npc_lims.get_session_info(session_id)
13001300
project=str(session_info.project)
1301-
print('loading session: '+session_id)
1301+
logger.info('loading session: '+session_id)
13021302
try:
13031303
performance=pd.read_parquet(
13041304
npc_lims.get_cache_path('performance',session_info.id,version='any')
13051305
)
13061306
except:
1307-
print('no cached performance table, skipping')
1307+
logger.info('no cached performance table, skipping')
13081308
continue
13091309

13101310
if session_info.is_annotated==False:
1311-
print('session not annotated, skipping')
1311+
logger.info('session not annotated, skipping')
13121312
continue
13131313

13141314
all_bal_acc[session_id]={}
13151315
all_trials_bal_acc[session_id]={}
13161316

13171317
nunits=decoder_results[session_id]['n_units']
13181318
if nunits!=nunits_global:
1319-
print('WARNING, session '+session_id+' has different n_units; skipping')
1319+
logger.info('WARNING, session '+session_id+' has different n_units; skipping')
13201320
continue
13211321

13221322
shifts=decoder_results[session_id]['shifts']
@@ -1356,7 +1356,7 @@ def concat_decoder_results(files,savepath=None,return_table=True,single_session=
13561356
if rr in decoder_results[session_id]['results'][aa]['shift'][nu].keys():
13571357
temp_bal_acc=[]
13581358
# else:
1359-
# print('n repeats invalid: '+str(rr))
1359+
# logger.info('n repeats invalid: '+str(rr))
13601360
# continue
13611361
for sh in half_shift_inds:
13621362
if sh in list(decoder_results[session_id]['results'][aa]['shift'][nu][rr].keys()):
@@ -1440,7 +1440,7 @@ def concat_decoder_results(files,savepath=None,return_table=True,single_session=
14401440
linear_shift_dict['n_units'].append(np.nan)
14411441
linear_shift_dict['probe'].append(np.nan)
14421442

1443-
print(aa+' done')
1443+
logger.info(aa+' done')
14441444

14451445
linear_shift_df=pd.DataFrame(linear_shift_dict)
14461446

@@ -1468,13 +1468,13 @@ def concat_decoder_results(files,savepath=None,return_table=True,single_session=
14681468
else:
14691469
linear_shift_df.to_csv(upath.UPath(savepath / 'all_linear_shift_decoding_results.csv'))
14701470

1471-
print('saved decoder results table to:',savepath)
1471+
logger.info('saved decoder results table to:',savepath)
14721472

14731473
except Exception as e:
14741474
tb_str = traceback.format_exception(e, value=e, tb=e.__traceback__)
14751475
tb_str=''.join(tb_str)
1476-
print(tb_str)
1477-
print('error saving linear shift df')
1476+
logger.info(tb_str)
1477+
logger.info('error saving linear shift df')
14781478

14791479
del decoder_results
14801480
gc.collect()
@@ -1800,7 +1800,7 @@ def concat_trialwise_decoder_results(files,savepath=None,return_table=False,n_un
18001800
npc_lims.get_cache_path('performance',session_id,version='any')
18011801
)
18021802
except:
1803-
print('trials or performance not available; skipping session:',session_id)
1803+
logger.info('trials or performance not available; skipping session:',session_id)
18041804
continue
18051805

18061806
trials_since_rewarded_target=[]
@@ -1934,7 +1934,7 @@ def concat_trialwise_decoder_results(files,savepath=None,return_table=False,n_un
19341934
decision_function_shifts=np.vstack(decision_function_shifts)
19351935
predict_proba_shifts=np.vstack(predict_proba_shifts)
19361936
except:
1937-
print(session_id,'failed to stack decision functions / predict_proba; skipping')
1937+
logger.info(session_id,'failed to stack decision functions / predict_proba; skipping')
19381938
continue
19391939

19401940
# #normalize all decision function values to the stdev of all the nulls
@@ -2350,8 +2350,8 @@ def concat_trialwise_decoder_results(files,savepath=None,return_table=False,n_un
23502350

23512351
total_time=time.time()-start_time
23522352
session_time=time.time()-session_start_time
2353-
print('finished session:',session_id)
2354-
print('session time: ',session_time,' seconds; total time:',total_time,' seconds')
2353+
logger.info('finished session:',session_id)
2354+
logger.info('session time: ',session_time,' seconds; total time:',total_time,' seconds')
23552355

23562356
decoder_confidence_versus_response_type_dict=decoder_confidence_versus_response_type.copy()
23572357
decoder_confidence_dprime_by_block_dict=decoder_confidence_dprime_by_block.copy()
@@ -2412,7 +2412,7 @@ def concat_trialwise_decoder_results(files,savepath=None,return_table=False,n_un
24122412
decoder_confidence_all_trials.to_pickle(upath.UPath(savepath) / (temp_session_str+'decoder_confidence_all_trials'+n_units_str+'.pkl'))
24132413
decoder_confidence_before_after_target.to_pickle(upath.UPath(savepath) / (temp_session_str+'decoder_confidence_before_after_target'+n_units_str+'.pkl'))
24142414

2415-
print('saved '+n_units_str+' decoder confidence tables to:',savepath)
2415+
logger.info('saved '+n_units_str+' decoder confidence tables to:',savepath)
24162416

24172417
del decoder_results
24182418
gc.collect()

0 commit comments

Comments
 (0)