diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 337c8b40..5afc2e6a 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -406,9 +406,8 @@ class SmartScanThing(OFMThing): if self._preview_stitcher is None: # This scan can't stitch. return - # Assume 4 images means at least one offset in x and y, making the stitching - # well constrained. - if self.scan_data.image_count > 3 and not self._preview_stitcher.running: + # Begin stitching once two images are captured + if self.scan_data.image_count >= 2 and not self._preview_stitcher.running: self._preview_stitcher.start() @_scan_running @@ -543,8 +542,8 @@ class SmartScanThing(OFMThing): @_scan_running def _perform_final_stitch(self) -> None: """Update the scan zip and perform final stitch of the data.""" - if self.scan_data.image_count <= 3: - self.logger.info("Not performing a stitch as 3 or fewer images taken") + if self.scan_data.image_count <= 1: + self.logger.info("Not performing a stitch as not enough images captured") return self.ongoing_scan.zip_files() @@ -758,6 +757,6 @@ class SmartScanThing(OFMThing): # Use the scan list (the data read by the gallery) to find any scans that # need stitching. for scan in self.get_data_for_gallery(): - if scan.dzi is None: + if scan.dzi is None and scan.number_of_images >= 2: self.logger.info(f"Stitching {scan.name}") self.stitch_scan(scan_name=scan.name) diff --git a/tests/unit_tests/test_stitching.py b/tests/unit_tests/test_stitching.py index 017d9291..801d2baf 100644 --- a/tests/unit_tests/test_stitching.py +++ b/tests/unit_tests/test_stitching.py @@ -333,10 +333,19 @@ def test_stitch_all_scans_continues_after_error(mocker, caplog, smart_scan_thing mocker.Mock(name="scan1", dzi=None), mocker.Mock(name="scan2", dzi=None), mocker.Mock(name="scan3", dzi=None), + mocker.Mock(name="scan4", dzi=None), ] scans[0].name = "scan1" scans[1].name = "scan2" scans[2].name = "scan3" + scans[3].name = "scan4" + + # stitch_all skips any scans with less than 2 images, without logging + + scans[0].number_of_images = 10 + scans[1].number_of_images = 10 + scans[2].number_of_images = 1 + scans[3].number_of_images = 10 mocker.patch.object( smart_scan_thing, @@ -373,9 +382,10 @@ def test_stitch_all_scans_continues_after_error(mocker, caplog, smart_scan_thing messages = [r.message for r in caplog.records] + # scan3 is not logged as there is only 1 image so it is ignored by ``stitch_all_scans`` assert messages == [ "Stitching scan1", "Stitching scan2", "Stitching failed: test_message", - "Stitching scan3", + "Stitching scan4", ] diff --git a/webapp/src/components/tabContentComponents/galleryComponents/galleryCard.vue b/webapp/src/components/tabContentComponents/galleryComponents/galleryCard.vue index 1d69591b..f53e93be 100644 --- a/webapp/src/components/tabContentComponents/galleryComponents/galleryCard.vue +++ b/webapp/src/components/tabContentComponents/galleryComponents/galleryCard.vue @@ -62,7 +62,7 @@