microeye 2.3.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. microEye/__init__.py +47 -0
  2. microEye/_version.py +2 -0
  3. microEye/analysis/__init__.py +1 -0
  4. microEye/analysis/checklist_dialog.py +143 -0
  5. microEye/analysis/cmosMaps.py +228 -0
  6. microEye/analysis/filters/__init__.py +9 -0
  7. microEye/analysis/filters/base.py +21 -0
  8. microEye/analysis/filters/spatial.py +338 -0
  9. microEye/analysis/filters/temporal.py +76 -0
  10. microEye/analysis/fitting/__init__.py +0 -0
  11. microEye/analysis/fitting/fit.py +680 -0
  12. microEye/analysis/fitting/nena.py +375 -0
  13. microEye/analysis/fitting/phasor_fit.py +90 -0
  14. microEye/analysis/fitting/processing.py +317 -0
  15. microEye/analysis/fitting/psf/__init__.py +6 -0
  16. microEye/analysis/fitting/psf/extract.py +1129 -0
  17. microEye/analysis/fitting/psf/rubost_mean.py +150 -0
  18. microEye/analysis/fitting/psf/spline.py +167 -0
  19. microEye/analysis/fitting/psf/stats/__init__.py +12 -0
  20. microEye/analysis/fitting/psf/stats/core.py +295 -0
  21. microEye/analysis/fitting/psf/stats/curve_fit.py +708 -0
  22. microEye/analysis/fitting/psf/stats/io.py +104 -0
  23. microEye/analysis/fitting/psf/stats/slope_fit.py +171 -0
  24. microEye/analysis/fitting/psf/temp.py +147 -0
  25. microEye/analysis/fitting/psf/test.py +47 -0
  26. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUfunctions.py +657 -0
  27. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUmleFit_LM.py +1336 -0
  28. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUsplineLib.py +270 -0
  29. microEye/analysis/fitting/pyfit3Dcspline/CPU/__init__.py +1 -0
  30. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUfunctions.py +609 -0
  31. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_EMCCD.py +1396 -0
  32. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_sCMOS.py +1426 -0
  33. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUsplineLib.py +231 -0
  34. microEye/analysis/fitting/pyfit3Dcspline/GPU/__init__.py +2 -0
  35. microEye/analysis/fitting/pyfit3Dcspline/__init__.py +10 -0
  36. microEye/analysis/fitting/pyfit3Dcspline/constants.py +27 -0
  37. microEye/analysis/fitting/pyfit3Dcspline/mainfunctions.py +903 -0
  38. microEye/analysis/fitting/results.py +917 -0
  39. microEye/analysis/fitting/results_stats.py +251 -0
  40. microEye/analysis/fitting/tardis.py +209 -0
  41. microEye/analysis/multi_viewer.py +568 -0
  42. microEye/analysis/processing/__init__.py +1 -0
  43. microEye/analysis/processing/frc.py +120 -0
  44. microEye/analysis/rendering/__init__.py +3 -0
  45. microEye/analysis/rendering/base.py +452 -0
  46. microEye/analysis/rendering/cloud.py +215 -0
  47. microEye/analysis/rendering/core.py +47 -0
  48. microEye/analysis/rendering/volumetric.py +198 -0
  49. microEye/analysis/tools/__init__.py +0 -0
  50. microEye/analysis/tools/kymograms.py +1079 -0
  51. microEye/analysis/tools/roi_selectors.py +556 -0
  52. microEye/analysis/utils/__init__.py +3 -0
  53. microEye/analysis/utils/coordinates.py +18 -0
  54. microEye/analysis/utils/images.py +68 -0
  55. microEye/analysis/utils/windows.py +19 -0
  56. microEye/analysis/viewer/__init__.py +3 -0
  57. microEye/analysis/viewer/image_options_widget.py +615 -0
  58. microEye/analysis/viewer/images.py +1225 -0
  59. microEye/analysis/viewer/layers_widget.py +415 -0
  60. microEye/analysis/viewer/localizations.py +1304 -0
  61. microEye/analysis/viewer/psf.py +1003 -0
  62. microEye/analysis/viewer/volume.py +456 -0
  63. microEye/hardware/__init__.py +3 -0
  64. microEye/hardware/cams/__init__.py +29 -0
  65. microEye/hardware/cams/camera_calibration.py +99 -0
  66. microEye/hardware/cams/camera_list.py +528 -0
  67. microEye/hardware/cams/camera_options.py +694 -0
  68. microEye/hardware/cams/camera_panel.py +941 -0
  69. microEye/hardware/cams/dummy/__init__.py +1 -0
  70. microEye/hardware/cams/dummy/dummy_panel.py +759 -0
  71. microEye/hardware/cams/jobs.py +497 -0
  72. microEye/hardware/cams/line_profiler.py +99 -0
  73. microEye/hardware/cams/linescan/IR_Cam.py +474 -0
  74. microEye/hardware/cams/linescan/__init__.py +1 -0
  75. microEye/hardware/cams/micam.py +524 -0
  76. microEye/hardware/cams/pco/__init__.py +58 -0
  77. microEye/hardware/cams/pco/enums.py +382 -0
  78. microEye/hardware/cams/pco/pco_cam.py +761 -0
  79. microEye/hardware/cams/pco/pco_panel.py +477 -0
  80. microEye/hardware/cams/shortcuts.py +312 -0
  81. microEye/hardware/cams/thorlabs/__init__.py +1 -0
  82. microEye/hardware/cams/thorlabs/thorlabs.py +1508 -0
  83. microEye/hardware/cams/thorlabs/thorlabs_panel.py +850 -0
  84. microEye/hardware/cams/ueye/__init__.py +1 -0
  85. microEye/hardware/cams/ueye/ueye_camera.py +1023 -0
  86. microEye/hardware/cams/ueye/ueye_panel.py +861 -0
  87. microEye/hardware/cams/vimba/__init__.py +1 -0
  88. microEye/hardware/cams/vimba/vimba_cam.py +1000 -0
  89. microEye/hardware/cams/vimba/vimba_panel.py +813 -0
  90. microEye/hardware/device.py +60 -0
  91. microEye/hardware/lasers/__init__.py +13 -0
  92. microEye/hardware/lasers/io_matchbox.py +791 -0
  93. microEye/hardware/lasers/io_params.py +85 -0
  94. microEye/hardware/lasers/io_single_laser.py +742 -0
  95. microEye/hardware/lasers/laser_relay.py +594 -0
  96. microEye/hardware/mieye/__init__.py +1 -0
  97. microEye/hardware/mieye/acquisition_manager.py +467 -0
  98. microEye/hardware/mieye/devices_manager.py +533 -0
  99. microEye/hardware/mieye/miEye.py +659 -0
  100. microEye/hardware/misc/__init__.py +0 -0
  101. microEye/hardware/misc/acquisition_view.py +71 -0
  102. microEye/hardware/misc/reglo.py +761 -0
  103. microEye/hardware/misc/temp.py +188 -0
  104. microEye/hardware/port_config.py +59 -0
  105. microEye/hardware/protocols/__init__.py +2 -0
  106. microEye/hardware/protocols/actions.py +402 -0
  107. microEye/hardware/protocols/actions_items.py +703 -0
  108. microEye/hardware/protocols/designer.py +244 -0
  109. microEye/hardware/protocols/scene_manager.py +191 -0
  110. microEye/hardware/protocols/serialization.py +97 -0
  111. microEye/hardware/pycromanager/__init__.py +16 -0
  112. microEye/hardware/pycromanager/core.py +1433 -0
  113. microEye/hardware/pycromanager/devices.py +461 -0
  114. microEye/hardware/pycromanager/enums.py +107 -0
  115. microEye/hardware/pycromanager/headless.py +153 -0
  116. microEye/hardware/pycromanager/utils.py +34 -0
  117. microEye/hardware/pycromanager/widgets/__init__.py +5 -0
  118. microEye/hardware/pycromanager/widgets/bridges.py +407 -0
  119. microEye/hardware/pycromanager/widgets/headless_manager.py +258 -0
  120. microEye/hardware/pycromanager/widgets/headless_options.py +224 -0
  121. microEye/hardware/pycromanager/widgets/pycro_panel.py +455 -0
  122. microEye/hardware/stages/__init__.py +18 -0
  123. microEye/hardware/stages/elliptec/__init__.py +5 -0
  124. microEye/hardware/stages/elliptec/baseDevice.py +314 -0
  125. microEye/hardware/stages/elliptec/device.py +384 -0
  126. microEye/hardware/stages/elliptec/deviceID.py +212 -0
  127. microEye/hardware/stages/elliptec/devicePort.py +379 -0
  128. microEye/hardware/stages/elliptec/deviceStatus.py +65 -0
  129. microEye/hardware/stages/elliptec/devicesView.py +706 -0
  130. microEye/hardware/stages/elliptec/ellDevices.py +134 -0
  131. microEye/hardware/stages/elliptec/messageUpdater.py +34 -0
  132. microEye/hardware/stages/elliptec/motorInfo.py +153 -0
  133. microEye/hardware/stages/elliptec/stage.py +62 -0
  134. microEye/hardware/stages/elliptec/test.py +139 -0
  135. microEye/hardware/stages/kinesis/__init__.py +1 -0
  136. microEye/hardware/stages/kinesis/kdc101/__init__.py +1 -0
  137. microEye/hardware/stages/kinesis/kdc101/enums.py +1002 -0
  138. microEye/hardware/stages/kinesis/kdc101/factory.py +171 -0
  139. microEye/hardware/stages/kinesis/kdc101/kdc101.py +718 -0
  140. microEye/hardware/stages/kinesis/kinesis.py +776 -0
  141. microEye/hardware/stages/piezo_concept.py +607 -0
  142. microEye/hardware/stages/stabilizer.py +785 -0
  143. microEye/hardware/stages/stage.py +89 -0
  144. microEye/hardware/widgets/__init__.py +10 -0
  145. microEye/hardware/widgets/controller.py +246 -0
  146. microEye/hardware/widgets/devices.py +133 -0
  147. microEye/hardware/widgets/focusWidget.py +264 -0
  148. microEye/hardware/widgets/qlist_slider.py +113 -0
  149. microEye/hardware/widgets/scan_acquisition.py +424 -0
  150. microEye/icons/1024.png +0 -0
  151. microEye/icons/128.png +0 -0
  152. microEye/icons/16.png +0 -0
  153. microEye/icons/24.png +0 -0
  154. microEye/icons/256.png +0 -0
  155. microEye/icons/32.png +0 -0
  156. microEye/icons/48.png +0 -0
  157. microEye/icons/512.png +0 -0
  158. microEye/icons/64.png +0 -0
  159. microEye/icons/__init__.py +0 -0
  160. microEye/icons/close.svg +88 -0
  161. microEye/icons/mieye.png +0 -0
  162. microEye/icons/min.svg +83 -0
  163. microEye/icons/viewer.png +0 -0
  164. microEye/launcher.py +42 -0
  165. microEye/qt.py +181 -0
  166. microEye/utils/__init__.py +2 -0
  167. microEye/utils/enum_encoder.py +10 -0
  168. microEye/utils/expandable_groupbox.py +93 -0
  169. microEye/utils/gui_helper.py +457 -0
  170. microEye/utils/hid/__init__.py +8 -0
  171. microEye/utils/hid/controller.py +153 -0
  172. microEye/utils/hid/device.py +63 -0
  173. microEye/utils/hid/enums.py +140 -0
  174. microEye/utils/hid/utils.py +58 -0
  175. microEye/utils/labelled_slider.py +134 -0
  176. microEye/utils/metadata.py +599 -0
  177. microEye/utils/metadata_tree.py +718 -0
  178. microEye/utils/micro_launcher.py +245 -0
  179. microEye/utils/parameter_tree.py +325 -0
  180. microEye/utils/pyscripting.py +444 -0
  181. microEye/utils/retry_exec.py +35 -0
  182. microEye/utils/start_gui.py +112 -0
  183. microEye/utils/thread_worker.py +115 -0
  184. microEye/utils/uImage.py +1512 -0
  185. microeye-2.3.2.dist-info/METADATA +401 -0
  186. microeye-2.3.2.dist-info/RECORD +190 -0
  187. microeye-2.3.2.dist-info/WHEEL +5 -0
  188. microeye-2.3.2.dist-info/entry_points.txt +2 -0
  189. microeye-2.3.2.dist-info/licenses/LICENSE +674 -0
  190. microeye-2.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,761 @@
1
+ import logging
2
+ import sys
3
+ from typing import Any, Optional, Union
4
+
5
+ import numpy as np
6
+ import pco
7
+ from pco.sdk import Sdk, shared_library_loader
8
+
9
+ from microEye.hardware.cams.micam import miCamera
10
+ from microEye.hardware.cams.pco.enums import *
11
+
12
+
13
+ class pco_cam(miCamera):
14
+ def __init__(self, Cam_ID=0, **kwargs) -> None:
15
+ super().__init__(Cam_ID)
16
+
17
+ self.bytes_per_pixel = 2
18
+
19
+ self.cam = pco.Camera(
20
+ interface=kwargs.get('interface'), serial=kwargs.get('serial')
21
+ )
22
+
23
+ self.initialize()
24
+
25
+ def initialize(self):
26
+ '''Initialize the camera'''
27
+ self.cam.default_configuration()
28
+ self.getExposure()
29
+ self.getDelay()
30
+
31
+ self.name = self.cam.camera_name.replace(' ', '_').replace('.', '_')
32
+ self.serial = self.cam.camera_serial
33
+ self.interface = self.cam.interface
34
+
35
+ self.print_status()
36
+
37
+ @property
38
+ def exposure_increment(self) -> float:
39
+ '''Get the exposure increment of the camera
40
+
41
+ Returns
42
+ -------
43
+ float
44
+ The exposure increment of the camera
45
+ '''
46
+ return self.getDescByKey(DescriptionKeys.MIN_EXPOSURE_STEP)
47
+
48
+ @property
49
+ def exposure_range(self) -> tuple[float, float]:
50
+ '''
51
+ Get the minimum and maximum exposure time of the camera
52
+
53
+ Returns
54
+ -------
55
+ tuple[float, float]
56
+ The minimum and maximum exposure time of the camera
57
+ '''
58
+ return (
59
+ self.getDescByKey(DescriptionKeys.MIN_EXPOSURE_TIME),
60
+ self.getDescByKey(DescriptionKeys.MAX_EXPOSURE_TIME),
61
+ )
62
+
63
+ @exposure_range.setter
64
+ def exposure_range(self, value: tuple[float, float]):
65
+ '''
66
+ Set the minimum and maximum exposure time of the camera
67
+
68
+ Parameters
69
+ ----------
70
+ value : tuple[float, float]
71
+ The minimum and maximum exposure time to set
72
+ '''
73
+ pass
74
+
75
+ @property
76
+ def pixel_rates(self) -> list[int]:
77
+ '''Get the pixel rates of the camera
78
+
79
+ Returns
80
+ -------
81
+ list[int]
82
+ The pixel rates of the camera
83
+ '''
84
+ return self.getDescByKey(DescriptionKeys.PIXELRATES)
85
+
86
+ @property
87
+ def delay_increment(self) -> float:
88
+ '''Get the delay increment of the camera
89
+
90
+ Returns
91
+ -------
92
+ float
93
+ The delay increment of the camera
94
+ '''
95
+ return self.getDescByKey(DescriptionKeys.MIN_DELAY_STEP)
96
+
97
+ @property
98
+ def delay_range(self) -> tuple[float, float]:
99
+ '''Get the minimum and maximum delay time of the camera
100
+
101
+ Returns
102
+ -------
103
+ tuple[float, float]
104
+ The minimum and maximum delay time of the camera
105
+ '''
106
+ return (
107
+ self.getDescByKey(DescriptionKeys.MIN_DELAY_TIME),
108
+ self.getDescByKey(DescriptionKeys.MAX_DELAY_TIME),
109
+ )
110
+
111
+ @property
112
+ def min_dim(self) -> tuple[int, int]:
113
+ '''Get the minimum dimensions of the camera
114
+
115
+ Returns
116
+ -------
117
+ tuple[int, int]
118
+ The minimum width and height of the camera
119
+ '''
120
+ return (
121
+ self.getDescByKey(DescriptionKeys.MIN_WIDTH),
122
+ self.getDescByKey(DescriptionKeys.MIN_HEIGHT),
123
+ )
124
+
125
+ @property
126
+ def max_dim(self) -> tuple[int, int]:
127
+ '''Get the maximum dimensions of the camera
128
+
129
+ Returns
130
+ -------
131
+ tuple[int, int]
132
+ The maximum width and height of the camera
133
+ '''
134
+ return (
135
+ self.getDescByKey(DescriptionKeys.MAX_WIDTH),
136
+ self.getDescByKey(DescriptionKeys.MAX_HEIGHT),
137
+ )
138
+
139
+ @property
140
+ def height(self):
141
+ '''Get the height of the camera ROI'''
142
+ return self.ROI[3]
143
+
144
+ @height.setter
145
+ def height(self, value):
146
+ '''Invalid set height, use `setROI` instead'''
147
+ print('Invalid set height, use setROI instead')
148
+ pass
149
+
150
+ @property
151
+ def width(self):
152
+ '''Get the width of the camera ROI'''
153
+ return self.ROI[2]
154
+
155
+ @width.setter
156
+ def width(self, value):
157
+ '''Invalid set width, use `setROI` instead'''
158
+ print('Invalid set width, use setROI instead')
159
+ pass
160
+
161
+ @property
162
+ def roi_steps(self) -> tuple[int, int]:
163
+ '''Get the steps for the ROI
164
+
165
+ Returns
166
+ -------
167
+ tuple[int, int]
168
+ The steps for the ROI in the horizontal and vertical direction
169
+ '''
170
+ return self.getDescByKey(DescriptionKeys.ROI_STEPS)
171
+
172
+ @property
173
+ def binning_steps(self) -> tuple[int, int]:
174
+ return (
175
+ self.getDescByKey(DescriptionKeys.BINNING_HORZ_VEC),
176
+ self.getDescByKey(DescriptionKeys.BINNING_VERT_VEC),
177
+ )
178
+
179
+ @property
180
+ def bit_res(self):
181
+ '''Get the bit resolution of the camera'''
182
+ return self.getDescByKey(DescriptionKeys.BIT_RESOLUTION)
183
+
184
+ @property
185
+ def ROI(self) -> tuple[int, int, int, int]:
186
+ '''
187
+ Get the current region of interest (ROI) of the camera
188
+
189
+ Returns
190
+ -------
191
+ tuple[int, int, int, int]
192
+ The current region of interest (x, y, width, height),
193
+ Note that x and y are 1-indexed.
194
+ '''
195
+ return self.getConfigByKey(ConfigKeys.ROI)
196
+
197
+ def close(self):
198
+ '''Close the camera'''
199
+ if self.cam is not None:
200
+ self.cam.close()
201
+
202
+ def populate_status(self):
203
+ self.status['Camera'] = {
204
+ 'Name': self.cam.camera_name,
205
+ 'Serial': self.cam.camera_serial,
206
+ 'Interface': self.cam.interface,
207
+ }
208
+
209
+ self.status['Exposure'] = {
210
+ 'Value': self.cam.exposure_time,
211
+ 'Delay': self.cam.delay_time,
212
+ 'Unit': 's',
213
+ }
214
+
215
+ self.status['Temperature'] = self.cam.sdk.get_temperature()
216
+
217
+ self.status['Description'] = self.cam.description
218
+
219
+ self.status['Configuration'] = self.cam.configuration
220
+
221
+ def get_temperature(self) -> float:
222
+ '''Reads out the sensor temperature value
223
+
224
+ Returns
225
+ -------
226
+ float
227
+ camera sensor temperature in C.
228
+ '''
229
+ self.temperature = -127
230
+ if self.cam is not None:
231
+ self.temperature = self.cam.sdk.get_temperature()['sensor temperature']
232
+ return self.temperature
233
+
234
+ def getExposure(self) -> float:
235
+ '''Get the current exposure time of the camera
236
+
237
+ Returns
238
+ -------
239
+ float
240
+ The current exposure time of the camera
241
+ '''
242
+ exp = -127
243
+ try:
244
+ if self.cam is not None:
245
+ self.exposure_current = self.cam.exposure_time
246
+ self.exposure_unit = 's'
247
+ return self.exposure_current
248
+ except Exception:
249
+ print('Exposure Get ERROR')
250
+ return exp
251
+
252
+ def setExposure(self, exp: float) -> float:
253
+ '''Set the exposure time of the camera
254
+
255
+ Parameters
256
+ ----------
257
+ exp : float
258
+ The exposure time to set in seconds
259
+
260
+ Returns
261
+ -------
262
+ float
263
+ The current exposure time of the camera
264
+ '''
265
+ try:
266
+ if self.cam is not None:
267
+ self.cam.exposure_time = exp
268
+ self.exposure_current = self.cam.exposure_time
269
+ return self.exposure_current
270
+ except Exception:
271
+ print('Exposure Set ERROR')
272
+ return -127
273
+
274
+ def getDelay(self) -> float:
275
+ '''Get the current delay time of the camera
276
+
277
+ Returns
278
+ -------
279
+ float
280
+ The current delay time of the camera
281
+ '''
282
+ delay = -127
283
+ try:
284
+ if self.cam is not None:
285
+ self.delay_current = self.cam.delay_time
286
+ return self.delay_current
287
+ except Exception:
288
+ print('Delay Get ERROR')
289
+ return delay
290
+
291
+ def setDelay(self, delay: float) -> float:
292
+ '''Set the delay time of the camera
293
+
294
+ Parameters
295
+ ----------
296
+ delay : float
297
+ The delay time to set in seconds
298
+
299
+ Returns
300
+ -------
301
+ float
302
+ The current delay time of the camera
303
+ '''
304
+ try:
305
+ if self.cam is not None:
306
+ self.cam.delay_time = delay
307
+ self.delay_current = self.cam.delay_time
308
+ return self.delay_current
309
+ except Exception:
310
+ print('Delay Set ERROR')
311
+ return -127
312
+
313
+ def isRecording(self):
314
+ '''Check if the camera is recording'''
315
+ return self.cam.is_recording
316
+
317
+ def isColor(self):
318
+ '''Check if the camera is color'''
319
+ return self.cam.is_color
320
+
321
+ @property
322
+ def recorded_image_count(self):
323
+ '''Get the number of recorded images'''
324
+ return self.cam.recorded_image_count
325
+
326
+ def getDescByKey(self, key: DescriptionKeys):
327
+ '''
328
+ Get the description of the camera by key
329
+
330
+ Parameters
331
+ ----------
332
+ key : DescriptionKeys
333
+ The key of the description to get
334
+
335
+ Returns
336
+ -------
337
+ Any
338
+ The description value of the camera
339
+ '''
340
+ return self.cam.description[key.value[0]]
341
+
342
+ def getConfigByKey(self, key: ConfigKeys):
343
+ '''
344
+ Get the configuration of the camera by key
345
+
346
+ Parameters
347
+ ----------
348
+ key : ConfigKeys
349
+ The key of the configuration to get
350
+
351
+ Returns
352
+ -------
353
+ Any
354
+ The configuration value of the camera
355
+ '''
356
+ return self.cam.configuration[key.value[0]]
357
+
358
+ def setConfigByKey(self, key: ConfigKeys, value):
359
+ if not isinstance(value, key.value[1]):
360
+ raise ValueError(
361
+ f'Value {value} is not of type {key.value[1]} for key {key.name}'
362
+ )
363
+ self.cam.configuration = {key.value[0]: value}
364
+
365
+ def getPixelRate(self) -> int:
366
+ '''Get the pixel rate of the camera'''
367
+ return self.getConfigByKey(ConfigKeys.PIXEL_RATE)
368
+
369
+ def setPixelRate(self, rate: int) -> None:
370
+ '''Set the pixel rate of the camera
371
+
372
+ Parameters
373
+ ----------
374
+ rate : int
375
+ The pixel rate to set
376
+
377
+ Raises
378
+ ------
379
+ ValueError
380
+ If the pixel rate is not supported by the camera
381
+ '''
382
+ if rate not in self.getDescByKey(DescriptionKeys.PIXELRATES):
383
+ raise ValueError(f'Pixelrate {rate} is not supported by the camera')
384
+ self.setConfigByKey(ConfigKeys.PIXEL_RATE, rate)
385
+
386
+ def getTrigger(self) -> str:
387
+ '''
388
+ Get the trigger mode of the camera
389
+
390
+ Returns
391
+ -------
392
+ str
393
+ The trigger mode of the camera
394
+ '''
395
+ return self.getConfigByKey(ConfigKeys.TRIGGER)
396
+
397
+ def setTrigger(self, trigger: str) -> None:
398
+ '''
399
+ Set the trigger mode of the camera
400
+ '''
401
+ self.setConfigByKey(ConfigKeys.TRIGGER, trigger)
402
+
403
+ def getAcquire(self) -> str:
404
+ '''
405
+ Get the acquire mode of the camera'''
406
+ return self.getConfigByKey(ConfigKeys.ACQUIRE)
407
+
408
+ def setAcquire(self, acquire: str) -> None:
409
+ '''
410
+ Set the acquire mode of the camera
411
+ '''
412
+ self.setConfigByKey(ConfigKeys.ACQUIRE, acquire)
413
+
414
+ def getMetadata(self) -> str:
415
+ '''
416
+ Get the metadata of the camera
417
+ '''
418
+ return self.getConfigByKey(ConfigKeys.METADATA)
419
+
420
+ def setMetadata(self, metadata: str) -> None:
421
+ '''
422
+ Set the metadata of the camera
423
+ '''
424
+ self.setConfigByKey(ConfigKeys.METADATA, metadata)
425
+
426
+ def getNoiseFilter(self) -> str:
427
+ '''
428
+ Get the noise filter of the camera
429
+ '''
430
+ return self.getConfigByKey(ConfigKeys.NOISE_FILTER)
431
+
432
+ def setNoiseFilter(self, noise_filter: str) -> None:
433
+ '''
434
+ Set the noise filter of the camera
435
+ '''
436
+ self.setConfigByKey(ConfigKeys.NOISE_FILTER, noise_filter)
437
+
438
+ def getBinning(self) -> tuple[int, int, str]:
439
+ '''
440
+ Get the binning of the camera
441
+
442
+ Returns
443
+ -------
444
+ tuple[int, int, str]
445
+ The binning of the camera, horizontal, vertical and mode
446
+ '''
447
+ return self.getConfigByKey(ConfigKeys.BINNING)
448
+
449
+ def setBinning(self, binning: tuple[int, int, str]) -> None:
450
+ '''
451
+ Set the binning of the camera
452
+
453
+ Parameters
454
+ ----------
455
+ binning : tuple[int, int, str]
456
+ The binning to set, horizontal, vertical and mode
457
+ '''
458
+ self.setConfigByKey(ConfigKeys.BINNING, binning)
459
+
460
+ def getAutoExposure(self) -> tuple[str, int, int]:
461
+ '''
462
+ Get the auto exposure of the camera
463
+
464
+ Returns
465
+ -------
466
+ tuple[str, int, int]
467
+ The auto exposure of the camera, mode, min and max exposure
468
+ '''
469
+ return self.getConfigByKey(ConfigKeys.AUTO_EXPOSURE)
470
+
471
+ def setAutoExposure(self, auto_exposure: tuple[str, int, int]) -> None:
472
+ '''
473
+ Set the auto exposure of the camera
474
+
475
+ Parameters
476
+ ----------
477
+ auto_exposure : tuple[str, int, int]
478
+ The auto exposure to set, mode, min and max exposure
479
+ '''
480
+ self.setConfigByKey(ConfigKeys.AUTO_EXPOSURE, auto_exposure)
481
+
482
+ def getTimestamp(self) -> str:
483
+ '''
484
+ Get the timestamp of the camera
485
+ '''
486
+ return self.getConfigByKey(ConfigKeys.TIMESTAMP)
487
+
488
+ def setTimestamp(self, timestamp: str) -> None:
489
+ '''
490
+ Set the timestamp of the camera
491
+
492
+ Parameters
493
+ ----------
494
+ timestamp : str
495
+ The timestamp to set
496
+ '''
497
+ self.setConfigByKey(ConfigKeys.TIMESTAMP, timestamp)
498
+
499
+ def setROI(self, roi: tuple[int, int, int, int]) -> None:
500
+ '''
501
+ Set the region of interest (ROI) of the camera
502
+
503
+ Parameters
504
+ ----------
505
+ roi : tuple[int, int, int, int]
506
+ The region of interest (x, y, width, height),
507
+ Note that x and y are 1-indexed.
508
+ '''
509
+ self.setConfigByKey(ConfigKeys.ROI, roi)
510
+
511
+ def resetROI(self) -> None:
512
+ '''Reset the region of interest (ROI) of the camera'''
513
+ self.setConfigByKey(ConfigKeys.ROI, (1, 1, self.max_dim[0], self.max_dim[1]))
514
+
515
+ def configureExposureTrigger(self, status: bool, rising_or_falling: bool):
516
+ '''Configure the exposure trigger of the camera
517
+
518
+ Parameters
519
+ ----------
520
+ status : bool
521
+ The status of the exposure trigger
522
+ rising_or_falling : bool
523
+ The rising or falling edge of the exposure trigger
524
+ '''
525
+ self.cam.configureHWIO_1_exposureTrigger(
526
+ status, 'rising edge' if rising_or_falling else 'falling edge'
527
+ )
528
+
529
+ def configureAcquireTrigger(self, status: bool, high_or_low: bool):
530
+ '''Configure the acquire trigger of the camera
531
+
532
+ Parameters
533
+ ----------
534
+ status : bool
535
+ The status of the acquire trigger
536
+ high_or_low : bool
537
+ The high or low level of the acquire trigger
538
+ '''
539
+ self.cam.configureHWIO_2_acquireEnable(
540
+ status, 'high level' if high_or_low else 'low level'
541
+ )
542
+
543
+ def configureStatusBusy(self, status: bool, high_or_low: bool, signal_type: str):
544
+ '''Configure the status busy of the camera
545
+
546
+ Parameters
547
+ ----------
548
+ status : bool
549
+ The status of the status busy
550
+ high_or_low : bool
551
+ The high or low level of the status busy
552
+ signal_type : str
553
+ The signal type of the status busy
554
+ '''
555
+ if signal_type not in ['status busy', 'status line', 'status armed']:
556
+ raise ValueError(f'Invalid signal type {signal_type}')
557
+ return self.cam.configureHWIO_3_statusBusy(status, high_or_low, signal_type)
558
+
559
+ def configureStatusExpos(
560
+ self,
561
+ status: bool,
562
+ high_or_low: bool,
563
+ signal_type: str,
564
+ signal_timing: Optional[str] = None,
565
+ ):
566
+ '''Configure the status expos of the camera
567
+
568
+ Parameters
569
+ ----------
570
+ status : bool
571
+ The status of the status expos
572
+ high_or_low : bool
573
+ The high or low level of the status expos
574
+ signal_type : str
575
+ The signal type of the status expos
576
+ signal_timing : str, optional
577
+ The signal timing of the status expos
578
+ '''
579
+ if signal_type not in ['status expos', 'status line', 'status armed']:
580
+ raise ValueError(f'Invalid signal type {signal_type}')
581
+ if signal_timing is not None and signal_timing not in [
582
+ 'first line',
583
+ 'global',
584
+ 'last line',
585
+ 'all lines',
586
+ ]:
587
+ raise ValueError(f'Invalid signal timing {signal_timing}')
588
+ return self.cam.configureHWIO_4_statusExpos(
589
+ status, high_or_low, signal_type, signal_timing
590
+ )
591
+
592
+ def configureAutoExposure(
593
+ self, region_type: ExposureRegionType, min_exp: int, max_exp: int
594
+ ):
595
+ '''Configure the auto exposure of the camera
596
+
597
+ Parameters
598
+ ----------
599
+ region_type : ExposureRegionType
600
+ The region type of the auto exposure
601
+ min_exp : int
602
+ The minimum exposure time of the auto exposure
603
+ max_exp : int
604
+ The maximum exposure time of the auto exposure
605
+ '''
606
+ return self.cam.configure_auto_exposure(region_type.value, min_exp, max_exp)
607
+
608
+ def setAutoExposure(self, on: bool):
609
+ '''Set the auto exposure of the camera
610
+
611
+ Parameters
612
+ ----------
613
+ on : bool
614
+ The status of the auto exposure
615
+ '''
616
+ if on:
617
+ self.cam.auto_exposure_on()
618
+ else:
619
+ self.cam.auto_exposure_off()
620
+
621
+ def stop(self):
622
+ '''Stop the camera'''
623
+ self.cam.stop()
624
+
625
+ def record(
626
+ self,
627
+ n_images: int = 1,
628
+ mode: RecorderModes = RecorderModes.SEQUENCE,
629
+ filename: Optional[str] = None,
630
+ ):
631
+ '''Record images with the camera
632
+
633
+ Parameters
634
+ ----------
635
+ n_images : int, optional
636
+ The number of images to record, by default 1
637
+ mode : RecorderModes, optional
638
+ The mode of the recorder, by default RecorderModes.SEQUENCE
639
+ filename : str, optional
640
+ The filename to save the images, by default None
641
+ '''
642
+ self.cam.record(n_images, mode.value[0], filename)
643
+
644
+ def wait_for_first_image(self, delay: bool = True, timeout: int = 60):
645
+ '''Wait for the first image from the camera
646
+
647
+ Parameters
648
+ ----------
649
+ delay : bool, optional
650
+ The delay for the first image, by default True
651
+ timeout : int, optional
652
+ The timeout for the first image, by default 60
653
+ '''
654
+ return self.cam.wait_for_first_image(delay, timeout)
655
+
656
+ def wait_for_new_image(self, delay: bool = True, timeout: int = 60):
657
+ '''Wait for a new image from the camera
658
+
659
+ Parameters
660
+ ----------
661
+ delay : bool, optional
662
+ The delay for the new image, by default True
663
+ timeout : int, optional
664
+ The timeout for the new image, by default 60
665
+ '''
666
+ return self.cam.wait_for_new_image(delay, timeout)
667
+
668
+ def get_convert_control(self, data_format: ImageFormats):
669
+ '''Get the convert control of the camera
670
+
671
+ Parameters
672
+ ----------
673
+ data_format : ImageFormats
674
+ The image format to get the convert control
675
+
676
+ Returns
677
+ -------
678
+ dict[str, Any]
679
+ The convert control of the camera
680
+ '''
681
+ return self.cam.get_convert_control(data_format.value)
682
+
683
+ def set_convert_control(
684
+ self, data_format: ImageFormats, convert_control: dict[str, Any]
685
+ ):
686
+ '''Set the convert control of the camera
687
+
688
+ Parameters
689
+ ----------
690
+ data_format : ImageFormats
691
+ The image format to set the convert control
692
+ convert_control : dict[str, Any]
693
+ The convert control to set
694
+ '''
695
+ return self.cam.set_convert_control(data_format.value, convert_control)
696
+
697
+ def load_lut(self, data_format: ImageFormats, filename: str):
698
+ '''Load the look-up table (LUT) of the camera
699
+
700
+ Parameters
701
+ ----------
702
+ data_format : ImageFormats
703
+ The image format to load the LUT
704
+ filename : str
705
+ The filename of the LUT
706
+ '''
707
+ return self.cam.load_lut(data_format.value, filename)
708
+
709
+ def get_image(
710
+ self,
711
+ idx: int,
712
+ roi: Optional[tuple[int, int, int, int]] = None,
713
+ data_format: ImageFormats = ImageFormats.MONO16,
714
+ Not_implemented_yet=None,
715
+ ) -> Union[np.ndarray, dict[str, Any]]:
716
+ '''Get the image from the camera
717
+
718
+ Parameters
719
+ ----------
720
+ idx : int
721
+ The index of the image
722
+ roi : tuple[int, int, int, int], optional
723
+ The region of interest (ROI) of the image, by default None
724
+ data_format : ImageFormats, optional
725
+ The image format to get the image, by default ImageFormats.MONO16
726
+ Not_implemented_yet : Any, optional
727
+ Not implemented yet, by default None
728
+
729
+ Returns
730
+ -------
731
+ Union[np.ndarray, dict[str, Any]]
732
+ The image from the camera, as a numpy array and metadata as a dictionary
733
+ '''
734
+ return self.cam.image(idx, roi, data_format.value, Not_implemented_yet)
735
+
736
+ def image_average(
737
+ self,
738
+ roi: Optional[tuple[int, int, int, int]] = None,
739
+ data_format: ImageFormats = ImageFormats.MONO16,
740
+ ):
741
+ '''Get the average image from the camera
742
+
743
+ Parameters
744
+ ----------
745
+ roi : tuple[int, int, int, int], optional
746
+ The region of interest (ROI) of the image, by default None
747
+ data_format : ImageFormats, optional
748
+ The image format to get the image, by default ImageFormats.MONO16
749
+
750
+ Returns
751
+ -------
752
+ np.ndarray
753
+ The average image from the camera
754
+ '''
755
+ return self.cam.image_average(roi, data_format.value)
756
+
757
+
758
+ if __name__ == '__main__':
759
+ cam = pco_cam()
760
+
761
+ print(cam.get_temperature())