From d1908eb29a1fde61c54659bc1325cfa0091540b7 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Sat, 13 Jan 2024 13:38:39 +0000 Subject: [PATCH] Run stitching thing with appropriate overlap setting --- .../things/smart_scan.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 619457aa..ef8ac1fa 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -553,7 +553,7 @@ class SmartScanThing(Thing): if not self.preview_stitch_running(): self.preview_stitch_start(images_folder) if not self.correlate_running(): - self.correlate_start(images_folder) + self.correlate_start(images_folder, overlap=overlap) # add the current position to the list of all positions visited true_path.append(loc) @@ -602,7 +602,7 @@ class SmartScanThing(Thing): logger.info("Stitching final image (may take some time)...") try: if scan_folder: - self.stitch_scan(logger, os.path.basename(scan_folder)) + self.stitch_scan(logger, os.path.basename(scan_folder), overlap=overlap) except SubprocessError as e: logger.exception(f"Stitching failed: {e}") logger.info("Creating zip archive of images (may take some time)...") @@ -804,13 +804,13 @@ class SmartScanThing(Thing): self._preview_stitch_popen.wait() _correlate_popen = None - def correlate_start(self, images_folder: str) -> None: + def correlate_start(self, images_folder: str, overlap: float = 0.1) -> None: """Start stitching a preview of the scan in a subprocess""" if self.correlate_running(): raise RuntimeError("Only one subprocess is allowed at a time") with self._correlate_popen_lock: self._correlate_popen = Popen( - [self._script, "--stitching_mode", "only_correlate", images_folder] + [self._script, "--stitching_mode", "only_correlate", "--minimum_overlap", f"{overlap*0.9}", images_folder] ) def correlate_running(self) -> bool: @@ -840,8 +840,8 @@ class SmartScanThing(Thing): return output @thing_action - def stitch_scan(self, logger: InvocationLogger, scan_name: Optional[str]=None, downsample: float=1.0) -> None: + def stitch_scan(self, logger: InvocationLogger, scan_name: Optional[str]=None, overlap: float = 0.1) -> None: """Generate a stitched image based on stage position metadata""" images_folder = self.images_folder(scan_name=scan_name) - self.run_subprocess(logger, [self._script, "--stitching_mode", "all", images_folder]) + self.run_subprocess(logger, [self._script, "--stitching_mode", "all", "--minimum_overlap", f"{overlap*0.9}", images_folder])