Skip to content

Commit

Permalink
[feat] add adaptive alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickcleeve2 committed Sep 6, 2024
1 parent 40114d9 commit 133b530
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 14 additions & 3 deletions autolamella/workflows/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
LamellaBottomEdge,
detect_features,
DetectedFeatures,
VolumeBlockCentre
VolumeBlockCentre,
AdaptiveLamellaCentre,
)
from autolamella.ui.AutoLamellaUI import AutoLamellaUI
from fibsem import config as fcfg
Expand Down Expand Up @@ -372,6 +373,11 @@ def mill_lamella(

# align sem using ml and beam shift
if settings.protocol["options"].get("use_sem_beam_shift_alignment", False):

# get adaptive model # TODO: generalise this better once models are finalised
checkpoint = settings.protocol.get("adaptive_polish", {}).get("model_path", None)

# align sem using ml and beam shift
lamella = align_feature_beam_shift(
microscope,
settings,
Expand All @@ -380,6 +386,8 @@ def mill_lamella(
validate=validate,
beam_type=BeamType.ELECTRON,
hfw=settings.image.hfw,
feature=AdaptiveLamellaCentre(),
checkpoint=checkpoint,
)


Expand Down Expand Up @@ -801,7 +809,8 @@ def align_feature_beam_shift(microscope: FibsemMicroscope,
validate: bool,
beam_type: BeamType = BeamType.ELECTRON,
hfw: float = fcfg.REFERENCE_HFW_MEDIUM,
feature: Feature = LamellaCentre()) -> Lamella:
feature: Feature = LamellaCentre(),
checkpoint: str = None) -> Lamella:
"""Align the feature to the centre of the image using the beamshift."""

# bookkeeping
Expand All @@ -818,7 +827,9 @@ def align_feature_beam_shift(microscope: FibsemMicroscope,
set_images_ui(parent_ui, eb_image, ib_image)

# detect
det = update_detection_ui(microscope, settings, features, parent_ui, validate, msg=lamella.info, position=lamella.state.microscope_state.stage_position)
det = update_detection_ui(microscope, settings, features, parent_ui, validate,
msg=lamella.info, position=None,
checkpoint=checkpoint)

# TODO: add movement modes; stable move, vertical move, beam shift

Expand Down
4 changes: 3 additions & 1 deletion autolamella/workflows/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def _update_mill_stages_ui(
time.sleep(0.5)

def update_detection_ui(
microscope, settings, features, parent_ui, validate: bool, msg: str = "Lamella", position: FibsemStagePosition = None,
microscope, settings, features, parent_ui, validate: bool, msg: str = "Lamella",
position: FibsemStagePosition = None, checkpoint: str = None
) -> DetectedFeatures:
feat_str = ", ".join([f.name for f in features])
update_status_ui(parent_ui, f"{msg}: Detecting Features ({feat_str})...")
Expand All @@ -112,6 +113,7 @@ def update_detection_ui(
settings=settings,
features=features,
point=position,
checkpoint=checkpoint,
)

if validate:
Expand Down

0 comments on commit 133b530

Please sign in to comment.