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.

This commit is contained in:
2025-07-09 17:14:10 +02:00
parent 2d4acf868d
commit 4ea0b7fbcd
+13 -8
View File
@@ -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