-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_widget.py
452 lines (409 loc) · 17.7 KB
/
settings_widget.py
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) Grigoriy A. Armeev, 2014
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as·
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License v2 for more details.
import sys, os
from PyQt4 import QtGui,QtCore
import matplotlib
matplotlib.use('QT4Agg')
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
class QHLine(QtGui.QFrame):
def __init__(self):
super(QHLine, self).__init__()
self.setFrameShape(QtGui.QFrame.HLine)
self.setFrameShadow(QtGui.QFrame.Sunken)
class SettingsWidget(QtGui.QWidget):
def __init__(self,workdir,parent=None):
super(SettingsWidget, self).__init__(parent)
self.parent=parent
mainLayout = QtGui.QGridLayout(self)
text=QtGui.QLabel(u'Φ<i>d</i>')
tooltip=u'Quantum yield of donor, varies from 0 to 1 '
text.setToolTip(tooltip)
mainLayout.addWidget(text,0,0)
self.QD=QtGui.QDoubleSpinBox(self)
self.QD.setRange(0,1)
self.QD.setSingleStep(0.01)
self.QD.setValue(1)
self.QD.editingFinished.connect(self.collectSettings)
self.QD.setToolTip(tooltip)
mainLayout.addWidget(self.QD,0,1)
text=QtGui.QLabel(u'Φ<i>a</i>')
tooltip=u'Quantum yield of acceptor, varies from 0 to 1 '
text.setToolTip(tooltip)
mainLayout.addWidget(text,0,2)
self.QA=QtGui.QDoubleSpinBox(self)
self.QA.setRange(0,1)
self.QA.setSingleStep(0.01)
self.QA.setValue(1)
self.QA.editingFinished.connect(self.collectSettings)
self.QA.setToolTip(tooltip)
mainLayout.addWidget(self.QA,0,3)
text=QtGui.QLabel('<i>kd</i>')
tooltip=u'Detector efficiency at donor emission wavelength,\n varies from 0 to 1 '
text.setToolTip(tooltip)
mainLayout.addWidget(text)
self.kD=QtGui.QDoubleSpinBox(self)
self.kD.setRange(0,1)
self.kD.setSingleStep(0.01)
self.kD.setValue(1.00)
self.kD.editingFinished.connect(self.collectSettings)
self.kD.setToolTip(tooltip)
mainLayout.addWidget(self.kD)
text=QtGui.QLabel('<i>ka</i>')
tooltip=u'Detector efficiency at acceptor emission wavelength,\n varies from 0 to 1 '
text.setToolTip(tooltip)
mainLayout.addWidget(text)
self.kA=QtGui.QDoubleSpinBox(self)
self.kA.setRange(0,1)
self.kA.setSingleStep(0.01)
self.kA.setValue(1)
self.kA.editingFinished.connect(self.collectSettings)
self.kA.setToolTip(tooltip)
mainLayout.addWidget(self.kA)
text=QtGui.QLabel(u'α <i>ad</i>')
tooltip=u'Donor crosstalk coefficient (A to D), \n varies from 0 to 1'
text.setToolTip(tooltip)
mainLayout.addWidget(text)
self.aAD=QtGui.QDoubleSpinBox(self)
self.aAD.setRange(0,1)
self.aAD.setSingleStep(0.01)
self.aAD.setValue(0.00)
self.aAD.editingFinished.connect(self.collectSettings)
self.aAD.setToolTip(tooltip)
mainLayout.addWidget(self.aAD)
text=QtGui.QLabel(u'α <i>da</i>:')
tooltip=u'Acceptor crosstalk coefficient (D to A), \n varies from 0 to 1'
text.setToolTip(tooltip)
mainLayout.addWidget(text)
self.aDA=QtGui.QDoubleSpinBox(self)
self.aDA.setRange(0,1)
self.aDA.setSingleStep(0.01)
self.aDA.setValue(0.19)
self.aDA.editingFinished.connect(self.collectSettings)
self.aDA.setToolTip(tooltip)
mainLayout.addWidget(self.aDA)
text=QtGui.QLabel('<i>DE</i>')
tooltip=u'Direct excitation of acceptor \n(in signal units, e.g. kHz or counts)'
text.setToolTip(tooltip)
mainLayout.addWidget(text)
self.DE=QtGui.QDoubleSpinBox(self)
self.DE.setRange(0,1000)
self.DE.setSingleStep(0.01)
self.DE.setValue(0)
self.DE.editingFinished.connect(self.collectSettings)
self.DE.setToolTip(tooltip)
mainLayout.addWidget(self.DE)
text=QtGui.QLabel('N bins')
tooltip=u'Amount od bins for FRET E histogram'
text.setToolTip(tooltip)
mainLayout.addWidget(text)
self.histBins=QtGui.QDoubleSpinBox(self)
self.histBins.setRange(0,1000)
self.histBins.setSingleStep(1)
self.histBins.setValue(50)
self.histBins.editingFinished.connect(self.collectSettings)
self.histBins.setToolTip(tooltip)
mainLayout.addWidget(self.histBins)
###################### BACKGROUND METHODS ############################
text=QtGui.QLabel('Background substraction:')
mainLayout.addWidget(text,6,0,1,2)
self.BackGrSubMethod=QtGui.QComboBox(self)
self.BackGrSubMethod.addItem('Auto (gauss)')
self.BackGrSubMethod.addItem('Manual')
self.BackGrSubMethod.setCurrentIndex(0)
self.BackGrSubMethod.currentIndexChanged.connect(self.collectSettings)
mainLayout.addWidget(self.BackGrSubMethod,6,2,1,2)
self.BDtext=QtGui.QLabel('Bd:')
mainLayout.addWidget(self.BDtext,7,0,1,1)
self.BD=QtGui.QDoubleSpinBox(self)
self.BD.setRange(0,1000)
self.BD.setSingleStep(0.1)
self.BD.setValue(9)
self.BD.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.BD,7,1,1,1)
self.BAtext=QtGui.QLabel('Ba:')
mainLayout.addWidget(self.BAtext,7,2,1,1)
self.BA=QtGui.QDoubleSpinBox(self)
self.BA.setRange(0,1000)
self.BA.setSingleStep(0.1)
self.BA.setValue(9)
self.BA.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.BA,7,3,1,1)
###################### THRESHOLD METHODS ############################
text=QtGui.QLabel('Thresholding method:')
mainLayout.addWidget(text,8,0,1,2)
self.ThresholdMethod=QtGui.QComboBox(self)
self.ThresholdMethod.addItem('Auto (gauss)')
self.ThresholdMethod.addItem('Manual thresholds')
self.ThresholdMethod.addItem('Select top events')
#self.ThresholdMethod.model().item(2).setEnabled(False)
self.ThresholdMethod.setCurrentIndex(0)
self.ThresholdMethod.currentIndexChanged.connect(self.collectSettings)
mainLayout.addWidget(self.ThresholdMethod,8,2,1,2)
text=QtGui.QLabel('Thresholding logic:')
mainLayout.addWidget(text,9,0,1,2)
self.ThresholdLogic=QtGui.QComboBox(self)
self.ThresholdLogic.addItem('OR')
self.ThresholdLogic.addItem('AND')
self.ThresholdLogic.addItem('SUM')
self.ThresholdLogic.setCurrentIndex(0)
self.ThresholdLogic.currentIndexChanged.connect(self.collectSettings)
mainLayout.addWidget(self.ThresholdLogic,9,2,1,2)
self.CDtext=QtGui.QLabel('Coef. D:')
mainLayout.addWidget(self.CDtext,10,0,1,1)
self.CD=QtGui.QDoubleSpinBox(self)
self.CD.setRange(0,1000)
self.CD.setSingleStep(0.1)
self.CD.setValue(9)
self.CD.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.CD,10,1,1,1)
self.CAtext=QtGui.QLabel('Coef. A:')
mainLayout.addWidget(self.CAtext,10,2,1,1)
self.CA=QtGui.QDoubleSpinBox(self)
self.CA.setRange(0,1000)
self.CA.setSingleStep(0.1)
self.CA.setValue(9)
self.CA.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.CA,10,3,1,1)
self.TDtext=QtGui.QLabel('Thresh. D:')
mainLayout.addWidget(self.TDtext,11,0,1,1)
self.TD=QtGui.QDoubleSpinBox(self)
self.TD.setRange(0,1000)
self.TD.setSingleStep(1.0)
self.TD.setValue(10)
self.TD.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.TD,11,1,1,1)
self.TAtext=QtGui.QLabel('Thresh. A:')
mainLayout.addWidget(self.TAtext,11,2,1,1)
self.TA=QtGui.QDoubleSpinBox(self)
self.TA.setRange(0,1000)
self.TA.setSingleStep(1.0)
self.TA.setValue(5)
self.TA.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.TA,11,3,1,1)
self.NDtext=QtGui.QLabel('Nd:')
mainLayout.addWidget(self.NDtext,12,0,1,1)
self.ND=QtGui.QDoubleSpinBox(self)
self.ND.setRange(0,100000)
self.ND.setSingleStep(0.1)
self.ND.setValue(5000)
self.ND.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.ND,12,1,1,1)
self.NAtext=QtGui.QLabel('Na:')
mainLayout.addWidget(self.NAtext,12,2,1,1)
self.NA=QtGui.QDoubleSpinBox(self)
self.NA.setRange(0,100000)
self.NA.setSingleStep(0.1)
self.NA.setValue(5000)
self.NA.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.NA,12,3,1,1)
###################### FIltering METHODS ############################
mainLayout.addWidget(QHLine(),13,0,1,4)
text=QtGui.QLabel(u'D↑thld:')
tooltip=u'Upper threshgold for donor kHz,\n i.e. if signal in donor channel is higher\n the burst is neglected! '
text.setToolTip(tooltip)
mainLayout.addWidget(text,14,0,1,1)
self.UTD=QtGui.QDoubleSpinBox(self)
self.UTD.setRange(0,100000)
self.UTD.setSingleStep(0.1)
self.UTD.setValue(50)
self.UTD.editingFinished.connect(self.collectSettings)
self.UTD.setToolTip(tooltip)
mainLayout.addWidget(self.UTD,14,1,1,1)
text=QtGui.QLabel(u'A↑thld:')
tooltip=u'Upper threshgold for acceptor kHz,\n i.e. if signal in acceptor channel is higher\n the burst is neglected! '
text.setToolTip(tooltip)
mainLayout.addWidget(text,14,2,1,1)
self.UTA=QtGui.QDoubleSpinBox(self)
self.UTA.setRange(0,100000)
self.UTA.setSingleStep(0.1)
self.UTA.setValue(50)
self.UTA.editingFinished.connect(self.collectSettings)
mainLayout.addWidget(self.UTA,14,3,1,1)
text=QtGui.QLabel(u'MaxTime:')
tooltip=u'Maximum burst length in time bins,\n i.e. if object was in the focus for\n more than N time bins, burst is neglected! '
text.setToolTip(tooltip)
mainLayout.addWidget(text,15,0,1,1)
self.ASML=QtGui.QDoubleSpinBox(self)
self.ASML.setRange(0,100)
self.ASML.setSingleStep(1)
self.ASML.setValue(5)
self.ASML.editingFinished.connect(self.collectSettings)
self.ASML.setToolTip(tooltip)
mainLayout.addWidget(self.ASML,15,1,1,1)
###################### FITTING METHODS ############################
text=QtGui.QLabel('Gauss fitting:')
mainLayout.addWidget(text,16,0,1,2)
self.gausFitting=QtGui.QComboBox(self)
self.gausFitting.addItem('None')
self.gausFitting.addItem('1')
self.gausFitting.addItem('2')
self.gausFitting.addItem('3')
self.gausFitting.addItem('4')
self.gausFitting.addItem('5')
self.gausFitting.setCurrentIndex(0)
self.gausFitting.currentIndexChanged.connect(self.collectSettings)
mainLayout.addWidget(self.gausFitting,16,2,1,2)
###################### FORMULAS ############################
windowColor = str(self.palette().color(QtGui.QPalette.Window).name())
self.figure = plt.figure(facecolor=windowColor)
self.canvas = FigureCanvas(self.figure)
mainLayout.addWidget(self.canvas,17,0,1,4)
mainLayout.setAlignment(QtCore.Qt.AlignTop)
self.drawFormulas()
self.changeHideStatus()
def drawFormulas(self):
self.figure.clf()
self.figure.suptitle(r"$E=\frac{F_a}{F_a+\gamma_d F_d}$" "\n"
r"$F_d=I_d - B_d -\alpha_{ad}(I_a-B_a)$" "\n"
r"$F_a=I_a - B_a -\alpha_{da}(I_d-B_d)-DE_a$" "\n"
r"$\gamma_d=\frac{\Phi_a k_a}{\Phi_d k_d}= " +
str(round((self.QA.value()*self.kA.value())/(self.QD.value()*self.kD.value()),4))+ "$\n"
r"$I - intensity, B - background$" "\n"
r"$\alpha - crosstalk, \gamma - instr.coef.$" ,
x=0.0, y=0.5,
fontsize=18,
horizontalalignment='left',
verticalalignment='center')
self.canvas.setMaximumWidth(278)
self.canvas.setMaximumHeight(190)
self.canvas.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
self.canvas.draw()
def changeHideStatus(self):
if self.BackGrSubMethod.currentText()=='Manual':
self.BAtext.show()
self.BA.show()
self.BDtext.show()
self.BD.show()
elif self.BackGrSubMethod.currentText()=='Auto (gauss)':
self.BAtext.hide()
self.BA.hide()
self.BDtext.hide()
self.BD.hide()
if (self.ThresholdLogic.currentText()=='OR') | (self.ThresholdLogic.currentText()=='AND'):
self.ThresholdMethod.model().item(2).setEnabled(True)
self.ThresholdLogic.model().item(2).setEnabled(True)
if self.ThresholdMethod.currentText()=='Auto (gauss)':
self.CD.show()
self.CDtext.show()
self.CA.show()
self.CAtext.show()
self.TD.hide()
self.TDtext.hide()
self.TA.hide()
self.TAtext.hide()
self.ThresholdLogic.model().item(2).setEnabled(True)
self.ND.hide()
self.NDtext.hide()
self.NA.hide()
self.NAtext.hide()
elif self.ThresholdMethod.currentText()=='Manual thresholds':
self.CD.hide()
self.CDtext.hide()
self.CA.hide()
self.CAtext.hide()
self.TD.show()
self.TDtext.show()
self.TA.show()
self.TAtext.show()
self.ThresholdLogic.model().item(2).setEnabled(True)
self.ND.hide()
self.NDtext.hide()
self.NA.hide()
self.NAtext.hide()
elif self.ThresholdMethod.currentText()=='Select top events':
self.CD.hide()
self.CDtext.hide()
self.CA.hide()
self.CAtext.hide()
self.TD.hide()
self.TDtext.hide()
self.TA.hide()
self.TAtext.hide()
self.ThresholdLogic.model().item(2).setEnabled(False)
self.ND.show()
self.NDtext.show()
self.NA.show()
self.NAtext.show()
else:
self.ThresholdMethod.model().item(2).setEnabled(False)
if self.ThresholdMethod.currentText()=='Select top events':
self.ThresholdMethod.setCurrentIndex(0)
self.CD.hide()
self.CDtext.hide()
self.TD.hide()
self.TDtext.hide()
elif self.ThresholdMethod.currentText()=='Auto (gauss)':
self.CD.show()
self.CDtext.show()
self.TD.hide()
self.TDtext.hide()
elif self.ThresholdMethod.currentText()=='Manual thresholds':
self.TD.show()
self.TDtext.show()
self.CD.hide()
self.CDtext.hide()
def hideAll(self):
self.BAtext.hide()
self.BA.hide()
self.BDtext.hide()
self.BD.hide()
self.CD.hide()
self.CDtext.hide()
self.CA.hide()
self.CAtext.hide()
self.TD.hide()
self.TDtext.hide()
self.TA.hide()
self.TAtext.hide()
self.ND.hide()
self.NDtext.hide()
self.NA.hide()
self.NAtext.hide()
def collectSettings(self):
self.drawFormulas()
self.changeHideStatus()
#self.drawFormulas()
settings={'QD':self.QD.value(),
'QA':self.QA.value(),
'kD':self.kD.value(),
'kA':self.kA.value(),
'BD':self.BD.value(),
'BA':self.BA.value(),
'CD':self.CD.value(),
'CA':self.CA.value(),
'TD':self.TD.value(),
'TA':self.TA.value(),
'ND':self.ND.value(),
'NA':self.NA.value(),
'DE':self.DE.value(),
'aAD':self.aAD.value(),
'aDA':self.aDA.value(),
'UTD':self.UTD.value(),
'UTA':self.UTA.value(),
'AggSearchMaxLength':self.ASML.value(),
'histBins':self.histBins.value(),
'threshMethod':self.ThresholdMethod.currentText(),
'threshLogic':self.ThresholdLogic.currentText(),
'backgrMetod':self.BackGrSubMethod.currentText(),
'nGausFit':self.gausFitting.currentIndex()}
self.emit(QtCore.SIGNAL("settingsUpdatedSignal"),settings)
return settings
def main():
app = QtGui.QApplication(sys.argv)
workDir=unicode(QtCore.QDir.currentPath())
ex = SettingsWidget(workDir)
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()