From 4ea0b7fbcd269089d5c8d762e923244787f05eb3 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 9 Jul 2025 17:14:10 +0200 Subject: [PATCH] DAQ: Updated identify_crystal_raster to filter images based on a ratio of ice spots to low res spots as well as if an image is indexed. Added tempoary logic to correctly calculate image grid positon. --- daq/src/aaredaq/daq.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/daq/src/aaredaq/daq.py b/daq/src/aaredaq/daq.py index 03c3b6b7..ce3a1ac1 100644 --- a/daq/src/aaredaq/daq.py +++ b/daq/src/aaredaq/daq.py @@ -290,22 +290,27 @@ class AareDAQ: def identify_crystal_raster(self, result, r: RasterGridRequest): if result.images: - indexed_images = [(i, img) for i, img in enumerate(result.images) if img.index] + filtered_images = [img for img in result.images + if img.spots_ice is not None and img.spots_low_res > 0 and (img.spots_ice / img.spots_low_res) < 5.0 + and (img.spots_ice / img.spots_low_res) != 1] + + indexed_images = [img for img in filtered_images if img.index] if indexed_images: - max_image = max(indexed_images, key=lambda x: x[1].spots_low_res) - max_index, max_image = max_image + max_image = max(indexed_images, key=lambda img: img.spots_low_res) + print(max_image.spots_ice / max_image.spots_low_res) print(f"Image with maximum spots_low_res: {max_image}") print(f"Maximum spots_low_res value: {max_image.spots_low_res}") else: - images = [(i, img) for i, img in enumerate(result.images)] + images = [img for img in filtered_images] print("No indexed images found.") - max_image = max(images, key=lambda x: x[1].spots_low_res) - max_index, max_image = max_image + max_image = max(images, key=lambda img: img.spots_low_res) print(f"Image with maximum spots_low_res: {max_image}") print(f"Maximum spots_low_res value: {max_image.spots_low_res}") - grid_x = max_index % r.n_x - grid_y = max_index // r.n_x + grid_x = max_image.number % r.n_x #this should be max_image.number, however on the return raster, the calc is n_x-max_index%n_x + grid_y = max_image.number // r.n_x + if grid_y % 2 == 1: + grid_x = r.n_x - grid_x - 1 print(f"Grid coordinates: ({grid_x}, {grid_y})") grid_mm_x = grid_x * r.grid_size_mm.x + r.grid_size_mm.x/2 grid_mm_y = grid_y * r.grid_size_mm.y + r.grid_size_mm.y/2