From 81f4b179ba8577ec8fb9e0c972de9c4db89c0fc4 Mon Sep 17 00:00:00 2001 From: danielsf Date: Fri, 18 Feb 2022 11:20:32 -0800 Subject: [PATCH] remove unused invocations of np.max The second arg of np.max is actually an axis, so these calls to np.max were not clipping the max shifts to be >= 0 (in fact, if you look at tests/utils/test_motion_border.py, our unit tests were written to expect negative values as a legal output). Probably this was not intended, but, all of our code has been built around the current implementation, so I'm not going to alter the logic in get_max_correction_values now. Ticket #458 has been opened to do a more thorough and self-consistent investigation of our treatment of motion borders in the future. At that time, we can consider altering get_max_correction_values to only return values >= 0 --- src/ophys_etl/utils/motion_border.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ophys_etl/utils/motion_border.py b/src/ophys_etl/utils/motion_border.py index a736bd616..ab4bf0e0c 100644 --- a/src/ophys_etl/utils/motion_border.py +++ b/src/ophys_etl/utils/motion_border.py @@ -49,10 +49,10 @@ def get_max_correction_values(x_series: pd.Series, y_series: pd.Series, y_no_outliers = y_series[(y_series >= -max_shift) & (y_series <= max_shift)] # calculate max border shifts - right_shift = np.max(-1 * x_no_outliers.min(), 0) - left_shift = np.max(x_no_outliers.max(), 0) - down_shift = np.max(-1 * y_no_outliers.min(), 0) - up_shift = np.max(y_no_outliers.max(), 0) + right_shift = -1 * x_no_outliers.min() + left_shift = x_no_outliers.max() + down_shift = -1 * y_no_outliers.min() + up_shift = y_no_outliers.max() max_shift = MaxFrameShift(left=left_shift, right=right_shift, up=up_shift, down=down_shift)