-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreproc_dialog.py
83 lines (56 loc) · 1.98 KB
/
preproc_dialog.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
#!/usr/bin/env python2.5
#
# Written (W) 2012 Christian Widmer
# Copyright (C) 2012-2014 Max-Planck-Society, MSKCC, TU-Berlin
"""
@author: Christian Widmer
@summary: dialog for preprocessing
"""
from PySide import QtCore, QtGui, QtUiTools
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
class MplWidget(QtGui.QWidget):
"""
thin Qt wrapper of matplotlib
"""
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
class PreprocDialog(QtGui.QDialog):
"""
simple dialog to fire up batch processing
"""
def __init__(self,parent=None):
"""
setup gui from ui file (edit with qt designer)
"""
QtGui.QDialog.__init__(self)
loader = QtUiTools.QUiLoader()
uifile = QtCore.QFile('preproc.ui')
uifile.open(QtCore.QFile.ReadOnly)
self.ui = loader.load(uifile, self)
self.ui.show()
def getValues(self):
"""
wraps up return values as dictionary
"""
# naming has to agree with method "fit_stack" in qt_gui.py
method_idx_to_name = ["squared", "eps", "circle"]
values = {}
values["radius_offset"] = self.radius_offset.value()
values["percentile"] = self.percentile.value()
values["std_cut"] = self.std_cut.value()
values["method"] = method_idx_to_name[self.method.currentIndex()]
return values