Apply suggestions from code review of branch scan-workflows
Co-authored-by: Joe Knapper <joe.knapper@glasgow.ac.uk>
This commit is contained in:
parent
504a47cbf8
commit
8f30f08bdf
3 changed files with 9 additions and 10 deletions
|
|
@ -189,15 +189,14 @@ class HistoricScanData(BaseScanData):
|
||||||
@model_validator(mode="before")
|
@model_validator(mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def coerce_legacy(cls, data: dict) -> dict:
|
def coerce_legacy(cls, data: dict) -> dict:
|
||||||
"""Coerce any legacy data."""
|
"""Coerce any scan data from before version 2 into the version 2 format."""
|
||||||
r"""Coerce any scan data from before version 2 into the version 2 format."""
|
|
||||||
# Before the current version no schema_version was set
|
# Before the current version no schema_version was set
|
||||||
if "schema_version" in data:
|
if "schema_version" in data:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
if "correlation_resize" and "overlap" in data:
|
if "correlation_resize" and "overlap" in data:
|
||||||
correlation_resize = data.pop("correlation_resize")
|
correlation_resize = data.pop("correlation_resize")
|
||||||
# Note we don't pop overlap is a setting for the legacy workflow as well
|
# Note we don't pop overlap, as it is a setting for the legacy workflow as well
|
||||||
# as a stitching setting.
|
# as a stitching setting.
|
||||||
# This is done because in future workflows the stitching overlap may be a
|
# This is done because in future workflows the stitching overlap may be a
|
||||||
# directly set setting or something that is calculated from other settings.
|
# directly set setting or something that is calculated from other settings.
|
||||||
|
|
|
||||||
|
|
@ -195,8 +195,8 @@ class HistoScanWorkflow(ScanWorkflow[HistoScanSettingsModel]):
|
||||||
"""The minimum number of images to capture in a stack.
|
"""The minimum number of images to capture in a stack.
|
||||||
|
|
||||||
This many images are captures and tested for focus, if the focus is not central
|
This many images are captures and tested for focus, if the focus is not central
|
||||||
enough more images may be captured. After new images are captured the number sets
|
enough more images may be captured. After new images are captured, this value sets
|
||||||
the number of images used for checking if focus is central.
|
the number of images used for checking if focus is achieved.
|
||||||
|
|
||||||
Defaults to 9 which balances reliability and speed.
|
Defaults to 9 which balances reliability and speed.
|
||||||
"""
|
"""
|
||||||
|
|
@ -286,7 +286,7 @@ class HistoScanWorkflow(ScanWorkflow[HistoScanSettingsModel]):
|
||||||
return scan_settings, stitching_settings
|
return scan_settings, stitching_settings
|
||||||
|
|
||||||
def _calc_displacement_from_overlap(self, overlap: float) -> tuple[int, int]:
|
def _calc_displacement_from_overlap(self, overlap: float) -> tuple[int, int]:
|
||||||
"""Take a test image and use camera stage mapping to calculate x and y displacement.
|
"""Use camera stage mapping to calculate x and y displacement.
|
||||||
|
|
||||||
:param overlap: The desired overlap as a fraction of the image. i.e. 0.5 means
|
:param overlap: The desired overlap as a fraction of the image. i.e. 0.5 means
|
||||||
that each image should overlap its nearest neighbour by 50%.
|
that each image should overlap its nearest neighbour by 50%.
|
||||||
|
|
@ -295,7 +295,7 @@ class HistoScanWorkflow(ScanWorkflow[HistoScanSettingsModel]):
|
||||||
"""
|
"""
|
||||||
csm_image_res = self._csm.image_resolution
|
csm_image_res = self._csm.image_resolution
|
||||||
if csm_image_res is None:
|
if csm_image_res is None:
|
||||||
raise RuntimeError("CSM not set. Scan shouldn't have progresses this far.")
|
raise RuntimeError("CSM not set. Scan shouldn't have progressed this far.")
|
||||||
|
|
||||||
# Calculate displacements in image coordinates
|
# Calculate displacements in image coordinates
|
||||||
dx_img = csm_image_res[1] * (1 - overlap)
|
dx_img = csm_image_res[1] * (1 - overlap)
|
||||||
|
|
@ -448,7 +448,7 @@ class HistoScanWorkflow(ScanWorkflow[HistoScanSettingsModel]):
|
||||||
imaged = focused or save_on_failure
|
imaged = focused or save_on_failure
|
||||||
|
|
||||||
if not imaged:
|
if not imaged:
|
||||||
msg = f"Stack failed at {xyz_pos} treating as background."
|
msg = f"Stack failed at {xyz_pos}. Treating as background."
|
||||||
self.logger.info(msg)
|
self.logger.info(msg)
|
||||||
|
|
||||||
# run_smart_stage always returns a focus height for the sharpest image even
|
# run_smart_stage always returns a focus height for the sharpest image even
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ T = TypeVar("T")
|
||||||
P = ParamSpec("P")
|
P = ParamSpec("P")
|
||||||
|
|
||||||
|
|
||||||
# This allows ActiveScanData to hold arbitrary workflow settings models during a scan.
|
# This allows ActiveScanData to hold arbitrary workflow settings models during a scan.
|
||||||
AnyModel = Annotated[
|
AnyModel = Annotated[
|
||||||
BaseModel,
|
BaseModel,
|
||||||
PlainSerializer(lambda value: value.model_dump(), return_type=dict),
|
PlainSerializer(lambda value: value.model_dump(), return_type=dict),
|
||||||
|
|
@ -233,7 +233,7 @@ class SmartScanThing(lt.Thing):
|
||||||
def sample_scan(self, scan_name: str = "") -> None:
|
def sample_scan(self, scan_name: str = "") -> None:
|
||||||
"""Move the stage to cover an area, taking images.
|
"""Move the stage to cover an area, taking images.
|
||||||
|
|
||||||
Depending on the way the stage moves depends on the selected workflow.
|
The way the stage moves depends on the selected workflow.
|
||||||
If images overlap for a scan workflow then the images can be stitched together
|
If images overlap for a scan workflow then the images can be stitched together
|
||||||
into a larger composite image.
|
into a larger composite image.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue