diff --git a/mx_bec/math.py b/mx_bec/math.py index 54166e2..44bdb1b 100644 --- a/mx_bec/math.py +++ b/mx_bec/math.py @@ -75,29 +75,28 @@ def gridscan_strategy_from_optical( ): if optical_results is None or len(boxes := optical_results.prediction.boxes) == 0: return mock_grid_calculation() + box_data = {box.label: ((box.x1, box.y1), (box.x2, box.y2)) for box in boxes} + logger.info(f"got detection boxes: {box_data}") + box_corners = None + for label_option in ["crystal", "loop_face", "loop_all"]: + if label_option in box_data: + box_corners = box_data[label_option] + logger.info(f"using best available box: {label_option}") + break + if box_corners is None: + return mock_grid_calculation() else: - box_data = {box.label: ((box.x1, box.y1), (box.x2, box.y2)) for box in boxes} - logger.info(f"got detection boxes: {box_data}") - box_corners = None - for label_option in ["crystal", "loop_face", "loop_all"]: - if label_option in box_data: - box_corners = box_data[label_option] - logger.info(f"using best available box: {label_option}") - break - if box_corners is None: - return mock_grid_calculation() - else: - file_prefix = f"AareBecTestGridScan_{secrets.token_hex(6)}" - return gridscan_calculation( - box_corners[0], - box_corners[1], - step_x_um / 1000, - step_y_um / 1000, - margin, - file_prefix, - exp_time_s, - dtz_mm, - ) + file_prefix = f"AareBecTestGridScan_{secrets.token_hex(6)}" + return gridscan_calculation( + box_corners[0], + box_corners[1], + step_x_um / 1000, + step_y_um / 1000, + margin, + file_prefix, + exp_time_s, + dtz_mm, + ) def gridscan_calculation(