Skip to content

Commit 96762e6

Browse files
Merge pull request #699 from TheDeanLab/adaptive-optics+develop-20231128
Adaptive Optics final merge (at the buzzer)
2 parents ce9c2e9 + 0a116a9 commit 96762e6

22 files changed

+3113
-51
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,4 @@ src/aslm/log_files/LOGS
295295
test.n5
296296
test_dir
297297
test.xml
298+
*_log.txt

src/aslm/controller/configuration_controller.py

+23
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,26 @@ def number_of_channels(self):
374374
if self.microscope_config is not None:
375375
return self.configuration["configuration"]["gui"]["channels"]["count"]
376376
return 5
377+
378+
@property
379+
def microscope_list(self):
380+
"""Return a list of microscope names
381+
382+
Returns
383+
-------
384+
microscope_list : list
385+
List of microscope names.
386+
"""
387+
return list(self.configuration["configuration"]["microscopes"].keys())
388+
389+
def get_zoom_value_list(self, microscope_name):
390+
"""Return a list of zoom values
391+
392+
Returns
393+
-------
394+
zoom_value_list : list
395+
List of zoom values.
396+
"""
397+
return self.configuration["waveform_constants"]["remote_focus_constants"][
398+
microscope_name
399+
].keys()

src/aslm/controller/controller.py

+70-21
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
AcquireBarController,
6262
FeaturePopupController,
6363
MenuController,
64+
# MicroscopePopupController,
65+
# AdaptiveOpticsPopupController,
6466
)
6567

6668
from aslm.controller.thread_pool import SynchronizedThreadPool
@@ -298,30 +300,35 @@ def update_acquire_control(self):
298300
command=self.stage_controller.stop_button_handler
299301
)
300302

301-
def change_microscope(self, microscope_name):
303+
def change_microscope(self, microscope_name, zoom=None):
302304
"""Change the microscope configuration.
303305
304306
Parameters
305307
----------
306308
microscope_name : string
307309
Name of the microscope to change to.
310+
zoom : string
311+
Name of the zoom value to change to.
308312
"""
309313
self.configuration["experiment"]["MicroscopeState"][
310314
"microscope_name"
311315
] = microscope_name
316+
if zoom:
317+
self.configuration["experiment"]["MicroscopeState"]["zoom"] = zoom
312318
if self.configuration_controller.change_microscope():
313319
# update widgets
314320
self.stage_controller.initialize()
315321
self.channels_tab_controller.initialize()
316322
self.camera_setting_controller.update_camera_device_related_setting()
317323
self.camera_setting_controller.calculate_physical_dimensions()
318-
if (
319-
hasattr(self, "waveform_popup_controller")
320-
and self.waveform_popup_controller
321-
):
322-
self.waveform_popup_controller.populate_experiment_values()
323324
self.camera_view_controller.update_snr()
324325

326+
if (
327+
hasattr(self, "waveform_popup_controller")
328+
and self.waveform_popup_controller
329+
):
330+
self.waveform_popup_controller.populate_experiment_values()
331+
325332
def initialize_cam_view(self):
326333
"""Populate view tab.
327334
@@ -590,22 +597,28 @@ def execute(self, command, *args):
590597
591598
Parameters
592599
----------
593-
args : dict
594-
dict = {'resolution_mode': self.resolution,
595-
'zoom': self.mag,
596-
'laser_info': self.resolution_info[
597-
'remote_focus_constants'][self.resolution][self.mag]
598-
}
600+
args : str
601+
"microscope_name zoom_value", "microscope_name", or "zoom_value"
599602
"""
600-
microscope_name, zoom = self.menu_controller.resolution_value.get().split()
601-
self.configuration["experiment"]["MicroscopeState"]["zoom"] = zoom
602-
if (
603-
microscope_name
604-
!= self.configuration["experiment"]["MicroscopeState"][
605-
"microscope_name"
606-
]
607-
):
608-
self.change_microscope(microscope_name)
603+
# get microscope name and zoom value from args[0]
604+
temp = args[0].split()
605+
if len(temp) == 1:
606+
# microscope name is given
607+
if temp[0] in self.configuration_controller.microscope_list:
608+
temp.append(
609+
self.configuration_controller.get_zoom_value_list(temp[0])[0]
610+
)
611+
elif temp[0] in self.configuration_controller.get_zoom_value_list(
612+
self.configuration_controller.microscope_name
613+
):
614+
temp = [self.configuration_controller.microscope_name, temp[0]]
615+
else:
616+
return
617+
resolution_value = " ".join(temp)
618+
if resolution_value != self.menu_controller.resolution_value.get():
619+
self.menu_controller.resolution_value.set(resolution_value)
620+
return
621+
self.change_microscope(temp[0], temp[1])
609622
work_thread = self.threads_pool.createThread(
610623
"model", lambda: self.model.run_command("update_setting", "resolution")
611624
)
@@ -647,6 +660,30 @@ def execute(self, command, *args):
647660
"model", lambda: self.model.run_command("stage_limits", *args)
648661
)
649662

663+
# mirror commands:
664+
elif command == "flatten_mirror":
665+
self.model.run_command("flatten_mirror", *args)
666+
elif command == "zero_mirror":
667+
self.model.run_command("zero_mirror", *args)
668+
elif command == "set_mirror":
669+
self.model.run_command("set_mirror", *args)
670+
elif command == "set_mirror_from_wcs":
671+
self.model.run_command("set_mirror_from_wcs", *args)
672+
elif command == "save_wcs_file":
673+
self.model.run_command("save_wcs_file", *args)
674+
elif command == "tony_wilson":
675+
self.threads_pool.createThread(
676+
"camera",
677+
self.capture_image,
678+
args=(
679+
"tony_wilson",
680+
"live",
681+
),
682+
)
683+
684+
# elif command == "change_camera":
685+
# self.model.run_command("change_camera", *args)
686+
650687
elif command == "autofocus":
651688
"""Execute autofocus routine."""
652689
self.threads_pool.createThread(
@@ -1091,6 +1128,18 @@ def update_event(self):
10911128
data=value[0], line_plot=value[1], clear_data=value[2]
10921129
)
10931130

1131+
elif event == "tonywilson":
1132+
if hasattr(self, "ao_popup_controller"):
1133+
# self.ao_popup_controller.set_widgets_from_coef(value['coefs'])
1134+
self.ao_popup_controller.plot_tonywilson(value)
1135+
# self.ao_popup_controller.plot_mirror(value)
1136+
if value["done"]:
1137+
print("Tony Wilson done! Updating expt...")
1138+
self.ao_popup_controller.update_experiment_values()
1139+
elif event == "mirror_update":
1140+
if hasattr(self, "ao_popup_controller"):
1141+
self.ao_popup_controller.set_widgets_from_coef(value["coefs"])
1142+
self.ao_popup_controller.plot_mirror(value)
10941143
elif event == "stop":
10951144
# Stop the software
10961145
break

src/aslm/controller/sub_controllers/__init__.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
from .waveform_tab_controller import WaveformTabController # noqa
77
from .waveform_popup_controller import WaveformPopupController # noqa
88
from .autofocus_popup_controller import AutofocusPopupController # noqa
9-
from .features_popup_controller import FeaturePopupController #noqa
10-
from .feature_advanced_setting_controller import FeatureAdvancedSettingController #noqa
9+
from .features_popup_controller import FeaturePopupController # noqa
10+
from .feature_advanced_setting_controller import (
11+
FeatureAdvancedSettingController, # noqa
12+
)
1113
from .keystroke_controller import KeystrokeController # noqa
1214
from .multi_position_controller import MultiPositionController # noqa
1315
from .ilastik_popup_controller import IlastikPopupController # noqa
1416
from .camera_map_setting_popup_controller import CameraMapSettingPopupController # noqa
1517
from .microscope_popup_controller import MicroscopePopupController # noqa
16-
from .help_popup_controller import HelpPopupController #noqa
17-
from .menu_controller import MenuController # noqa
18+
from .help_popup_controller import HelpPopupController # noqa
19+
from .adaptiveoptics_popup_controller import AdaptiveOpticsPopupController # noqa
20+
from .menu_controller import MenuController # noqa

0 commit comments

Comments
 (0)