def __init__(self, parent=None, title=None, xlabel=None, ylabel=None, xunit=None, yunit=None, section="plot", show_itemlist=False, gridparam=None, curve_antialiasing=None, **kwargs): if PYQT5: super(BaseCurveWidget, self).__init__(parent, **kwargs) self.setOrientation(Qt.Horizontal) else: QSplitter.__init__(self, Qt.Horizontal, parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.plot = CurvePlot(parent=self, title=title, xlabel=xlabel, ylabel=ylabel, xunit=xunit, yunit=yunit, section=section, gridparam=gridparam) if curve_antialiasing is not None: self.plot.set_antialiasing(curve_antialiasing) self.addWidget(self.plot) self.itemlist = PlotItemList(self) self.itemlist.setVisible(show_itemlist) self.addWidget(self.itemlist) configure_plot_splitter(self)
class BaseCurveWidget(QSplitter): """ Construct a BaseCurveWidget object, which includes: * A plot (:py:class:`guiqwt.curve.CurvePlot`) * An `item list` panel (:py:class:`guiqwt.curve.PlotItemList`) This object does nothing in itself because plot and panels are not connected to each other. See children class :py:class:`guiqwt.plot.CurveWidget` """ def __init__(self, parent=None, title=None, xlabel=None, ylabel=None, xunit=None, yunit=None, section="plot", show_itemlist=False, gridparam=None, curve_antialiasing=None, **kwargs): if PYQT5: super(BaseCurveWidget, self).__init__(parent, **kwargs) self.setOrientation(Qt.Horizontal) else: QSplitter.__init__(self, Qt.Horizontal, parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.plot = CurvePlot(parent=self, title=title, xlabel=xlabel, ylabel=ylabel, xunit=xunit, yunit=yunit, section=section, gridparam=gridparam) if curve_antialiasing is not None: self.plot.set_antialiasing(curve_antialiasing) self.addWidget(self.plot) self.itemlist = PlotItemList(self) self.itemlist.setVisible(show_itemlist) self.addWidget(self.itemlist) configure_plot_splitter(self)
def fixed_do_autoscale(self, *args, **kwargs): CurvePlot.old_do_autoscale(self, *args, **kwargs) if not isinstance(self, ImagePlot): if old_guiqwt: self.emit(SIG_PLOT_AXIS_CHANGED, self) else: self.SIG_PLOT_AXIS_CHANGED.emit(self)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle(self.__doc__) self.setWindowIcon(get_icon("guiqwt.svg")) self.manager = manager = PlotManager(None) manager.set_main(self) self.subplotwidget = spwidget = SubplotWidget(manager, parent=self) self.setLayout(QW.QVBoxLayout()) toolbar = QW.QToolBar(_("Tools")) manager.add_toolbar(toolbar) self.layout().addWidget(toolbar) self.layout().addWidget(spwidget) plot1 = CurvePlot(title="TL") plot2 = CurvePlot(title="TR") plot3 = CurvePlot(title="BL") plot4 = CurvePlot(title="BR") spwidget.add_subplot(plot1, 0, 0, "1") spwidget.add_subplot(plot2, 0, 1, "2") spwidget.add_subplot(plot3, 1, 0, "3") spwidget.add_subplot(plot4, 1, 1, "4") spwidget.add_itemlist() manager.synchronize_axis(BasePlot.X_BOTTOM, ["1", "3"]) manager.synchronize_axis(BasePlot.X_BOTTOM, ["2", "4"]) manager.synchronize_axis(BasePlot.Y_LEFT, ["1", "2"]) manager.synchronize_axis(BasePlot.Y_LEFT, ["3", "4"]) self.manager.register_all_curve_tools()
def setup_widget(self): self.plot = CurvePlot(self) self.data_cut = make.curve(self.xdata, self.ydata) self.data_fit = make.curve(self.xfit, self.yfit) self.plot.add_item(self.data_cut) self.plot.add_item(self.data_fit) vlayout = QVBoxLayout() vlayout.addWidget(self.plot) self.setLayout(vlayout)
def plot_init(self): self.manager = PlotManager(self) self.plots = [] self.plot = CurvePlot(xlabel="", ylabel="") # self.plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(10) self.manager.add_plot(self.plot) self.plots.append(self.plot) self.plot.plot_id = id(self.plot) self.curve = make.curve([0], [0], color="blue", title="gray value") self.plot.add_item(self.curve) self.plot.add_item(make.legend("TR")) self.ui_obj.line_info_display.addWidget(self.plot)
def setup_plot(self, i, j, win): p = CurvePlot(win, xlabel=self.xlabel, ylabel=self.ylabel) self.main_widget = p win.add_plot(i, j, p) for item in self.plots: p.add_item(item) p.enable_used_axes() active_item = p.get_active_item(force=True) p.set_scales(self.xscale, self.yscale) active_item.unselect() if self.legend_position is not None: p.add_item(make.legend(self.legend_position)) return p
def test_adding_to_plot(self): s = ScanningParam() a = AxisParam() a.length = 9 a.increment = 0.5 a.start = -2.0 a.unit = 'V' s.axis1 = a m = Measurement(np.arange(9),s) curve = ThothCurveItem(m) from guiqwt.curve import CurvePlot plot = CurvePlot(title="Test") plot.add_item(curve) plot.show()
def setup_widget(self): # ---Create the plot widget: x = self.x y = self.y self.plot = CurvePlot(self) self.curve_item = make.curve([], [], color="b") self.plot.add_item(self.curve_item) self.plot.set_antialiasing(True) width = x[-1] - x[0] self.intrange = make.range(x[0] + 0.4 * width, x[-1] - 0.4 * width) self.plot.add_item(self.intrange) self.lbgrange = make.range(x[0] + 0.3 * width, x[-1] - 0.65 * width) self.plot.add_item(self.lbgrange) self.lbgrange.pen = Qt.QPen(Qt.QColor("blue")) self.lbgrange.brush = Qt.QBrush(Qt.QColor(0, 0, 120, 100)) self.rbgrange = make.range(x[0] + 0.7 * width, x[-1] - 0.1 * width) self.rbgrange.pen = Qt.QPen(Qt.QColor("blue")) self.rbgrange.brush = Qt.QBrush(Qt.QColor(0, 0, 120, 100)) self.label1 = make.label(r"", "TR", (0, 0), "TR") self.plot.add_item(self.rbgrange) self.bg_item = make.curve([], [], color="r") self.plot.add_item(self.bg_item) self.fit_bg() self.plot.add_item(self.label1) self.connect(self.plot, SIG_RANGE_CHANGED, self.fit_bg) # --- vlayout = QVBoxLayout() vlayout.addWidget(self.plot) self.setLayout(vlayout) self.update_curve()
def setup_widget(self, title): #---Create the plot widget: self.plot = CurvePlot(self) self.curve_item = make.curve([], [], color='b') self.plot.add_item(self.curve_item) self.plot.set_antialiasing(True) #--- button = QPushButton("Test filter: %s" % title) button.clicked.connect(self.process_data) vlayout = QVBoxLayout() vlayout.addWidget(self.plot) vlayout.addWidget(button) self.setLayout(vlayout) self.update_curve()
def create_plot(self, options): manager = PlotManager(None) self.plotwidget = CurveWidget(self, manager=manager, **options) manager.set_main(self.plotwidget) plot1 = CurvePlot(title="TL") plot2 = CurvePlot(title="TR") plot3 = CurvePlot(title="BL") plot4 = CurvePlot(title="BR") self.plotwidget.add_plot(plot1, 0, 0, "1") self.plotwidget.add_plot(plot2, 0, 1, "2") self.plotwidget.add_plot(plot3, 1, 0, "3") self.plotwidget.add_plot(plot4, 1, 1, "4") self.plotwidget.finalize() manager.synchronize_axis(BasePlot.X_BOTTOM, ["1", "3"]) manager.synchronize_axis(BasePlot.X_BOTTOM, ["2", "4"]) manager.synchronize_axis(BasePlot.Y_LEFT, ["1", "2"]) manager.synchronize_axis(BasePlot.Y_LEFT, ["3", "4"]) self.layout.addWidget(self.plotwidget, 0, 0)
class CutScreen(QWidget): def __init__(self, parent, xdata=[], ydata=[], xfit=[], yfit=[], sizex=100, sizey=100): QWidget.__init__(self, parent) self.sizex = sizex self.sizey = sizey self.setMinimumSize(self.sizex, self.sizey) self.xdata = xdata self.ydata = ydata self.xfit = xfit self.yfit = yfit self.plot = None self.data_cut = None self.fit_cut = None self.setup_widget() def setup_widget(self): self.plot = CurvePlot(self) self.data_cut = make.curve(self.xdata, self.ydata) self.data_fit = make.curve(self.xfit, self.yfit) self.plot.add_item(self.data_cut) self.plot.add_item(self.data_fit) vlayout = QVBoxLayout() vlayout.addWidget(self.plot) self.setLayout(vlayout)
def __init__(self, parent=None, title=None, xlabel=None, ylabel=None, xunit=None, yunit=None, section="plot", show_itemlist=False, gridparam=None, curve_antialiasing=None): QSplitter.__init__(self, Qt.Horizontal, parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.plot = CurvePlot(parent=self, title=title, xlabel=xlabel, ylabel=ylabel, xunit=xunit, yunit=yunit, section=section, gridparam=gridparam) if curve_antialiasing is not None: self.plot.set_antialiasing(curve_antialiasing) self.addWidget(self.plot) self.itemlist = PlotItemList(self) self.itemlist.setVisible(show_itemlist) self.addWidget(self.itemlist) configure_plot_splitter(self)
def test_adding_to_plot(self): s = ScanningParam() a = AxisParam() a.length = 9 a.increment = 0.5 a.start = -2.0 a.unit = 'V' s.axis1 = a m = Measurement(np.arange(9), s) curve = ThothCurveItem(m) from guiqwt.curve import CurvePlot plot = CurvePlot(title="Test") plot.add_item(curve) plot.show()
class CutScreen(QWidget): def __init__(self, parent, xdata=[], ydata=[], xfit=[], yfit=[], sizex=100, sizey=100): QWidget.__init__(self, parent) self.sizex = sizex self.sizey = sizey #self.setMinimumSize(self.sizex,self.sizey) self.xdata = xdata self.ydata = ydata self.xfit = xfit self.yfit = yfit self.plot = None self.data_cut = None self.fit_cut = None self.setup_widget() def setup_widget(self): self.plot = CurvePlot(self) self.data_cut = make.curve(self.xdata, self.ydata, color="b") self.data_fit = make.curve(self.xfit, self.yfit, color="r") self.plot.add_item(self.data_cut) self.plot.add_item(self.data_fit) vlayout = QVBoxLayout() vlayout.addWidget(self.plot) self.setLayout(vlayout) def update_plot(self): self.data_cut.set_data(self.xdata, self.ydata) self.data_fit.set_data(self.xfit, self.yfit) self.plot.set_plot_limits(self.xdata.min(), self.xdata.max(), self.ydata.min(), self.ydata.max()) self.plot.replot()
def SpectrumVisu(self,item,value,parent): #app=guidata.qapplication() from guiqwt.curve import CurvePlot plot=CurvePlot(title="spectrum",xlabel="x",ylabel="y") number1=self.chosensoil1 spectrum1=Set.SpectrumList[number1] x1=range(len(spectrum1)) number2=self.chosensoil2 spectrum2=Set.SpectrumList[number2] x2=range(len(spectrum2)) from guiqwt.builder import make curve1=make.curve(x1,spectrum1,title="curve1",color='b') plot.add_item(curve1) curve2=make.curve(x2,spectrum2,title="curve2",color='r') plot.add_item(curve2) #app.exec_() plot.show() print(self.chosensoil1)
class FilterTestWidget(QWidget): """ Filter testing widget parent: parent widget (QWidget) x, y: NumPy arrays func: function object (the signal filter to be tested) """ def __init__(self, parent, x, y, func): QWidget.__init__(self, parent) self.setMinimumSize(320, 200) self.x = x self.y = y self.func = func # ---guiqwt related attributes: self.plot = None self.curve_item = None # --- def setup_widget(self, title): # ---Create the plot widget: self.plot = CurvePlot(self) self.curve_item = make.curve([], [], color="b") self.plot.add_item(self.curve_item) self.plot.set_antialiasing(True) # --- button = QPushButton("Test filter: %s" % title) button.clicked.connect(self.process_data) vlayout = QVBoxLayout() vlayout.addWidget(self.plot) vlayout.addWidget(button) self.setLayout(vlayout) self.update_curve() def process_data(self): self.y = self.func(self.y) self.update_curve() def update_curve(self): # ---Update curve self.curve_item.set_data(self.x, self.y) self.plot.replot()
class FilterTestWidget(QWidget): """ Filter testing widget parent: parent widget (QWidget) x, y: NumPy arrays func: function object (the signal filter to be tested) """ def __init__(self, parent, x, y, func): QWidget.__init__(self, parent) self.setMinimumSize(320, 200) self.x = x self.y = y self.func = func #---guiqwt related attributes: self.plot = None self.curve_item = None #--- def setup_widget(self, title): #---Create the plot widget: self.plot = CurvePlot(self) self.curve_item = make.curve([], [], color='b') self.plot.add_item(self.curve_item) self.plot.set_antialiasing(True) #--- button = QPushButton("Test filter: %s" % title) button.clicked.connect(self.process_data) vlayout = QVBoxLayout() vlayout.addWidget(self.plot) vlayout.addWidget(button) self.setLayout(vlayout) self.update_curve() def process_data(self): self.y = self.func(self.y) self.update_curve() def update_curve(self): #---Update curve self.curve_item.set_data(self.x, self.y) self.plot.replot()
class iScopeWidget(QWidget): """ Filter testing widget parent: parent widget (QWidget) x, y: NumPy arrays func: function object (the signal filter to be tested) """ def __init__(self, parent, x, y): QWidget.__init__(self, parent) self.setMinimumSize(320, 200) self.x = x self.y = y # ---guiqwt related attributes: self.plot = None self.curve_item = None # --- def setup_widget(self): # ---Create the plot widget: x = self.x y = self.y self.plot = CurvePlot(self) self.curve_item = make.curve([], [], color="b") self.plot.add_item(self.curve_item) self.plot.set_antialiasing(True) width = x[-1] - x[0] self.intrange = make.range(x[0] + 0.4 * width, x[-1] - 0.4 * width) self.plot.add_item(self.intrange) self.lbgrange = make.range(x[0] + 0.3 * width, x[-1] - 0.65 * width) self.plot.add_item(self.lbgrange) self.lbgrange.pen = Qt.QPen(Qt.QColor("blue")) self.lbgrange.brush = Qt.QBrush(Qt.QColor(0, 0, 120, 100)) self.rbgrange = make.range(x[0] + 0.7 * width, x[-1] - 0.1 * width) self.rbgrange.pen = Qt.QPen(Qt.QColor("blue")) self.rbgrange.brush = Qt.QBrush(Qt.QColor(0, 0, 120, 100)) self.label1 = make.label(r"", "TR", (0, 0), "TR") self.plot.add_item(self.rbgrange) self.bg_item = make.curve([], [], color="r") self.plot.add_item(self.bg_item) self.fit_bg() self.plot.add_item(self.label1) self.connect(self.plot, SIG_RANGE_CHANGED, self.fit_bg) # --- vlayout = QVBoxLayout() vlayout.addWidget(self.plot) self.setLayout(vlayout) self.update_curve() def fit_bg(self): degree = 3 table = array([self.x, self.y]) low, high = self.lbgrange.get_range() idxlower = set(where(table[0] <= high)[0]) idxhigher = set(where(table[0] >= low)[0]) idx1 = list(idxhigher.intersection(idxlower)) low, high = self.rbgrange.get_range() idxlower = set(where(table[0] <= high)[0]) idxhigher = set(where(table[0] >= low)[0]) idx2 = list(idxhigher.intersection(idxlower)) idx = idx1 + idx2 x, y = table[:, idx] self.coeff = polyfit(x, y, degree) left, right = self.intrange.get_range() # bg = abs(quad(lambda x: polyval(self.coeff, x), left, right)[0]) idxlower = set(where(table[0] <= right)[0]) idxhigher = set(where(table[0] >= left)[0]) idx = list(idxhigher.intersection(idxlower)) x, y = table[:, idx] self.int = abs(trapz(y - polyval(self.coeff, x), x=x)) self.update_label() self.update_curve() def update_label(self): self.label1.set_text(u"""trapz(red) - int(blue) = %e""" % self.int) def update_curve(self): # ---Update curve self.curve_item.set_data(self.x, self.y) self.plot.replot() y = polyval(self.coeff, self.x) self.bg_item.set_data(self.x, y)
def do_autoscale(self, replot=True): CurvePlot.do_autoscale(self, replot=replot) self.emit(SIG_PLOT_AXIS_CHANGED, self)
def fixed_do_zoom_rect_view(self, *args, **kwargs): CurvePlot.old_do_zoom_rect_view(self, *args, **kwargs) if old_guiqwt: self.emit(SIG_PLOT_AXIS_CHANGED, self) else: self.SIG_PLOT_AXIS_CHANGED.emit(self)
class PlotWidget(qg.QWidget): """ """ def __init__(self, parent): qg.QWidget.__init__(self, parent) self.data = Dbase(DBaseName = None) self.y1Data = np.arange(0,100) #self.data.Query() self.y2Data = np.arange(0,100) self.xData = np.arange(0,100) #np.arange(0, len(self.yData)) self.setMinimumSize(700, 600) #---guiqwt related attributes: self.plot = None self.curve_item = None #--- def setup_widget(self, title): """Create the plot widget: """ self.plot = CurvePlot(self) self.curve_item = (make.curve([], [], color='b')) self.second_curve_item = (make.curve([], [], color='g')) self.plot.add_item(self.curve_item) self.plot.add_item(self.second_curve_item) self.plot.set_antialiasing(True) self.databaseScroll = treeList(DBaseName = None) self.databaseScroll.setSortingEnabled(True) spacer = qg.QSpacerItem(30,40) preprocessData = qg.QGroupBox(u"preprocess data") # create buttons listButton = qg.QPushButton(u"Refresh list") processButton = qg.QPushButton(u" run preprocessing ") addwaveletButton = qg.QPushButton(u" add wavelet spikes to DB ") self.checkAddData = qg.QMessageBox() self.wavelet = qg.QCheckBox(u"wavelet filter ") label1 = qg.QLabel("enter threshold value: ") self.waveletThreshold = qg.QLineEdit(u"10") # connect user actions with methods: self.connect(listButton, qc.SIGNAL('clicked()'), self.but_clicked) self.connect(processButton, qc.SIGNAL('clicked()'), self.run_preprocess) self.connect(self.databaseScroll, qc.SIGNAL("doubleClicked(QModelIndex)"), self.double_clicked) self.connect(addwaveletButton, qc.SIGNAL('clicked()'), self.add_data_to_DBase) vlayout = qg.QVBoxLayout() hlayout = qg.QHBoxLayout() vlayout.addWidget(self.databaseScroll) vlayout.addWidget(listButton) vlayout.addWidget(self.plot) vlayout.addSpacerItem(spacer) hlayout.addWidget(self.wavelet) hlayout.addWidget(label1) hlayout.addWidget(self.waveletThreshold) hlayout.addWidget(processButton) hlayout.addWidget(addwaveletButton) preprocessData.setLayout(hlayout) vlayout.addWidget(preprocessData) self.setLayout(vlayout) self.update_curve() def run_preprocess(self): """ """ if self.wavelet.isChecked(): try: yData = self.y1Data waveletFilt = pp.wavefilter(yData) self.y1Data = waveletFilt thresh = float(self.waveletThreshold.displayText()) foo = self.y1Data > thresh self.y2Data = self.spikes = pp.spikeThreshold(foo) self.y2Data = self.y2Data * max(self.y1Data) index = self.databaseScroll root = index.parent().parent().row() neuron = index.parent().row() epoch = index.row() r = self.databaseScroll self.data = Dbase(r, PRINT = 1) n = self.databaseScroll epochs = self.data.GetTree(n) e = epochs[epoch] self.spikeOverwriteLoc = [r, n + '.' + e + '.spikes', n + '.' + e, n, n + '_' + e + '_spikes'] self.data.Data.CloseDatabase(PRINT=1) print 'spike handle: ', self.spikeOverwriteLoc[0:2] self.update_curve() except ValueError: print 'ValueError. Could not compute wave filter' pass def add_data_to_DBase(self): """ """ self.checkAddData.setText("Are you sure you want to add filtered \ spikes (green trace) to the DB?") self.checkAddData.setInformativeText("This will overwrite the existing\ spike data.") self.checkAddData.setStandardButtons(qg.QMessageBox.Yes | qg.QMessageBox.No ) self.checkAddData.setDefaultButton(qg.QMessageBox.Yes) choice = self.checkAddData.exec_() == qg.QMessageBox.Yes if choice: tim = dt.datetime.utcnow().ctime() self.data = Dbase(self.spikeOverwriteLoc[0], PRINT = 1) self.data.Data.RemoveChild(self.spikeOverwriteLoc[1], option=1) self.data.Data.AddData2Database('spikes', self.spikes, self.spikeOverwriteLoc[2]) self.data.Data.AddGitVersion(self.spikeOverwriteLoc[3], Action = 'updated_{0}'.format( self.spikeOverwriteLoc[4] + str(tim.day) + '_' + str(tim.month) + '_' + str(tim.year) )) self.data.Data.CloseDatabase(PRINT=1) """ add git version here """ print 'spike data successfully overwritten.' def update_curve(self): """Update curve """ self.curve_item.set_data(self.xData, self.y1Data) self.second_curve_item.set_data(self.xData, self.y2Data) self.plot.replot() self.plot.do_autoscale() def but_clicked(self): """ when refresh button is clicked, the tree is refreshed """ self.databaseScroll.refreshTree() def double_clicked(self): """ when a name button is clicked, iterate over the model, find the neuron with this name, and set the treeviews current item """ index = self.databaseScroll.currentIndex() item = self.databaseScroll.currentItem() clickedCol = index.column() hasChild = True ind = index.parent() colCount = 1 parents = [] while hasChild: #find root index and parents root = ind.row() if root != -1: parent = str(self.databaseScroll.itemFromIndex( ind).text(clickedCol - colCount)) parents.insert(0, parent) if root == -1: hasChild = False if parents == []: parent = str(self.databaseScroll.itemFromIndex( index).text(0)) parents.insert(0, parent) ind = ind.parent() colCount += 1 name = str(item.text(clickedCol)) print 'name: ', name print 'parents: ', parents if len(parents) == 1: parents.append('') if name[:-3] == '.h5': name = '/' kind = self.databaseScroll.GetDtype(parents[0], name, parents[1:]) print kind #if dtype_ == 'np.array': # clickedData = self.databaseScroll.GetData(parents[0], name, # parents[1:]) # print clickedData '''
def __init__(self, axis=None, updateWidgets=None, *args, **kwargs): CurvePlot.__init__(self, *args, **kwargs) self.axis = axis self.tmp_axis = None self.updateWidgets = updateWidgets
def setup_widget(self, title): """Create the plot widget: """ self.plot = CurvePlot(self) self.curve_item = (make.curve([], [], color='b')) self.second_curve_item = (make.curve([], [], color='g')) self.plot.add_item(self.curve_item) self.plot.add_item(self.second_curve_item) self.plot.set_antialiasing(True) self.databaseScroll = treeList(DBaseName = None) self.databaseScroll.setSortingEnabled(True) spacer = qg.QSpacerItem(30,40) preprocessData = qg.QGroupBox(u"preprocess data") # create buttons listButton = qg.QPushButton(u"Refresh list") processButton = qg.QPushButton(u" run preprocessing ") addwaveletButton = qg.QPushButton(u" add wavelet spikes to DB ") self.checkAddData = qg.QMessageBox() self.wavelet = qg.QCheckBox(u"wavelet filter ") label1 = qg.QLabel("enter threshold value: ") self.waveletThreshold = qg.QLineEdit(u"10") # connect user actions with methods: self.connect(listButton, qc.SIGNAL('clicked()'), self.but_clicked) self.connect(processButton, qc.SIGNAL('clicked()'), self.run_preprocess) self.connect(self.databaseScroll, qc.SIGNAL("doubleClicked(QModelIndex)"), self.double_clicked) self.connect(addwaveletButton, qc.SIGNAL('clicked()'), self.add_data_to_DBase) vlayout = qg.QVBoxLayout() hlayout = qg.QHBoxLayout() vlayout.addWidget(self.databaseScroll) vlayout.addWidget(listButton) vlayout.addWidget(self.plot) vlayout.addSpacerItem(spacer) hlayout.addWidget(self.wavelet) hlayout.addWidget(label1) hlayout.addWidget(self.waveletThreshold) hlayout.addWidget(processButton) hlayout.addWidget(addwaveletButton) preprocessData.setLayout(hlayout) vlayout.addWidget(preprocessData) self.setLayout(vlayout) self.update_curve()
def __init__(self, parent=None, view_duration = 10., t_start = 0., zoom_limit = (0.001, 100), analogsignals = None, spiketrains = None, vlimits = None, nplot = 1, ): QWidget.__init__(self, parent) self.zoom_limit = zoom_limit self.mainlayout = QVBoxLayout() self.setLayout(self.mainlayout) self.analogsignals =analogsignals self.spiketrains = spiketrains self.vlimits = vlimits self.nplot = nplot self.selectedspikes = [ ] self.plots = [ ] for i in range(nplot): plot = CurvePlot() self.mainlayout.addWidget(plot) self.plots.append(plot) plot.del_all_items(except_grid=False) # TODO : # xaxis off fo i>0 self.x_min,self.x_max = 0., 60. self.y_min , self.y_max = -1., 1. h = QHBoxLayout() self.mainlayout.addLayout(h) # position h.addWidget(QLabel('Pos')) self.hslider = QSlider(Qt.Horizontal) self.hslider.setMaximum(1000) h.addWidget(self.hslider,6) #self.hspinbox = QDoubleSpinBox(decimals=3, minimum = -np.inf, maximum =np.inf, value = 0.) self.hspinbox = QDoubleSpinBox() self.hspinbox.setDecimals(3) self.hspinbox.setMinimum( -np.inf) self.hspinbox.setMaximum( np.inf) self.hspinbox.setValue( 0.) h.addWidget(self.hspinbox,3) #self.popupStep = QToolButton(popupMode = QToolButton.MenuButtonPopup, toolButtonStyle = Qt.ToolButtonTextBesideIcon) self.popupStep = QToolButton( ) self.popupStep.setPopupMode( QToolButton.MenuButtonPopup ) self.popupStep.setToolButtonStyle( Qt.ToolButtonTextBesideIcon ) self.popupStep.setText('step') h.addWidget(self.popupStep) h.addSpacing(20) self.hslider.valueChanged.connect(self.hsliderChanged) self.hspinbox.valueChanged.connect(self.refresh) #~ self.actPopup = [ ] #ag = QActionGroup(self.popupStep, exclusive = True) ag = QActionGroup(self.popupStep ) ag.setExclusive( True) for s in ['60s','10s', '1s', '100ms', '5ms' ]: #act = QAction(s, self.popupStep, checkable = True) act = QAction(s, self.popupStep) act.setCheckable( True) ag.addAction(act) self.popupStep.addAction(act) ag.triggered.connect(self.changeHStep) #H zoom factor h.addWidget(QLabel('HZoom')) #self.hzslider= QSlider(Qt.Horizontal, minimum = 0, maximum = 100,) self.hzslider= QSlider(Qt.Horizontal) self.hzslider.setMinimum( 0 ) self.hzslider.setMaximum( 100) h.addWidget(self.hzslider,1) self.hzslider.valueChanged.connect(self.hzsliderChanged) #self.hzspinbox = QDoubleSpinBox(decimals=5,value=1., singleStep = .1, # minimum = self.zoom_limit[0], maximum = self.zoom_limit[1],) self.hzspinbox = QDoubleSpinBox( ) self.hzspinbox.setDecimals(5) self.hzspinbox.setValue(1.) self.hzspinbox.setSingleStep( .1 ) self.hzspinbox.setMinimum(self.zoom_limit[0]) self.hzspinbox.setMaximum( self.zoom_limit[1]) h.addWidget(self.hzspinbox) self.hzspinbox.valueChanged.connect(self.hzspinboxChanged) self.hzspinbox.setValue(view_duration) self.hzspinbox.valueChanged.connect(self.refresh) h.addSpacing(20) # V zoom v = QVBoxLayout() h.addLayout(v) #self.vz2spinbox = QDoubleSpinBox(decimals=5,value=1., singleStep = .1, minimum = -np.inf, maximum =np.inf,) self.vz2spinbox = QDoubleSpinBox( ) self.vz2spinbox.setDecimals(5 ) self.vz2spinbox.setValue( 1. ) self.vz2spinbox.setSingleStep( .1 ) self.vz2spinbox.setMinimum( -np.inf ) self.vz2spinbox.setMaximum( np.inf ) v.addWidget(self.vz2spinbox) #self.vz1spinbox = QDoubleSpinBox(decimals=5,value=-1., singleStep = .1, minimum = -np.inf, maximum =np.inf,) self.vz1spinbox = QDoubleSpinBox( ) self.vz1spinbox.setDecimals(5) self.vz1spinbox.setValue( -1. ) self.vz1spinbox.setSingleStep( .1 ) self.vz1spinbox.setMinimum( -np.inf) self.vz1spinbox.setMaximum( np.inf) v.addWidget(self.vz1spinbox) self.vz2spinbox.valueChanged.connect(self.vzspinboxChanged) self.vz1spinbox.valueChanged.connect(self.vzspinboxChanged) #~ self.vz2spinbox.valueChanged.connect(self.refresh) #~ self.vz1spinbox.valueChanged.connect(self.refresh) # self.changeData( analogsignals = analogsignals, spiketrains = spiketrains, vlimits = vlimits, )
class UI(QtGui.QMainWindow): def __init__(self, parent=None): super(UI, self).__init__(parent) self.ui_obj = None self.y_position = 0 self.slider_pos = 0 self.image_temp = None self.image_w = 0 self.image_h = 0 self.image_path = None self.ui_init() self.init_connect() self.plot_init() def ui_init(self): self.ui_obj = Ui_MainWindow() self.ui_obj.setupUi(self) def init_connect(self): self.connect(self.ui_obj.y_verticalSlider, QtCore.SIGNAL('valueChanged(int)'), self.plot_line_gray) self.ui_obj.open_image_button.clicked.connect(self.open_image) self.ui_obj.save_plot_button.clicked.connect(self.save_image) def open_image(self): self.file_name = QtGui.QFileDialog.getOpenFileName( self, "open file dialog", "C:\Users\Administrator\Desktop", "*.jpg *.png") print self.file_name if self.file_name != "": # if self.ui_obj.image_path_lineEdit.text() != "": # self.image_path = self.ui_obj.image_path_lineEdit.text() self.image_path = self.file_name if os.path.exists(self.image_path): self.display_image() else: # self.image_clean() print "path is not exists!!\n" else: # self.image_clean() print "pls fill imagepath\n" def save_image(self): pass def image_clean(self): self.image_temp = None self.image_w = 0 self.image_h = 0 def display_image(self): # print "cv2 imread path :"+str(self.image_path) self.image_temp = cv2.imread(str(self.image_path)) self.image_h = len(self.image_temp) self.image_w = len(self.image_temp[0]) # #print image.shape[1],image.shape[0] # #print self.ui_obj.picture_display.width(),self.ui_obj.picture_display.height() # qimage = QtGui.QImage(image, image.shape[1], image.shape[0], QtGui.QImage.Format_RGB888) # qimage_resize = qimage.scaled(self.ui_obj.picture_display.width(), self.ui_obj.picture_display.height(), 0, 0) # self.ui_obj.picture_display.setPixmap(QtGui.QPixmap.fromImage(qimage_resize)) # self.ui_obj.picture_display.show() pixmap = QtGui.QPixmap() pixmap.load(str(self.image_path)) newpixmap = pixmap.scaled(self.ui_obj.picture_display.width(), self.ui_obj.picture_display.height(), 0, 0) self.ui_obj.picture_display.setPixmap(newpixmap) self.ui_obj.picture_display.setAlignment(QtCore.Qt.AlignCenter) self.ui_obj.picture_display.show() def plot_init(self): self.manager = PlotManager(self) self.plots = [] self.plot = CurvePlot(xlabel="", ylabel="") # self.plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(10) self.manager.add_plot(self.plot) self.plots.append(self.plot) self.plot.plot_id = id(self.plot) self.curve = make.curve([0], [0], color="blue", title="gray value") self.plot.add_item(self.curve) self.plot.add_item(make.legend("TR")) self.ui_obj.line_info_display.addWidget(self.plot) def plot_line_gray(self): self.slider_pos = self.ui_obj.y_verticalSlider.value() # print"print line ",self.slider_pos # print type(self.slider_pos), len(self.image_temp) self.y_position = (100 - self.slider_pos) * (int(self.image_h) / 100) print "y_position:", self.y_position line = [ self.image_temp[self.y_position][i][1] for i in range(len(self.image_temp[self.y_position])) ] print len(line), [i for i in range(len(line))] self.plot.set_axis_limits('left', 0, 255) self.plot.set_axis_limits('bottom', 0, self.image_w) self.curve.set_data([i for i in range(len(line))], line) self.plot.replot() # print "image :", self.image_temp[3] def blur(self, kernel): pass def nosie(self, method): pass
def fixed_do_zoom_rect_view(self, *args, **kwargs): CurvePlot.old_do_zoom_rect_view(self, *args, **kwargs) self.emit(SIG_PLOT_AXIS_CHANGED, self)
def do_zoom_rect_view(self, start, end): CurvePlot.do_zoom_rect_view(self, start, end) self.emit(SIG_PLOT_AXIS_CHANGED, self)
def __init__(self, *args, **kwargs): CurvePlot.__init__(self, *args, **kwargs)
def __init__( self, parent=None, view_duration=10., t_start=0., zoom_limit=(0.001, 100), analogsignals=None, spiketrains=None, vlimits=None, nplot=1, ): QWidget.__init__(self, parent) self.zoom_limit = zoom_limit self.mainlayout = QVBoxLayout() self.setLayout(self.mainlayout) self.analogsignals = analogsignals self.spiketrains = spiketrains self.vlimits = vlimits self.nplot = nplot self.selectedspikes = [] self.plots = [] for i in range(nplot): plot = CurvePlot() self.mainlayout.addWidget(plot) self.plots.append(plot) plot.del_all_items(except_grid=False) # TODO : # xaxis off fo i>0 self.x_min, self.x_max = 0., 60. self.y_min, self.y_max = -1., 1. h = QHBoxLayout() self.mainlayout.addLayout(h) # position h.addWidget(QLabel('Pos')) self.hslider = QSlider(Qt.Horizontal) self.hslider.setMaximum(1000) h.addWidget(self.hslider, 6) #self.hspinbox = QDoubleSpinBox(decimals=3, minimum = -np.inf, maximum =np.inf, value = 0.) self.hspinbox = QDoubleSpinBox() self.hspinbox.setDecimals(3) self.hspinbox.setMinimum(-np.inf) self.hspinbox.setMaximum(np.inf) self.hspinbox.setValue(0.) h.addWidget(self.hspinbox, 3) #self.popupStep = QToolButton(popupMode = QToolButton.MenuButtonPopup, toolButtonStyle = Qt.ToolButtonTextBesideIcon) self.popupStep = QToolButton() self.popupStep.setPopupMode(QToolButton.MenuButtonPopup) self.popupStep.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.popupStep.setText('step') h.addWidget(self.popupStep) h.addSpacing(20) self.hslider.valueChanged.connect(self.hsliderChanged) self.hspinbox.valueChanged.connect(self.refresh) #~ self.actPopup = [ ] #ag = QActionGroup(self.popupStep, exclusive = True) ag = QActionGroup(self.popupStep) ag.setExclusive(True) for s in ['60s', '10s', '1s', '100ms', '5ms']: #act = QAction(s, self.popupStep, checkable = True) act = QAction(s, self.popupStep) act.setCheckable(True) ag.addAction(act) self.popupStep.addAction(act) ag.triggered.connect(self.changeHStep) #H zoom factor h.addWidget(QLabel('HZoom')) #self.hzslider= QSlider(Qt.Horizontal, minimum = 0, maximum = 100,) self.hzslider = QSlider(Qt.Horizontal) self.hzslider.setMinimum(0) self.hzslider.setMaximum(100) h.addWidget(self.hzslider, 1) self.hzslider.valueChanged.connect(self.hzsliderChanged) #self.hzspinbox = QDoubleSpinBox(decimals=5,value=1., singleStep = .1, # minimum = self.zoom_limit[0], maximum = self.zoom_limit[1],) self.hzspinbox = QDoubleSpinBox() self.hzspinbox.setDecimals(5) self.hzspinbox.setValue(1.) self.hzspinbox.setSingleStep(.1) self.hzspinbox.setMinimum(self.zoom_limit[0]) self.hzspinbox.setMaximum(self.zoom_limit[1]) h.addWidget(self.hzspinbox) self.hzspinbox.valueChanged.connect(self.hzspinboxChanged) self.hzspinbox.setValue(view_duration) self.hzspinbox.valueChanged.connect(self.refresh) h.addSpacing(20) # V zoom v = QVBoxLayout() h.addLayout(v) #self.vz2spinbox = QDoubleSpinBox(decimals=5,value=1., singleStep = .1, minimum = -np.inf, maximum =np.inf,) self.vz2spinbox = QDoubleSpinBox() self.vz2spinbox.setDecimals(5) self.vz2spinbox.setValue(1.) self.vz2spinbox.setSingleStep(.1) self.vz2spinbox.setMinimum(-np.inf) self.vz2spinbox.setMaximum(np.inf) v.addWidget(self.vz2spinbox) #self.vz1spinbox = QDoubleSpinBox(decimals=5,value=-1., singleStep = .1, minimum = -np.inf, maximum =np.inf,) self.vz1spinbox = QDoubleSpinBox() self.vz1spinbox.setDecimals(5) self.vz1spinbox.setValue(-1.) self.vz1spinbox.setSingleStep(.1) self.vz1spinbox.setMinimum(-np.inf) self.vz1spinbox.setMaximum(np.inf) v.addWidget(self.vz1spinbox) self.vz2spinbox.valueChanged.connect(self.vzspinboxChanged) self.vz1spinbox.valueChanged.connect(self.vzspinboxChanged) #~ self.vz2spinbox.valueChanged.connect(self.refresh) #~ self.vz1spinbox.valueChanged.connect(self.refresh) # self.changeData( analogsignals=analogsignals, spiketrains=spiketrains, vlimits=vlimits, )