예제 #1
0
 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()
예제 #2
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin, trapz

    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))

    curve = make.curve(x, y, "ab", "b")
    range = make.range(-2, 2)
    disp0 = make.range_info_label(range,
                                  "BR",
                                  "x = %.1f ± %.1f cm",
                                  title="Range infos")

    disp1 = make.computation(range, "BL", "trapz=%g", curve,
                             lambda x, y: trapz(y, x))

    disp2 = make.computations(
        range,
        "TL",
        [
            (curve, "min=%.5f", lambda x, y: y.min()),
            (curve, "max=%.5f", lambda x, y: y.max()),
            (curve, "avg=%.5f", lambda x, y: y.mean()),
        ],
    )
    legend = make.legend("TR")
    plot(curve, range, disp0, disp1, disp2, legend)
예제 #3
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin, trapz

    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))

    curve = make.curve(x, y, "ab", "b")
    range = make.range(-2, 2)
    disp0 = make.range_info_label(range, "BR", "x = %.1f ± %.1f cm", title="Range infos")

    disp1 = make.computation(range, "BL", "trapz=%g", curve, lambda x, y: trapz(y, x))

    disp2 = make.computations(
        range,
        "TL",
        [
            (curve, "min=%.5f", lambda x, y: y.min()),
            (curve, "max=%.5f", lambda x, y: y.max()),
            (curve, "avg=%.5f", lambda x, y: y.mean()),
        ],
    )
    legend = make.legend("TR")
    plot(curve, range, disp0, disp1, disp2, legend)
예제 #4
0
    def add_range_to_plot(self, plot, this_range):

        self.myrange = make.range(this_range[0], this_range[1])
        self.myrange.itemChanged()
        self.myrange.set_movable(False)

        if False:
            # make all colors black/gray
            # check /usr/lib/python2.7/dist-packages/guiqwt/config.py for parameters
            # 
            from guidata.dataset.dataitems import ColorItem
            self.myrange.shapeparam.fill = ColorItem("gray")
            self.myrange.shapeparam.line.color = "#000000"
            self.myrange.shapeparam.sel_line.color = "#000000"
            self.myrange.shapeparam.symbol.facecolor = "#000000"
            self.myrange.shapeparam.sel_symbol.facecolor = "#000000"
            #
            self.myrange.shapeparam.update_range(self.myrange) # creates all the above QObjects

        self.myrange.set_resizable(False)
        self.myrange.itemChanged()

        # print self.myrange._can_move, "move"
        # disp2 = make.computations(self.myrange, "TL",
        #                               [(curve, "min=%.5f", lambda x,y: y.min()),
        #                                (curve, "max=%.5f", lambda x,y: y.max()),
        #                                (curve, "avg=%.5f", lambda x,y: y.mean())])
        # plot.add_item( disp2 )
        plot.add_item( self.myrange )
        self.myranges.append( self.myrange )
예제 #5
0
파일: helper.py 프로젝트: mczhu/spykeutils
def add_epochs(plot, epochs, units=None):
    """ Add Epoch markers to a guiqwt plot.

    :param plot: The plot object.
    :type plot: :class:`guiqwt.baseplot.BasePlot`
    :param sequence epochs: The epochs (neo :class:`neo.Epoch` objects).
    :param units: The x-scale of the plot. If this is ``None``,
        the time unit of the events will be use.
    """
    for e in epochs:
        if units:
            start = e.time.rescale(units)
            end = (e.time + e.duration).rescale(units)
        else:
            start = e.time
            end = e.time + e.duration
        time = (start + end) / 2.0

        o = make.range(start, end)
        o.setTitle(e.label)
        o.set_readonly(True)
        o.set_movable(False)
        o.set_resizable(False)
        o.set_selectable(False)
        o.set_rotatable(False)
        plot.add_item(o)

        nameObject = _MarkerName(e.label)
        plot.add_item(make.marker(
            (time, 0), nameObject.get_name,
            movable=False, markerstyle='|', color='k', linestyle='NoPen',
            linewidth=1))
    def testFcn(self):
        x = np.linspace(0, 100, 1000)

        y = (np.random.rand(len(x)) - 0.5).cumsum()

        curve = make.curve(x, y, "ab", "b")
        range = make.range(0, 5)

        disp2 = make.computations(
            range,
            "TL",
            [
                (curve, "min=%.5f", lambda x, y: y.min()),
                (curve, "max=%.5f", lambda x, y: y.max()),
                (curve, "avg=%.5f", lambda x, y: y.mean()),
            ],
        )
        legend = make.legend("TR")
        items = [curve, range, disp2, legend]

        win = CurveDialog(edit=False, toolbar=True, parent=self)
        plot = win.get_plot()
        for item in items:
            plot.add_item(item)
        win.show()
예제 #7
0
    def add_range_to_plot(self, plot, this_range):

        self.myrange = make.range(this_range[0], this_range[1])
        self.myrange.itemChanged()
        self.myrange.set_movable(False)

        if False:
            # make all colors black/gray
            # check /usr/lib/python2.7/dist-packages/guiqwt/config.py for parameters
            #
            from guidata.dataset.dataitems import ColorItem
            self.myrange.shapeparam.fill = ColorItem("gray")
            self.myrange.shapeparam.line.color = "#000000"
            self.myrange.shapeparam.sel_line.color = "#000000"
            self.myrange.shapeparam.symbol.facecolor = "#000000"
            self.myrange.shapeparam.sel_symbol.facecolor = "#000000"
            #
            self.myrange.shapeparam.update_range(
                self.myrange)  # creates all the above QObjects

        self.myrange.set_resizable(False)
        self.myrange.itemChanged()

        # print self.myrange._can_move, "move"
        # disp2 = make.computations(self.myrange, "TL",
        #                               [(curve, "min=%.5f", lambda x,y: y.min()),
        #                                (curve, "max=%.5f", lambda x,y: y.max()),
        #                                (curve, "avg=%.5f", lambda x,y: y.mean())])
        # plot.add_item( disp2 )
        plot.add_item(self.myrange)
        self.myranges.append(self.myrange)
예제 #8
0
 def process(self):
     params = {}
     print(self.tableWidget.rowCount())
     for i in range(self.tableWidget.rowCount()):
         a = self.tableWidget.item(i, 0)
         b = self.tableWidget.item(i, 1)
         params[str(a.text())] = int(b.text())
    # print "params",params
     outpN = self.tableWidget.item(0, 0)
     #params = {"none": "none", "output_length": outpN}
     '''
     if self.currentdata==[]:
         data = self.prc.preprocData(self.flowData, params)
     else:
         data = self.prc.preprocData(self.currentdata, params)
     '''
     #self.dc.setCurrentDataFlowObject(data)
     #print data
     if params==[]:
         data = self.prc.preprocData(self.flowData, params)
     elif params!=[]:
         data = self.prc.preprocData(self.flowData, params)
     self.plot.del_all_items()
     print data
     print type(data)
     self.plot.add_item(make.curve(range(0, len(data)), data))
     self.rangeSelection = make.range(-2, 2)
     disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm",
                                   title="Range infos")
     #self.plot.add_item(self.rangeSelection)
     #self.plot.add_item(disp0)
     self.plot.replot()
     #self.dc.setCurrentDataFlowObject(data)
     self.dc.preprocData = data
     self.currentdata = np.reshape(data, (-1, 1))
예제 #9
0
 def loadData(self):
     self.trainingData = self.dataController.loadSampleData()
     self.plot.add_item(make.curve(range(0, self.trainingData.shape[0]), self.trainingData["PIR"][:]))
     self.rangeSelection = make.range(-2, 2)
     disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm",
                                   title="Range infos")
     self.plot.add_item(self.rangeSelection)
     self.plot.add_item(disp0)
     self.plot.replot()
예제 #10
0
파일: fit.py 프로젝트: gyenney/Tools
    def refresh(self, slider_value=None):
        """Refresh Fit Tool dialog box"""
        # Update button states
        enable = self.x is not None and self.y is not None \
                 and self.x.size > 0 and self.y.size > 0 \
                 and self.fitfunc is not None and self.fitparams is not None \
                 and len(self.fitparams) > 0
        for btn in self.button_list:
            btn.setEnabled(enable)

        if not enable:
            # Fit widget is not yet configured
            return

        fitargs, fitkwargs = self.get_fitfunc_arguments()
        yfit = self.fitfunc(self.x, [p.value for p in self.fitparams],
                            *fitargs, **fitkwargs)

        plot = self.get_plot()

        if self.legend is None:
            self.legend = make.legend(anchor=self.legend_anchor)
            plot.add_item(self.legend)

        if self.xrange is None:
            self.xrange = make.range(0., 1.)
            plot.add_item(self.xrange)
        self.xrange.set_range(self.autofit_prm.xmin, self.autofit_prm.xmax)
        self.xrange.setVisible(self.show_xrange)

        if self.data_curve is None:
            self.data_curve = make.curve([], [],
                                         _("Data"),
                                         color="b",
                                         linewidth=2)
            plot.add_item(self.data_curve)
        self.data_curve.set_data(self.x, self.y)

        if self.fit_curve is None:
            self.fit_curve = make.curve([], [],
                                        _("Fit"),
                                        color="r",
                                        linewidth=2)
            plot.add_item(self.fit_curve)
        self.fit_curve.set_data(self.x, yfit)

        plot.replot()
        plot.disable_autoscale()
예제 #11
0
 def loadData(self):
     self.trainingData = self.dataController.loadSampleData()
     import logic.DimensionalityReduceControl as controller
     c = controller.DimensionalityReduceControl()
     c.selectAlgorithm(2)
     outpN = 100
     params = {"none": "none", "output_length": outpN}
     data = c.reduceData(self.trainingData["PIR"][:],params)
     print data
     self.plot.add_item(make.curve(range(0, len(data)), data))
     self.rangeSelection = make.range(-2, 2)
     disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm",
                                   title="Range infos")
     self.plot.add_item(self.rangeSelection)
     self.plot.add_item(disp0)
     self.plot.replot()
예제 #12
0
파일: fit.py 프로젝트: CaptainAL/Spyder
    def refresh(self, slider_value=None):
        """Refresh Fit Tool dialog box"""
        # Update button states
        enable = self.x is not None and self.y is not None \
                 and self.x.size > 0 and self.y.size > 0 \
                 and self.fitfunc is not None and self.fitparams is not None \
                 and len(self.fitparams) > 0
        for btn in self.button_list:
            btn.setEnabled(enable)
            
        if not enable:
            # Fit widget is not yet configured
            return

        fitargs, fitkwargs = self.get_fitfunc_arguments()
        yfit = self.fitfunc(self.x, [p.value for p in self.fitparams],
                            *fitargs, **fitkwargs)
                            
        plot = self.get_plot()
        
        if self.legend is None:
            self.legend = make.legend(anchor=self.legend_anchor)
            plot.add_item(self.legend)
        
        if self.xrange is None:
            self.xrange = make.range(0., 1.)
            plot.add_item(self.xrange)
        self.xrange.set_range(self.autofit_prm.xmin, self.autofit_prm.xmax)
        self.xrange.setVisible(self.show_xrange)
        
        if self.data_curve is None:
            self.data_curve = make.curve([], [],
                                         _("Data"), color="b", linewidth=2)
            plot.add_item(self.data_curve)
        self.data_curve.set_data(self.x, self.y)
        
        if self.fit_curve is None:
            self.fit_curve = make.curve([], [],
                                        _("Fit"), color="r", linewidth=2)
            plot.add_item(self.fit_curve)
        self.fit_curve.set_data(self.x, yfit)
        
        plot.replot()
        plot.disable_autoscale()
예제 #13
0
    def testFcn(self):
        x = np.linspace(0, 100, 1000)

        y = (np.random.rand(len(x)) - 0.5).cumsum()

        curve = make.curve(x, y, "ab", "b")
        range = make.range(0, 5)

        disp2 = make.computations(range, "TL",
                                  [(curve, "min=%.5f", lambda x, y: y.min()),
                                   (curve, "max=%.5f", lambda x, y: y.max()),
                                   (curve, "avg=%.5f", lambda x, y: y.mean())])
        legend = make.legend("TR")
        items = [curve, range, disp2, legend]

        win = CurveDialog(edit=False, toolbar=True, parent=self)
        plot = win.get_plot()
        for item in items:
            plot.add_item(item)
        win.show()
예제 #14
0
    def plot(self, pdDataFrame):
        ''' plot some random stuff '''
        x1 = pdDataFrame.index
        y1 = pdDataFrame['Close']
        x = np.linspace(0, 100, 1000)

        y = (np.random.rand(len(x)) - 0.5).cumsum()

        curve = make.curve(x1, y1, "ab", "b")
        range = make.range(0, 5)

        disp2 = make.computations(range, "TL",
                                  [(curve, "min=%.5f", lambda x, y: y.min()),
                                   (curve, "max=%.5f", lambda x, y: y.max()),
                                   (curve, "avg=%.5f", lambda x, y: y.mean())])
        legend = make.legend("TR")
        #        items = [ curve, range, disp2, legend]
        items = [curve]

        self.plotw = self.gWindow.get_plot()
        for item in items:
            self.plotw.add_item(item)
예제 #15
0
파일: response.py 프로젝트: horsje/tril
    def __init__(self, *args):
        super(ResponseDlg, self).__init__(*args)

        self.setupUi(self)

        self.plotWidget.plot.set_axis_limits('left', 0, 2)
        self.plotWidget.plot.set_axis_limits('bottom', 1, 400)
        self.plotWidget.plot.set_axis_title('bottom', 'freq [Hz]')
        self.plotWidget.plot.set_axis_scale('bottom', 'log')
        self.plotWidget.register_all_curve_tools()

        self.resultTrace = make.curve([], [], 'Spectrum', color='b')
        self.plotWidget.plot.add_item(self.resultTrace)
        self.upper_limit = make.curve([], [], 'UL', color='r')
        self.plotWidget.plot.add_item(self.upper_limit)
        self.lower_limit = make.curve([], [], 'LL', color='r')
        self.plotWidget.plot.add_item(self.lower_limit)

        self.rng = make.range(0, 0)
        self.math = make.computations(self.rng, "TR",
                             [(self.resultTrace, "total=%.2f", lambda x, y: (y**2).sum()**.5)])
        self.plotWidget.plot.add_item(self.rng)
        self.plotWidget.plot.add_item(self.math)
        self.hide_total_range()
예제 #16
0
def add_epochs(plot, epochs, units=None):
    """ Add Epoch markers to a guiqwt plot.

    :param plot: The plot object.
    :type plot: :class:`guiqwt.baseplot.BasePlot`
    :param sequence epochs: The epochs (neo :class:`neo.Epoch` objects).
    :param units: The x-scale of the plot. If this is ``None``,
        the time unit of the events will be use.
    """
    for e in epochs:
        if units:
            start = e.time.rescale(units)
            end = (e.time + e.duration).rescale(units)
        else:
            start = e.time
            end = e.time + e.duration
        time = (start + end) / 2.0

        o = make.range(start, end)
        o.setTitle(e.label)
        o.set_readonly(True)
        o.set_movable(False)
        o.set_resizable(False)
        o.set_selectable(False)
        o.set_rotatable(False)
        plot.add_item(o)

        nameObject = _MarkerName(e.label)
        plot.add_item(
            make.marker((time, 0),
                        nameObject.get_name,
                        movable=False,
                        markerstyle='|',
                        color='k',
                        linestyle='NoPen',
                        linewidth=1))
예제 #17
0
    def __init__(self, fit):
        Plot.__init__(self, fit)

        self.layout = QtWidgets.QVBoxLayout(self)
        self.source = fit.surface
        self.d1 = np.array([0.0])
        self.d2 = np.array([0.0])

        top_left = QtWidgets.QFrame(self)
        top_left.setMaximumHeight(150)
        top_left.setFrameShape(QtWidgets.QFrame.StyledPanel)
        topl = QtWidgets.QVBoxLayout(top_left)

        top_right = QtWidgets.QFrame(self)
        top_right.setMaximumHeight(150)
        top_right.setFrameShape(QtWidgets.QFrame.StyledPanel)
        topr = QtWidgets.QVBoxLayout(top_right)

        bottom = QtWidgets.QFrame(self)
        bottom.setFrameShape(QtWidgets.QFrame.StyledPanel)
        bot = QtWidgets.QVBoxLayout(bottom)

        splitter1 = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        splitter1.addWidget(top_left)
        splitter1.addWidget(top_right)

        splitter2 = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        splitter2.addWidget(splitter1)
        splitter2.addWidget(bottom)
        self.splitter = splitter2

        self.layout.addWidget(splitter2)

        # x-axis
        win = CurveDialog()
        self.g_xplot = win.get_plot()
        self.g_xhist_m = make.histogram([], color='#ff00ff')
        self.g_xhist_a = make.histogram([], color='#6f0000')
        self.g_xplot.add_item(self.g_xhist_a)
        self.g_xplot.add_item(self.g_xhist_m)
        topl.addWidget(self.g_xplot)

        # y-axis
        win = CurveDialog()
        self.g_yplot = win.get_plot()
        self.g_yhist_m = make.histogram([], color='#00ff00')
        self.g_yhist_a = make.histogram([], color='#006600')
        self.g_yplot.add_item(self.g_yhist_a)
        self.g_yplot.add_item(self.g_yhist_m)
        topr.addWidget(self.g_yplot)

        # 2D-Histogram
        self.g_hist2d_m = make.histogram2D(np.array([0.0, 0.0]), np.array([0.0, 0.0]), logscale=True)
        self.g_hist2d_a = make.histogram2D(np.array([0.0, 0.0]), np.array([0.0, 0.0]), logscale=True)
        self.g_hist2d_m.set_color_map('hot')
        self.g_hist2d_a.set_color_map('Blues')
        #self.g_hist2d_m.set_interpolation(INTERP_LINEAR)
        #self.g_hist2d_a.set_interpolation(INTERP_LINEAR)

        win = ImageDialog(edit=False, toolbar=False)
        self.g_xyplot = win.get_plot()
        self.g_xyplot.set_aspect_ratio(lock=False)
        self.g_xyplot.add_item(self.g_hist2d_a)
        self.g_xyplot.add_item(self.g_hist2d_m)
        bot.addWidget(win)

        #selection
        self.selection_x = make.range(.25, .5)
        self.g_xplot.add_item(self.selection_x)

        self.selection_y = make.range(.25, .5)
        self.g_yplot.add_item(self.selection_y)

        self.pltControl = SurfacePlotWidget(self)
        self.widgets = [self.pltControl]
예제 #18
0
    def refresh(self, slider_value=None):
        """Refresh Fit Tool dialog box"""
        # Update button states
        enable = self.x is not None and self.y is not None \
                 and self.x.size > 0 and self.y.size > 0 \
                 and self.fitfunc is not None and self.fitparams is not None \
                 and len(self.fitparams) > 0
        for btn in self.button_list:
            btn.setEnabled(enable)

        if not enable:
            # Fit widget is not yet configured
            return

        plot = self.get_plot()

        if self.xrange is None:
            self.xrange = make.range(0., 1.)
            plot.add_item(self.xrange)

        self.xrange.set_range(self.autofit_prm.xmin, self.autofit_prm.xmax)
        self.xrange.setVisible(self.show_xrange)

        if self.data_curve is None:
            self.data_curve = make.curve([], [],
                                         _("Data"),
                                         color="b",
                                         marker='o',
                                         markerfacecolor='w',
                                         markersize=8,
                                         linestyle='DashLine',
                                         linewidth=1.)
            plot.add_item(self.data_curve)
        self.data_curve.set_data(self.x, self.y)

        colors = [u'#d4f200', u'#00e639', u'#009fff', u'#7900f2']

        for i in xrange(self._idxlen):
            if len(self.fit_curves) < self._idxlen:
                self.fit_curves.append(
                    make.curve([], [],
                               _('%s' % self.fitnames[i]),
                               color=colors[i % len(colors)],
                               linestyle='--',
                               linewidth=2))
                plot.add_item(self.fit_curves[-1])

            fitargs, fitkwargs = self.get_fitfunc_arguments()

            yfit = self.fitfunc[i](self.x,
                                   *([p.value for p in self.fitparams[i]] +
                                     list(fitargs)), **fitkwargs)

            if plot.get_scales()[1] == 'log':
                self.fit_curves[i].set_data(self.x[yfit > 1e-80],
                                            yfit[yfit > 1e-80])
            else:
                self.fit_curves[i].set_data(self.x, yfit)

        self.get_itemlist_panel().show()

        if self.fit_curve is not None:
            self.fit_curve.curveparam.line.color = self.fit_curves[
                self.idx].curveparam.line.color
            self.fit_curve.curveparam.line.style = 'DashLine'

        self.fit_curve = self.fit_curves[self.idx]
        self.fit_curve.curveparam.line.color = u'#ff0000'
        self.fit_curve.curveparam.line.style = 'SolidLine'

        [item.update_params() for item in self.fit_curves]

        if self.legend is None:
            self.legend = make.legend(anchor=self.legend_anchor)
            plot.add_item(self.legend)

        plot.set_antialiasing(False)

        plot.replot()
예제 #19
0
    def process(self):
        params = {}
        for i in range(self.tableWidget.rowCount()):
            a = self.tableWidget.item(i, 0)
            b = self.tableWidget.item(i, 1)
            params[str(a.text())] = int(b.text())
        print "params", params
        outpN = self.tableWidget.item(0, 0)
        #params = {"none": "none", "output_length": outpN}


        r = np.array(range(len(self.dc.dimrecprocData))).reshape(len(self.dc.dimrecprocData), 1)
        s = np.array(self.dc.dimrecprocData).reshape(len(self.dc.dimrecprocData), 1)
        rs = np.hstack((s, s))

        labels = self.fec.extractFeature(rs, params)
        print labels
        self.plot.del_all_items()
        self.plot.replot()
        self.plot.add_item(
            make.curve(range(0, len(self.dc.dimrecprocData)), self.dc.dimrecprocData))

        from guiqwt.styles import AnnotationParam

        i = 0
        i_beg = 0
        i_end = 0
        while i < len(labels):
            cur = labels[i_end]

            if i < len(labels) - 1:
                if labels[i_end + 1] != cur:
                    i_end = i
                    from guiqwt.annotations import AnnotatedRectangle

                    param = AnnotationParam()
                    param.title = str(labels[int(i_beg)])
                    param.show_computations = False

                    anno = AnnotatedRectangle(r[int(i_beg)], self.dc.dimrecprocData[int(i_beg)], int(i_end), self.dc.dimrecprocData[r[int(i_end)]], param) #TODO: y axis scaling
                    self.plot.add_item(anno)
                    i_beg = i_end
                    print "s1"
                else:
                    i_end = i
                    print "s2"
                print "s3"
            print "s4", i_end, len(labels)
            i += 1

        self.rangeSelection = make.range(-2, 2)
        disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm",
                                      title="Range infos")
        #self.plot.add_item(self.rangeSelection)
        #self.plot.add_item(disp0)
        #self.dc.setCurrentDataFlowObject(self.flowData)
        self.dc.featureexData = self.flowData
        self.dc.setCurrentLabels(labels)
        print(self.dc.setCurrentLabels)
        #ToDo: Check that following line, make property in data controller
        self.dc.dimrecprocData = rs
        self.plot.replot()
        self.currentdata = np.reshape(labels, (-1, 1))
예제 #20
0
 def refresh(self,):
     t_start = self.hspinbox.value()
     visible = self.hzspinbox.value()
     t_stop = t_start + visible
     
     # signals
     if self.analogsignals:
         for i, analist in enumerate(self.analogsignals):
             for p, ana in enumerate(analist):
                 curve = self.signal_curves[i][p]
                 if t_start>=ana.t_start+ana.signal.size/ana.sampling_rate:
                     curve.set_data([ ], [ ])
                 elif t_stop<ana.t_start: 
                     curve.set_data([ ], [ ])
                 else:
                     ind_start = (t_start-ana.t_start)*ana.sampling_rate
                     ind_stop = (t_stop-ana.t_start)*ana.sampling_rate
                     if ind_start<0: ind_start=0
                     if ind_stop>ana.signal.size: ind_stop=ana.signal.size
                     curve.set_data(ana.t()[ind_start:ind_stop], ana.signal[ind_start:ind_stop])
     
     # spiketrains on signal
     if self.spiketrains:
         
         for i, analist in enumerate(self.analogsignals):
             
             for j in range(len(self.spiketrains[i])):
                 
                 
                 sptr = self.spiketrains[i][j]
                 st = sptr.spike_times[(sptr.spike_times>=t_start) & (sptr.spike_times<t_stop)]
                 for p in range(self.nplot):
                     ana = self.analogsignals[i][p]
                     ind = ((st - ana.t_start)*ana.sampling_rate).astype('i')
                     
                     curve = self.spike_curves[p][i][j]
                     curve.set_data( st, ana.signal[ind])
     
     # slection of spikes
     if self.selectedspikes:
         for i, selectedspike in enumerate(self.selectedspikes):
             st = selectedspike.spike_times
             st = st[(st>=t_start) & (st<t_stop)]
             for p in range(self.nplot):
                 ana = self.analogsignals[i][p]
                 ind = ((st - ana.t_start)*ana.sampling_rate).astype('i')
                 curve = self.selectedspikes_curves[p][i]
                 #~ print 'i p', i, p, st.size
                 curve.set_data( st, ana.signal[ind])
                 
     
     for vlimit in self.vlimits:
         for p in range(self.nplot):
             if (vlimit>t_start) and (vlimit<t_stop):
                 r = make.range(vlimit, vlimit)
                 self.plots[p].add_item(r)
         
     for p in range(self.nplot):
         plot = self.plots[p]            
         xaxis, yaxis = plot.get_active_axes()
         plot.setAxisScale(xaxis, t_start, t_stop )
         
         plot.setAxisScale(yaxis, self.y_min , self.y_max )
         plot.replot()
예제 #21
0
 def addBounds(self):
     self.xRange = make.range(0., 1.)
     self.plot.add_item(self.xRange)
예제 #22
0
    def refresh(self, ):
        t_start = self.hspinbox.value()
        visible = self.hzspinbox.value()
        t_stop = t_start + visible

        # signals
        if self.analogsignals:
            for i, analist in enumerate(self.analogsignals):
                for p, ana in enumerate(analist):
                    curve = self.signal_curves[i][p]
                    if t_start >= ana.t_start + ana.signal.size / ana.sampling_rate:
                        curve.set_data([], [])
                    elif t_stop < ana.t_start:
                        curve.set_data([], [])
                    else:
                        ind_start = (t_start - ana.t_start) * ana.sampling_rate
                        ind_stop = (t_stop - ana.t_start) * ana.sampling_rate
                        if ind_start < 0: ind_start = 0
                        if ind_stop > ana.signal.size:
                            ind_stop = ana.signal.size
                        curve.set_data(ana.t()[ind_start:ind_stop],
                                       ana.signal[ind_start:ind_stop])

        # spiketrains on signal
        if self.spiketrains:

            for i, analist in enumerate(self.analogsignals):

                for j in range(len(self.spiketrains[i])):

                    sptr = self.spiketrains[i][j]
                    st = sptr.spike_times[(sptr.spike_times >= t_start)
                                          & (sptr.spike_times < t_stop)]
                    for p in range(self.nplot):
                        ana = self.analogsignals[i][p]
                        ind = ((st - ana.t_start) *
                               ana.sampling_rate).astype('i')

                        curve = self.spike_curves[p][i][j]
                        curve.set_data(st, ana.signal[ind])

        # slection of spikes
        if self.selectedspikes:
            for i, selectedspike in enumerate(self.selectedspikes):
                st = selectedspike.spike_times
                st = st[(st >= t_start) & (st < t_stop)]
                for p in range(self.nplot):
                    ana = self.analogsignals[i][p]
                    ind = ((st - ana.t_start) * ana.sampling_rate).astype('i')
                    curve = self.selectedspikes_curves[p][i]
                    #~ print 'i p', i, p, st.size
                    curve.set_data(st, ana.signal[ind])

        for vlimit in self.vlimits:
            for p in range(self.nplot):
                if (vlimit > t_start) and (vlimit < t_stop):
                    r = make.range(vlimit, vlimit)
                    self.plots[p].add_item(r)

        for p in range(self.nplot):
            plot = self.plots[p]
            xaxis, yaxis = plot.get_active_axes()
            plot.setAxisScale(xaxis, t_start, t_stop)

            plot.setAxisScale(yaxis, self.y_min, self.y_max)
            plot.replot()