etho-python 1.2.2__tar.gz → 1.2.3__tar.gz

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 (128) hide show
  1. {etho_python-1.2.2 → etho_python-1.2.3}/PKG-INFO +1 -1
  2. etho_python-1.2.3/docs/api/etho.services.camera.spinnaker_old.rst +5 -0
  3. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api_etho.rst +1 -1
  4. {etho_python-1.2.2 → etho_python-1.2.3}/pyproject.toml +1 -1
  5. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/DAQZeroService.py +5 -11
  6. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/spinnaker.py +20 -28
  7. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/spinnaker_old.py +1 -2
  8. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/daq/IOTask.py +16 -16
  9. etho_python-1.2.3/tests/test_daq_playlist.py +42 -0
  10. etho_python-1.2.2/docs/api/etho.utils.shuffled_cycle.rst +0 -5
  11. etho_python-1.2.2/src/etho/services/daq/ai.py +0 -174
  12. etho_python-1.2.2/src/etho/utils/shuffled_cycle.py +0 -45
  13. etho_python-1.2.2/tests/test_shuffled_cycle.py +0 -12
  14. {etho_python-1.2.2 → etho_python-1.2.3}/.github/workflows/draft-pdf.yml +0 -0
  15. {etho_python-1.2.2 → etho_python-1.2.3}/.github/workflows/python-package.yml +0 -0
  16. {etho_python-1.2.2 → etho_python-1.2.3}/.github/workflows/static.yml +0 -0
  17. {etho_python-1.2.2 → etho_python-1.2.3}/.gitignore +0 -0
  18. {etho_python-1.2.2 → etho_python-1.2.3}/CITATION.cff +0 -0
  19. {etho_python-1.2.2 → etho_python-1.2.3}/CONTRIBUTING.md +0 -0
  20. {etho_python-1.2.2 → etho_python-1.2.3}/LICENSE +0 -0
  21. {etho_python-1.2.2 → etho_python-1.2.3}/README.md +0 -0
  22. {etho_python-1.2.2 → etho_python-1.2.3}/docs/Makefile +0 -0
  23. {etho_python-1.2.2 → etho_python-1.2.3}/docs/README.md +0 -0
  24. {etho_python-1.2.2 → etho_python-1.2.3}/docs/_static/etho_dark.svg +0 -0
  25. {etho_python-1.2.2 → etho_python-1.2.3}/docs/_static/etho_light.svg +0 -0
  26. {etho_python-1.2.2 → etho_python-1.2.3}/docs/_templates/api_head.rst +0 -0
  27. {etho_python-1.2.2 → etho_python-1.2.3}/docs/_templates/autosummary/module.rst +0 -0
  28. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.app.rst +0 -0
  29. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.cli.rst +0 -0
  30. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.client.rst +0 -0
  31. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.BLTZeroService.rst +0 -0
  32. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.DAQZeroService.rst +0 -0
  33. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.GCMZeroService.rst +0 -0
  34. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.GOVZeroService.rst +0 -0
  35. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.NICounterZeroService.rst +0 -0
  36. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.TemplateZeroService.rst +0 -0
  37. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.ZeroService.rst +0 -0
  38. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.camera.base.rst +0 -0
  39. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.camera.basler.rst +0 -0
  40. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.camera.dummy.rst +0 -0
  41. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.camera.hamamatsu.rst +0 -0
  42. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.camera.spinnaker.rst +0 -0
  43. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.camera.ximea.rst +0 -0
  44. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.dlp.dlp_make_warpfiles.rst +0 -0
  45. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.utils.concurrent_task.rst +0 -0
  46. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.services.utils.log_exceptions.rst +0 -0
  47. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.utils.calibration.rst +0 -0
  48. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.utils.config.rst +0 -0
  49. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.utils.runner.rst +0 -0
  50. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.utils.sound.rst +0 -0
  51. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.utils.tui.rst +0 -0
  52. {etho_python-1.2.2 → etho_python-1.2.3}/docs/api/etho.utils.zeroclient.rst +0 -0
  53. {etho_python-1.2.2 → etho_python-1.2.3}/docs/callbacks.md +0 -0
  54. {etho_python-1.2.2 → etho_python-1.2.3}/docs/cli.md +0 -0
  55. {etho_python-1.2.2 → etho_python-1.2.3}/docs/conf.py +0 -0
  56. {etho_python-1.2.2 → etho_python-1.2.3}/docs/configuration/calibration_led.md +0 -0
  57. {etho_python-1.2.2 → etho_python-1.2.3}/docs/configuration/calibration_speaker.md +0 -0
  58. {etho_python-1.2.2 → etho_python-1.2.3}/docs/configuration/configuration.rst +0 -0
  59. {etho_python-1.2.2 → etho_python-1.2.3}/docs/configuration/global.md +0 -0
  60. {etho_python-1.2.2 → etho_python-1.2.3}/docs/configuration/playlist.md +0 -0
  61. {etho_python-1.2.2 → etho_python-1.2.3}/docs/configuration/protocol.md +0 -0
  62. {etho_python-1.2.2 → etho_python-1.2.3}/docs/extensions.md +0 -0
  63. {etho_python-1.2.2 → etho_python-1.2.3}/docs/hardware/camera.md +0 -0
  64. {etho_python-1.2.2 → etho_python-1.2.3}/docs/hardware/govee.md +0 -0
  65. {etho_python-1.2.2 → etho_python-1.2.3}/docs/hardware/hardware.rst +0 -0
  66. {etho_python-1.2.2 → etho_python-1.2.3}/docs/hardware/nidaq.md +0 -0
  67. {etho_python-1.2.2 → etho_python-1.2.3}/docs/hardware/projector.md +0 -0
  68. {etho_python-1.2.2 → etho_python-1.2.3}/docs/hardware/scanimage.md +0 -0
  69. {etho_python-1.2.2 → etho_python-1.2.3}/docs/index.rst +0 -0
  70. {etho_python-1.2.2 → etho_python-1.2.3}/docs/install.rst +0 -0
  71. {etho_python-1.2.2 → etho_python-1.2.3}/docs/logging.md +0 -0
  72. {etho_python-1.2.2 → etho_python-1.2.3}/docs/make.bat +0 -0
  73. {etho_python-1.2.2 → etho_python-1.2.3}/docs/make_api_doctree.py +0 -0
  74. {etho_python-1.2.2 → etho_python-1.2.3}/docs/tutorial.md +0 -0
  75. {etho_python-1.2.2 → etho_python-1.2.3}/paper/bib.bib +0 -0
  76. {etho_python-1.2.2 → etho_python-1.2.3}/paper/fig_flow.pdf +0 -0
  77. {etho_python-1.2.2 → etho_python-1.2.3}/paper/paper.md +0 -0
  78. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/__init__.py +0 -0
  79. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/app.py +0 -0
  80. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/assets/etho_icon1_pipeline_dark.svg +0 -0
  81. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/assets/etho_icon1_pipeline_light.svg +0 -0
  82. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/cli.py +0 -0
  83. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/client.py +0 -0
  84. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/res_app.py +0 -0
  85. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/resumable.py +0 -0
  86. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/BLTZeroService.py +0 -0
  87. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/DLPZeroService.py +0 -0
  88. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/GCMZeroService.py +0 -0
  89. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/GOVZeroService.py +0 -0
  90. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/NICounterZeroService.py +0 -0
  91. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/ScanImageTriggerZeroService.py +0 -0
  92. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/TemplateZeroService.py +0 -0
  93. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/ZeroService.py +0 -0
  94. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/__init__.py +0 -0
  95. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/callbacks/__init__.py +0 -0
  96. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/callbacks/_base.py +0 -0
  97. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/callbacks/_image.py +0 -0
  98. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/callbacks/_trace.py +0 -0
  99. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/__init__.py +0 -0
  100. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/base.py +0 -0
  101. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/basler.py +0 -0
  102. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/dummy.py +0 -0
  103. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/hamamatsu.py +0 -0
  104. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/camera/ximea.py +0 -0
  105. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/dlp/dlp_make_warpfiles.py +0 -0
  106. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/dlp/dlp_runners.py +0 -0
  107. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/resumable.py +0 -0
  108. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/utils/__init__.py +0 -0
  109. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/utils/concurrent_task.py +0 -0
  110. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/services/utils/log_exceptions.py +0 -0
  111. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/utils/__init__.py +0 -0
  112. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/utils/calibration.py +0 -0
  113. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/utils/config.py +0 -0
  114. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/utils/runner.py +0 -0
  115. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/utils/sound.py +0 -0
  116. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/utils/tui.py +0 -0
  117. {etho_python-1.2.2 → etho_python-1.2.3}/src/etho/utils/zeroclient.py +0 -0
  118. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_cli_gui_smoke.py +0 -0
  119. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_config.py +0 -0
  120. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_config.yaml +0 -0
  121. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_gov_service.py +0 -0
  122. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_import.py +0 -0
  123. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_resumable.py +0 -0
  124. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_service_client_wiring.py +0 -0
  125. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_services.py +0 -0
  126. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_sound.py +0 -0
  127. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_sound_playlist_mono.txt +0 -0
  128. {etho_python-1.2.2 → etho_python-1.2.3}/tests/test_sound_playlist_stereo.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: etho-python
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: etho
5
5
  Author-email: Jan Clemens <clemensjan@googlemail.com>
6
6
  Requires-Python: >=3.10
@@ -0,0 +1,5 @@
1
+ etho.services.camera.spinnaker_old
2
+ ==================================
3
+
4
+ .. automodule:: etho.services.camera.spinnaker_old
5
+ :members:
@@ -20,7 +20,6 @@ Developer API
20
20
  etho.utils.calibration
21
21
  etho.utils.config
22
22
  etho.utils.runner
23
- etho.utils.shuffled_cycle
24
23
  etho.utils.sound
25
24
  etho.utils.tui
26
25
  etho.utils.zeroclient
@@ -36,6 +35,7 @@ Developer API
36
35
  etho.services.camera.dummy
37
36
  etho.services.camera.hamamatsu
38
37
  etho.services.camera.spinnaker
38
+ etho.services.camera.spinnaker_old
39
39
  etho.services.camera.ximea
40
40
  etho.services.utils.concurrent_task
41
41
  etho.services.utils.log_exceptions
@@ -17,7 +17,7 @@ dependencies = [
17
17
  'pydaqmx', 'pyqtgraph', 'qtpy', 'PySide6-Essentials', 'zarr', 'zerorpc-numpy'
18
18
  ]
19
19
  readme= "README.md"
20
- version="1.2.2"
20
+ version="1.2.3"
21
21
 
22
22
  [project.scripts]
23
23
  etho = "etho.cli:main"
@@ -2,9 +2,7 @@ from .ZeroService import BaseZeroService
2
2
  import time
3
3
  import threading
4
4
  import sys
5
- import copy
6
- from itertools import cycle
7
- from typing import Iterable, Sequence, Optional, Dict, Any
5
+ from typing import Sequence, Optional, Dict, Any
8
6
  from . import register_service
9
7
  from .. import config as global_config
10
8
  from ..utils.config import undefaultify
@@ -67,8 +65,6 @@ class DAQ(BaseZeroService):
67
65
  if prot["maxduration"] == -1:
68
66
  logging.info(f"Setting maxduration from playlist to {totallen}.")
69
67
  prot["maxduration"] = totallen
70
- playlist_items = cycle(playlist_items)
71
-
72
68
  if prot[service_key]["digital_chans_out"] is not None:
73
69
  nb_digital_chans_out = len(prot[service_key]["digital_chans_out"])
74
70
  digital_data = [snd[:, -nb_digital_chans_out:].astype(np.uint8) for snd in sounds]
@@ -112,7 +108,7 @@ class DAQ(BaseZeroService):
112
108
  def setup(
113
109
  self,
114
110
  savefilename: str = None,
115
- play_order: Iterable = None,
111
+ play_order: Sequence = None,
116
112
  playlist_info=None,
117
113
  duration: float = -1,
118
114
  fs: int = 10000,
@@ -134,7 +130,7 @@ class DAQ(BaseZeroService):
134
130
 
135
131
  Args:
136
132
  savefilename (str, optional): [description]. Defaults to None.
137
- play_order (Iterable, optional): [description]. Defaults to None.
133
+ play_order (Sequence, optional): [description]. Defaults to None.
138
134
  playlist_info ([type], optional): [description]. Defaults to None.
139
135
  duration (float, optional): [description]. Defaults to -1.
140
136
  fs (int, optional): [description]. Defaults to 10000.
@@ -185,8 +181,7 @@ class DAQ(BaseZeroService):
185
181
  )
186
182
  if analog_data_out[0].shape[-1] is not len(self.analog_chans_out):
187
183
  raise ValueError(f"Number of analog output channels ({len(self.analog_chans_out)}) does not match the number of channels in the sound files ({analog_data_out[0].shape[-1]}).")
188
- play_order_new = copy.deepcopy(play_order)
189
- self.taskAO.data_gen = data_playlist(analog_data_out, play_order_new, playlist_info, self.log, name="AO")
184
+ self.taskAO.data_gen = data_playlist(analog_data_out, play_order, playlist_info, self.log, name="AO")
190
185
  if clock_source is None:
191
186
  self.taskAO.CfgDigEdgeStartTrig("ai/StartTrigger", DAQmx_Val_Rising)
192
187
  else:
@@ -200,8 +195,7 @@ class DAQ(BaseZeroService):
200
195
  clock_source=clock_source,
201
196
  logger=self.log,
202
197
  )
203
- play_order_new = copy.deepcopy(play_order)
204
- self.taskDO.data_gen = data_playlist(digital_data_out, play_order_new, name="DO")
198
+ self.taskDO.data_gen = data_playlist(digital_data_out, play_order, name="DO")
205
199
  if clock_source is None:
206
200
  self.taskDO.CfgDigEdgeStartTrig("ai/StartTrigger", DAQmx_Val_Rising)
207
201
  else:
@@ -2,19 +2,18 @@ import time
2
2
  import numpy as np
3
3
  from typing import Tuple, Union
4
4
  from .base import BaseCam
5
- import cv2
6
5
 
7
6
 
8
7
  try:
9
8
  import PySpin
9
+
10
10
  pyspin_error = None
11
11
  except ImportError as pyspin_error:
12
12
  pass
13
13
 
14
- class Spinnaker(BaseCam):
15
-
16
- NAME = 'SPN'
17
14
 
15
+ class Spinnaker(BaseCam):
16
+ NAME = "SPN"
18
17
 
19
18
  def __init__(self, serialnumber):
20
19
  if pyspin_error is not None:
@@ -22,7 +21,7 @@ class Spinnaker(BaseCam):
22
21
  self.serialnumber = serialnumber
23
22
 
24
23
  def init(self):
25
- self.cam_system = PySpin.System_GetInstance()
24
+ self.cam_system = PySpin.System.GetInstance()
26
25
  self.cam_list = self.cam_system.GetCameras()
27
26
  self.c = self.cam_list.GetBySerial(self.serialnumber)
28
27
  self.c.Init()
@@ -75,7 +74,7 @@ class Spinnaker(BaseCam):
75
74
  try:
76
75
  x0, y0, x, y = x0_y0_x_y
77
76
  except ValueError:
78
- raise ValueError('Need 4-tuple with x0_y0_x_y')
77
+ raise ValueError("Need 4-tuple with x0_y0_x_y")
79
78
  else:
80
79
  self._min_max_inc(self.c.Width, int(x))
81
80
  self._min_max_inc(self.c.Height, int(y))
@@ -114,7 +113,7 @@ class Spinnaker(BaseCam):
114
113
 
115
114
  @exposure.setter
116
115
  def exposure(self, value: Union[float, str]):
117
- if value == 'AUTO':
116
+ if value == "AUTO":
118
117
  self.c.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous)
119
118
  else:
120
119
  self.c.ExposureAuto.SetValue(PySpin.ExposureAuto_Off)
@@ -127,18 +126,18 @@ class Spinnaker(BaseCam):
127
126
 
128
127
  @gain.setter
129
128
  def gain(self, value: Union[float, str]):
130
- if value == 'AUTO':
129
+ if value == "AUTO":
131
130
  self.c.GainAuto.SetValue(PySpin.GainAuto_Continuous)
132
131
  else:
133
132
  self.c.GainAuto.SetValue(PySpin.GainAuto_Off)
134
133
  self.c.Gain.SetValue(float(value))
135
134
 
136
135
  def optimize_auto_exposure(self):
137
- self.setattr('AutoExposureControlLoopDamping', 0.1)
138
- self.setattr('AutoExposureLightingMode_Val', 2) # Frontlight
139
- self.setattr('AutoExposureExposureTimeLowerLimit', 6)
140
- self.setattr('AutoExposureExposureTimeUpperLimit', 30000)
141
- self.setattr('AutoExposureEVCompensation', 3)
136
+ self.setattr("AutoExposureControlLoopDamping", 0.1)
137
+ self.setattr("AutoExposureLightingMode_Val", 2) # Frontlight
138
+ self.setattr("AutoExposureExposureTimeLowerLimit", 6)
139
+ self.setattr("AutoExposureExposureTimeUpperLimit", 30000)
140
+ self.setattr("AutoExposureEVCompensation", 3)
142
141
 
143
142
  @property
144
143
  def external_trigger(self):
@@ -155,12 +154,7 @@ class Spinnaker(BaseCam):
155
154
 
156
155
  def _generate_attrs(self):
157
156
 
158
- self._rw_modes = {
159
- PySpin.RO: "read only",
160
- PySpin.RW: "read/write",
161
- PySpin.WO: "write only",
162
- PySpin.NA: "not available"
163
- }
157
+ self._rw_modes = {PySpin.RO: "read only", PySpin.RW: "read/write", PySpin.WO: "write only", PySpin.NA: "not available"}
164
158
 
165
159
  self._attr_types = {
166
160
  PySpin.intfIFloat: PySpin.CFloatPtr,
@@ -171,12 +165,12 @@ class Spinnaker(BaseCam):
171
165
  }
172
166
 
173
167
  self._attr_type_names = {
174
- PySpin.intfIFloat: 'float',
175
- PySpin.intfIBoolean: 'bool',
176
- PySpin.intfIInteger: 'int',
177
- PySpin.intfIEnumeration: 'enum',
178
- PySpin.intfIString: 'string',
179
- PySpin.intfICommand: 'command',
168
+ PySpin.intfIFloat: "float",
169
+ PySpin.intfIBoolean: "bool",
170
+ PySpin.intfIInteger: "int",
171
+ PySpin.intfIEnumeration: "enum",
172
+ PySpin.intfIString: "string",
173
+ PySpin.intfICommand: "command",
180
174
  }
181
175
 
182
176
  self.camera_attributes = {}
@@ -195,7 +189,6 @@ class Spinnaker(BaseCam):
195
189
 
196
190
  def getattr(self, attr):
197
191
  if attr in self.camera_attributes:
198
-
199
192
  prop = self.camera_attributes[attr]
200
193
  if not PySpin.IsReadable(prop):
201
194
  raise AttributeError("Camera property '%s' is not readable" % attr)
@@ -213,12 +206,11 @@ class Spinnaker(BaseCam):
213
206
 
214
207
  def setattr(self, attr, val):
215
208
  if attr in self.camera_attributes:
216
-
217
209
  prop = self.camera_attributes[attr]
218
210
  if not PySpin.IsWritable(prop):
219
211
  raise AttributeError("Property '%s' is not currently writable!" % attr)
220
212
 
221
- if hasattr(prop, 'SetValue'):
213
+ if hasattr(prop, "SetValue"):
222
214
  prop.SetValue(val)
223
215
  else:
224
216
  prop.FromString(val)
@@ -2,7 +2,6 @@ import time
2
2
  import numpy as np
3
3
  from typing import Tuple, Union
4
4
  from .base import BaseCam
5
- import cv2
6
5
 
7
6
 
8
7
  try:
@@ -24,7 +23,7 @@ class Spinnaker_OLD(BaseCam):
24
23
  self.serialnumber = serialnumber
25
24
 
26
25
  def init(self):
27
- self.cam_system = PySpin.System_GetInstance()
26
+ self.cam_system = PySpin.System.GetInstance()
28
27
  self.cam_list = self.cam_system.GetCameras()
29
28
  self.c = self.cam_list.GetBySerial(self.serialnumber)
30
29
  self.c.Init()
@@ -292,22 +292,22 @@ def coroutine(func):
292
292
 
293
293
 
294
294
  @coroutine
295
- def data_playlist(sounds, play_order, playlist_info=None, logger=None, name="standard"):
296
- """sounds - list of nparrays"""
297
- first_run = True
298
- run_cnt = 0
299
- playlist_cnt = 0
300
-
301
- try:
302
- while play_order:
303
- run_cnt += 1
304
- # duplicate first stim - otherwise we miss the first in the playlist
305
- if first_run:
306
- pp = 0
307
- first_run = False
308
- else:
309
- pp = next(play_order)
310
- playlist_cnt += 1
295
+ def data_playlist(sounds, play_order, playlist_info=None, logger=None, name="standard"):
296
+ """sounds - list of nparrays"""
297
+ first_run = True
298
+ playlist_index = 0
299
+ playlist_cnt = 0
300
+
301
+ try:
302
+ while play_order:
303
+ # duplicate first stim - otherwise we miss the first in the playlist
304
+ if first_run:
305
+ pp = 0
306
+ first_run = False
307
+ else:
308
+ pp = play_order[playlist_index % len(play_order)]
309
+ playlist_index += 1
310
+ playlist_cnt += 1
311
311
  if playlist_info is not None:
312
312
  msg = _format_playlist(playlist_info.loc[pp], playlist_cnt)
313
313
  if logger:
@@ -0,0 +1,42 @@
1
+ import pickle
2
+
3
+ import numpy as np
4
+
5
+ from etho.services.DAQZeroService import DAQ
6
+
7
+
8
+ class FakeService:
9
+ def setup(self, *args, **kwargs):
10
+ self.play_order = args[1]
11
+
12
+ def init_local_logger(self, *_):
13
+ pass
14
+
15
+
16
+ def test_setup_client_passes_pickleable_playlist(monkeypatch):
17
+ service = FakeService()
18
+ monkeypatch.setattr(DAQ, "make", lambda *args, **kwargs: service)
19
+ monkeypatch.setattr("etho.services.DAQZeroService.parse_table", lambda _: None)
20
+ monkeypatch.setattr("etho.services.DAQZeroService.load_sounds", lambda *args, **kwargs: [np.zeros((1, 1)), np.zeros((1, 1))])
21
+ monkeypatch.setattr("etho.services.DAQZeroService.build_playlist", lambda *args, **kwargs: ([1, 0], 2))
22
+
23
+ daq = {
24
+ "samplingrate": 1,
25
+ "shuffle": False,
26
+ "device": None,
27
+ "port": None,
28
+ "clock_source": None,
29
+ "nb_inputsamples_per_cycle": 1,
30
+ "analog_chans_in": [],
31
+ "analog_chans_out": None,
32
+ "digital_chans_out": None,
33
+ "analog_chans_in_info": None,
34
+ "analog_chans_out_info": None,
35
+ "digital_chans_out_info": None,
36
+ }
37
+ defaults = {"host": "localhost", "serializer": "default", "python_exe": "python", "savefolder": "/tmp"}
38
+
39
+ DAQ.setup_client("DAQ", 0, {"DAQ": daq, "maxduration": 1}, defaults, "playlist.txt", "run", False, False)
40
+
41
+ assert service.play_order == [1, 0]
42
+ pickle.dumps(service.play_order)
@@ -1,5 +0,0 @@
1
- etho.utils.shuffled_cycle
2
- =========================
3
-
4
- .. automodule:: etho.utils.shuffled_cycle
5
- :members:
@@ -1,174 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import threading
3
- import time
4
- import numpy as np
5
- import logging
6
- from ..utils.log_exceptions import for_all_methods, log_exceptions
7
- from typing import Optional, List
8
-
9
- try:
10
- import PyDAQmx as daq
11
- from PyDAQmx.DAQmxCallBack import *
12
- from PyDAQmx.DAQmxConstants import *
13
- from PyDAQmx.DAQmxFunctions import *
14
-
15
- pydaqmx_import_error = None
16
- except (ImportError, NotImplementedError) as pydaqmx_import_error:
17
- pass
18
-
19
-
20
- logger = logging.getLogger(__name__)
21
-
22
-
23
- @for_all_methods(log_exceptions(logger))
24
- class AI(daq.Task):
25
- def __init__(
26
- self,
27
- dev_name="Dev1",
28
- cha_name=["ai0"],
29
- limits=None,
30
- rate=10000.0,
31
- nb_inputsamples_per_cycle=None,
32
- clock_source=None,
33
- terminals: Optional[List[str]] = None,
34
- logger=None,
35
- ):
36
- """[summary]
37
-
38
- Args:
39
- dev_name (str, optional): [description]. Defaults to "Dev1".
40
- cha_name (list, optional): [description]. Defaults to ["ai0"].
41
- limits (float, optional): [description]. Defaults to 10.0.
42
- rate (float, optional): [description]. Defaults to 10000.0.
43
- nb_inputsamples_per_cycle ([type], optional): [description]. Defaults to None.
44
- clock_source (str, optional): None for AI-synced clock.
45
- Use 'OnboardClock' for boards that don't support this (USB-DAQ).
46
- Defaults to None.
47
- terminals (List[str], optional):
48
-
49
- Raises:
50
- TypeError: [description]
51
- ValueError: [description]
52
- """
53
- if pydaqmx_import_error is not None:
54
- raise pydaqmx_import_error
55
-
56
- self.log = logger
57
-
58
- # check inputs
59
- super().__init__()
60
- if not isinstance(cha_name, (list, tuple)):
61
- raise TypeError(f"`cha_name` is {type(cha_name)}. Should be `list` or `tuple`")
62
-
63
- self.samples_read = daq.int32()
64
-
65
- self.cha_names = [dev_name + "/" + ch for ch in cha_name] # append device name
66
- self.cha_string = ", ".join(self.cha_names)
67
- self.num_channels = len(cha_name) # need to fix this if we want to use blocks "ai0:8"
68
- if nb_inputsamples_per_cycle is None:
69
- nb_inputsamples_per_cycle = int(rate)
70
-
71
- # terminals
72
- terminal_types = {
73
- "RSE": daq.DAQmx_Val_RSE,
74
- "NRSE": daq.DAQmx_Val_NRSE,
75
- "Diff": daq.DAQmx_Val_Diff,
76
- None: daq.DAQmx_Val_RSE, # default
77
- }
78
- if terminals is None: # default
79
- terminals = ["RSE" for _ in self.cha_names]
80
- elif len(terminals) != len(self.cha_names):
81
- raise ValueError("need term for each channel")
82
- self.cha_terminals = [terminal_types[terminal] for terminal in terminals]
83
-
84
- # limits
85
- if limits is None: # default
86
- self.cha_limits = [[-10.0, 10.0] for _ in self.cha_names]
87
- elif isinstance(limits, (float, int)): # single number
88
- self.cha_limits = [[-limits, limits] for _ in self.cha_names]
89
- else:
90
- self.cha_limits = limits
91
-
92
- if len(self.cha_limits) != len(self.cha_names) or not all([len(limit) == 2 for limit in self.cha_limits]):
93
- raise ValueError("need term for each channel")
94
-
95
- # FIX: input and output tasks can have different sizes
96
- self.callback = None
97
- self.data_rec = None # called at end of callback
98
-
99
- # add all channels
100
- for name, terminal, limit in zip(self.cha_names, self.cha_terminals, self.cha_limits):
101
- self.CreateAIVoltageChan(
102
- name,
103
- "",
104
- terminal,
105
- limit[0],
106
- limit[1],
107
- daq.DAQmx_Val_Volts,
108
- None,
109
- )
110
- self.num_samples_per_chan = nb_inputsamples_per_cycle
111
- self.num_samples_per_event = nb_inputsamples_per_cycle # self.num_samples_per_chan*self.num_channels
112
- self.AutoRegisterEveryNSamplesEvent(daq.DAQmx_Val_Acquired_Into_Buffer, self.num_samples_per_event, 0)
113
- self.CfgInputBuffer(self.num_samples_per_chan * self.num_channels * 4)
114
-
115
- self._data = np.zeros((self.num_samples_per_chan, self.num_channels), dtype=np.float64) # init empty data array
116
-
117
- clock_source = "OnboardClock" # use internal clock
118
-
119
- self.CfgSampClkTiming(
120
- clock_source,
121
- rate,
122
- daq.DAQmx_Val_Rising,
123
- daq.DAQmx_Val_ContSamps,
124
- self.num_samples_per_chan,
125
- )
126
-
127
- self.AutoRegisterDoneEvent(0)
128
- self._data_lock = threading.Lock()
129
- self._newdata_event = threading.Event()
130
-
131
- def __repr__(self):
132
- return "{0}: {1}".format(self.cha_type[0], self.cha_string)
133
-
134
- def stop(self):
135
- """Stop DAQ."""
136
- if self.data_rec is not None:
137
- for data_rec in self.data_rec:
138
- data_rec.send(None)
139
- data_rec.finish(verbose=True, sleepcycletimeout=2)
140
- data_rec.close()
141
-
142
- def EveryNCallback(self):
143
- """Call whenever there is data to be read from the buffer.
144
-
145
- Calls `self.data_rec` for processing data.
146
- """
147
- # for clean teardown, catch PyDAQmx.DAQmxFunctions.GenStoppedToPreventRegenOfOldSamplesError
148
- with self._data_lock:
149
- systemtime = time.time()
150
- self.ReadAnalogF64(
151
- daq.DAQmx_Val_Auto,
152
- 1.0,
153
- daq.DAQmx_Val_GroupByScanNumber,
154
- self._data,
155
- self.num_samples_per_chan * self.num_channels,
156
- daq.byref(self.samples_read),
157
- None,
158
- )
159
- # only keep samples that were actually read, .value converts c_long to int
160
- self._data = self._data[: self.samples_read.value, :]
161
-
162
- if self.data_rec is not None:
163
- for data_rec in self.data_rec:
164
- if self._data is not None:
165
- self.log.warning(f"{data_rec} {systemtime}")
166
- data_rec.send((self._data, systemtime))
167
- self._newdata_event.set()
168
-
169
- return 0 # The function should return an integer
170
-
171
- def DoneCallback(self, status):
172
- """Call when Task is stopped/done."""
173
- self.log.warning("Done status", status)
174
- return 0 # The function should return an integer
@@ -1,45 +0,0 @@
1
- from typing import Iterable
2
- from itertools import cycle
3
- import random
4
-
5
-
6
- class shuffled_cycle(cycle):
7
- """Shuffled cycle.
8
-
9
- cycle('ABCD') --> ABCD ABCD ABCD ...
10
- cycle('ABCD', shuffle='block') --> ACBD BDCA CDAB ...
11
- cycle('ABCD', shuffle='full') --> ACCBBDBDCABA ...
12
- """
13
-
14
- def __init__(self, it: Iterable, shuffle: str = "block"):
15
- """.
16
-
17
- Arguments:
18
- it: Iterable
19
- shuffle: None, 'block', 'full'
20
- """
21
- allowed_shuffles = ["block", "full"]
22
- if shuffle not in allowed_shuffles:
23
- raise ValueError(f"shuffle should be one of {allowed_shuffles}.")
24
- super(shuffled_cycle, self).__init__()
25
- self._shuffle = shuffle
26
- self._it = list(it)
27
- self._pos = -1
28
-
29
- def __next__(self):
30
- """Return next item in iterator."""
31
- self._pos = (self._pos + 1) % len(self._it) # wrap index
32
- if self._shuffle == "block":
33
- if self._pos == 0:
34
- random.shuffle(self._it) # in-place shuffle the iterator
35
- idx = self._pos
36
- elif self._shuffle == "full":
37
- idx = random.randint(0, len(self._it) - 1) # since randint bounds are inclusive
38
- # else:
39
- # idx = self._pos
40
- return self._it[idx]
41
-
42
- def __deepcopy__(self, memo=None):
43
- cp = shuffled_cycle(self._it, shuffle=self._shuffle)
44
- cp._pos = self._pos
45
- return cp
@@ -1,12 +0,0 @@
1
- from etho.utils.shuffled_cycle import shuffled_cycle
2
-
3
-
4
- def test_shuffled_cycle():
5
- sc = shuffled_cycle(range(4))
6
- print([next(sc) for _ in range(10)])
7
-
8
- sc = shuffled_cycle(range(4), shuffle='block')
9
- print([next(sc) for _ in range(10)])
10
-
11
- sc = shuffled_cycle(range(4), shuffle='full')
12
- print([next(sc) for _ in range(10)])
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes