forked from mesoSPIM/mesoSPIM-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_config.py
401 lines (354 loc) · 16.3 KB
/
demo_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
import numpy as np
'''
mesoSPIM configuration file.
Use this file as a starting point to set up all mesoSPIM hardware by replacing the 'Demo' designations
with real hardware one-by-one. Make sure to rename your new configuration file to a different filename
(The extension has to be .py).
'''
'''
Dark mode: Renders the UI dark
'''
ui_options = {'dark_mode' : True, # Dark mode: Renders the UI dark if enabled
'enable_x_buttons' : True, # Here, specific sets of UI buttons can be disabled
'enable_y_buttons' : True,
'enable_z_buttons' : True,
'enable_f_buttons' : True,
'enable_rotation_buttons' : True,
'enable_loading_buttons' : True,
'button_sleep_ms_xyzft' : (250, 0, 250, 0, 0), # step-motion buttons disabled for N ms after click. Prevents stage overshooting outside of safe limits, for slow stages.
'window_pos': (100, 100), # position of the main window on the screen, top left corner.
'usb_webcam': False, # open USB web-camera in a separate window
}
logging_level = 'INFO' # 'DEBUG' for ultra-detailed, 'INFO' for general logging level
'''
Waveform output for Galvos, ETLs etc.
'''
waveformgeneration = 'DemoWaveFormGeneration' # 'DemoWaveFormGeneration' or 'NI'
'''
Card designations need to be the same as in NI MAX, if necessary, use NI MAX
to rename your cards correctly.
The new mesoSPIM configuration (benchtop-inspired) uses one card (PXI6733) and allows up to 4 laser channels.
Physical channels must be connected in certain order:
- 'galvo_etl_task_line' takes Galvo-L, Galvo-R, ETL-L, ETL-R
(e.g. value 'PXI6259/ao0:3' means Galvo-L on ao0, Galvo-R on ao1, ETL-L on ao2, ETL-R on ao3)
- 'laser_task_line' takes laser modulation, lasers sorted in increasing wavelength order,
(e.g. value 'PXI6733/ao4:7' means '405 nm' connected to ao4, '488 nm' to ao5, etc.)
'''
acquisition_hardware = {'master_trigger_out_line' : 'PXI6259/port0/line1',
'camera_trigger_source' : '/PXI6259/PFI0',
'camera_trigger_out_line' : '/PXI6259/ctr0',
'galvo_etl_task_line' : 'PXI6259/ao0:3',
'galvo_etl_task_trigger_source' : '/PXI6259/PFI0',
'laser_task_line' : 'PXI6733/ao0:3',
'laser_task_trigger_source' : '/PXI6259/PFI0'}
sidepanel = 'Demo' #'Demo' or 'FarmSimulator', deprecated
'''
Digital laser enable lines
'''
laser = 'Demo' # 'Demo' or 'NI'
''' The `laserdict` specifies laser labels of the GUI and their digital modulation channels.
Keys are the laser designation that will be shown in the user interface
Values are DO ports used for laser ENABLE digital signal.
Critical: entries must be sorted in the increasing wavelength order: 405, 488, etc.
'''
laserdict = {'488 nm': 'PXI6733/port0/line2',
'520 nm': 'PXI6733/port0/line3',
'568 nm': 'PXI6733/port0/line4',
'638 nm': 'PXI6733/port0/line5',
}
''' Laser blanking indicates whether the laser enable lines should be set to LOW between
individual images or stacks. This is helpful to avoid laser bleedthrough between images caused by insufficient
modulation depth of the analog input (even at 0V, some laser light is still emitted).
'''
laser_blanking = 'images' # if 'images', laser is off before and after every image; if 'stacks', before and after each stack.
'''
Shutter configuration
If shutterswitch = True:
'shutter_left' is the general shutter
'shutter_right' is the left/right switch (Right==True)
If shutterswitch = False or missing:
'shutter_left' and 'shutter_right' are two independent shutters.
'''
shutter = 'Demo' # 'Demo' or 'NI'
shutterswitch = False # see legend above
shutteroptions = ('Left', 'Right') # Shutter options of the GUI
shutterdict = {'shutter_left' : 'PXI6259/port0/line0', # left (general) shutter
'shutter_right' : 'PXI6259/port2/line0'} # flip mirror or right shutter, depending on physical configuration
'''
Camera configuration
For a DemoCamera, only the following options are necessary
(x_pixels and y_pixels can be chosen arbitrarily):
camera_parameters = {'x_pixels' : 1024,
'y_pixels' : 1024,
'x_pixel_size_in_microns' : 6.5,
'y_pixel_size_in_microns' : 6.5,
'subsampling' : [1,2,4]}
For a Hamamatsu Orca Flash 4.0 V2 or V3, the following parameters are necessary:
camera_parameters = {'x_pixels' : 2048,
'y_pixels' : 2048,
'x_pixel_size_in_microns' : 6.5,
'y_pixel_size_in_microns' : 6.5,
'subsampling' : [1,2,4],
'camera_id' : 0,
'sensor_mode' : 12, # 12 for progressive
'defect_correct_mode': 2,
'binning' : '1x1',
'readout_speed' : 1,
'trigger_active' : 1,
'trigger_mode' : 1, # it is unclear if this is the external lightsheeet mode - how to check this?
'trigger_polarity' : 2, # positive pulse
'trigger_source' : 2, # external
}
For a Photometrics Iris 15, the following parameters are necessary:
camera_parameters = {'x_pixels' : 5056,
'y_pixels' : 2960,
'x_pixel_size_in_microns' : 6.5,
'y_pixel_size_in_microns' : 6.5,
'subsampling' : [1,2,4],
'speed_table_index': 0,
'exp_mode' : 'Edge Trigger', # Lots of options in PyVCAM --> see constants.py
'readout_port': 0,
'gain_index': 1,
'exp_out_mode': 4, # 4: line out
'binning' : '1x1',
'scan_mode' : 1, # Scan mode options: {'Auto': 0, 'Line Delay': 1, 'Scan Width': 2}
'scan_direction' : 0, # Scan direction options: {'Down': 0, 'Up': 1, 'Down/Up Alternate': 2}
'scan_line_delay' : 6, # 10.26 us x factor, a factor = 6 equals 71.82 us
}
For a Photometrics Prime BSI Express, the following parameters are necessary:
camera_parameters = {'x_pixels' : 2048, #5056
'y_pixels' : 2048, # 2960
'x_pixel_size_in_microns' : 6.5,
'y_pixel_size_in_microns' : 6.5,
'subsampling' : [1,2,4],
'speed_table_index': 1, # 1 for 100 MHz
'exp_mode' : 'Edge Trigger', # Lots of options in PyVCAM --> see constants.py
'readout_port': 0,
'gain_index': 1, # Enable HDR mode
'exp_out_mode': 4, # 4: line out
'binning' : '1x1',
'scan_mode' : 1, # Scan mode options: {'Auto': 0, 'Line Delay': 1, 'Scan Width': 2}
'scan_direction' : 0, # Scan direction options: {'Down': 0, 'Up': 1, 'Down/Up Alternate': 2}
'scan_line_delay' : 7, # 11.2 us x factor, a factor = 3 equals 33.6 us
}
'''
camera = 'DemoCamera' # 'DemoCamera' or 'HamamatsuOrca' or 'Photometrics'
camera_parameters = {'x_pixels' : 1024,
'y_pixels' : 1024,
'x_pixel_size_in_microns' : 6.5,
'y_pixel_size_in_microns' : 6.5,
'subsampling' : [1,2,4],
'camera_id' : 0,
'sensor_mode' : 12, # 12 for progressive
'defect_correct_mode': 2,
'binning' : '1x1',
'readout_speed' : 1,
'trigger_active' : 1,
'trigger_mode' : 1, # it is unclear if this is the external lightsheeet mode - how to check this?
'trigger_polarity' : 2, # positive pulse
'trigger_source' : 2, # external
}
binning_dict = {'1x1': (1,1), '2x2':(2,2), '4x4':(4,4)}
'''
Stage configuration
'''
'''
The stage_parameter dictionary defines the general stage configuration, initial positions,
and safety limits. The rotation position defines a XYZ position (in absolute coordinates)
where sample rotation is safe. Additional hardware dictionaries (e.g. pi_parameters)
define the stage configuration details.
All positions are absolute.
'stage_type' option:
ASI stages, 'stage_type' : 'TigerASI', 'MS2000ASI'
PI stages, 'stage_type' : 'PI' or 'PI_1controllerNstages' (equivalent), 'PI_NcontrollersNstages'
Mixed stages, 'stage_type' : 'PI_rot_and_Galil_xyzf', 'GalilStage', 'PI_f_rot_and_Galil_xyz', 'PI_rotz_and_Galil_xyf', 'PI_rotzf_and_Galil_xy',
'''
stage_parameters = {'stage_type' : 'DemoStage', # one of 'DemoStage', 'PI_1controllerNstages', 'PI_NcontrollersNstages', 'TigerASI', etc, see above
'y_load_position': -86000,
'y_unload_position': -120000,
'x_max' : 3000,
'x_min' : -3000,
'y_max' : 3000,
'y_min' : -3000,
'z_max' : 3000,
'z_min' : -3000,
'f_max' : 3000,
'f_min' : -3000,
'theta_max' : 999,
'theta_min' : -999,
}
''''
If 'stage_type' = 'PI_1controllerNstages' (vanilla mesoSPIM V5 with single 6-axis controller):
pi_parameters = {'controllername' : 'C-884',
'stages' : ('L-509.20DG10','L-509.40DG10','L-509.20DG10','M-060.DG','M-406.4PD','NOSTAGE'),
'refmode' : ('FRF',),
'serialnum' : ('118075764'),
}
If 'stage_type' = 'PI_NcontrollersNstages' (mesoSPIM V5 with multiple single-axis controllers):
pi_parameters = {'axes_names': ('x', 'y', 'z', 'theta', 'f'),
'stages': ('L-509.20SD00', 'L-509.40SD00', 'L-509.20SD00', None, 'MESOSPIM_FOCUS'),
'controllername': ('C-663', 'C-663', 'C-663', None, 'C-663'),
'serialnum': ('**********', '**********', '**********', None, '**********'),
'refmode': ('FRF', 'FRF', 'FRF', None, 'RON')
}
If 'stage_type' = 'TigerASI' (benchtop mesoSPIM with an ASI Tiger controller)
The stage assignment dictionary assigns a mesoSPIM stage (xyzf and theta - dict key) to an ASI stage (XYZ etc)
which are the values of the dict.
asi_parameters = {'COMport' : 'COM32',
'baudrate' : 115200,
'stage_assignment': {'x':'X', 'y':'V', 'z':'Z', 'theta':'T', 'f':'Y'},
'encoder_conversion': {'V': 10., 'Z': 10., 'R': 100., 'X': 10., 'Y': 10.}, # num of encoder counts per um or degree, depending on stage type.
'stage_trigger_source': '/PXI1Slot4/PFI0',
'stage_trigger_out_line': '/PXI1Slot4/ctr1',
'stage_trigger_delay_%' : 92.5, # Set to 92.5 for stage triggering exactly after the ETL sweep
'stage_trigger_pulse_%' : 1,
'ttl_motion_enabled': True,
'ttl_cards':(2,3),
}
'''
'''
Filterwheel configuration
For a DemoFilterWheel, no COMport needs to be specified.
For a Ludl Filterwheel, a valid COMport is necessary. Ludl marking 10 = position 0.
For a Dynamixel FilterWheel, valid baudrate and servoi_id are necessary.
'''
filterwheel_parameters = {'filterwheel_type' : 'Demo', # 'Demo', 'Ludl', 'Sutter', 'Dynamixel', 'ZWO'
'COMport' : 'COM3', # irrelevant for 'ZWO'
'baudrate' : 115200, # relevant only for 'Dynamixel'
'servo_id' : 1, # relevant only for 'Dynamixel'
}
'''
filterdict contains filter labels and their positions. The valid positions are:
For Ludl: 0, 1, 2, 3, .., 9, i.e. position ids (int)
For Dynamixel: servo encoder counts, e.g. 0 for 0 deg, 1024 for 45 deg (360 deg = 4096 counts, or 11.377 counts/deg).
Dynamixel encoder range in multi-turn mode: -28672 .. +28672 counts.
For ZWO EFW Mini 5-slot wheel: positions 0, 1, .. 4.
'''
filterdict = {'Empty' : 0, # Every config should contain at least this entry
'405-488-647-Tripleblock' : 1,
'405-488-561-640-Quadrupleblock' : 2,
'464 482-35' : 3,
'508 520-35' : 4,
'515LP' : 5,
'529 542-27' : 6,
'561LP' : 7,
'594LP' : 8,
'417 447-60' : 9}
'''
Zoom configuration
For the DemoZoom, servo_id, COMport and baudrate do not matter. For a Dynamixel zoom,
these values have to be there
'''
zoom_parameters = {'zoom_type' : 'DemoZoom', # 'DemoZoom' or 'Dynamixel'
'servo_id' : 4,
'COMport' : 'COM38',
'baudrate' : 1000000}
'''
The keys in the zoomdict define what zoom positions are displayed in the selection box
(combobox) in the user interface.
'''
zoomdict = {'0.63x' : 3423,
'0.8x' : 3071,
'1x' : 2707,
'1.25x' : 2389,
'1.6x' : 2047,
'2x' : 1706,
'2.5x' : 1354,
'3.2x' : 967,
'4x' : 637,
'5x' : 318,
'6.3x' : 0}
'''
Pixelsize in micron
'''
pixelsize = {'0.63x' : 10.52,
'0.8x' : 8.23,
'1x' : 6.55,
'1.25x' : 5.26,
'1.6x' : 4.08,
'2x' : 3.26,
'2.5x' : 2.6,
'3.2x' : 2.03,
'4x' : 1.60,
'5x' : 1.27,
'6.3x' : 1.03}
'''
HDF5 parameters, if this format is used for data saving (optional).
Downsampling and compression slows down writing by 5x - 10x, use with caution.
Imaris can open these files if no subsampling and no compression is used.
'''
hdf5 = {'subsamp': ((1, 1, 1),), #((1, 1, 1),) no subsamp, ((1, 1, 1), (1, 4, 4)) for 2-level (z,y,x) subsamp.
'compression': None, # None, 'gzip', 'lzf'
'flip_xyz': (True, True, False), # match BigStitcher coordinates to mesoSPIM axes.
'transpose_xy': False, # in case X and Y axes need to be swapped for the correct tile positions
}
'''
Rescale the galvo amplitude when zoom is changed
For example, if 'galvo_l_amplitude' = 1 V at zoom '1x', it will ve 2 V at zoom '0.5x'
'''
scale_galvo_amp_with_zoom = True
'''
Initial acquisition parameters
Used as initial values after startup
When setting up a new mesoSPIM, make sure that:
* 'max_laser_voltage' is correct (5 V for Toptica MLEs, 10 V for Omicron SOLE)
* 'galvo_l_amplitude' and 'galvo_r_amplitude' (in V) are correct (not above the max input allowed by your galvos)
* all the filepaths exist
* the initial filter exists in the filter dictionary above
'''
startup = {
'state' : 'init', # 'init', 'idle' , 'live', 'snap', 'running_script'
'samplerate' : 100000,
'sweeptime' : 0.2,
'position' : {'x_pos':0,'y_pos':1,'z_pos':2,'f_pos':3,'theta_pos':180},
'ETL_cfg_file' : 'config/etl_parameters/ETL-parameters.csv',
'folder' : 'D:/tmp/',
'snap_folder' : 'D:/tmp/',
'file_prefix' : '',
'file_suffix' : '000001',
'zoom' : '1x',
'pixelsize' : 6.55,
'laser' : '488 nm',
'max_laser_voltage':10,
'intensity' : 10,
'shutterstate':False, # Is the shutter open or not?
'shutterconfig':'Right', # Can be "Left", "Right","Both","Interleaved"
'laser_interleaving':False,
'filter' : 'Empty',
'etl_l_delay_%' : 7.5,
'etl_l_ramp_rising_%' : 85,
'etl_l_ramp_falling_%' : 2.5,
'etl_l_amplitude' : 0.7,
'etl_l_offset' : 2.3,
'etl_r_delay_%' : 2.5,
'etl_r_ramp_rising_%' : 5,
'etl_r_ramp_falling_%' : 85,
'etl_r_amplitude' : 0.65,
'etl_r_offset' : 2.36,
'galvo_l_frequency' : 99.9,
'galvo_l_amplitude' : 2.5,
'galvo_l_offset' : 0,
'galvo_l_duty_cycle' : 50,
'galvo_l_phase' : np.pi/2,
'galvo_r_frequency' : 99.9,
'galvo_r_amplitude' : 2.5,
'galvo_r_offset' : 0,
'galvo_r_duty_cycle' : 50,
'galvo_r_phase' : np.pi/2,
'laser_l_delay_%' : 10,
'laser_l_pulse_%' : 87,
'laser_l_max_amplitude_%' : 100,
'laser_r_delay_%' : 10,
'laser_r_pulse_%' : 87,
'laser_r_max_amplitude_%' : 100,
'camera_delay_%' : 10,
'camera_pulse_%' : 1,
'camera_exposure_time':0.02,
'camera_line_interval':0.000075,
'camera_display_live_subsampling': 2,
#'camera_display_snap_subsampling': 1, #deprecated
'camera_display_acquisition_subsampling': 2,
'camera_binning':'1x1',
'camera_sensor_mode':'ASLM',
'average_frame_rate': 4.969,
}