Merge branch 'equal-offsets' into 'v3'
Allow histo scans with equal dx and dy See merge request openflexure/openflexure-microscope-server!517
This commit is contained in:
commit
0fdcb9b623
2 changed files with 52 additions and 3 deletions
|
|
@ -370,6 +370,11 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]):
|
|||
* 200 for 20x
|
||||
"""
|
||||
|
||||
equal_distances: bool = lt.setting(default=False)
|
||||
"""Make the distances in x and y equal in motor steps, rather than in overlap.
|
||||
|
||||
Uses the shorter distance (usually dy) as both dx and dy"""
|
||||
|
||||
# The noqa statement is because scan_name is unused but is needed for equivalence
|
||||
# with other workflows that may want to validate the scan name.
|
||||
def check_before_start(self, scan_name: str) -> None: # noqa: ARG002
|
||||
|
|
@ -408,7 +413,22 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]):
|
|||
return self._background_detector.ready
|
||||
|
||||
def _build_scan_settings(self, base_kwargs: dict) -> HistoScanSettingsModel:
|
||||
"""Construct the SettingModel for all_settings."""
|
||||
"""Construct the SettingModel for all_settings.
|
||||
|
||||
Adjust dx and dy to be equal if `equal_distances` is set.
|
||||
"""
|
||||
# Make dx and dy equal if requested
|
||||
if self.equal_distances:
|
||||
dx = abs(base_kwargs.get("dx", 0))
|
||||
dy = abs(base_kwargs.get("dy", 0))
|
||||
min_displacement = min(dx, dy)
|
||||
base_kwargs["dx"] = min_displacement
|
||||
base_kwargs["dy"] = min_displacement
|
||||
|
||||
self.logger.info(
|
||||
f"Scanning with steps of dx={base_kwargs['dx']} and dy={base_kwargs['dy']}."
|
||||
)
|
||||
|
||||
return HistoScanSettingsModel(
|
||||
**base_kwargs,
|
||||
max_dist=self.max_range,
|
||||
|
|
@ -578,6 +598,9 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]):
|
|||
property_control_for(
|
||||
self, "skip_background", label="Detect and Skip Empty Fields"
|
||||
),
|
||||
property_control_for(
|
||||
self, "equal_distances", label="Set Equal x and y Distances"
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,31 @@ def test_histo_workflow_settings_generation(histo_workflow, mocker):
|
|||
assert workflow_settings.capture_params.images_dir == "/this/img_dir"
|
||||
|
||||
|
||||
def test_histo_workflow_settings_generation_equal_overlap(histo_workflow, mocker):
|
||||
"""Check that setting x and y equal behaves as expected."""
|
||||
mocker.patch.object(
|
||||
histo_workflow, "_calc_displacement_from_overlap", return_value=(123, 456)
|
||||
)
|
||||
|
||||
# Different when False
|
||||
histo_workflow.equal_distances = False
|
||||
workflow_settings, _stitching_settings = histo_workflow.all_settings(
|
||||
"/this/img_dir"
|
||||
)
|
||||
|
||||
assert workflow_settings.dx == 123
|
||||
assert workflow_settings.dy == 456
|
||||
|
||||
# Same when set True
|
||||
histo_workflow.equal_distances = True
|
||||
workflow_settings, _stitching_settings = histo_workflow.all_settings(
|
||||
"/this/img_dir"
|
||||
)
|
||||
|
||||
assert workflow_settings.dx == 123
|
||||
assert workflow_settings.dy == 123
|
||||
|
||||
|
||||
# A CSM that is "normal" changing from camera maxtrix coordinates (y,x) to normal
|
||||
# (x, y) coordinates
|
||||
CSM_NORMAL = [
|
||||
|
|
@ -349,7 +374,7 @@ def test_histo_workflow_settings_ui(histo_workflow):
|
|||
"""Check that the workflow specifies the expected controls."""
|
||||
ui = histo_workflow.settings_ui
|
||||
|
||||
assert len(ui) == 7
|
||||
assert len(ui) == 8
|
||||
for element in ui:
|
||||
assert isinstance(element, PropertyControl)
|
||||
|
||||
|
|
@ -362,5 +387,6 @@ def test_histo_workflow_settings_ui(histo_workflow):
|
|||
"autofocus_dz",
|
||||
"max_range",
|
||||
"skip_background",
|
||||
"equal_distances",
|
||||
]
|
||||
assert names == expected_names
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue