Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions mantis/acquisition/acq_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,11 @@ def check_acq_finished(axes, dataset):
else:
logger.error('O3 autofocus is taking longer than expected - aborting.')
microscope_operations.abort_acquisition_sequence(self.ls_acq.mmc, camera)
acq.await_completion() # Cleanup
logger.debug('Would have waited for acquisition to complete')
# acq.await_completion() # Cleanup
logger.debug('Closing dataset')
acq.get_dataset().close() # Close dataset
logger.debug('Acquisition aborted')
else:
z_stack = microscope_operations.acquire_defocus_stack(
mmc, z_stage, z_range, backlash_correction_distance=KIM101_BACKLASH
Expand Down Expand Up @@ -979,8 +982,8 @@ def refocus_ls_path(
o3_position = float(self.ls_acq.mmc.get_property(o3_z_stage, 'Position'))
logger.debug(f'Starting O3 position: {o3_position} um')

o3_z_start = -3.3
o3_z_end = 3.3
o3_z_start = -5.0
o3_z_end = 5.0
o3_z_step = 0.3
if scan_left:
logger.info('O3 refocus will scan further to the left')
Expand Down Expand Up @@ -1016,7 +1019,7 @@ def refocus_ls_path(
data = self.acquire_ls_defocus_stack(
z_range=o3_range_abs,
galvo_range=galvo_range_abs,
use_pycromanager=True,
use_pycromanager=False,
)

# Abort if the acquisition failed
Expand Down Expand Up @@ -1426,7 +1429,7 @@ def await_cz_acq_completion(self):
time.sleep(wait_time)

def abort_stalled_acquisition(self):
buffer_time = 5
buffer_time = 10
lf_acq_aborted = False
ls_acq_aborted = False

Expand Down
13 changes: 9 additions & 4 deletions mantis/acquisition/microscope_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def acquire_defocus_stack(
backlash_correction_distance: int = 0,
):
"""Snap image at every z position and put image in a Micro-manager datastore
Note: KinesisPiezoMotor stage is deprecated

Parameters
----------
Expand All @@ -361,19 +362,20 @@ def acquire_defocus_stack(

"""
data = []
relative_z_steps = np.hstack((z_range[0], np.diff(z_range)))
# relative_z_steps = np.hstack((z_range[0], np.diff(z_range)))

# get z0 and define move_z callable for the given stage
if isinstance(z_stage, str):
# this is a MM stage
move_z = partial(mmc.set_relative_position, z_stage) # test if this works
move_z = partial(mmc.set_position, z_stage) # test if this works
elif isinstance(z_stage, KinesisPiezoMotor):
# this is a pylablib stage
move_z = partial(set_relative_kim101_position, z_stage)
else:
raise RuntimeError(f'Unknown z stage: {z_stage}')

for z_ind, rel_z in enumerate(relative_z_steps):
move_z(z_range[0]); time.sleep(0.3)
for z_ind, rel_z in enumerate(z_range):
# set z position
move_z(rel_z)

Expand All @@ -400,7 +402,7 @@ def acquire_defocus_stack(
datastore.put_image(image)

# reset z stage
move_z(-relative_z_steps.sum() + backlash_correction_distance)
# move_z(-relative_z_steps.sum() + backlash_correction_distance)

return np.asarray(data)

Expand Down Expand Up @@ -553,8 +555,11 @@ def abort_acquisition_sequence(
"""

for stage in sequenced_stages:
logger.debug(f'Stopping sequence on stage {stage}')
mmc.stop_stage_sequence(stage)
logger.debug('Stopping camera sequence acquisition')
mmc.stop_sequence_acquisition(camera)
logger.debug('Clearing circular buffer')
mmc.clear_circular_buffer()


Expand Down
Loading