Skip to content

Commit

Permalink
calculate_mags_to_downsample: raise on infinite loop (#432)
Browse files Browse the repository at this point in the history
* calculate_mags_to_downsample: raise on infinite loop

* formatting
  • Loading branch information
jstriebel authored Sep 29, 2021
1 parent e551391 commit 4b20c69
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions webknossos/webknossos/dataset/downsampling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ def calculate_mags_to_downsample(
# The smaller the ratio between the smallest dimension and the largest dimension, the better.
if all_scaled_ratio < min_scaled_ratio:
# Multiply all dimensions with "2"
current_mag = Mag(np.minimum(current_mag.to_np() * 2, max_mag.to_np()))
new_mag = Mag(np.minimum(current_mag.to_np() * 2, max_mag.to_np()))
else:
# Multiply only the minimal dimension by "2".
current_mag = Mag(
np.minimum(current_mag.to_np() * factor, max_mag.to_np())
new_mag = Mag(np.minimum(current_mag.to_np() * factor, max_mag.to_np()))
if new_mag == current_mag:
raise RuntimeError(
f"The maximum mag {max_mag} can not be reached from {current_mag} with scale {scale}!"
)
current_mag = new_mag

mags += [current_mag]

Expand Down

0 comments on commit 4b20c69

Please sign in to comment.