From 46b1a6045f0ba1ccebc0b780b40cc5727aa918ca Mon Sep 17 00:00:00 2001 From: Christopher Morrison Date: Tue, 31 Oct 2023 13:35:45 -0700 Subject: [PATCH] Check for bad omitted stimulus at start of both active and passive blocks. --- .../data_objects/stimuli/presentations.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/allensdk/brain_observatory/behavior/data_objects/stimuli/presentations.py b/allensdk/brain_observatory/behavior/data_objects/stimuli/presentations.py index 0a36a240f..b935a2591 100644 --- a/allensdk/brain_observatory/behavior/data_objects/stimuli/presentations.py +++ b/allensdk/brain_observatory/behavior/data_objects/stimuli/presentations.py @@ -596,10 +596,18 @@ def _check_for_errant_omitted_stimulus( found, return input_df unmodified. """ if "omitted" in input_df.columns and len(input_df) > 0: - first_row = input_df.iloc[0] - if not pd.isna(first_row["omitted"]): - if first_row["omitted"]: - input_df = input_df.drop(first_row.name, axis=0) + if "stimulus_block" in input_df.columns: + for stim_block in input_df['stimulus_block'].unique(): + first_row = input_df[ + input_df['stimulus_block'] == stim_block].iloc[0] + if not pd.isna(first_row["omitted"]): + if first_row["omitted"]: + input_df = input_df.drop(first_row.name, axis=0) + else: + first_row = input_df.iloc[0] + if not pd.isna(first_row["omitted"]): + if first_row["omitted"]: + input_df = input_df.drop(first_row.name, axis=0) return input_df @staticmethod