예제 #1
0
class PyQtGraphImagePlot(ImageView):
    def __init__(self, *args, **kwargs):
        super(PyQtGraphImagePlot, self).__init__(*args, **kwargs)
        self.ui.histogram.hide()
        self.ui.roiBtn.hide()
        self.ui.normBtn.hide()
        self.line1 = InfiniteLine(pos=0, angle=0, movable=False)
        self.line2 = InfiniteLine(pos=0, angle=90, movable=False)
        self.addItem(self.line1)
        self.addItem(self.line2)

    def plot(self, arr):
        self.setImage(np.array(arr))
        self.line1.setPos(arr.shape[0]/2.)
        self.line2.setPos(arr.shape[1]/2.)
예제 #2
0
class TimePlot(PlotWidget):
    def __init__(self, *args, **kwargs):
        super(TimePlot, self).__init__(*args, **kwargs)
        self.add_line()
        win.time_slider.valueChanged.connect(self.set_time)

    def add_line(self):
        self.time_vline = InfiniteLine(angle=90)
        self.addItem(self.time_vline)

    def plot(self, x, *args, **kwargs):
        self.time_pts = x
        win.time_slider.setMaximum(len(self.time_pts)-1)
        self.plotItem.plot(x, *args, **kwargs)

    def set_time(self, time_idx):
        pos = self.time_pts[time_idx]
        self.time_vline.setPos(pos)
예제 #3
0
class MyImageView(ImageView):
    def __init__(self):
        super(MyImageView, self).__init__()
        self.ui.histogram.gradient.restoreState(
            {"ticks": [(0.0, (255, 0, 0)), (0.5, (255, 255, 255)), (1.0, (0, 0, 255))], "mode": "rgb"}
        )
        self.h_line = InfiniteLine(pos=0, angle=0)
        self.v_line = InfiniteLine(pos=0, angle=90)
        self.view.addItem(self.h_line)
        self.view.addItem(self.v_line)
        win.time_slider.valueChanged.connect(self.set_time)

    def setImage(self, img, **kwargs):
        super(MyImageView, self).setImage(img, **kwargs)
        self.v_line.setPos(img.shape[1]/2.)
        self.h_line.setPos(img.shape[2]/2.)
        max_value = abs(img).max()
        self.setLevels(-max_value, max_value)
        win.time_slider.setMaximum(len(kwargs['xvals'])-1)

    def set_time(self, time_idx):
        self.setCurrentIndex(time_idx)