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
20 changes: 16 additions & 4 deletions src/navigate/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,17 @@ def update_experiment_setting(self):

"""
self.camera_setting_controller.update_experiment_values()

# set waveform template
if self.acquire_bar_controller.mode in ["live", "single", "z-stack"]:
camera_setting = self.configuration["experiment"]["CameraParameters"]
if camera_setting["sensor_mode"] == "Light-Sheet" and camera_setting[
"readout_direction"
] in ["Bidirectional", "Rev. Bidirectional"]:
self.waveform_tab_controller.set_waveform_template("Bidirectional")
else:
self.waveform_tab_controller.set_waveform_template("Default")

# update multi-positions
positions = self.multiposition_tab_controller.get_positions()
update_config_dict(
Expand Down Expand Up @@ -752,9 +763,11 @@ def execute(self, command, *args):
)

# Save the waveform_constants.yaml file.
save_yaml_file(file_directory=file_directory,
content_dict=self.configuration['waveform_constants'],
filename="waveform_constants.yml")
save_yaml_file(
file_directory=file_directory,
content_dict=self.configuration["waveform_constants"],
filename="waveform_constants.yml",
)

self.camera_setting_controller.solvent = self.configuration["experiment"][
"Saving"
Expand Down Expand Up @@ -985,7 +998,6 @@ def capture_image(self, command, mode, *args):
)
self.execute("stop_acquire")


# Display the Image in the View
self.camera_view_controller.try_to_display_image(image_id=image_id)
images_received += 1
Expand Down
17 changes: 17 additions & 0 deletions src/navigate/controller/sub_controllers/waveform_tab_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,20 @@ def set_mode(self, mode):
"""
state = "normal" if mode == "stop" else "disabled"
self.view.waveform_settings.inputs["waveform_template"].widget["state"] = state

def set_waveform_template(self, template_name):
"""Set the waveform template name

Parameters
----------
template_name : str
Set the waveform template name

Examples
--------
>>> self.set_waveform_template(template_name)
"""
self.view.waveform_settings.inputs["waveform_template"].set(template_name)
self.parent_controller.configuration["experiment"]["MicroscopeState"][
"waveform_template"
] = template_name
46 changes: 46 additions & 0 deletions test/controller/test_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import MagicMock

import pytest

Expand Down Expand Up @@ -48,6 +49,11 @@ def controller(tk_root):
waveform_templates_path,
args,
)
# To make sure the testcases won't hang on because of the model.event_queue
# The changes here won't affect other testcases,
# because the testcases from other files use DummyController and DummyModel instead of this controller fixture
controller.model = MagicMock()
controller.model.get_offset_variance_maps.return_value = (None, None)

yield controller

Expand Down Expand Up @@ -89,3 +95,43 @@ def test_prepare_acquire_data(controller):
def test_execute(controller):
controller.execute("acquire", "single")
assert True


@pytest.mark.parametrize(
"acquisition_mode, sensor_mode, readout_direction, template_name, expected_template_name",
[
("live", "Normal", "", "Bidirectional", "Default"),
("z-stack", "Normal", "", "Bidirectional", "Default"),
("customized", "Normal", "", "Bidirectional", "Bidirectional"),
("live", "Light-Sheet", "Top-To-Bottom", "Bidirectional", "Default"),
("live", "Light-Sheet", "Bidirectional", "Bidirectional", "Bidirectional"),
("customized", "Light-Sheet", "Bidirectional", "Bidirectional", "Bidirectional",),
("z-stack", "Light-Sheet", "Bidirectional", "Default", "Bidirectional"),
("z-stack", "Light-Sheet", "Top-To-Bottom", "Default", "Default"),
],
)
def test_waveform_template(
controller,
acquisition_mode,
sensor_mode,
readout_direction,
template_name,
expected_template_name,
):
controller.configuration["experiment"]["MicroscopeState"][
"waveform_template"
] = template_name
controller.configuration["experiment"]["MicroscopeState"][
"image_mode"
] = acquisition_mode
controller.configuration["experiment"]["CameraParameters"]["number_of_pixels"] = 10
controller.populate_experiment_setting(in_initialize=True)

controller.camera_setting_controller.mode_widgets["Readout"].set(readout_direction)
controller.camera_setting_controller.mode_widgets["Sensor"].set(sensor_mode)
controller.update_experiment_setting()

assert (
controller.configuration["experiment"]["MicroscopeState"]["waveform_template"]
== expected_template_name
)