From 3b051e45a480853152e33818bb3ee1636812d4e7 Mon Sep 17 00:00:00 2001 From: Mayo Faulkner Date: Tue, 17 Dec 2024 13:19:03 +0000 Subject: [PATCH] add back compatibility for old json keys --- brainbox/behavior/training.py | 2 +- ibllib/pipes/training_status.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/brainbox/behavior/training.py b/brainbox/behavior/training.py index 59abd8563..a8f2f383d 100644 --- a/brainbox/behavior/training.py +++ b/brainbox/behavior/training.py @@ -870,7 +870,7 @@ def criterion_1a(psych, n_trials, perf_easy, signed_contrast): criteria = Bunch() criteria['Zero_contrast'] = {'val': signed_contrast, 'pass': np.any(signed_contrast == 0)} - criteria['LapseLow_50'] = {'val': psych[2], 'pass': psych[2] < 0.2 } + criteria['LapseLow_50'] = {'val': psych[2], 'pass': psych[2] < 0.2} criteria['LapseHigh_50'] = {'val': psych[3], 'pass': psych[3] < 0.2} criteria['Bias'] = {'val': psych[0], 'pass': abs(psych[0]) < 16} criteria['Threshold'] = {'val': psych[1], 'pass': psych[1] < 19} diff --git a/ibllib/pipes/training_status.py b/ibllib/pipes/training_status.py index 6a6ece21f..50d28707f 100644 --- a/ibllib/pipes/training_status.py +++ b/ibllib/pipes/training_status.py @@ -116,7 +116,7 @@ def load_existing_dataframe(subj_path): return None -def load_trials(sess_path, one, collections=None, force=True, mode='warn'): +def load_trials(sess_path, one, collections=None, force=True, mode='raise'): """ Load trials data for session. First attempts to load from local session path, if this fails will attempt to download via ONE, if this also fails, will then attempt to re-extract locally @@ -208,9 +208,11 @@ def load_combined_trials(sess_paths, one, force=True): """ trials_dict = {} for sess_path in sess_paths: - trials = load_trials(Path(sess_path), one, force=force) + trials = load_trials(Path(sess_path), one, force=force, mode='warn') if trials is not None: - trials_dict[Path(sess_path).stem] = load_trials(Path(sess_path), one, force=force) + trials_dict[Path(sess_path).stem] = load_trials(Path(sess_path), one, force=force, mode='warn' + + ) return training.concatenate_trials(trials_dict) @@ -442,12 +444,13 @@ def compute_session_duration_delay_location(sess_path, collections=None, **kwarg try: start_time, end_time = _get_session_times(sess_path, md, sess_data) session_duration = session_duration + int((end_time - start_time).total_seconds() / 60) - session_delay = session_delay + md.get('SESSION_DELAY_START', 0) + session_delay = session_delay + md.get('SESSION_DELAY_START', + md.get('SESSION_START_DELAY_SEC', 0)) except Exception: session_duration = session_duration + 0 session_delay = session_delay + 0 - if 'ephys' in md.get('RIG_NAME', None): + if 'ephys' in md.get('RIG_NAME', md.get('PYBPOD_BOARD', None)): session_location = 'ephys_rig' else: session_location = 'training_rig' @@ -806,6 +809,7 @@ def _array_to_string(vals): axs[0].set_axis_off() axs[1].set_axis_off() + def plot_fit_params(df, subject): fig, axs = plt.subplots(2, 3, figsize=(12, 6), gridspec_kw={'width_ratios': [2, 2, 1]}) @@ -902,7 +906,7 @@ def plot_fit_params(df, subject): def plot_psychometric_curve(df, subject, one): df = df.drop_duplicates('date').reset_index(drop=True) sess_path = Path(df.iloc[-1]["session_path"]) - trials = load_trials(sess_path, one) + trials = load_trials(sess_path, one, mode='warn') fig, ax1 = plt.subplots(figsize=(8, 6))