Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for metadata return in AcquisitionFuture.await_image_saved #800

Merged
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
14 changes: 7 additions & 7 deletions pycromanager/acquisition/acq_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,20 @@ def await_image_saved(self, axes=None, return_image=True, return_metadata=False)
while not self._notification_recieved[key][AcqNotification.Image.IMAGE_SAVED]:
self._condition.wait()

if return_image:
if return_image and return_metadata:
if isinstance(axes, list):
return [(self._acq.get_dataset().read_image(**ax), self._acq.get_dataset().read_metadata(**ax)) for ax in axes]
else:
return self._acq.get_dataset().read_image(**axes), self._acq.get_dataset().read_metadata(**axes)
elif return_image:
if isinstance(axes, list):
return [self._acq.get_dataset().read_image(**ax) for ax in axes]
else:
return self._acq.get_dataset().read_image(**axes)
if return_metadata:
elif return_metadata:
if isinstance(axes, list):
return [self._acq.get_dataset().read_metadata(**ax) for ax in axes]
else:
return self._acq.get_dataset().read_metadata(**axes)
if return_image and return_metadata:
if isinstance(axes, list):
return [(self._acq.get_dataset().read_image(**ax), self._acq.get_dataset().read_metadata(**ax)) for ax in axes]
else:
return self._acq.get_dataset().read_image(**axes), self._acq.get_dataset().read_metadata(**axes)


8 changes: 8 additions & 0 deletions pycromanager/test/test_notifications_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def test_async_image_read(launch_mm_headless, setup_data_folder):
assert np.all(image == acq.get_dataset().read_image(time=5))
acq.get_dataset().close()

def test_async_image_read_metadata_return(launch_mm_headless, setup_data_folder):
events = multi_d_acquisition_events(num_time_points=10, time_interval_s=0.5)
with Acquisition(directory=setup_data_folder, name='test_async_image_read', show_display=False) as acq:
future = acq.acquire(events)
_, metadata = future.await_image_saved({'time': 5}, return_image=True, return_metadata=True)
assert isinstance(metadata, dict)
acq.get_dataset().close()

def test_async_image_read_sequence(launch_mm_headless, setup_data_folder):
events = multi_d_acquisition_events(num_time_points=10, time_interval_s=0)
with Acquisition(directory=setup_data_folder, name='test_async_image_read_sequence', show_display=False) as acq:
Expand Down
Loading