From b0c9223b043feee0c1cba071e72c1f6aca8b711b Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Mon, 9 Mar 2026 18:53:39 +0000 Subject: [PATCH] Move pre_scan and switch stream as late as possible --- src/openflexure_microscope_server/things/smart_scan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 57ba5190..cb7488fd 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -376,11 +376,7 @@ class SmartScanThing(OFMThing): starting x,y,z position. """ try: - self._cam.start_streaming(main_resolution=(3280, 2464)) self._scan_data = self._collect_scan_data(workflow) - - workflow.pre_scan_routine(self._scan_data.workflow_settings) - self.ongoing_scan.save_scan_data(self._scan_data) images_dir = self.ongoing_scan.images_dir # Type narrowing if images_dir is None: @@ -388,6 +384,10 @@ class SmartScanThing(OFMThing): "Couldn't run scan, images directory was not created." ) + self.ongoing_scan.save_scan_data(self._scan_data) + self._cam.start_streaming(main_resolution=(3280, 2464)) + workflow.pre_scan_routine(self._scan_data.workflow_settings) + # If stitching settings are None then this type of scan can't be stitched if self.scan_data.stitching_settings is not None: # Settings exist, so create preview stitcher