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,477 @@
1
+ import logging
2
+ import traceback
3
+ from enum import Enum
4
+
5
+ from microEye.analysis.tools.roi_selectors import (
6
+ MultiRectangularROISelector,
7
+ convert_pos_size_to_rois,
8
+ convert_rois_to_pos_size,
9
+ )
10
+ from microEye.hardware.cams.camera_options import CamParams
11
+ from microEye.hardware.cams.camera_panel import Camera_Panel
12
+ from microEye.hardware.cams.pco.pco_cam import (
13
+ ConfigKeys,
14
+ DescriptionKeys,
15
+ RecorderModes,
16
+ pco_cam,
17
+ )
18
+ from microEye.qt import QDateTime, QtCore, QtWidgets, getOpenFileName, getSaveFileName
19
+ from microEye.utils.gui_helper import get_scaling_factor
20
+ from microEye.utils.metadata_tree import MetaParams
21
+ from microEye.utils.thread_worker import QThreadWorker
22
+ from microEye.utils.uImage import uImage
23
+
24
+
25
+ class pcoParams(Enum):
26
+ FREERUN = 'Acquisition.Freerun'
27
+ STOP = 'Acquisition.Stop'
28
+ # EXPOSURE_MODE = 'Acquisition Settings.Exposure Mode'
29
+ # EXPOSURE_AUTO = 'Acquisition Settings.Exposure Auto'
30
+ DELAY = 'Acquisition Settings.Delay'
31
+ # TRIGGER_MODE = 'Acquisition Settings.Trigger Mode'
32
+ # PIXEL_FORMAT = 'Acquisition Settings.Pixel Format'
33
+
34
+ def __str__(self):
35
+ '''
36
+ Return the last part of the enum value (Param name).
37
+ '''
38
+ return self.value.split('.')[-1]
39
+
40
+ def get_path(self):
41
+ '''
42
+ Return the full parameter path.
43
+ '''
44
+ return self.value.split('.')
45
+
46
+
47
+ class PCO_Panel(Camera_Panel):
48
+ '''
49
+ A Qt Widget for controlling an PCO Camera through pco.python
50
+ | Inherits Camera_Panel
51
+ '''
52
+
53
+ PARAMS = pcoParams
54
+
55
+ def __init__(self, cam: pco_cam, mini=False, *args, **kwargs):
56
+ '''
57
+ Initializes a new PCO_Panel Qt widget.
58
+
59
+ Inherits Camera_Panel.
60
+
61
+ Parameters
62
+ ----------
63
+ cam : pco_cam
64
+ PCO Camera python adapter.
65
+
66
+ mini : bool, optional
67
+ Flag indicating if this is a mini camera panel, by default False.
68
+
69
+ Other Parameters
70
+ ---------------
71
+ *args
72
+ Arguments to pass to the Camera_Panel constructor.
73
+
74
+ **kwargs
75
+ Keyword arguments to pass to the Camera_Panel constructor.
76
+ '''
77
+ super().__init__(cam, mini, *args, **kwargs)
78
+
79
+ self.OME_tab.set_param_value(MetaParams.CHANNEL_NAME, self._cam.name)
80
+ self.OME_tab.set_param_value(MetaParams.DET_MANUFACTURER, 'Excelitas PCO')
81
+ self.OME_tab.set_param_value(MetaParams.DET_MODEL, self._cam.name)
82
+ self.OME_tab.set_param_value(MetaParams.DET_SERIAL, self._cam.serial)
83
+ self.OME_tab.set_param_value(MetaParams.DET_TYPE, 'CMOS')
84
+
85
+ # exposure init
86
+ exposure = self.camera_options.get_param(CamParams.EXPOSURE)
87
+ exposure.setLimits((self._cam.exposure_range[0], self._cam.exposure_range[1]))
88
+ exposure.setOpts(
89
+ step=self._cam.exposure_increment, suffix=self._cam.exposure_unit
90
+ )
91
+ exposure.setValue(self._cam.exposure_current)
92
+ exposure.sigValueChanged.connect(self.exposure_spin_changed)
93
+
94
+ # exposure auto
95
+
96
+ delay = {
97
+ 'name': str(pcoParams.DELAY),
98
+ 'type': 'float',
99
+ 'value': self._cam.delay_current,
100
+ 'dec': False,
101
+ 'decimals': 6,
102
+ 'step': 0.1,
103
+ 'limits': [self._cam.delay_range[0], self._cam.delay_range[1]],
104
+ 'suffix': self._cam.exposure_unit,
105
+ 'enabled': True,
106
+ }
107
+ self.camera_options.add_param_child(CamParams.ACQ_SETTINGS, delay)
108
+ self.camera_options.get_param(pcoParams.DELAY).sigValueChanged.connect(
109
+ lambda: self.cam_cbox_changed(pcoParams.DELAY)
110
+ )
111
+
112
+ # trigger mode
113
+
114
+ # trigger source
115
+
116
+ # trigger selector
117
+
118
+ # trigger activation
119
+
120
+ # start freerun mode button
121
+ freerun = self.get_event_action(pcoParams.FREERUN)
122
+ self.camera_options.add_param_child(CamParams.ACQUISITION, freerun)
123
+ self.camera_options.get_param(pcoParams.FREERUN).sigActivated.connect(
124
+ self.start_free_run
125
+ )
126
+
127
+ # stop acquisition button
128
+ stop = {'name': str(pcoParams.STOP), 'type': 'action'}
129
+ self.camera_options.add_param_child(CamParams.ACQUISITION, stop)
130
+ self.camera_options.get_param(pcoParams.STOP).sigActivated.connect(self.stop)
131
+
132
+ # config buttons
133
+ # load = {'name': str(pcoParams.LOAD), 'type': 'action'}
134
+ # self.camera_options.add_param_child(CamParams.ACQ_SETTINGS, load)
135
+ # self.camera_options.get_param(pcoParams.LOAD).sigActivated.connect(
136
+ # self.load_config
137
+ # )
138
+
139
+ # save = {'name': str(pcoParams.SAVE), 'type': 'action'}
140
+ # self.camera_options.add_param_child(CamParams.ACQ_SETTINGS, save)
141
+ # self.camera_options.get_param(pcoParams.SAVE).sigActivated.connect(
142
+ # self.save_config
143
+ # )
144
+
145
+ # ROI
146
+ self.camera_options.set_roi_limits(
147
+ (1, self.cam.max_dim[0]),
148
+ (1, self.cam.max_dim[1]),
149
+ (self.cam.min_dim[0], self.cam.max_dim[0]),
150
+ (self.cam.min_dim[1], self.cam.max_dim[1]),
151
+ )
152
+
153
+ # GPIOs
154
+
155
+ # Timers
156
+
157
+ @property
158
+ def cam(self):
159
+ '''The pco_cam property.
160
+
161
+ Returns
162
+ -------
163
+ pco_cam
164
+ the cam property value
165
+ '''
166
+ return self._cam
167
+
168
+ @cam.setter
169
+ def cam(self, cam: pco_cam):
170
+ '''The pco_cam property.
171
+
172
+ Parameters
173
+ ----------
174
+ cam : pco_cam
175
+ the pco_cam to set as panel camera.
176
+ '''
177
+ self._cam = cam
178
+
179
+ def setExposure(self, value):
180
+ '''Sets the exposure time widget of camera
181
+
182
+ Parameters
183
+ ----------
184
+ value : float
185
+ selected exposure time
186
+ '''
187
+ super().setExposure(value / 1e3)
188
+
189
+ def set_ROI(self):
190
+ '''Sets the ROI for the slected pco_cam'''
191
+ if self.cam.acquisition:
192
+ QtWidgets.QMessageBox.warning(
193
+ self, 'Warning', 'Cannot set ROI while acquiring images!'
194
+ )
195
+ return # if acquisition is already going on
196
+
197
+ self.cam.setROI(self.camera_options.get_roi_info())
198
+
199
+ self.camera_options.set_roi_info(*self.cam._roi)
200
+
201
+ def reset_ROI(self):
202
+ '''Resets the ROI for the slected IDS_Camera'''
203
+ if self.cam.acquisition:
204
+ QtWidgets.QMessageBox.warning(
205
+ self, 'Warning', 'Cannot reset ROI while acquiring images!'
206
+ )
207
+ return # if acquisition is already going on
208
+
209
+ self.cam.resetROI()
210
+
211
+ self.camera_options.set_roi_info(*self.cam._roi)
212
+
213
+ def center_ROI(self):
214
+ '''Sets the ROI for the slected pco_cam'''
215
+ if self.cam.acquisition:
216
+ QtWidgets.QMessageBox.warning(
217
+ self, 'Warning', 'Cannot set ROI while acquiring images!'
218
+ )
219
+ return # if acquisition is already going on
220
+
221
+ width, height = self.camera_options.get_roi_info(True)[:2]
222
+
223
+ self.cam.setROI(
224
+ (
225
+ (self.cam.max_dim[0] - width) // 2 + 1,
226
+ (self.cam.max_dim[1] - height) // 2 + 1,
227
+ width,
228
+ height,
229
+ )
230
+ )
231
+
232
+ self.camera_options.set_roi_info(*self.cam._roi)
233
+
234
+ def select_ROI(self):
235
+ '''
236
+ Opens a dialog to select a ROI from the last image.
237
+ '''
238
+ if self.cam.acquisition:
239
+ QtWidgets.QMessageBox.warning(
240
+ self, 'Warning', 'Cannot set ROI while acquiring images!'
241
+ )
242
+ return # if acquisition is already going on
243
+
244
+ if self.acq_job is not None:
245
+ try:
246
+
247
+ def work_func(**kwargs):
248
+ try:
249
+ image = uImage(self.acq_job.frame.image)
250
+
251
+ image.equalizeLUT(nLUT=True)
252
+
253
+ scale_factor = get_scaling_factor(image.height, image.width)
254
+
255
+ selector = MultiRectangularROISelector.get_selector(
256
+ image._view, scale_factor, max_rois=1
257
+ )
258
+ # if old_rois:
259
+ # selector.rois = old_rois
260
+
261
+ rois = selector.select_rectangular_rois()
262
+
263
+ rois = convert_rois_to_pos_size(rois)
264
+
265
+ if len(rois) > 0:
266
+ return rois[0]
267
+ else:
268
+ return None
269
+ except Exception:
270
+ traceback.print_exc()
271
+ return None
272
+
273
+ def done(result: list):
274
+ if result is not None:
275
+ x, y, w, h = result
276
+ self.camera_options.set_roi_info(x + 1, y + 1, w, h)
277
+
278
+ self.worker = QThreadWorker(work_func)
279
+ self.worker.signals.result.connect(done)
280
+ # Execute
281
+ self._threadpool.start(self.worker)
282
+ except Exception:
283
+ traceback.print_exc()
284
+
285
+ def select_ROIs(self):
286
+ '''
287
+ Opens a dialog to select multiple ROIs from the last image.
288
+ '''
289
+ if self.cam.acquisition:
290
+ QtWidgets.QMessageBox.warning(
291
+ self, 'Warning', 'Cannot set ROI while acquiring images!'
292
+ )
293
+ return # if acquisition is already going on
294
+
295
+ if self.acq_job is not None:
296
+ try:
297
+
298
+ def work_func(**kwargs):
299
+ try:
300
+ image = uImage(self.acq_job.frame.image)
301
+
302
+ image.equalizeLUT(nLUT=True)
303
+
304
+ scale_factor = get_scaling_factor(image.height, image.width)
305
+
306
+ selector = MultiRectangularROISelector.get_selector(
307
+ image._view, scale_factor, max_rois=4, one_size=True
308
+ )
309
+
310
+ old_rois = self.camera_options.get_export_rois()
311
+
312
+ if len(old_rois) > 0:
313
+ old_rois = convert_pos_size_to_rois(old_rois)
314
+ selector.rois = old_rois
315
+
316
+ rois = selector.select_rectangular_rois()
317
+
318
+ rois = convert_rois_to_pos_size(rois)
319
+
320
+ if len(rois) > 0:
321
+ return rois
322
+ else:
323
+ return None
324
+ except Exception:
325
+ traceback.print_exc()
326
+ return None
327
+
328
+ def done(results: list[list]):
329
+ if results is not None:
330
+ rois_param = self.camera_options.get_param(
331
+ CamParams.EXPORTED_ROIS
332
+ )
333
+ rois_param.clearChildren()
334
+ for x, y, w, h in results:
335
+ self.camera_options.add_param_child(
336
+ CamParams.EXPORTED_ROIS,
337
+ {
338
+ 'name': 'ROI 1',
339
+ 'type': 'str',
340
+ 'readonly': True,
341
+ 'removable': True,
342
+ 'value': f'{x}, {y}, {w}, {h}',
343
+ },
344
+ )
345
+
346
+ self.worker = QThreadWorker(work_func)
347
+ self.worker.signals.result.connect(done)
348
+ # Execute
349
+ self._threadpool.start(self.worker)
350
+ except Exception:
351
+ traceback.print_exc()
352
+
353
+ def cam_cbox_changed(self, param: pcoParams):
354
+ '''
355
+ Slot for changed combobox values
356
+
357
+ Parameters
358
+ ----------
359
+ param : pcoParams
360
+ selected parameter enum
361
+ '''
362
+ value = self.camera_options.get_param_value(param)
363
+
364
+ if param == pcoParams.DELAY:
365
+ self._cam.setDelay(value)
366
+
367
+ def exposure_spin_changed(self, param, value: float):
368
+ '''
369
+ Slot for changed exposure
370
+
371
+ Parameters
372
+ ----------
373
+ Value : double
374
+ selected exposure in micro-seconds
375
+ '''
376
+ self._cam.setExposure(value)
377
+
378
+ self.refresh_exposure()
379
+ self.refresh_framerate()
380
+
381
+ self.OME_tab.set_param_value(
382
+ MetaParams.EXPOSURE, float(self._cam.exposure_current * 1000)
383
+ )
384
+ if self.master:
385
+ self.exposureChanged.emit()
386
+
387
+ def refresh_exposure(self):
388
+ self.camera_options.set_param_value(
389
+ CamParams.EXPOSURE, self._cam.exposure_current, self.exposure_spin_changed
390
+ )
391
+
392
+ def refresh_framerate(self, value=None):
393
+ pass
394
+
395
+ def cam_capture(self, *args, **kwargs):
396
+ '''Capture function executed by the capture worker.
397
+
398
+ Sends software trigger signals and transfers the
399
+ acquired frame to the display processing stack.
400
+
401
+ Parameters
402
+ ----------
403
+ cam : pco_cam
404
+ the pco_cam used to acquire frames.
405
+ '''
406
+ try:
407
+ # Continuous image capture
408
+ self._cam.record(
409
+ # self.acq_job.frames,
410
+ 100,
411
+ RecorderModes.RING_BUFFER,
412
+ )
413
+
414
+ while not self.acq_job.c_event.isSet():
415
+ if self.acq_job.frames_captured < self.acq_job.frames or self.mini:
416
+ self._cam.wait_for_new_image()
417
+ self._buffer.put(self.cam.get_image(0xFFFFFFFF)[0])
418
+ # add sensor temperature to the stack
419
+ self._temps.put(self.cam.get_temperature())
420
+ self.acq_job.frames_captured = self.acq_job.frames_captured + 1
421
+ if (
422
+ self.acq_job.frames_captured > self.acq_job.frames - 1
423
+ and not self.mini
424
+ ):
425
+ self.acq_job.c_event.set()
426
+ self.acq_job.stop_threads = True
427
+ logging.debug('Stop')
428
+ print('Capture Stopped!')
429
+
430
+ self.acq_job.c_event.wait()
431
+ except Exception:
432
+ traceback.print_exc()
433
+ finally:
434
+ # reset flags and release resources
435
+ self._cam.stop()
436
+ self._cam.cam.rec.cleanup()
437
+ self._cam.acquisition = False
438
+ QtCore.QThreadPool.globalInstance().releaseThread()
439
+ return QDateTime.currentDateTime()
440
+
441
+ def getCaptureArgs(self) -> list:
442
+ '''User specific arguments to be passed to the parallelized
443
+ Camera_Panel.cam_capture function.
444
+
445
+ Example
446
+ ------
447
+ check child panels (vimba, ueye or thorlabs)
448
+
449
+ Returns
450
+ -------
451
+ list
452
+ list of args to be passed in order to
453
+ Camera_Panel.cam_capture function.
454
+
455
+ Raises
456
+ ------
457
+ NotImplementedError
458
+ Has to be implemented by the use in child class.
459
+ '''
460
+ args = []
461
+ return args
462
+
463
+ if __name__ == '__main__':
464
+ import sys
465
+
466
+ from microEye.hardware.cams.pco.pco_cam import pco_cam
467
+ from microEye.hardware.cams.pco.pco_panel import PCO_Panel
468
+ from microEye.qt import QApplication
469
+
470
+ app = QApplication(sys.argv)
471
+
472
+ cam = pco_cam()
473
+
474
+ panel = PCO_Panel(cam)
475
+ panel.show()
476
+
477
+ sys.exit(app.exec())