fix: supply max image with not enough spots
CI / lint (push) Skipped
CI / test (3.11) (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / lint (pull_request) Failing after 19s
CI / test (3.11) (pull_request) Skipped
CI / test (3.12) (pull_request) Skipped
CI / test (3.13) (pull_request) Skipped

This commit is contained in:
David Perl committed 2026-08-27 14:18:40 +02:00
1 parent 2202b426e8
commit b5a163b6af
1 file changed
+4 -5
+4 -5
View File
@@ -326,9 +326,6 @@ def raster_highest_score(images, min_low_res_spots: float = 10.0) -> CenterOfMas
collecting at a noisy cell, so a 'nothing here' result is centred and
deliberate rather than random noise.
spots_indexed is deliberately not part of the guard: indexing was dropped
from the crystal score (w_indexed=0.00), so a crystal that diffracts but
fails to index must still be targeted, not routed to centre.
"""
score_array = compute_crystal_score_array(images)
max_low_res = max((getattr(img, "spots_low_res", 0) or 0 for img in images), default=0)
@@ -340,7 +337,9 @@ def raster_highest_score(images, min_low_res_spots: float = 10.0) -> CenterOfMas
)
# get_com_mm maps index i -> (i+0.5)*step, so index (N-1)/2 is the true
# geometric centre of the grid for both odd and even N (and N==1).
return CenterOfMassModel(n_x=(n_nx - 1) / 2.0, n_y=(n_ny - 1) / 2.0)
y_pos = (n_ny - 1) / 2.0
x_pos = (n_nx - 1) / 2.0
return CenterOfMassModel(n_x=x_pos, n_y=y_pos, max_image=int(y_pos*n_nx+x_pos))
return _to_com_model(_max_cell(score_array), images, "Highest score")
@@ -360,7 +359,7 @@ def has_sufficient_low_res_spots(result_array: np.ndarray, min_spots_low_res: fl
def compute_crystal_score_array(
scan_results: list, w_bkg: float = 0.25, w_low_res: float = 0.75, w_indexed: float = 0.00
scan_results: list, w_bkg: float = 0.01, w_low_res: float = 0.99, w_indexed: float = 0.00
) -> np.ndarray:
"""Combine bkg (25%), spots_low_res (75%), and spots_indexed (00%) into a 0–100 score.