From edbdab6625b5e3fefb81b4b9d02a743465abe2aa Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 9 Jul 2025 17:15:20 +0200 Subject: [PATCH] GUI: Add spot ice ratio to the drop down panel and grid scan result visualisation. Fixed bug where spot count (ice) wasn't being correctly parsed to the GUI. --- gui/src/aaregui/panels/raster_data_collection.py | 1 + .../aaregui/scan_logic/raster_grid_manager.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gui/src/aaregui/panels/raster_data_collection.py b/gui/src/aaregui/panels/raster_data_collection.py index 30e0c701..0b52cf7d 100644 --- a/gui/src/aaregui/panels/raster_data_collection.py +++ b/gui/src/aaregui/panels/raster_data_collection.py @@ -83,6 +83,7 @@ class RasterDataCollectionPanel(ScanSettingsPanel): self.metric_combo.addItem("Spot count (low res.)", RasterGridMetric.SPOTS_LOW_RES) self.metric_combo.addItem("Spot count (indexed)", RasterGridMetric.SPOTS_INDEXED) self.metric_combo.addItem("Spot count (ice)", RasterGridMetric.SPOTS_ICE) + self.metric_combo.addItem("Spot ratio (ice/low res.)", RasterGridMetric.SPOTS_ICE_LOW_RES) self.metric_combo.addItem("Background estimate", RasterGridMetric.BKG) self.metric_combo.addItem("Indexing result", RasterGridMetric.INDEXING) self.metric_combo.addItem("Mosaicity", RasterGridMetric.MOS) diff --git a/gui/src/aaregui/scan_logic/raster_grid_manager.py b/gui/src/aaregui/scan_logic/raster_grid_manager.py index 872f5117..17242f08 100644 --- a/gui/src/aaregui/scan_logic/raster_grid_manager.py +++ b/gui/src/aaregui/scan_logic/raster_grid_manager.py @@ -23,6 +23,7 @@ class RasterGridMetric(Enum): RES = 6 SPOTS_ICE = 7 SPOTS_INDEXED = 8 + SPOTS_ICE_LOW_RES = 9 def float_to_viridis_brush(value: float, alpha: int = 127) -> QBrush: """ @@ -265,6 +266,12 @@ class RasterGridManager(QObject): if grid.result.images[cell].spots is not None and grid.result.images[cell].spots >= 0: txt += f"Spot count {grid.result.images[cell].spots}
" + if grid.result.images[cell].spots_ice is not None and grid.result.images[cell].spots_ice >= 0: + txt += f"Spot count (ice) {grid.result.images[cell].spots_ice}
" + + if self.spot_ice_ratio(grid.result.images[cell]) is not None and self.spot_ice_ratio(grid.result.images[cell]) >= 0: + txt += f"Spot ratio (ice/low res.) {self.spot_ice_ratio(grid.result.images[cell])}
" + if grid.result.images[cell].spots_low_res is not None and grid.result.images[cell].spots_low_res >= 0: txt += f"Spot count (low res.) {grid.result.images[cell].spots_low_res}
" @@ -301,6 +308,13 @@ class RasterGridManager(QObject): grid = copy.deepcopy(self.__active_grid) self.grid_scan.emit(grid) + + def spot_ice_ratio(self, obj): + if obj.spots_ice is None or obj.spots_low_res is None or obj.spots_low_res <= 0: + return None + else: + return obj.spots_ice / obj.spots_low_res + def draw_grid(self, painter: QPainter, alpha: int = 127): self._draw_grid(painter, self.__active_grid) for i in self.__completed_grids: @@ -322,6 +336,8 @@ class RasterGridManager(QObject): v = [obj.res for obj in i.result.images] case RasterGridMetric.SPOTS_ICE: v = [obj.spots_ice for obj in i.result.images] + case RasterGridMetric.SPOTS_ICE_LOW_RES: + v = [self.spot_ice_ratio(obj) for obj in i.result.images] case RasterGridMetric.SPOTS_INDEXED: v = [obj.spots_indexed for obj in i.result.images] self._draw_grid(painter, i.request, v, alpha)