Skip to content

Commit

Permalink
attempt to clear memory after results files are saved
Browse files Browse the repository at this point in the history
  • Loading branch information
egmcbride committed Nov 1, 2024
1 parent a2c2a1c commit 8009868
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/dynamic_routing_analysis/decoding_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gc
import glob
import os
import pickle
Expand Down Expand Up @@ -881,6 +882,9 @@ def decode_context_with_linear_shift(session=None,params=None,trials=None,units=
only_use_all_units=params['only_use_all_units']
else:
only_use_all_units=False

if 'return_results' in params:
return_results=params['return_results']

if session is not None:
session_info=npc_lims.get_session_info(session)
Expand Down Expand Up @@ -1138,6 +1142,13 @@ def decode_context_with_linear_shift(session=None,params=None,trials=None,units=

print(f'finished {session_id}')
# print(f'time elapsed: {time.time()-start_time}')
del decoder_results
del trial_da
del units
del trials
gc.collect()
if return_results:
return decoder_results


def concat_decoder_results(files,savepath=None,return_table=True,single_session=False,use_zarr=False):
Expand Down Expand Up @@ -1331,8 +1342,12 @@ def concat_decoder_results(files,savepath=None,return_table=True,single_session=
print(e)
print('error saving linear shift df')

del decoder_results
gc.collect()

if return_table:
return linear_shift_df



def compute_significant_decoding_by_area(all_decoder_results):
Expand Down Expand Up @@ -2007,6 +2022,9 @@ def concat_trialwise_decoder_results(files,savepath=None,return_table=False,n_un

print('saved '+n_units_str+' decoder confidence tables to:',savepath)

del decoder_results
gc.collect()

if return_table:
return decoder_confidence_versus_response_type,decoder_confidence_dprime_by_block,decoder_confidence_by_switch,decoder_confidence_versus_trials_since_rewarded_target,decoder_confidence_before_after_target

Expand Down

0 comments on commit 8009868

Please sign in to comment.