Skip to content

Commit

Permalink
Merge pull request #62 from Cephla-Lab/scan-coordinate-preview-bug-fix
Browse files Browse the repository at this point in the history
Scan coordinate preview bug fix
  • Loading branch information
hongquanli authored Jan 4, 2025
2 parents 4e457c0 + 24b89c8 commit 5ed55c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 6 additions & 5 deletions software/control/gui_hcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,10 @@ def makeConnections(self):
self.movement_updater.position_after_move.connect(self.navigationViewer.draw_fov_current_location)
if WELLPLATE_FORMAT == "glass slide":
# TODO(imo): This well place logic is duplicated below in onWellPlateChanged. We should change it to only exist in 1 location.
self.movement_updater.sent_after_stopped.connect(self.wellplateMultiPointWidget.set_live_scan_coordinates)
# self.movement_updater.sent_after_stopped.connect(self.wellplateMultiPointWidget.set_live_scan_coordinates)
self.movement_updater.position_after_move.connect(
self.wellplateMultiPointWidget.update_live_coordinates
)
self.is_live_scan_grid_on = True
self.multipointController.signal_register_current_fov.connect(self.navigationViewer.register_fov)
self.multipointController.signal_current_configuration.connect(self.liveControlWidget.set_microscope_mode)
Expand Down Expand Up @@ -1163,10 +1166,9 @@ def onWellplateChanged(self, format_):
if isinstance(format_, QVariant):
format_ = format_.value()

# TODO(imo): Not sure why glass slide is so special here? It seems like it's just a "1 well plate". Also why is the objective forced to inverted for all non-glass slide, and not inverted for glass slide?
# TODO(imo): Not sure why glass slide is so special here? It seems like it's just a "1 well plate".
if format_ == "glass slide":
self.toggleWellSelector(False)
self.multipointController.inverted_objective = False
if not self.is_live_scan_grid_on: # connect live scan grid for glass slide
self.movement_updater.position_after_move.connect(
self.wellplateMultiPointWidget.update_live_coordinates
Expand All @@ -1176,7 +1178,6 @@ def onWellplateChanged(self, format_):
self.setupSlidePositionController(is_for_wellplate=False)
else:
self.toggleWellSelector(True)
self.multipointController.inverted_objective = True
if self.is_live_scan_grid_on: # disconnect live scan grid for wellplate
self.movement_updater.position_after_move.disconnect(
self.wellplateMultiPointWidget.update_live_coordinates
Expand Down Expand Up @@ -1267,7 +1268,7 @@ def toggleAcquisitionStart(self, acquisition_started):
self.is_live_scan_grid_on = False
else:
self.log.info("FINISHED ACQUISITION")
if not self.is_live_scan_grid_on: # reconnect live scan grid if was on before acqusition
if not self.is_live_scan_grid_on and "glass slide" in self.wellplateFormatWidget.wellplate_format:
self.movement_updater.position_after_move.connect(
self.wellplateMultiPointWidget.update_live_coordinates
)
Expand Down
8 changes: 5 additions & 3 deletions software/control/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3619,7 +3619,7 @@ def update_coordinates(self):

elif "glass slide" in self.navigationViewer.sample:
pos = self.stage.get_pos()
self.scanCoordinates.set_live_scan_coordinates(pos.x_mm, pos.y_mm)
self.scanCoordinates.set_live_scan_coordinates(pos.x_mm, pos.y_mm, scan_size_mm, overlap_percent, shape)
else:
if self.scanCoordinates.has_regions():
self.scanCoordinates.clear_regions()
Expand All @@ -3636,13 +3636,15 @@ def update_well_coordinates(self, selected):
elif self.scanCoordinates.has_regions():
self.scanCoordinates.clear_regions()

def update_live_coordinates(self, x, y):
def update_live_coordinates(self, pos: squid.abc.Pos):
x_mm = pos.x_mm
y_mm = pos.y_mm
if hasattr(self.parent, "recordTabWidget") and self.parent.recordTabWidget.currentWidget() != self:
return
scan_size_mm = self.entry_scan_size.value()
overlap_percent = self.entry_overlap.value()
shape = self.combobox_shape.currentText()
self.scanCoordinates.set_live_scan_coordinates(x, y, scan_size_mm, overlap_percent, shape)
self.scanCoordinates.set_live_scan_coordinates(x_mm, y_mm, scan_size_mm, overlap_percent, shape)

def toggle_acquisition(self, pressed):
if not self.base_path_is_set:
Expand Down

0 comments on commit 5ed55c0

Please sign in to comment.