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

Clarify camera notifications #754

Merged
merged 7 commits into from
Apr 10, 2024
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 java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.micro-manager.pycro-manager</groupId>
<artifactId>PycroManagerJava</artifactId>
<version>0.46.1</version>
<version>0.46.2</version>
<packaging>jar</packaging>
<name>Pycro-Manager Java</name>
<description>The Java components of Pycro-Manager</description>
Expand Down Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>org.micro-manager.acqengj</groupId>
<artifactId>AcqEngJ</artifactId>
<version>0.35.1</version>
<version>0.36.0</version>
</dependency>
<dependency>
<groupId>org.micro-manager.ndviewer</groupId>
Expand Down Expand Up @@ -112,11 +112,11 @@
</goals>

<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>

</execution>
</executions>
Expand Down
2 changes: 1 addition & 1 deletion pycromanager/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (0, 31, 1)
version_info = (0, 31, 2)
__version__ = ".".join(map(str, version_info))
3 changes: 2 additions & 1 deletion pycromanager/acq_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def _add_notifications(self, axes_or_axes_list):

AcqNotification.Camera.PRE_SNAP: False,
AcqNotification.Camera.PRE_SEQUENCE_STARTED: False,
AcqNotification.Camera.POST_EXPOSURE: False,
AcqNotification.Camera.POST_SNAP: False,
AcqNotification.Camera.POST_SEQUENCE_STOPPED: False,

AcqNotification.Image.IMAGE_SAVED: False,
}
Expand Down
8 changes: 7 additions & 1 deletion pycromanager/acquisition/acq_eng_py/internal/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def acquire_images(self, event: AcquisitionEvent, hardware_sequences_in_progress
height = self.core.get_image_height()
self.core.snap_image()
event.acquisition_.post_notification(AcqNotification(
AcqNotification.Camera, event.axisPositions_, AcqNotification.Camera.POST_EXPOSURE))
AcqNotification.Camera, event.axisPositions_, AcqNotification.Camera.POST_SNAP))
for h in event.acquisition_.get_after_exposure_hooks():
h.run(event)

Expand Down Expand Up @@ -383,6 +383,12 @@ def acquire_images(self, event: AcquisitionEvent, hardware_sequences_in_progress
corresponding_event.acquisition_.add_to_image_metadata(ti.tags)
corresponding_event.acquisition_.add_to_output(ti)

self.stop_hardware_sequences(hardware_sequences_in_progress)

if event.get_sequence() is not None:
event.acquisition_.post_notification(AcqNotification(
AcqNotification.Camera, event.axisPositions_, AcqNotification.Camera.POST_SEQUENCE_STOPPED))

if timeout:
raise TimeoutError("Timeout waiting for images to arrive in circular buffer")

Expand Down
7 changes: 4 additions & 3 deletions pycromanager/acquisition/acq_eng_py/main/acq_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def to_string():

class Camera:
PRE_SEQUENCE_STARTED = "pre_sequence_started"
POST_SEQUENCE_STOPPED = "post_sequence_stopped"
PRE_SNAP = "pre_snap"
POST_EXPOSURE = "post_exposure"
POST_SNAP = "post_snap"

@staticmethod
def to_string():
Expand All @@ -45,8 +46,8 @@ def __init__(self, type, payload, milestone=None):
self.type = AcqNotification.Image
self.payload = payload
self.milestone = milestone
elif milestone in [AcqNotification.Camera.PRE_SNAP, AcqNotification.Camera.POST_EXPOSURE,
AcqNotification.Camera.PRE_SEQUENCE_STARTED]:
elif milestone in [AcqNotification.Camera.PRE_SNAP, AcqNotification.Camera.POST_SNAP,
AcqNotification.Camera.PRE_SEQUENCE_STARTED, AcqNotification.Camera.POST_SEQUENCE_STOPPED]:
self.type = AcqNotification.Camera
self.payload = json.loads(payload) if isinstance(payload, str) else payload # convert from '{'time': 5}' to {'time': 5}
elif milestone in [AcqNotification.Hardware.PRE_HARDWARE, AcqNotification.Hardware.POST_HARDWARE]:
Expand Down
15 changes: 15 additions & 0 deletions pycromanager/test/test_acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,3 +652,18 @@ def test_multi_channel_parsing(launch_mm_headless, setup_data_folder):
assert all([channel in dataset.get_channel_names() for channel in ["DAPI", "FITC"]])
finally:
dataset.close()


def test_empty_axes(launch_mm_headless, setup_data_folder):
"""
Test that images with empty axes are correctly saved
"""

with Acquisition(setup_data_folder, 'acq', show_display=False) as acq:
acq.acquire({'axes': {}})

dataset = acq.get_dataset()
try:
assert dataset.read_image() is not None and dataset.read_image().max() > 0
finally:
dataset.close()
Loading