Skip to content

Commit 1b7e2e9

Browse files
Merge pull request #959 from annie-xd-wang/update-caculate-focus-range-feature
2 parents 2ab9f22 + 59e9940 commit 1b7e2e9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/navigate/model/features/auto_tile_scan.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def pre_func_signal(self):
114114
stage_pos = self.model.get_stage_position()
115115
#: float: The current z position of the stage.
116116
self.current_z_pos = stage_pos["z_pos"]
117+
#: float: The current f position of the stage.
118+
self.current_f_pos = stage_pos["f_pos"]
117119
#: float: The last z position of the stage in a stack.
118120
self.last_z_pos = self.current_z_pos + float(
119121
self.model.configuration["experiment"]["MicroscopeState"]["end_position"]
@@ -132,10 +134,11 @@ def in_func_signal(self):
132134
self.focus_end_pos = self.autofocus.in_func_signal()
133135

134136
# calculate the slope and save it
135-
if self.focus_end_pos:
137+
if self.focus_end_pos is not None:
136138
microscope_state = self.model.configuration["experiment"][
137139
"MicroscopeState"
138140
]
141+
microscope_state["start_focus"] = self.focus_start_pos - self.current_f_pos
139142
microscope_state["end_focus"] = (
140143
float(microscope_state["start_focus"])
141144
+ self.focus_end_pos
@@ -161,7 +164,11 @@ def end_func_signal(self):
161164
# TODO: should the focus move at the same time?
162165
self.model.move_stage({"z_abs": self.last_z_pos}, wait_until_done=True)
163166
self.autofocus.pre_func_signal()
164-
return self.autofocus_count >= 2
167+
if self.autofocus_count >= 2:
168+
# move stage back
169+
self.model.move_stage({"z_abs": self.current_z_pos, "f_abs": self.current_f_pos})
170+
return True
171+
return False
165172

166173
def pre_func_data(self):
167174
"""Prepare for the data acquisition stage, if applicable.

0 commit comments

Comments
 (0)