Skip to content

Commit

Permalink
remove unused invocations of np.max
Browse files Browse the repository at this point in the history
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
  • Loading branch information
danielsf committed Feb 18, 2022
1 parent 8a1ebd5 commit 81f4b17
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ophys_etl/utils/motion_border.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 81f4b17

Please sign in to comment.