From 5017fea9d196ed03d205e26e4df2a1e27c69d33a Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Tue, 2 Dec 2025 09:54:27 +0000 Subject: [PATCH] A couple of final edits suggested in review --- src/openflexure_microscope_server/things/autofocus.py | 4 +++- src/openflexure_microscope_server/things/camera/picamera.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openflexure_microscope_server/things/autofocus.py b/src/openflexure_microscope_server/things/autofocus.py index a8e3ec39..c80b5308 100644 --- a/src/openflexure_microscope_server/things/autofocus.py +++ b/src/openflexure_microscope_server/things/autofocus.py @@ -585,7 +585,7 @@ class AutofocusThing(lt.Thing): supplied by LabThings dependency injection :param stack_parameters: A StackParams object containing the required parameters to run a stack. - :param save_on_failure: Whether to save an image even if the capture failed + :param save_on_failure: Whether to save an image even if no focus was found. :param check_turning_points: Whether to check the number of turning points in the sharpnesses of the images in the stack is exactly 1. (May fail with thick samples) @@ -876,11 +876,13 @@ def _get_peak_turning_point(sharpnesses: np.ndarray) -> float: # Fit the peak x = range(len(sharpnesses)) coeffs, cov = np.polyfit(x, sharpnesses, deg=2, cov=True) + # a in the equation a*x^2 + bx + c a = float(coeffs[0]) fit_func = np.poly1d(coeffs) # find the peaks's x-position turning = float(fit_func.deriv().roots[0]) + # sigma_a the standard error of a sigma_a = float(np.sqrt(cov[0, 0])) # Estimate the upper 95% confidence bound for the x^2 term ci_high = a + 2 * sigma_a diff --git a/src/openflexure_microscope_server/things/camera/picamera.py b/src/openflexure_microscope_server/things/camera/picamera.py index 918c28f5..7c664dbc 100644 --- a/src/openflexure_microscope_server/things/camera/picamera.py +++ b/src/openflexure_microscope_server/things/camera/picamera.py @@ -777,7 +777,7 @@ class StreamingPiCamera2(BaseCamera): self.calibrate_lens_shading() for _i in range(3): try: - time.sleep(1) + time.sleep(self._sensor_info.long_pause) self.set_background(portal) # Return if background is set return