From 6c6b5c24c03ab75b8794bd78813b9282dd5d27f7 Mon Sep 17 00:00:00 2001 From: Michael Milton Date: Fri, 27 Sep 2024 15:51:42 +1000 Subject: [PATCH 1/2] Better conversion from napari Shapes to Rois --- plugin/napari_lattice/fields.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/napari_lattice/fields.py b/plugin/napari_lattice/fields.py index c151412a..08f56853 100644 --- a/plugin/napari_lattice/fields.py +++ b/plugin/napari_lattice/fields.py @@ -481,12 +481,18 @@ def _enable_crop(self, enabled: bool) -> bool: def _make_model(self) -> Optional[CropParams]: import numpy as np + from lls_core.models.crop import Roi + if self.fields_enabled.value: - deskew = self._get_deskew() + rois = [] + for shape_layer in self.shapes.value: + for x in shape_layer.data: + rois.append(Roi.from_array(x)) + return CropParams( # Convert from the input image space to the deskewed image space # We assume here that dx == dy which isn't ideal - roi_list=ShapesData([np.array(shape.data) / deskew.dy for shape in self.shapes.value if len(shape.data) > 0]), + roi_list=rois, z_range=tuple(self.z_range.value), ) return None From 88e210cd9adf7ddf69f07faf88bebe59baf61ddb Mon Sep 17 00:00:00 2001 From: Michael Milton Date: Wed, 2 Oct 2024 14:07:53 +1000 Subject: [PATCH 2/2] Correctly rescale the ROI --- plugin/napari_lattice/fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/napari_lattice/fields.py b/plugin/napari_lattice/fields.py index 08f56853..2360c69f 100644 --- a/plugin/napari_lattice/fields.py +++ b/plugin/napari_lattice/fields.py @@ -484,10 +484,11 @@ def _make_model(self) -> Optional[CropParams]: from lls_core.models.crop import Roi if self.fields_enabled.value: + deskew = self._get_deskew() rois = [] for shape_layer in self.shapes.value: for x in shape_layer.data: - rois.append(Roi.from_array(x)) + rois.append(Roi.from_array(x / deskew.dy)) return CropParams( # Convert from the input image space to the deskewed image space