biosignal-device-interface 0.1.12b0__py3-none-any.whl → 0.1.32a1__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.
- biosignal_device_interface/constants/devices/core/base_device_constants.py +10 -0
- biosignal_device_interface/constants/devices/otb/otb_quattrocento_constants.py +313 -0
- biosignal_device_interface/constants/devices/otb/otb_syncstation_constants.py +233 -0
- biosignal_device_interface/devices/__init__.py +2 -0
- biosignal_device_interface/devices/core/base_device.py +8 -9
- biosignal_device_interface/devices/otb/__init__.py +8 -0
- biosignal_device_interface/devices/otb/otb_muovi.py +4 -5
- biosignal_device_interface/devices/otb/otb_quattrocento.py +332 -0
- biosignal_device_interface/devices/otb/otb_quattrocento_light.py +14 -15
- biosignal_device_interface/devices/otb/otb_syncstation.py +407 -0
- biosignal_device_interface/gui/device_template_widgets/all_devices_widget.py +8 -0
- biosignal_device_interface/gui/device_template_widgets/core/base_device_widget.py +17 -8
- biosignal_device_interface/gui/device_template_widgets/core/base_multiple_devices_widget.py +7 -4
- biosignal_device_interface/gui/device_template_widgets/otb/otb_devices_widget.py +8 -0
- biosignal_device_interface/gui/device_template_widgets/otb/otb_muovi_plus_widget.py +9 -9
- biosignal_device_interface/gui/device_template_widgets/otb/otb_muovi_widget.py +9 -9
- biosignal_device_interface/gui/device_template_widgets/otb/otb_quattrocento_light_widget.py +59 -55
- biosignal_device_interface/gui/device_template_widgets/otb/otb_quattrocento_widget.py +260 -0
- biosignal_device_interface/gui/device_template_widgets/otb/otb_syncstation_widget.py +262 -0
- biosignal_device_interface/gui/plot_widgets/biosignal_plot_widget.py +9 -4
- biosignal_device_interface/gui/ui/otb_quattrocento_template_widget.ui +415 -0
- biosignal_device_interface/gui/ui/otb_syncstation_template_widget.ui +732 -0
- biosignal_device_interface/gui/ui_compiled/otb_quattrocento_template_widget.py +318 -0
- biosignal_device_interface/gui/ui_compiled/otb_syncstation_template_widget.py +495 -0
- biosignal_device_interface-0.1.32a1.dist-info/LICENSE +675 -0
- {biosignal_device_interface-0.1.12b0.dist-info → biosignal_device_interface-0.1.32a1.dist-info}/METADATA +7 -17
- {biosignal_device_interface-0.1.12b0.dist-info → biosignal_device_interface-0.1.32a1.dist-info}/RECORD +28 -18
- biosignal_device_interface-0.1.12b0.dist-info/LICENSE +0 -395
- {biosignal_device_interface-0.1.12b0.dist-info → biosignal_device_interface-0.1.32a1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Device class for real-time interfacing the OTB Syncstation device.
|
|
3
|
+
Developer: Dominik I. Braun
|
|
4
|
+
Contact: dome.braun@fau.de
|
|
5
|
+
Last Update: 2025-01-09
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
from functools import partial
|
|
10
|
+
from typing import TYPE_CHECKING, Dict
|
|
11
|
+
|
|
12
|
+
from biosignal_device_interface.gui.device_template_widgets.core.base_device_widget import (
|
|
13
|
+
BaseDeviceWidget,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# Local Libraries
|
|
17
|
+
from biosignal_device_interface.gui.ui_compiled.otb_syncstation_template_widget import (
|
|
18
|
+
Ui_SyncStationForm,
|
|
19
|
+
)
|
|
20
|
+
from biosignal_device_interface.devices.otb.otb_syncstation import OTBSyncStation
|
|
21
|
+
|
|
22
|
+
# Constants
|
|
23
|
+
from biosignal_device_interface.constants.devices.otb.otb_syncstation_constants import (
|
|
24
|
+
SyncStationDetectionMode,
|
|
25
|
+
SyncStationProbeConfigMode,
|
|
26
|
+
SyncStationRecOnMode,
|
|
27
|
+
SyncStationWorkingMode,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from PySide6.QtWidgets import (
|
|
32
|
+
QMainWindow,
|
|
33
|
+
QWidget,
|
|
34
|
+
QGroupBox,
|
|
35
|
+
QPushButton,
|
|
36
|
+
QCheckBox,
|
|
37
|
+
QComboBox,
|
|
38
|
+
QLabel,
|
|
39
|
+
QTabWidget,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class OTBSyncStationWidget(BaseDeviceWidget):
|
|
44
|
+
def __init__(self, parent: QWidget | QMainWindow | None = None):
|
|
45
|
+
super().__init__(parent)
|
|
46
|
+
self._set_device(OTBSyncStation(self))
|
|
47
|
+
|
|
48
|
+
def _toggle_connection(self):
|
|
49
|
+
if not self._device.is_connected:
|
|
50
|
+
self._command_connect_push_button.setEnabled(False)
|
|
51
|
+
|
|
52
|
+
self._device.toggle_connection(
|
|
53
|
+
(self._connection_ip_label.text(), int(self._connection_port_label.text())),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def _connection_toggled(self, is_connected: bool) -> None:
|
|
57
|
+
self._command_connect_push_button.setEnabled(True)
|
|
58
|
+
if is_connected:
|
|
59
|
+
self._command_connect_push_button.setText("Disconnect")
|
|
60
|
+
self._command_connect_push_button.setChecked(True)
|
|
61
|
+
self._command_configure_push_button.setEnabled(True)
|
|
62
|
+
self._connection_group_box.setEnabled(False)
|
|
63
|
+
else:
|
|
64
|
+
self._command_connect_push_button.setText("Connect")
|
|
65
|
+
self._command_connect_push_button.setChecked(False)
|
|
66
|
+
self._command_configure_push_button.setEnabled(False)
|
|
67
|
+
self._command_stream_push_button.setEnabled(False)
|
|
68
|
+
self._connection_group_box.setEnabled(True)
|
|
69
|
+
|
|
70
|
+
self.connect_toggled.emit(is_connected)
|
|
71
|
+
|
|
72
|
+
def _toggle_configuration(self) -> None:
|
|
73
|
+
self._device_params["working_mode"] = SyncStationWorkingMode(
|
|
74
|
+
self._input_working_mode_combo_box.currentIndex() + 1
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
count_enabled = 0
|
|
78
|
+
for key, value in self._probes_dict.items():
|
|
79
|
+
is_enabled = value["probe_status"].isChecked()
|
|
80
|
+
self._device_params["bytes_configuration_A"][key][
|
|
81
|
+
"probe_status"
|
|
82
|
+
] = is_enabled
|
|
83
|
+
self._device_params["bytes_configuration_A"][key]["detection_mode"] = (
|
|
84
|
+
SyncStationDetectionMode(value["detection_mode"].currentIndex() + 1)
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if is_enabled:
|
|
88
|
+
count_enabled += 1
|
|
89
|
+
|
|
90
|
+
self._device_params["number_of_probes"] = count_enabled
|
|
91
|
+
|
|
92
|
+
self._device.configure_device(self._device_params)
|
|
93
|
+
|
|
94
|
+
def _configuration_toggled(self, is_configured: bool) -> None:
|
|
95
|
+
if is_configured:
|
|
96
|
+
self._command_stream_push_button.setEnabled(True)
|
|
97
|
+
|
|
98
|
+
self.configure_toggled.emit(is_configured)
|
|
99
|
+
|
|
100
|
+
def _toggle_stream(self) -> None:
|
|
101
|
+
self._command_stream_push_button.setEnabled(False)
|
|
102
|
+
self._device.toggle_streaming()
|
|
103
|
+
|
|
104
|
+
def _stream_toggled(self, is_streaming: bool) -> None:
|
|
105
|
+
self._command_stream_push_button.setEnabled(True)
|
|
106
|
+
if is_streaming:
|
|
107
|
+
self._command_stream_push_button.setText("Stop Streaming")
|
|
108
|
+
self._command_stream_push_button.setChecked(True)
|
|
109
|
+
self._command_configure_push_button.setEnabled(False)
|
|
110
|
+
self._input_group_box.setEnabled(False)
|
|
111
|
+
else:
|
|
112
|
+
self._command_stream_push_button.setText("Start Streaming")
|
|
113
|
+
self._command_stream_push_button.setChecked(False)
|
|
114
|
+
self._command_configure_push_button.setEnabled(True)
|
|
115
|
+
self._input_group_box.setEnabled(True)
|
|
116
|
+
|
|
117
|
+
self.stream_toggled.emit(is_streaming)
|
|
118
|
+
|
|
119
|
+
def _update_probe_params(self, probe: SyncStationProbeConfigMode, state) -> None:
|
|
120
|
+
self._probes_dict[probe]["detection_mode"].setEnabled(state == 2)
|
|
121
|
+
|
|
122
|
+
def _initialize_device_params(self) -> None:
|
|
123
|
+
self._device_params = {
|
|
124
|
+
"rec_on_mode": SyncStationRecOnMode.OFF,
|
|
125
|
+
"working_mode": SyncStationWorkingMode.EMG,
|
|
126
|
+
"number_of_probes": 0,
|
|
127
|
+
"bytes_configuration_A": {
|
|
128
|
+
SyncStationProbeConfigMode(i): {
|
|
129
|
+
"probe_status": False,
|
|
130
|
+
"detection_mode": SyncStationDetectionMode.MONOPOLAR_GAIN_LOW,
|
|
131
|
+
}
|
|
132
|
+
for i in range(1, len(SyncStationProbeConfigMode))
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
def _set_default_probe_params(self) -> None:
|
|
137
|
+
for values in self._probes_dict.values():
|
|
138
|
+
values["detection_mode"].setCurrentIndex(1)
|
|
139
|
+
values["probe_status"].setChecked(True)
|
|
140
|
+
values["probe_status"].setChecked(False)
|
|
141
|
+
|
|
142
|
+
self._probes_dict[SyncStationProbeConfigMode.MUOVI_PROBE_ONE][
|
|
143
|
+
"probe_status"
|
|
144
|
+
].setChecked(True)
|
|
145
|
+
|
|
146
|
+
self._probes_dict[SyncStationProbeConfigMode.MUOVI_PROBE_TWO][
|
|
147
|
+
"probe_status"
|
|
148
|
+
].setChecked(True)
|
|
149
|
+
|
|
150
|
+
def _initialize_ui(self):
|
|
151
|
+
self.ui = Ui_SyncStationForm()
|
|
152
|
+
self.ui.setupUi(self)
|
|
153
|
+
|
|
154
|
+
# Command Push Buttons
|
|
155
|
+
self._command_connect_push_button: QPushButton = (
|
|
156
|
+
self.ui.commandConnectionPushButton
|
|
157
|
+
)
|
|
158
|
+
self._command_connect_push_button.clicked.connect(self._toggle_connection)
|
|
159
|
+
self._device.connect_toggled.connect(self._connection_toggled)
|
|
160
|
+
|
|
161
|
+
self._command_configure_push_button: QPushButton = (
|
|
162
|
+
self.ui.commandConfigurationPushButton
|
|
163
|
+
)
|
|
164
|
+
self._command_configure_push_button.clicked.connect(self._toggle_configuration)
|
|
165
|
+
self._command_configure_push_button.setEnabled(False)
|
|
166
|
+
self._device.configure_toggled.connect(self._configuration_toggled)
|
|
167
|
+
|
|
168
|
+
self._command_stream_push_button: QPushButton = self.ui.commandStreamPushButton
|
|
169
|
+
self._command_stream_push_button.clicked.connect(self._toggle_stream)
|
|
170
|
+
self._command_stream_push_button.setEnabled(False)
|
|
171
|
+
self._device.stream_toggled.connect(self._stream_toggled)
|
|
172
|
+
|
|
173
|
+
# Connection Paramters
|
|
174
|
+
self._connection_group_box: QGroupBox = self.ui.connectionGroupBox
|
|
175
|
+
self._connection_ip_label: QLabel = self.ui.connectionIPAddressLabel
|
|
176
|
+
self._connection_port_label: QLabel = self.ui.connectionPortLabel
|
|
177
|
+
|
|
178
|
+
# Input Parameters
|
|
179
|
+
self._input_group_box: QGroupBox = self.ui.inputGroupBox
|
|
180
|
+
self._input_working_mode_combo_box: QComboBox = self.ui.inputWorkingModeComboBox
|
|
181
|
+
self._input_working_mode_combo_box.setCurrentIndex(1)
|
|
182
|
+
|
|
183
|
+
self._probes_tab_widget: QTabWidget = self.ui.probesTabWidget
|
|
184
|
+
self._probes_tab_widget.setCurrentIndex(0)
|
|
185
|
+
self._probes_dict: Dict[
|
|
186
|
+
SyncStationProbeConfigMode, dict[str, QComboBox | QCheckBox]
|
|
187
|
+
] = self._configure_probes_dict()
|
|
188
|
+
|
|
189
|
+
for key, value in self._probes_dict.items():
|
|
190
|
+
value["probe_status"].stateChanged.connect(
|
|
191
|
+
partial(self._update_probe_params, key)
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
self._set_default_probe_params()
|
|
195
|
+
|
|
196
|
+
def _configure_probes_dict(self) -> None:
|
|
197
|
+
return {
|
|
198
|
+
SyncStationProbeConfigMode.MUOVI_PROBE_ONE: {
|
|
199
|
+
"probe_status": self.ui.muoviProbeOneEnableCheckBox,
|
|
200
|
+
"detection_mode": self.ui.muoviProbeOneDetectionModeComboBox,
|
|
201
|
+
},
|
|
202
|
+
SyncStationProbeConfigMode.MUOVI_PROBE_TWO: {
|
|
203
|
+
"probe_status": self.ui.muoviProbeTwoEnableCheckBox,
|
|
204
|
+
"detection_mode": self.ui.muoviProbeTwoDetectionModeComboBox,
|
|
205
|
+
},
|
|
206
|
+
SyncStationProbeConfigMode.MUOVI_PROBE_THREE: {
|
|
207
|
+
"probe_status": self.ui.muoviProbeThreeEnableCheckBox,
|
|
208
|
+
"detection_mode": self.ui.muoviProbeThreeDetectionModeComboBox,
|
|
209
|
+
},
|
|
210
|
+
SyncStationProbeConfigMode.MUOVI_PROBE_FOUR: {
|
|
211
|
+
"probe_status": self.ui.muoviProbeFourEnableCheckBox,
|
|
212
|
+
"detection_mode": self.ui.muoviProbeFourDetectionModeComboBox,
|
|
213
|
+
},
|
|
214
|
+
SyncStationProbeConfigMode.MUOVI_PLUS_PROBE_ONE: {
|
|
215
|
+
"probe_status": self.ui.muoviPlusProbeOneEnableCheckBox,
|
|
216
|
+
"detection_mode": self.ui.muoviPlusProbeOneDetectionModeComboBox,
|
|
217
|
+
},
|
|
218
|
+
SyncStationProbeConfigMode.MUOVI_PLUS_PROBE_TWO: {
|
|
219
|
+
"probe_status": self.ui.muoviPlusProbeTwoEnableCheckBox,
|
|
220
|
+
"detection_mode": self.ui.muoviPlusProbeTwoDetectionModeComboBox,
|
|
221
|
+
},
|
|
222
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_ONE: {
|
|
223
|
+
"probe_status": self.ui.duePlusProbeOneEnableCheckBox,
|
|
224
|
+
"detection_mode": self.ui.duePlusProbeOneDetectionModeComboBox,
|
|
225
|
+
},
|
|
226
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_TWO: {
|
|
227
|
+
"probe_status": self.ui.duePlusProbeTwoEnableCheckBox,
|
|
228
|
+
"detection_mode": self.ui.duePlusProbeTwoDetectionModeComboBox,
|
|
229
|
+
},
|
|
230
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_THREE: {
|
|
231
|
+
"probe_status": self.ui.duePlusProbeThreeEnableCheckBox,
|
|
232
|
+
"detection_mode": self.ui.duePlusProbeThreeDetectionModeComboBox,
|
|
233
|
+
},
|
|
234
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_FOUR: {
|
|
235
|
+
"probe_status": self.ui.duePlusProbeFourEnableCheckBox,
|
|
236
|
+
"detection_mode": self.ui.duePlusProbeFourDetectionModeComboBox,
|
|
237
|
+
},
|
|
238
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_FIVE: {
|
|
239
|
+
"probe_status": self.ui.duePlusProbeFiveEnableCheckBox,
|
|
240
|
+
"detection_mode": self.ui.duePlusProbeFiveDetectionModeComboBox,
|
|
241
|
+
},
|
|
242
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_SIX: {
|
|
243
|
+
"probe_status": self.ui.duePlusProbeSixEnableCheckBox,
|
|
244
|
+
"detection_mode": self.ui.duePlusProbeSixDetectionModeComboBox,
|
|
245
|
+
},
|
|
246
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_SEVEN: {
|
|
247
|
+
"probe_status": self.ui.duePlusProbeSevenEnableCheckBox,
|
|
248
|
+
"detection_mode": self.ui.duePlusProbeSevenDetectionModeComboBox,
|
|
249
|
+
},
|
|
250
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_EIGHT: {
|
|
251
|
+
"probe_status": self.ui.duePlusProbeEightEnableCheckBox,
|
|
252
|
+
"detection_mode": self.ui.duePlusProbeEightDetectionModeComboBox,
|
|
253
|
+
},
|
|
254
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_NINE: {
|
|
255
|
+
"probe_status": self.ui.duePlusProbeNineEnableCheckBox,
|
|
256
|
+
"detection_mode": self.ui.duePlusProbeNineDetectionModeComboBox,
|
|
257
|
+
},
|
|
258
|
+
SyncStationProbeConfigMode.DUE_PLUS_PROBE_TEN: {
|
|
259
|
+
"probe_status": self.ui.duePlusProbeTenEnableCheckBox,
|
|
260
|
+
"detection_mode": self.ui.duePlusProbeTenDetectionModeComboBox,
|
|
261
|
+
},
|
|
262
|
+
}
|
|
@@ -95,12 +95,16 @@ class BiosignalPlotWidget(QWidget):
|
|
|
95
95
|
def configure(
|
|
96
96
|
self,
|
|
97
97
|
lines: int,
|
|
98
|
-
|
|
98
|
+
sampling_frequency: int = 2000,
|
|
99
|
+
plot_sampling_frequency: int | None = None,
|
|
99
100
|
display_time: int = 10,
|
|
101
|
+
line_height: int = 50,
|
|
100
102
|
background_color: np.ndarray = np.array([18.0, 18.0, 18.0, 1]),
|
|
101
103
|
):
|
|
102
104
|
self.number_of_lines = lines
|
|
103
|
-
self.external_sampling_frequency =
|
|
105
|
+
self.external_sampling_frequency = sampling_frequency
|
|
106
|
+
if plot_sampling_frequency is not None:
|
|
107
|
+
self.internal_sampling_frequency_threshold = plot_sampling_frequency
|
|
104
108
|
|
|
105
109
|
if (
|
|
106
110
|
self.external_sampling_frequency
|
|
@@ -129,7 +133,7 @@ class BiosignalPlotWidget(QWidget):
|
|
|
129
133
|
)
|
|
130
134
|
|
|
131
135
|
self.space_for_each_line = min(
|
|
132
|
-
int(self.max_texture_size // self.number_of_lines // 1.5),
|
|
136
|
+
int(self.max_texture_size // self.number_of_lines // 1.5), line_height
|
|
133
137
|
)
|
|
134
138
|
|
|
135
139
|
self.canvas.configure(
|
|
@@ -343,7 +347,8 @@ class VispyFastPlotCanvas(app.Canvas):
|
|
|
343
347
|
self.line_data[:, :-input_vertices] = self.line_data[:, input_vertices:]
|
|
344
348
|
self.line_data[:, -input_vertices:] = input_data
|
|
345
349
|
|
|
346
|
-
self.
|
|
350
|
+
plot_data = self.line_data.ravel().astype(np.float32)
|
|
351
|
+
self.program["a_position"].set_data(plot_data)
|
|
347
352
|
self.update()
|
|
348
353
|
self.context.flush()
|
|
349
354
|
|