Skip to content

Commit 91269ab

Browse files
Merge pull request #848 from TheDeanLab/842-configurationyaml-configurator-gui
842 configurationyaml configurator gui
2 parents 0894118 + b4e7257 commit 91269ab

File tree

28 files changed

+1497
-103
lines changed

28 files changed

+1497
-103
lines changed

src/navigate/config/config.py

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import yaml
4545

4646
# Local Imports
47-
47+
from navigate.tools.common_functions import build_ref_name
4848

4949
def get_navigate_path():
5050
"""Establish a program home directory in AppData/Local/.navigate for Windows
@@ -764,10 +764,8 @@ def verify_waveform_constants(manager, configuration):
764764
waveform_dict[microscope_name][zoom],
765765
laser,
766766
{
767-
"amplitude": config_dict["remote_focus_device"][
768-
"amplitude"
769-
],
770-
"offset": config_dict["remote_focus_device"]["offset"],
767+
"amplitude": 0,
768+
"offset": 0,
771769
# "percent_smoothing": "0",
772770
# "delay": config_dict["remote_focus_device"][
773771
# "delay"
@@ -864,9 +862,9 @@ def verify_waveform_constants(manager, configuration):
864862
waveform_dict[microscope_name],
865863
zoom,
866864
{
867-
"amplitude": "0.11",
868-
"offset": config_dict["galvo"][i]["offset"],
869-
"frequency": config_dict["galvo"][i]["frequency"],
865+
"amplitude": "0",
866+
"offset": 0,
867+
"frequency": 10,
870868
},
871869
)
872870
else:
@@ -896,12 +894,8 @@ def verify_waveform_constants(manager, configuration):
896894
other_constants_dict = {
897895
"remote_focus_settle_duration": "0",
898896
"percent_smoothing": "0",
899-
"remote_focus_delay": config_dict["remote_focus_device"][
900-
"delay"
901-
],
902-
"remote_focus_ramp_falling": config_dict["remote_focus_device"][
903-
"ramp_falling"
904-
]
897+
"remote_focus_delay": "0",
898+
"remote_focus_ramp_falling": "5"
905899
}
906900
if (
907901
"other_constants" not in waveform_dict.keys()
@@ -924,7 +918,16 @@ def verify_configuration(manager, configuration):
924918
925919
Supports old version of configurations.
926920
"""
921+
channel_count = 5
922+
# generate hardware header section
927923
device_config = configuration["configuration"]["microscopes"]
924+
hardware_dict = {}
925+
ref_list = {
926+
"camera": [],
927+
"stage": [],
928+
"zoom": None,
929+
"mirror": None,
930+
}
928931
for microscope_name in device_config.keys():
929932
# camera
930933
# delay_percent -> delay
@@ -938,3 +941,54 @@ def verify_configuration(manager, configuration):
938941
remote_focus_config["ramp_falling"] = remote_focus_config.get("ramp_falling_percent", 5)
939942
if "delay" not in remote_focus_config.keys():
940943
remote_focus_config["delay"] = remote_focus_config.get("delay_percent", 0)
944+
945+
# daq
946+
daq_type = device_config[microscope_name]["daq"]["hardware"]["type"]
947+
if not daq_type.lower().startswith("synthetic"):
948+
hardware_dict["daq"] = {"type": daq_type}
949+
950+
# camera
951+
if "camera" not in hardware_dict:
952+
hardware_dict["camera"] = []
953+
camera_idx = build_ref_name("-", camera_config["hardware"]["type"], camera_config["hardware"]["serial_number"])
954+
if camera_idx not in ref_list["camera"]:
955+
ref_list["camera"].append(camera_idx)
956+
hardware_dict["camera"].append(camera_config["hardware"])
957+
958+
try:
959+
channel_count = max(channel_count, camera_config.get("count", 5))
960+
except TypeError:
961+
channel_count = 5
962+
963+
# zoom (one zoom)
964+
if "zoom" not in hardware_dict:
965+
zoom_config = device_config[microscope_name]["zoom"]["hardware"]
966+
# zoom_idx = build_ref_name("-", zoom_config["type"], zoom_config["servo_id"])
967+
hardware_dict["zoom"] = zoom_config
968+
969+
# filter wheel
970+
if "filter_wheel" not in hardware_dict:
971+
filter_wheel_config = device_config[microscope_name]["filter_wheel"]["hardware"]
972+
hardware_dict["filter_wheel"] = filter_wheel_config
973+
# stage
974+
if "stage" not in hardware_dict:
975+
hardware_dict["stage"] = []
976+
stages = device_config[microscope_name]["stage"]["hardware"]
977+
if type(stages) != ListProxy:
978+
stages = [stages]
979+
for i, stage in enumerate(stages):
980+
stage_idx = build_ref_name("-", stage["type"], stage["serial_number"])
981+
if stage_idx not in ref_list["stage"]:
982+
hardware_dict["stage"].append(stage)
983+
984+
# mirror
985+
if "mirror" in device_config[microscope_name].keys() and "mirror" not in hardware_dict:
986+
hardware_dict["mirror"] = device_config[microscope_name]["mirror"]["hardware"]
987+
988+
if "daq" not in hardware_dict:
989+
hardware_dict["daq"] = {
990+
"type": "synthetic"
991+
}
992+
update_config_dict(manager, configuration["configuration"], "hardware", hardware_dict)
993+
994+
update_config_dict(manager, configuration["configuration"], "gui", {"channels": {"count": channel_count}})
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
camera_device_types = {
2+
"Hamamatsu ORCA Lightning": "HamamatsuOrcaLightning",
3+
"Hamamatsu ORCA Fire": "HamamatsuOrcaFire",
4+
"Hamamatsu Flash 4.0": "HamamatsuOrca",
5+
"Photometrics Iris 15B": "Photometrics",
6+
"Virtual Device": "synthetic"
7+
}
8+
9+
camera_hardware_widgets = {
10+
"hardware/type": ["Device Type", "Combobox", "string", camera_device_types, None],
11+
"hardware/serial_number": ["Serial Number", "Input", "string", None, 'Example: "302352"'],
12+
"hardware/camera_connection": ["Camera Connection", "Input", "string", None, "*Photometrics Iris 15B only"],
13+
"defect_correct_mode": ["Defect Correct Mode", "Combobox", "string", {"On": 2.0, "Off": 1.0}, None],
14+
"delay": ["Delay (ms)", "Spinbox", "float", None, None],
15+
"flip_x": ["Flip X", "Checkbutton", "bool", None, None],
16+
"flip_y": ["Flip Y", "Checkbutton", "bool", None, None],
17+
"count": ["Microscope Channel Count", "Spinbox", "int", {"from": 5, "to": 10, "step": 1}, None]
18+
}
19+
20+
filter_wheel_device_types = {
21+
"Sutter Instruments": "SutterFilterWheel",
22+
"Applied Scientific Instrumentation": "ASI",
23+
"Virtual Device": "synthetic",
24+
}
25+
26+
filter_wheel_widgets = {
27+
"filter_name": ["Filter Name", "Input", "string", None, "Example: Empty-Alignment"],
28+
"filter_value": ["Filter Value", "Input", "string", None, "Example: 0"],
29+
"button_1": ["Delete", "Button", {"delete": True}],
30+
"frame_config": {"ref": "available_filters", "format": "item(filter_name,filter_value),", "direction": "horizon"}
31+
}
32+
33+
filter_wheel_hardware_widgets = {
34+
"hardware/type": ["Device Type", "Combobox", "string", filter_wheel_device_types, None],
35+
"hardware/wheel_number": ["Number of Wheels", "Spinbox", "int", None, "Example: 1"],
36+
"hardware/port": ["Serial Port", "Input", "string", None, "Example: COM1"],
37+
"hardware/baudrate": ["Baudrate", "Input", "int", None, "Example: 9200"],
38+
"filter_wheel_delay": ["Filter Wheel Delay (s)", "Input", "float", None, "Example: 0.03"],
39+
"button_1": ["Add Available Filters", "Button", {"widgets":filter_wheel_widgets, "ref": "available_filters", "direction": "horizon"}]
40+
}
41+
42+
daq_device_types = {
43+
"National Instruments": "NI",
44+
}
45+
46+
daq_hardware_widgets = {
47+
"hardware/type": ["Device Type", "Combobox", "string", daq_device_types, None],
48+
"sample_rate": ["Sample Rate", "Input", "int", None, "Example: 9600"],
49+
"master_trigger_out_line": ["Master Trigger Out", "Input", "string", None, "Example: PXI6259/port0/line1"],
50+
"camera_trigger_out_line": ["Camera Trigger Out", "Input", "string", None, "Example: /PXI6259/ctr0"],
51+
"trigger_source": ["Trigger Source", "Input", "string", None, "Example: /PXI6259/PFI0"],
52+
"laser_port_switcher": ["Laser Switcher Port", "Input", "string", None, "Example: PXI6733/port0/line0"],
53+
"laser_switch_state": ["Laser Switch On State", "Combobox", "bool", [True, False], None],
54+
}
55+
56+
shutter_device_types = {
57+
"Analog/Digital Device": "NI",
58+
"Virtual Device": "synthetic",
59+
}
60+
61+
shutter_hardware_widgets = {
62+
"type": ["Device Type", "Combobox", "string", shutter_device_types, None],
63+
"channel": ["NI Channel", "Input", "string", None, "Example: PXI6259/port0/line0"],
64+
"min": ["Minimum Voltage", "Spinbox", "float", None, "Example: 0"],
65+
"max": ["Maximum Voltage", "Spinbox", "float", None, "Example: 5"],
66+
"frame_config": {"ref": "hardware"}
67+
}
68+
69+
stage_device_types = {
70+
"Applied Scientific Instrumentation": "ASI",
71+
"Analog/Digital Device": "GalvoNIStage",
72+
"Mad City Labs": "MCL",
73+
"Physik Instrumente": "PI",
74+
"Sutter Instruments": "MP285",
75+
"ThorLabs KCube Inertial Device": "Thorlabs",
76+
"Virtual Device": "synthetic",
77+
}
78+
79+
stage_hardware_widgets = {
80+
"type": ["Device Type", "Combobox", "string", stage_device_types, None],
81+
"serial_number": ["Serial Number", "Input", "string", None, None],
82+
"axes": ["Axes", "Input", "string", None, "Example: [x, y, z]"],
83+
"axes_mapping": ["Axes Mapping", "Input", "string", None, "Example: [X, M, Y]"],
84+
"volts_per_micron": ["Volts Per Micron", "Spinbox", "float", {"from": 0, "to": 100, "step":0.1}, "*Analog/Digital Device only"],
85+
"min": ["Minimum Volts", "Spinbox", "float", {"from": 0, "to": 5, "step": 0.1}, "*Analog/Digital Device only",],
86+
"max": ["Maximum Volts", "Spinbox", "float", {"from": 1, "to": 100, "step": 0.1}, "*Analog/Digital Device only",],
87+
"controllername": ["Controller Name", "Input", "string", None, "*Physik Instrumente only. Example: 'C-884'"],
88+
"stages": ["PI Stages", "Input", "string", None, "*Physik Instrumente only. Example: L-509.20DG10 L-509.40DG10"],
89+
"refmode": ["REF Modes", "Input", "string", None, "*Physik Instrumente only. Example: FRF FRF"],
90+
"port": ["Serial Port", "Input", "string", None, "Example: COM1"],
91+
"baudrate": ["Baudrate", "Input", "int", None, "Example: 9200"],
92+
"button_2": ["Delete", "Button", {"delete": True}],
93+
"frame_config": {"collapsible": True, "title": "Stage", "ref": "hardware", "format": "list-dict"}
94+
}
95+
96+
stage_top_widgets = {
97+
"button_1": ["Add New Stage Device", "Button", {"widgets": stage_hardware_widgets, "ref": "hardware", "parent": "hardware"}],
98+
}
99+
100+
stage_constants_widgets = {
101+
"joystick_axes": ["Joystick Axes", "Input", "string", None, "Example: [x, y, z]"],
102+
"x_min": ["Min X", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, None],
103+
"x_max": ["Max X", "Spinbox", "float", {"from": 0, "to": 10000, "step": 1000}, None],
104+
"y_min": ["Min Y", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, None],
105+
"y_max": ["Max Y", "Spinbox", "float", {"from": 0, "to": 10000, "step": 1000}, None],
106+
"z_min": ["Min Z", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, None],
107+
"z_max": ["Max Z", "Spinbox", "float", {"from": 0, "to": 10000, "step": 1000}, None],
108+
"theta_min": ["Min Theta", "Spinbox", "float", {"from": 0, "to": 360, "step": 1000}, None],
109+
"theta_max": ["Max Theta", "Spinbox", "float", {"from": 0, "to": 360, "step": 1000}, None],
110+
"f_min": ["Min Focus", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, None],
111+
"f_max": ["Max Focus", "Spinbox", "float", {"from": 0, "to": 10000, "step": 1000}, None],
112+
"x_offset": ["Offset of X", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, "Example: 0"],
113+
"y_offset": ["Offset of Y", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, "Example: 0"],
114+
"z_offset": ["Offset of Z", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, "Example: 0"],
115+
"theta_offset": ["Offset of Theta", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, "Example: 0"],
116+
"f_offset": ["Offset of Focus", "Spinbox", "float", {"from": -100000, "to": 10000, "step": 1000}, "Example: 0"],
117+
"frame_config": {"collapsible": True, "title": "Stage Constants"}
118+
}
119+
120+
remote_focus_device_types = {
121+
"Equipment Solutions": "EquipmentSolutions",
122+
"Analog Device": "NI",
123+
"Virtual Device": "synthetic"
124+
}
125+
126+
remote_focus_hardware_widgets = {
127+
"type": ["Device Type", "Combobox", "string", remote_focus_device_types, None],
128+
"channel": ["DAQ Channel", "Input", "string", None, "Example: PXI6259/ao3"],
129+
"min": ["Minimum Voltage", "Spinbox", "float", {"from": -10, "to": 10, "step": 1}, None],
130+
"max": ["Maximum Voltage", "Spinbox", "float", {"from": 0, "to": 10, "step": 1}, None],
131+
"comport": ["Serial Port", "Input", "string", None, "*Equipment Solutions only"],
132+
"baudrate": ["Baudrate", "Input", "int", None, "*Equipment Solutions only. Example: 9200"],
133+
"frame_config": {"ref": "hardware"}
134+
}
135+
136+
galvo_device_types = {
137+
"Analog Device": "NI",
138+
"Virtual Device": "synthetic"
139+
}
140+
141+
waveform_types = {
142+
"Sine": "sine",
143+
"Sawtooth": "sawtooth",
144+
"Square": "square",
145+
}
146+
147+
galvo_hardware_widgets = {
148+
"hardware/type": ["Device Type", "Combobox", "string", galvo_device_types, None],
149+
"hardware/channel": ["DAQ Channel", "Input", "string", None, "Example: PXI6259/ao1"],
150+
"hardware/min": ["Minimum Voltage", "Spinbox", "float", {"from": -10, "to": 10, "step": 0.1}, None],
151+
"hardware/max": ["Maximum Voltage", "Spinbox", "float", {"from": 0, "to": 10, "step": 0.1}, None],
152+
"waveform": ["Waveform", "Combobox", "string", waveform_types, None],
153+
"phase": ["Phase", "Input", "string", None, "Example: 1.57"],
154+
"button_1": ["Delete", "Button", {"delete": True}],
155+
"frame_config": {"collapsible": True, "title": "Galvo Device", "ref": "None", "format": "list-dict"}
156+
}
157+
158+
galvo_top_widgets = {
159+
"button_1": ["Add New Device", "Button", {"widgets": galvo_hardware_widgets, "parent": "hardware"}],
160+
}
161+
162+
zoom_device_types = {
163+
"Dynamixel": "DynamixelZoom",
164+
"Virtual Device": "synthetic"
165+
}
166+
167+
zoom_position_widgets = {
168+
"zoom_value": ["Zoom Value", "Input", "string", None, "Example: 16x"],
169+
"position": ["Position", "Input", "float", None, "Example: 1000"],
170+
"pixel_size": ["Pixel Size (um)", "Input", "float", None, "Example: 0.5"],
171+
"button_1": ["Delete", "Button", {"delete": True}],
172+
"frame_config": {"ref": "position;pixel_size", "format": "item(zoom_value, position);item(zoom_value, pixel_size)", "direction": "horizon"}
173+
}
174+
175+
zoom_hardware_widgets = {
176+
"type": ["Device Type", "Combobox", "string", zoom_device_types, None],
177+
"servo_id": ["Servo ID", "Input", "string", None, "Example: 1"],
178+
"port": ["Serial Port", "Input", "string", None, "Example: COM1"],
179+
"baudrate": ["Baudrate", "Input", "int", None, "Example: 9600"],
180+
"button_1": ["Add Zoom Value", "Button", {"widgets":zoom_position_widgets, "ref": "position;pixel_size", "direction": "horizon"}],
181+
"frame_config": {"ref": "hardware"}
182+
}
183+
184+
mirror_device_types = {
185+
"Imagine Optics": "ImagineOpticsMirror",
186+
"Virtual Device": "SyntheticMirror"
187+
}
188+
189+
mirror_hardware_widgets = {
190+
"type": ["Device Type", "Combobox", "string", mirror_device_types, None],
191+
"frame_config": {"ref": "hardware"}
192+
}
193+
194+
laser_device_types = {
195+
"Analog Device": "NI",
196+
"Virtual Device": "synthetic"
197+
}
198+
199+
laser_hardware_widgets = {
200+
"wavelength": ["Wavelength", "Input", "int", None, None, "Example: 488"],
201+
"onoff": ["On/Off Setting", "Label", None, None, None],
202+
"onoff/hardware/type": ["Type", "Combobox", "string", laser_device_types, None],
203+
"onoff/hardware/channel": ["DAQ Channel", "Input", "string", None, "Example: PXI6733/port0/line2"],
204+
"onoff/hardware/min": ["Minimum Voltage", "Spinbox", "float", {"from": 0, "to": 100, "step": 1}, None],
205+
"onoff/hardware/max": ["Maximum Voltage", "Spinbox", "float", {"from": 0, "to": 100, "step": 1}, None],
206+
"power": ["Power Setting", "Label", None, None, None],
207+
"power/hardware/type": ["Type", "Combobox", "string", laser_device_types, None],
208+
"power/hardware/channel": ["DAQ Channel", "Input", "string", None, "Example: PXI6733/ao0"],
209+
"power/hardware/min": ["Minimum Voltage", "Spinbox", "float", {"from": 0, "to": 100, "step": 1}, None],
210+
"power/hardware/max": ["Maximum Voltage", "Spinbox", "float", {"from": 0, "to": 100, "step": 1}, None],
211+
"button_1": ["Delete", "Button", {"delete": True}],
212+
"frame_config": {"collapsible": True, "title": "Wavelength", "format": "list-dict", "ref": "None"}
213+
}
214+
215+
laser_top_widgets = {
216+
"button_1": ["Add Wavelength", "Button", {"widgets": laser_hardware_widgets, "parent": "hardware"}],
217+
}
218+
219+
hardwares_dict = {
220+
"Camera": camera_hardware_widgets,
221+
"Data Acquisition Card": daq_hardware_widgets,
222+
"Filter Wheel": (None, filter_wheel_hardware_widgets, filter_wheel_widgets),
223+
"Galvo": (galvo_top_widgets, galvo_hardware_widgets, None),
224+
"Lasers": (laser_top_widgets, laser_hardware_widgets, None),
225+
"Remote Focus Devices": remote_focus_hardware_widgets,
226+
"Adaptive Optics": mirror_hardware_widgets,
227+
"Shutters": shutter_hardware_widgets,
228+
"Stages": (stage_top_widgets, stage_hardware_widgets, stage_constants_widgets),
229+
"Zoom Device": (None, zoom_hardware_widgets, zoom_position_widgets)
230+
}
231+
232+
hardwares_config_name_dict = {
233+
"Camera": "camera",
234+
"Data Acquisition Card": "daq",
235+
"Filter Wheel": "filter_wheel",
236+
"Galvo": "galvo",
237+
"Lasers": "lasers",
238+
"Remote Focus Devices": "remote_focus_device",
239+
"Adaptive Optics": "mirror",
240+
"Shutters": "shutter",
241+
"Stages": "stage",
242+
"Zoom Device": "zoom",
243+
}

0 commit comments

Comments
 (0)