def __init__(self, app, classes): """Effectively a modal dialog for selecting masking parameters interactively """ self.app = app QtGui.QWidget.__init__(self, None) nx = classes[0]["nx"] self.classes = classes self.classview = EMImageMXWidget(self, classes) self.vbl = QtGui.QVBoxLayout(self) self.vbl.addWidget(self.classview) self.hbl = QtGui.QHBoxLayout() self.cmode = CheckBox(self, "orig", value=1) self.hbl.addWidget(self.cmode) self.slpres = ValSlider(self, (0.001, 0.2), "Low-pass Filter:", 0.03, 90) self.hbl.addWidget(self.slpres) self.snmax = ValSlider(self, (0, 20), "NMax:", 5, 90) self.snmax.intonly = 1 self.hbl.addWidget(self.snmax) self.sshells = ValSlider(self, (0, 40), "NShells:", nx // 8, 90) self.sshells.intonly = 1 self.hbl.addWidget(self.sshells) self.ssigma = ValSlider(self, (0, 2), "Sigma:", 0.333, 90) self.hbl.addWidget(self.ssigma) self.bok = QtGui.QPushButton("OK") self.hbl.addWidget(self.bok) self.vbl.addLayout(self.hbl) QtCore.QObject.connect(self.cmode, QtCore.SIGNAL("valueChanged"), self.newParm) QtCore.QObject.connect(self.slpres, QtCore.SIGNAL("valueChanged"), self.newParm) QtCore.QObject.connect(self.snmax, QtCore.SIGNAL("valueChanged"), self.newParm) QtCore.QObject.connect(self.sshells, QtCore.SIGNAL("valueChanged"), self.newParm) QtCore.QObject.connect(self.ssigma, QtCore.SIGNAL("valueChanged"), self.newParm) QtCore.QObject.connect(self.bok, QtCore.SIGNAL("clicked(bool)"), self.close) self.newParm()
class GUImask(QtWidgets.QWidget): def __init__(self,app,classes): """Effectively a modal dialog for selecting masking parameters interactively """ self.app=app QtWidgets.QWidget.__init__(self,None) nx=classes[0]["nx"] self.classes=classes self.classview=EMImageMXWidget(self,classes) self.vbl = QtWidgets.QVBoxLayout(self) self.vbl.addWidget(self.classview) self.hbl = QtWidgets.QHBoxLayout() self.cmode=CheckBox(self,"orig",value=1) self.hbl.addWidget(self.cmode) self.slpres=ValSlider(self,(0.001,0.2),"Low-pass Filter:",0.03,90) self.hbl.addWidget(self.slpres) self.snmax=ValSlider(self,(0,20),"NMax:",5,90) self.snmax.intonly=1 self.hbl.addWidget(self.snmax) self.sshells=ValSlider(self,(0,40),"NShells:",nx//8,90) self.sshells.intonly=1 self.hbl.addWidget(self.sshells) self.ssigma=ValSlider(self,(0,2),"Sigma:",0.333,90) self.hbl.addWidget(self.ssigma) self.bok=QtWidgets.QPushButton("OK") self.hbl.addWidget(self.bok) self.vbl.addLayout(self.hbl) self.cmode.valueChanged.connect(self.newParm) self.slpres.valueChanged.connect(self.newParm) self.snmax.valueChanged.connect(self.newParm) self.sshells.valueChanged.connect(self.newParm) self.ssigma.valueChanged.connect(self.newParm) self.bok.clicked[bool].connect(self.close) self.newParm() def quit(self): self.app.close_specific(self) def newParm(self): if self.cmode.getValue(): self.classview.set_data(self.classes) return self.masked=[i.process("filter.lowpass.gauss",{"cutoff_freq":self.slpres.value}) for i in self.classes] nx=self.masked[0]["nx"] for i,im in enumerate(self.masked): im.process_inplace("mask.auto2d",{"nmaxseed":int(self.snmax.value),"nshells":int(self.sshells.value),"radius":old_div(nx,10),"return_mask":1,"sigma":self.ssigma.value}) im.process_inplace("filter.lowpass.gauss",{"cutoff_freq":0.03}) im.mult(self.classes[i]) self.classview.set_data(self.masked)