Skip to content
Closed
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
8 changes: 6 additions & 2 deletions src/navigate/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,10 @@ def verify_waveform_constants(manager, configuration):
waveform_dict[microscope_name][zoom],
laser,
{
"amplitude": 0,
"offset": 0,
"amplitude": "0",
"offset": "0",
"dither_amplitude": "0",
"dither_frequency": "0",
# "percent_smoothing": "0",
# "delay": config_dict["remote_focus"][
# "delay"
Expand All @@ -756,6 +758,8 @@ def verify_waveform_constants(manager, configuration):
for k in [
"amplitude",
"offset",
"dither_amplitude",
"dither_frequency",
# "percent_smoothing",
# "delay",
]:
Expand Down
48 changes: 48 additions & 0 deletions src/navigate/config/waveform_constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
"488nm": {
"amplitude": "0.11",
"offset": "0.10",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "0.115",
"offset": "0.062",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "0",
"offset": "0",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand All @@ -27,18 +33,24 @@
"488nm": {
"amplitude": "2.5",
"offset": "2.336",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "2.5",
"offset": "2.336",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "2.5",
"offset": "2.336",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand All @@ -47,18 +59,24 @@
"488nm": {
"amplitude": "1",
"offset": "2.60",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "0.53",
"offset": "2.46",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "0.23",
"offset": "2.50",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand All @@ -67,18 +85,24 @@
"488nm": {
"amplitude": "0.20",
"offset": "2.52",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "0.466",
"offset": "1.534",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "0.20",
"offset": "2.53",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand All @@ -87,18 +111,24 @@
"488nm": {
"amplitude": "1",
"offset": "2.60",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "0.15",
"offset": "2.50",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "0.16",
"offset": "2.50",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand All @@ -107,18 +137,24 @@
"488nm": {
"amplitude": "0.141",
"offset": "2.392",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "0.141",
"offset": "2.392",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "0.141",
"offset": "2.392",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand All @@ -127,18 +163,24 @@
"488nm": {
"amplitude": "0.141",
"offset": "2.392",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "0.141",
"offset": "2.392",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "0.141",
"offset": "2.392",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand All @@ -147,18 +189,24 @@
"488nm": {
"amplitude": "0.15",
"offset": "2.52",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"562nm": {
"amplitude": "0.15",
"offset": "2.51",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
},
"642nm": {
"amplitude": "0.15",
"offset": "2.51",
"dither_amplitude": "0",
"dither_frequency": "0",
"percent_smoothing": "0",
"percent_delay": "0"
}
Expand Down
96 changes: 82 additions & 14 deletions src/navigate/controller/sub_controllers/waveform_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def __init__(
#: float: the maximum value of remote focus device
self.laser_max = 1.0

#: float: the maximum dither amplitude for the remote focus device.
self.dither_amplitude_max = 1.0

#: dict: Dictionary of galvo minimum values
self.galvo_min = {}

Expand Down Expand Up @@ -154,6 +157,18 @@ def __init__(
"write",
self.update_remote_focus_settings(laser + " Off", laser, "offset"),
)
self.variables[laser + " Dither Amp"].trace_add(
"write",
self.update_remote_focus_settings(
laser + " Dither Amp", laser, "dither_amplitude"
),
)
self.variables[laser + " Dither Freq"].trace_add(
"write",
self.update_remote_focus_settings(
laser + " Dither Freq", laser, "dither_frequency"
),
)

# Changes to the galvo constants (amplitude, offset, etc.)
for i in range(self.configuration_controller.galvo_num):
Expand Down Expand Up @@ -246,6 +261,13 @@ def configure_widget_range(self) -> None:
self.laser_max = self.configuration_controller.remote_focus_dict["hardware"][
"max"
]
self.dither_amplitude_max = max(abs(self.laser_min), abs(self.laser_max))
dither_frequency_max = (
self.parent_controller.configuration["configuration"]["microscopes"][
self.resolution
]["daq"]["sample_rate"]
/ 2
)

precision = int(
self.configuration_controller.remote_focus_dict["hardware"].get(
Expand Down Expand Up @@ -280,6 +302,26 @@ def configure_widget_range(self) -> None:
self.widgets[laser + " Off"].widget.set_precision(precision)
self.widgets[laser + " Off"].widget.trigger_focusout_validation()

self.widgets[laser + " Dither Amp"].widget.configure(from_=0)
self.widgets[laser + " Dither Amp"].widget.configure(
to=self.dither_amplitude_max
)
self.widgets[laser + " Dither Amp"].widget.configure(
increment=self.increment
)
self.widgets[laser + " Dither Amp"].widget.set_precision(precision)
self.widgets[laser + " Dither Amp"].widget.trigger_focusout_validation()

self.widgets[laser + " Dither Freq"].widget.configure(from_=0)
self.widgets[laser + " Dither Freq"].widget.configure(
to=dither_frequency_max
)
self.widgets[laser + " Dither Freq"].widget.configure(
increment=max(self.increment, 0.1)
)
self.widgets[laser + " Dither Freq"].widget.set_precision(precision)
self.widgets[laser + " Dither Freq"].widget.trigger_focusout_validation()

for galvo, d in zip(self.galvos, self.galvo_dict):
galvo_min = d["hardware"]["min"]
galvo_max = d["hardware"]["max"]
Expand Down Expand Up @@ -398,15 +440,20 @@ def show_laser_info(self, *args: tuple) -> None:
# get magnification setting
self.mag = self.widgets["Mag"].widget.get()
for laser in self.lasers:
remote_focus_settings = self.resolution_info["remote_focus_constants"][
self.resolution
][self.mag][laser]
self.variables[laser + " Amp"].set(
self.resolution_info["remote_focus_constants"][self.resolution][
self.mag
][laser]["amplitude"]
remote_focus_settings.get("amplitude", 0)
)
self.variables[laser + " Off"].set(
self.resolution_info["remote_focus_constants"][self.resolution][
self.mag
][laser]["offset"]
remote_focus_settings.get("offset", 0)
)
self.variables[laser + " Dither Amp"].set(
remote_focus_settings.get("dither_amplitude", 0)
)
self.variables[laser + " Dither Freq"].set(
remote_focus_settings.get("dither_frequency", 0)
)

# do not tell the model to update galvo
Expand Down Expand Up @@ -496,9 +543,12 @@ def update_remote_focus_settings(
# and when changing magnification it will run 0.63x
# before whatever mag is selected
def func_laser(*args):
value = self.resolution_info["remote_focus_constants"][self.resolution][
self.mag
][laser][remote_focus_name]
remote_focus_settings = self.resolution_info["remote_focus_constants"][
self.resolution
][self.mag][laser]
value = remote_focus_settings.get(remote_focus_name, "0")
if remote_focus_name not in remote_focus_settings:
remote_focus_settings[remote_focus_name] = value

# Will only run code if value in constants does not match whats in GUI
# for Amp or Off AND in Live mode
Expand All @@ -517,13 +567,20 @@ def func_laser(*args):
value = float(variable_value)
except ValueError:
return
if value < self.laser_min or value > self.laser_max:
min_value = self.laser_min
max_value = self.laser_max
if remote_focus_name == "dither_amplitude":
min_value = 0
max_value = self.dither_amplitude_max
elif remote_focus_name == "dither_frequency":
min_value = 0
max_value = None

if value < min_value or (max_value is not None and value > max_value):
return
self.resolution_info["remote_focus_constants"][self.resolution][
self.mag
][laser][remote_focus_name] = variable_value
remote_focus_settings[remote_focus_name] = variable_value
logger.debug(
f"Remote Focus Amplitude/Offset Changed:, {variable_value}"
f"Remote Focus {remote_focus_name} Changed:, {variable_value}"
)

# Delay feature.
Expand Down Expand Up @@ -749,8 +806,14 @@ def toggle_waveform_state(self):
self.amplitude_dict[laser] = self.resolution_info[
"remote_focus_constants"
][self.resolution][self.mag][laser]["amplitude"]
self.amplitude_dict[laser + " dither"] = self.resolution_info[
"remote_focus_constants"
][self.resolution][self.mag][laser].get("dither_amplitude", 0)
self.variables[laser + " Amp"].set(0)
self.variables[laser + " Dither Amp"].set(0)
self.widgets[laser + " Amp"].widget.config(state="disabled")
self.widgets[laser + " Dither Amp"].widget.config(state="disabled")
self.widgets[laser + " Dither Freq"].widget.config(state="disabled")

for galvo in self.galvos:
self.amplitude_dict[galvo] = self.resolution_info["galvo_constants"][
Expand Down Expand Up @@ -800,7 +863,12 @@ def restore_amplitude(self) -> None:
self.resolution_info["remote_focus_constants"][resolution][mag][laser][
"amplitude"
] = self.amplitude_dict[laser]
self.resolution_info["remote_focus_constants"][resolution][mag][laser][
"dither_amplitude"
] = self.amplitude_dict[laser + " dither"]
self.widgets[laser + " Amp"].widget.config(state="normal")
self.widgets[laser + " Dither Amp"].widget.config(state="normal")
self.widgets[laser + " Dither Freq"].widget.config(state="normal")
for galvo in self.galvos:
self.resolution_info["galvo_constants"][galvo][resolution][mag][
"amplitude"
Expand Down
Loading
Loading