-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbpodFlexChannelSettingsDialog.py
More file actions
133 lines (118 loc) · 6.58 KB
/
Copy pathbpodFlexChannelSettingsDialog.py
File metadata and controls
133 lines (118 loc) · 6.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import logging
from PyQt5.QtWidgets import QDialog
from ui_files.bpod_flex_channel_settings_dialog_ui import Ui_Dialog
logging.basicConfig(format="%(message)s", level=logging.INFO)
class BpodFlexChannelSettingsDialog(QDialog, Ui_Dialog):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setupUi(self)
self.setWindowTitle("Bpod Flex Channel Settings")
self.connectSignalsSlots()
self.maxFlexVoltage = 5
self.settingsDict = {
'channelTypes': [
self.channelTypeComboBox_1.currentIndex(),
self.channelTypeComboBox_2.currentIndex(),
self.channelTypeComboBox_3.currentIndex(),
self.channelTypeComboBox_4.currentIndex()
],
'thresholds_1': [
((self.threshold_1_doubleSpinBox_1.value() / self.maxFlexVoltage) * 4095),
((self.threshold_1_doubleSpinBox_2.value() / self.maxFlexVoltage) * 4095),
((self.threshold_1_doubleSpinBox_3.value() / self.maxFlexVoltage) * 4095),
((self.threshold_1_doubleSpinBox_4.value() / self.maxFlexVoltage) * 4095)
],
'thresholds_2': [
((self.threshold_2_doubleSpinBox_1.value() / self.maxFlexVoltage) * 4095),
((self.threshold_2_doubleSpinBox_2.value() / self.maxFlexVoltage) * 4095),
((self.threshold_2_doubleSpinBox_3.value() / self.maxFlexVoltage) * 4095),
((self.threshold_2_doubleSpinBox_4.value() / self.maxFlexVoltage) * 4095)
],
'polarities_1': [
self.polarity_1_comboBox_1.currentIndex(),
self.polarity_1_comboBox_2.currentIndex(),
self.polarity_1_comboBox_3.currentIndex(),
self.polarity_1_comboBox_4.currentIndex()
],
'polarities_2': [
self.polarity_2_comboBox_1.currentIndex(),
self.polarity_2_comboBox_2.currentIndex(),
self.polarity_2_comboBox_3.currentIndex(),
self.polarity_2_comboBox_4.currentIndex()
],
'modes': [
self.modeComboBox_1.currentIndex(),
self.modeComboBox_2.currentIndex(),
self.modeComboBox_3.currentIndex(),
self.modeComboBox_4.currentIndex()
],
'samplingPeriod': self.samplingPeriodSpinBox.value()
}
def connectSignalsSlots(self):
self.buttonBox.accepted.connect(self.updateSettingsDict)
def updateSettingsDict(self):
self.settingsDict['channelTypes'] = [
self.channelTypeComboBox_1.currentIndex(),
self.channelTypeComboBox_2.currentIndex(),
self.channelTypeComboBox_3.currentIndex(),
self.channelTypeComboBox_4.currentIndex()
]
self.settingsDict['thresholds_1'] = [
((self.threshold_1_doubleSpinBox_1.value() / self.maxFlexVoltage) * 4095),
((self.threshold_1_doubleSpinBox_2.value() / self.maxFlexVoltage) * 4095),
((self.threshold_1_doubleSpinBox_3.value() / self.maxFlexVoltage) * 4095),
((self.threshold_1_doubleSpinBox_4.value() / self.maxFlexVoltage) * 4095)
]
self.settingsDict['thresholds_2'] = [
((self.threshold_2_doubleSpinBox_1.value() / self.maxFlexVoltage) * 4095),
((self.threshold_2_doubleSpinBox_2.value() / self.maxFlexVoltage) * 4095),
((self.threshold_2_doubleSpinBox_3.value() / self.maxFlexVoltage) * 4095),
((self.threshold_2_doubleSpinBox_4.value() / self.maxFlexVoltage) * 4095)
]
self.settingsDict['polarities_1'] = [
self.polarity_1_comboBox_1.currentIndex(),
self.polarity_1_comboBox_2.currentIndex(),
self.polarity_1_comboBox_3.currentIndex(),
self.polarity_1_comboBox_4.currentIndex()
]
self.settingsDict['polarities_2'] = [
self.polarity_2_comboBox_1.currentIndex(),
self.polarity_2_comboBox_2.currentIndex(),
self.polarity_2_comboBox_3.currentIndex(),
self.polarity_2_comboBox_4.currentIndex()
]
self.settingsDict['modes'] = [
self.modeComboBox_1.currentIndex(),
self.modeComboBox_2.currentIndex(),
self.modeComboBox_3.currentIndex(),
self.modeComboBox_4.currentIndex()
]
self.settingsDict['samplingPeriod'] = self.samplingPeriodSpinBox.value()
def loadSettings(self, settingsDict):
self.channelTypeComboBox_1.setCurrentIndex(settingsDict['channelTypes'][0])
self.channelTypeComboBox_2.setCurrentIndex(settingsDict['channelTypes'][1])
self.channelTypeComboBox_3.setCurrentIndex(settingsDict['channelTypes'][2])
self.channelTypeComboBox_4.setCurrentIndex(settingsDict['channelTypes'][3])
self.threshold_1_doubleSpinBox_1.setValue(settingsDict['thresholds_1'][0])
self.threshold_1_doubleSpinBox_2.setValue(settingsDict['thresholds_1'][1])
self.threshold_1_doubleSpinBox_3.setValue(settingsDict['thresholds_1'][2])
self.threshold_1_doubleSpinBox_4.setValue(settingsDict['thresholds_1'][3])
self.threshold_2_doubleSpinBox_1.setValue(settingsDict['thresholds_2'][0])
self.threshold_2_doubleSpinBox_2.setValue(settingsDict['thresholds_2'][1])
self.threshold_2_doubleSpinBox_3.setValue(settingsDict['thresholds_2'][2])
self.threshold_2_doubleSpinBox_4.setValue(settingsDict['thresholds_2'][3])
self.polarity_1_comboBox_1.setCurrentIndex(settingsDict['polarities_1'][0])
self.polarity_1_comboBox_2.setCurrentIndex(settingsDict['polarities_1'][1])
self.polarity_1_comboBox_3.setCurrentIndex(settingsDict['polarities_1'][2])
self.polarity_1_comboBox_4.setCurrentIndex(settingsDict['polarities_1'][3])
self.polarity_2_comboBox_1.setCurrentIndex(settingsDict['polarities_2'][0])
self.polarity_2_comboBox_2.setCurrentIndex(settingsDict['polarities_2'][1])
self.polarity_2_comboBox_3.setCurrentIndex(settingsDict['polarities_2'][2])
self.polarity_2_comboBox_4.setCurrentIndex(settingsDict['polarities_2'][3])
self.modeComboBox_1.setCurrentIndex(settingsDict['modes'][0])
self.modeComboBox_2.setCurrentIndex(settingsDict['modes'][1])
self.modeComboBox_3.setCurrentIndex(settingsDict['modes'][2])
self.modeComboBox_4.setCurrentIndex(settingsDict['modes'][3])
self.samplingPeriodSpinBox.setValue(settingsDict['samplingPeriod'])
def getSettings(self):
return self.settingsDict