Skip to content

Commit

Permalink
ui bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alpaca233 committed Feb 24, 2025
1 parent 479e458 commit 189e460
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions software/control/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4931,10 +4931,10 @@ def set_reference(self) -> bool:

# Store cropped and normalized reference image
center_y = int(reference_image.shape[0] / 2)
x_start = max(0, int(x) - self.SPOT_CROP_SIZE // 2)
x_end = min(reference_image.shape[1], int(x) + self.SPOT_CROP_SIZE // 2)
y_start = max(0, center_y - self.SPOT_CROP_SIZE // 2)
y_end = min(reference_image.shape[0], center_y + self.SPOT_CROP_SIZE // 2)
x_start = max(0, int(x) - self.laser_af_properties.spot_crop_size // 2)
x_end = min(reference_image.shape[1], int(x) + self.laser_af_properties.spot_crop_size // 2)
y_start = max(0, center_y - self.laser_af_properties.spot_crop_size // 2)
y_end = min(reference_image.shape[0], center_y + self.laser_af_properties.spot_crop_size // 2)

reference_crop = reference_image[y_start:y_end, x_start:x_end].astype(np.float32)
self.reference_crop = (reference_crop - np.mean(reference_crop)) / np.max(reference_crop)
Expand Down
3 changes: 3 additions & 0 deletions software/control/gui_hcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,9 @@ def connect_objective_changed_laser_af():
self.laserAutofocusSettingWidget.signal_newAnalogGain.connect(
self.cameraSettingWidget_focus_camera.set_analog_gain
)
self.laserAutofocusSettingWidget.signal_apply_settings.connect(
self.laserAutofocusControlWidget.update_init_state
)

self.laserAutofocusSettingWidget.update_exposure_time(self.laserAutofocusSettingWidget.exposure_spinbox.value())
self.laserAutofocusSettingWidget.update_analog_gain(self.laserAutofocusSettingWidget.analog_gain_spinbox.value())
Expand Down
7 changes: 5 additions & 2 deletions software/control/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class LaserAutofocusSettingWidget(QWidget):

signal_newExposureTime = Signal(float)
signal_newAnalogGain = Signal(float)
signal_start_live = Signal()
signal_apply_settings = Signal()

def __init__(self, liveController, laserAutofocusController, stretch=True):
super().__init__()
Expand Down Expand Up @@ -387,7 +387,6 @@ def init_ui(self):
self.exposure_spinbox = QDoubleSpinBox()
self.exposure_spinbox.setRange(self.liveController.camera.EXPOSURE_TIME_MS_MIN, self.liveController.camera.EXPOSURE_TIME_MS_MAX)
self.exposure_spinbox.setValue(self.laserAutofocusController.laser_af_properties.focus_camera_exposure_time_ms)
self.exposure_spinbox.setDecimals(1)
exposure_layout.addWidget(self.exposure_spinbox)

# Analog gain control
Expand Down Expand Up @@ -514,6 +513,9 @@ def _add_spinbox(self, layout, label: str, property_name: str,
self.spinboxes[property_name] = spinbox

def toggle_live(self, pressed):
# Print traceback for debugging
import traceback
traceback.print_stack()
if pressed:
self.liveController.start_live()
self.btn_live.setText("Stop Live")
Expand Down Expand Up @@ -568,6 +570,7 @@ def apply_settings(self):
}
self.laserAutofocusController.set_laser_af_properties(updates)
self.laserAutofocusController.initialize_auto()
self.signal_apply_settings.emit()
self.update_calibration_label()

def update_calibration_label(self):
Expand Down

0 comments on commit 189e460

Please sign in to comment.