Ejemplo n.º 1
0
 def init_data(self):
     # calculating colors
     self.Main.Options.view['colors'],self.Main.Options.view['color_maps'] = self.Main.Processing.calc_colormaps(self.Main.Data.nTrials)
     # ini and connect
     for n in range(self.Main.Data.nTrials):
         # for raw
         self.raw_levels.append(self.Main.Processing.calc_levels(self.Main.Data.raw[:,:,:,n],fraction=(0.3,0.9995),nbins=200,samples=4000))
         LUTwidget = pg.HistogramLUTWidget()
         LUTwidget.setImageItem(self.Data_Display.Frame_Visualizer.ImageItems[n])
         LUTwidget.item.setHistogramRange(self.Main.Data.raw.min(),self.Main.Data.raw.max()) # disables autoscaling
         LUTwidget.item.setLevels(self.raw_levels[n][0],self.raw_levels[n][1])
         LUTwidget.item.gradient.setColorMap(self.Main.Options.view['color_maps'][n])
         self.LUTwidgets.addWidget(LUTwidget)
 
         # for dFF        
         self.dFF_levels.append(self.Main.Processing.calc_levels(self.Main.Data.dFF[:,:,:,n],fraction=(0.7,0.9995),nbins=200,samples=4000))
         LUTwidget = pg.HistogramLUTWidget()
         LUTwidget.setImageItem(self.Data_Display.Frame_Visualizer.ImageItems_dFF[n])
         LUTwidget.item.setHistogramRange(self.Main.Data.dFF.min(),self.Main.Data.dFF.max()) # disables autoscaling
         LUTwidget.item.setLevels(self.dFF_levels[n][0],self.dFF_levels[n][1])
         LUTwidget.item.gradient.setColorMap(self.Main.Options.view['color_maps'][n])
         self.LUTwidgets_dFF.addWidget(LUTwidget)
         pass
     
     for n in range(self.Main.Data.nTrials):
         self.LUTwidgets.widget(n).item.sigLevelsChanged.connect(self.LUT_changed)
         self.LUTwidgets_dFF.widget(n).item.sigLevelsChanged.connect(self.LUT_changed)
         pass
     pass
Ejemplo n.º 2
0
    def setupUI(self):
        vlayout = QtWidgets.QVBoxLayout()
        hsplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)

        self.parent.setLayout(vlayout)
        vlayout.addWidget(hsplitter)

        self.image_widget = ImageWidget()
        hsplitter.addWidget(self.image_widget)

        self.scaled_xaxis = self.image_widget.add_scaled_axis('top')
        self.scaled_yaxis = self.image_widget.add_scaled_axis('right')
        # self.scaled_xaxis.linkToView(self.image_widget.view)
        # self.scaled_yaxis.linkToView(self.image_widget.view)

        # self.image_widget.plotitem.layout.addItem(self.scaled_xaxis, *(1, 1))
        # self.image_widget.plotitem.layout.addItem(self.scaled_yaxis, *(2, 2))

        self.image_widget.view.sig_double_clicked.connect(self.double_clicked)

        # histograms
        self.histo_widget = QtWidgets.QWidget()
        histo_layout = QtWidgets.QHBoxLayout()
        self.histo_widget.setLayout(histo_layout)
        self.histogram_red = pg.HistogramLUTWidget()
        self.histogram_green = pg.HistogramLUTWidget()
        self.histogram_blue = pg.HistogramLUTWidget()
        self.histogram_adaptive = pg.HistogramLUTWidget()
        Ntick = 3
        colors_red = [(int(r), 0, 0) for r in np.linspace(0, 255, Ntick)]
        colors_green = [(0, int(g), 0) for g in np.linspace(0, 255, Ntick)]
        colors_blue = [(0, 0, int(b)) for b in np.linspace(0, 255, Ntick)]
        colors_adaptive = [(int(b), int(b), int(b))
                           for b in np.linspace(0, 255, Ntick)]
        cmap_red = pg.ColorMap(pos=np.linspace(0.0, 1.0, Ntick),
                               color=colors_red)
        cmap_green = pg.ColorMap(pos=np.linspace(0.0, 1.0, Ntick),
                                 color=colors_green)
        cmap_blue = pg.ColorMap(pos=np.linspace(0.0, 1.0, Ntick),
                                color=colors_blue)
        cmap_adaptive = pg.ColorMap(pos=np.linspace(0.0, 1.0, Ntick),
                                    color=colors_adaptive)

        self.histogram_red.gradient.setColorMap(cmap_red)
        self.histogram_green.gradient.setColorMap(cmap_green)
        self.histogram_blue.gradient.setColorMap(cmap_blue)
        self.histogram_adaptive.gradient.setColorMap(cmap_adaptive)

        histo_layout.addWidget(self.histogram_red)
        histo_layout.addWidget(self.histogram_green)
        histo_layout.addWidget(self.histogram_blue)
        histo_layout.addWidget(self.histogram_adaptive)
        hsplitter.addWidget(self.histo_widget)
Ejemplo n.º 3
0
    def init_data(self):
        # get weakref to dataset
        self.data = weakref.ref(self.Data_Display.MainWindow.Main.Data)()
        self.Options = weakref.ref(self.Data_Display.MainWindow.Main.Options)()

        # ini and connect
        for n in range(self.data.nFiles):
            # for raw
            self.raw_levels.append(
                self.calc_levels(self.data.raw[:, :, :, n],
                                 fraction=(0.3, 0.9995),
                                 nbins=100,
                                 samples=2000))
            LUTwidget = pg.HistogramLUTWidget()
            LUTwidget.setImageItem(
                self.Data_Display.Frame_Visualizer.ImageItems[n])
            LUTwidget.item.setHistogramRange(
                self.data.raw.min(),
                self.data.raw.max())  # disables autoscaling
            LUTwidget.item.setLevels(self.raw_levels[n][0],
                                     self.raw_levels[n][1])
            LUTwidget.item.gradient.setColorMap(
                self.Data_Display.color_maps[n])
            self.LUTwidgets.addWidget(LUTwidget)

            # for dFF
            self.dFF_levels.append(
                self.calc_levels(self.data.dFF[:, :, :, n],
                                 fraction=(0.7, 0.9995),
                                 nbins=100,
                                 samples=2000))
            LUTwidget = pg.HistogramLUTWidget()
            LUTwidget.setImageItem(
                self.Data_Display.Frame_Visualizer.ImageItems_dFF[n])
            LUTwidget.item.setHistogramRange(
                self.data.dFF.min(),
                self.data.dFF.max())  # disables autoscaling
            LUTwidget.item.setLevels(self.dFF_levels[n][0],
                                     self.dFF_levels[n][1])
            LUTwidget.item.gradient.setColorMap(
                self.Data_Display.color_maps[n])
            self.LUTwidgets_dFF.addWidget(LUTwidget)
            pass

        for n in range(self.data.nFiles):
            self.LUTwidgets.widget(n).item.sigLevelsChanged.connect(
                self.LUT_changed)
            self.LUTwidgets_dFF.widget(n).item.sigLevelsChanged.connect(
                self.LUT_changed)
            pass
        pass
Ejemplo n.º 4
0
    def initUI(self):
        self.show()
        hb3 = QtGui.QHBoxLayout()
        self.file_name_title = QtGui.QLabel("_")
        lbl1 = QtGui.QLabel("x pos")
        self.lbl2 = QtGui.QLabel("")
        lbl3 = QtGui.QLabel("y pos")
        self.lbl4 = QtGui.QLabel("")
        btn1 = QtGui.QPushButton("position")
        hb3.addWidget(lbl1)
        hb3.addWidget(self.lbl2)
        hb3.addWidget(lbl3)
        hb3.addWidget(self.lbl4)
        hb3.addWidget(btn1)

        btn1.clicked.connect(self.updatePanel)

        hb2 = QtGui.QHBoxLayout()
        hb1 = QtGui.QHBoxLayout()
        vb1 = QtGui.QVBoxLayout()
        self.view = IView2()
        self.sld = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.lcd = QtGui.QLCDNumber(self)
        self.hist = pg.HistogramLUTWidget()
        self.hist.setImageItem(self.view.projView)
        self.hist.setMaximumWidth(110)
        hb2.addWidget(self.lcd)
        hb2.addWidget(self.sld)
        vb1.addWidget(self.file_name_title)
        vb1.addLayout(hb3)
        vb1.addWidget(self.view)
        vb1.addLayout(hb2)
        hb1.addLayout(vb1)
        hb1.addWidget(self.hist, 10)
        self.setLayout(hb1)
Ejemplo n.º 5
0
def testHistogramLUTWidget():
    pg.mkQApp()
    
    win = QtGui.QMainWindow()
    win.show()

    cw = QtGui.QWidget()
    win.setCentralWidget(cw)

    l = QtGui.QGridLayout()
    cw.setLayout(l)
    l.setSpacing(0)

    v = pg.GraphicsView()
    vb = pg.ViewBox()
    vb.setAspectLocked()
    v.setCentralItem(vb)
    l.addWidget(v, 0, 0, 3, 1)

    w = pg.HistogramLUTWidget(background='w')
    l.addWidget(w, 0, 1)

    data = pg.gaussianFilter(np.random.normal(size=(256, 256, 3)), (20, 20, 0))
    for i in range(32):
        for j in range(32):
            data[i*8, j*8] += .1
    img = pg.ImageItem(data)
    vb.addItem(img)
    vb.autoRange()

    w.setImageItem(img)
    
    QtGui.QApplication.processEvents()
    win.close()
Ejemplo n.º 6
0
    def __init__(self):
        QtCore.QObject.__init__(self)

        self.scale = None
        self.interpolate = True

        self.img1 = AtlasImageItem()
        self.img2 = AtlasImageItem()
        self.img1.mouseHovered.connect(self.mouseHovered)
        self.img2.mouseHovered.connect(self.mouseHovered)

        self.line_roi = RulerROI([.005, 0], [.008, 0],
                                 angle=90,
                                 pen=(0, 9),
                                 movable=False)
        self.line_roi.sigRegionChanged.connect(self.update_slice_image)

        self.zslider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.zslider.valueChanged.connect(self.update_ortho_image)

        self.angle_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.angle_slider.setRange(-45, 45)
        self.angle_slider.valueChanged.connect(self.angle_slider_changed)

        self.lut = pg.HistogramLUTWidget()
        self.lut.setImageItem(self.img1.atlas_img)
        self.lut.sigLookupTableChanged.connect(self.histlut_changed)
        self.lut.sigLevelsChanged.connect(self.histlut_changed)

        self.display_ctrl = AtlasDisplayCtrl()
        self.display_ctrl.params.sigTreeStateChanged.connect(
            self.display_ctrl_changed)

        self.label_tree = LabelTree()
        self.label_tree.labels_changed.connect(self.labels_changed)
Ejemplo n.º 7
0
    def __init__(self,path=None,data=None,*args,**kwargs):
        super(VolumeViewer, self).__init__()

        self.levels = [0, 1]

        ly = QtGui.QHBoxLayout()
        ly.setContentsMargins(0,0,0,0)
        ly.setSpacing(0)

        self.volumeRenderWidget= VolumeRenderWidget()
        ly.addWidget(self.volumeRenderWidget.native)

        self.HistogramLUTWidget = None
        self.HistogramLUTWidget = pg.HistogramLUTWidget(image=self, parent=self)
        self.HistogramLUTWidget.setMaximumWidth(self.HistogramLUTWidget.minimumWidth()+15)# Keep static width
        self.HistogramLUTWidget.setMinimumWidth(self.HistogramLUTWidget.minimumWidth()+15)

        ly.addWidget(self.HistogramLUTWidget)

        self.xregion = SliceWidget(parent=self)
        self.yregion = SliceWidget(parent=self)
        self.zregion = SliceWidget(parent=self)
        self.xregion.item.region.setRegion([0, 1000])
        self.yregion.item.region.setRegion([0, 1000])
        self.zregion.item.region.setRegion([0, 1000])
        self.xregion.sigSliceChanged.connect(self.setVolume) #change to setVolume
        self.yregion.sigSliceChanged.connect(self.setVolume)
        self.zregion.sigSliceChanged.connect(self.setVolume)
        ly.addWidget(self.xregion)
        ly.addWidget(self.yregion)
        ly.addWidget(self.zregion)

        self.setLayout(ly)
Ejemplo n.º 8
0
 def initUI(self):
     self.show()
     hb1 = QtGui.QHBoxLayout()
     self.view = IView()
     self.hist = pg.HistogramLUTWidget()
     self.hist.setImageItem(self.view.projView)
     hb1.addWidget(self.view)
     hb1.addWidget(self.hist, 10)
     self.hist.setMaximumWidth(110)
     self.setLayout(hb1)
Ejemplo n.º 9
0
    def __init__(self, data=None):
        super(VolumeViewer, self).__init__()

        self.levels = [0, 1]

        ly = QHBoxLayout()
        ly.setContentsMargins(0, 0, 0, 0)
        ly.setSpacing(0)

        self.volumeRenderWidget = VolumeRenderWidget(data)
        ly.addWidget(self.volumeRenderWidget.native)

        self.HistogramLUTWidget = None
        self.HistogramLUTWidget = pg.HistogramLUTWidget(image=self,
                                                        parent=self)
        self.HistogramLUTWidget.setMaximumWidth(
            self.HistogramLUTWidget.minimumWidth() + 15)  # Keep static width
        self.HistogramLUTWidget.setMinimumWidth(
            self.HistogramLUTWidget.minimumWidth() + 15)

        v = QVBoxLayout()
        v.addWidget(self.HistogramLUTWidget)

        # ly.addWidget(self.HistogramLUTWidget)

        self.setButton = histDialogButton('Set', parent=self)
        self.setButton.setMaximumWidth(self.HistogramLUTWidget.minimumWidth() +
                                       15)
        self.setButton.setMinimumWidth(self.HistogramLUTWidget.minimumWidth() +
                                       15)
        self.setButton.connectToHistWidget(self.HistogramLUTWidget)
        v.addWidget(self.setButton)
        ly.addLayout(v)

        # self.xregion = SliceWidget(parent=self)
        # self.yregion = SliceWidget(parent=self)
        # self.zregion = SliceWidget(parent=self)
        # self.xregion.item.region.setRegion([0, 1000])
        # self.yregion.item.region.setRegion([0, 1000])
        # self.zregion.item.region.setRegion([0, 1000])
        # self.xregion.sigSliceChanged.connect(self.setVolume) #change to setVolume
        # self.yregion.sigSliceChanged.connect(self.setVolume)
        # self.zregion.sigSliceChanged.connect(self.setVolume)
        # ly.addWidget(self.xregion)
        # ly.addWidget(self.yregion)
        # ly.addWidget(self.zregion)

        self.setLayout(ly)

        self.volumeRenderWidget.setData(data=data)
Ejemplo n.º 10
0
 def __init__(self, grad_rect_size):
     super().__init__()
     self.custom_histogram_LUT_widget = pg.HistogramLUTWidget(grad_rect_size=grad_rect_size)
     # グラジエント自体は変更しないないので、Tickは表示しない
     # for tick in self.custom_histogram_LUT_widget.item.gradient.ticks.keys():
     #     tick.hide()
     self.gradientChanged()
     # ヒストグラムLUTレイアウト
     self.custom_histogram_LUT_widget.item.vb.setMinimumWidth(gf.histogram_height)
     self.custom_histogram_LUT_widget.item.vb.setMaximumWidth(gf.histogram_height)
     self.custom_histogram_LUT_widget.setMinimumWidth(gf.icon_width)
     self.custom_histogram_LUT_widget.setMaximumWidth(gf.icon_width)
     self.custom_histogram_LUT_widget.item.vb.removeItem(self.custom_histogram_LUT_widget.axis)
     self.custom_histogram_LUT_widget.item.layout.removeAt(0)
     # ラベル
     self.min_label = CustomSmallLabel("0")
     self.max_label = CustomSmallLabel("1")
     # レンジ固定ボタン
     self.fix_btn = QPushButton("FIX")
     self.fix_btn.setMaximumWidth(gf.icon_width)
     self.fix_btn.setMaximumHeight(gf.icon_width / 2)
     # self.fix_btn.setDown(True)
     self.fix_btn.setFont(gf.just_small(9))
     self.FIX = True
     self.btn_fix_pressed()  # 初期設定は、fixしない設定
     # レンジ設定ボタン
     self.range_set_btn = CustomSmallButton("SET")
     # レンジ設定ボタン
     self.BIT = 16
     self.bit_btn = CustomSmallButton("16B")
     # 全体レイアウト
     self.v_layout = QVBoxLayout()
     self.v_layout.setContentsMargins(0, 0, 0, 0)
     self.v_layout.setSpacing(1)
     self.v_layout.addWidget(self.max_label)
     self.v_layout.addWidget(self.custom_histogram_LUT_widget)
     self.v_layout.addWidget(self.min_label)
     self.v_layout.addWidget(self.fix_btn)
     self.v_layout.addWidget(self.range_set_btn)
     self.v_layout.addWidget(self.bit_btn)
     self.setLayout(self.v_layout)
     # イベントコネクト(コントラスト変更時にラベルの数値をアップデート)
     self.custom_histogram_LUT_widget.item.vb.sigRangeChanged.connect(self.viewRangeChanged)
     self.custom_histogram_LUT_widget.item.region.sigRegionChanged.connect(self.viewRangeChanged)
     self.custom_histogram_LUT_widget.item.gradient.sigGradientChanged.connect(self.gradientChanged)
     self.fix_btn.clicked.connect(self.btn_fix_pressed)
     self.range_set_btn.clicked.connect(self.range_btn_pressed)
     self.bit_btn.clicked.connect(self.bit_btn_pressed)
Ejemplo n.º 11
0
    def __init__(self, axes):
        QtGui.QWidget.__init__(self)
        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)
        self.layout.setContentsMargins(0, 0, 0, 0)
        
        self.dockarea = pg.dockarea.DockArea()
        self.layout.addWidget(self.dockarea)

        self.viewers = []
        self.data = None
        self.axes = OrderedDict([(ax, AxisData(name=ax, **ax_info)) for ax, ax_info in axes.items()])
        
        self.params = pg.parametertree.Parameter(name='params', type='group', children=[
            {'name': 'index', 'type': 'group', 'children': [{'name': ax, 'type': 'int', 'value': self.axes[ax].selection} for ax in self.axes]},
            {'name': 'max project', 'type': 'group', 'children': [{'name': ax, 'type': 'bool', 'value': False} for ax in self.axes]},
            ColorAxisParam(name='color axis', slicer=self),
            {'name': '1D views', 'type': 'group'},
            MultiAxisParam(ndim=2, slicer=self),
        ])

        pos = {'position': 'right', 'relativeTo': None}
        for ax in axes:
            ch = pg.parametertree.Parameter.create(name=ax, type='bool', value=True)
            self.params.child('1D views').addChild(ch)
            ch.sigValueChanged.connect(self.one_d_show_changed)
            ch.viewer, dock = self.add_view(axes=[ax], position=pos)
            pos = {'position': 'bottom', 'relativeTo': dock}
            
        self.params.child('max project').sigTreeStateChanged.connect(self.max_project_changed)
        self.params.child('color axis').axis_color_changed.connect(self.axis_color_changed)
        
        self.ctrl_split = pg.QtGui.QSplitter(pg.QtCore.Qt.Vertical)
        
        self.ptree = pg.parametertree.ParameterTree(showHeader=False)
        self.ptree.setParameters(self.params, showTop=False)
        self.ctrl_split.addWidget(self.ptree)
        
        self.histlut = pg.HistogramLUTWidget()
        self.histlut.sigLevelsChanged.connect(self.histlut_changed)
        self.histlut.sigLookupTableChanged.connect(self.histlut_changed)
        self.ctrl_split.addWidget(self.histlut)
        
        self.ctrl_dock = pg.dockarea.Dock("view selection")
        self.ctrl_dock.addWidget(self.ctrl_split)
        self.dockarea.addDock(self.ctrl_dock, 'left')
Ejemplo n.º 12
0
    def initUI(self):
        self.file_name_title = QtWidgets.QLabel("_")
        lbl1 = QtWidgets.QLabel("x pos")
        self.lbl2 = QtWidgets.QLabel("")
        lbl3 = QtWidgets.QLabel("y pos")
        self.lbl4 = QtWidgets.QLabel("")
        self.lbl5 = QtWidgets.QLabel("Angle")
        btn1 = QtWidgets.QPushButton("position")

        hb0 = QtWidgets.QHBoxLayout()
        hb0.addWidget(lbl1)
        hb0.addWidget(self.lbl2)
        hb0.addWidget(lbl3)
        hb0.addWidget(self.lbl4)
        hb0.addWidget(btn1)

        btn1.clicked.connect(self.updatePanel)

        self.view = xfluo.HistogramWidget(self)
        self.sld = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
        self.lcd = QtWidgets.QLCDNumber(self)
        self.hist = pyqtgraph.HistogramLUTWidget()
        self.hist.setMinimumSize(120, 120)
        self.hist.setMaximumWidth(120)
        self.hist.setImageItem(self.view.projView)

        hb1 = QtWidgets.QHBoxLayout()
        hb1.addWidget(self.lbl5)
        hb1.addWidget(self.lcd)
        hb1.addWidget(self.sld)

        vb1 = QtWidgets.QVBoxLayout()
        vb1.addWidget(self.file_name_title)
        vb1.addLayout(hb0)
        vb1.addWidget(self.view)
        vb1.addLayout(hb1)

        hb2 = QtWidgets.QHBoxLayout()
        hb2.addLayout(vb1)
        hb2.addWidget(self.hist, 10)

        self.setLayout(hb2)
Ejemplo n.º 13
0
    def initUI(self):
        self.ViewControl = xfluo.SinogramControlsWidget()
        self.sinoView = xfluo.SinogramView()
        self.lbl = QtWidgets.QLabel('Row y')
        self.sld = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
        self.sld.setValue(1)
        self.lcd = QtWidgets.QLCDNumber(self)
        self.hist = pyqtgraph.HistogramLUTWidget()
        self.hist.setMinimumSize(120,120)
        self.hist.setMaximumWidth(120)
        self.hist.setImageItem(self.sinoView.projView)
        self.x_shifts = None
        self.y_shifts = None
        self.centers = None

        hb0 = QtWidgets.QHBoxLayout()
        hb0.addWidget(self.lbl)
        hb0.addWidget(self.lcd)
        hb0.addWidget(self.sld)
        vb1 = QtWidgets.QVBoxLayout()
        vb1.addWidget(self.sinoView)
        vb1.addLayout(hb0)

        sinoBox = QtWidgets.QHBoxLayout()
        sinoBox.addWidget(self.ViewControl)
        sinoBox.addLayout(vb1)
        sinoBox.addWidget(self.hist, 10)

        self.setLayout(sinoBox)

        palette = self.lcd.palette()
        # foreground color
        palette.setColor(palette.WindowText, QtGui.QColor(85, 85, 255))
        # background color
        palette.setColor(palette.Background, QtGui.QColor(0, 170, 255))
        # "light" border
        palette.setColor(palette.Light, QtGui.QColor(255, 255, 0))
        # "dark" border
        palette.setColor(palette.Dark, QtGui.QColor(0, 0, 0))
        # set the palette
        self.lcd.setPalette(palette)
Ejemplo n.º 14
0
def histogram_factory(image_item=None, gradient='red'):
    """
    Create a pyqtgraph HistogramLUTWidget widget (histogram) and link it to the corresponding image_item
    Parameters
    ----------
    image_item: (ImageItem) the image item to be linked with the histogram
    gradient: (str) either 'red', 'green', 'blue', 'spread' or one of the Gradients

    Returns
    -------
    HistogramLUTWidget instance
    """

    if gradient not in Gradients:
        raise KeyError(f'Possible gradient are {Gradients} not {gradient}')

    histo = pg.HistogramLUTWidget()
    if image_item is not None:
        histo.setImageItem(image_item)

    histo.gradient.loadPreset(gradient)
    return histo
Ejemplo n.º 15
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        # Setup range slider
        #self.rangeSlider = RangeSlider(self)
        #self.sliderLayout = Qt.QtWidgets.QVBoxLayout(self.ui.sliderFrame)
        #self.sliderLayout.addWidget(self.rangeSlider)

        # Image pane setup
        self.image_layout = Qt.QtWidgets.QHBoxLayout(self.ui.imageFrame)
        self.image_layout.setContentsMargins(0, 0, 0, 0)
        self.image_layout.setSpacing(0)
        self.image_win = pg.GraphicsLayoutWidget()
        self.image_layout.addWidget(self.image_win)
        self.histogram = pg.HistogramLUTWidget(self.image_win)
        self.ui.toolLayout.addWidget(self.histogram, 1, 0, 1, 2)
        self.imageViewBox = RectViewBox()
        self.image_plot = self.image_win.addPlot(viewBox=self.imageViewBox)
        self.imageItem = pg.ImageItem(colormap=cm.get_cmap('viridis'))

        self.image_plot.addItem(self.imageItem)
        self.histogram.setImageItem(self.imageItem)
        self.histogram.vb.setMouseEnabled(x=False, y=False)
        self.raw_image = np.array(0)
        self.norm_image = np.array(0)
        self.displayed_image = np.array(0)
        starter = np.random.normal(50, 10, 256 * 256)
        starter.sort()
        self.setImage(starter.reshape((256, 256)))

        self.ui.logButton.toggled.connect(self.update_image)
        self.ui.cmapBox.currentIndexChanged.connect(self.set_cmap)
        self.set_cmap(0)

        self.show()
Ejemplo n.º 16
0
def show_error_surface(err_img, amps, taus, plt=None, hist=None):
    """Show an error surface image inside a plot.


    """
    if plt is None:
        plt = pg.plot()
    if hist is None:
        hist = pg.HistogramLUTWidget()
    plt.setLabels(left='tau (µm)', bottom='amp')
    plt.getAxis('left').setTicks([[(t, '%0.2f' % (t * 1e6)) for t in taus]])
    plt.getAxis('bottom').setTicks([[(a, '%0.2f' % a) for a in amps]])

    normed = np.log(err_img)
    err_image = pg.ImageItem(normed)
    hist.item.setImageItem(err_image)
    hist.show()

    plt.addItem(err_image)
    bounds = pg.QtCore.QRectF(amps[0], taus[0], amps[-1] - amps[0],
                              taus[-1] - taus[0])
    err_image.setRect(bounds)

    return err_image, plt, hist
Ejemplo n.º 17
0
win.setWindowTitle('pyqtgraph example: Histogram LUT')

cw = QtWidgets.QWidget()
win.setCentralWidget(cw)

layout = QtWidgets.QGridLayout()
cw.setLayout(layout)
layout.setSpacing(0)

view = pg.GraphicsView()
vb = pg.ViewBox()
vb.setAspectLocked()
view.setCentralItem(vb)
layout.addWidget(view, 0, 1, 3, 1)

hist = pg.HistogramLUTWidget(gradientPosition="left")
layout.addWidget(hist, 0, 2)


monoRadio = QtWidgets.QRadioButton('mono')
rgbaRadio = QtWidgets.QRadioButton('rgba')
layout.addWidget(monoRadio, 1, 2)
layout.addWidget(rgbaRadio, 2, 2)
monoRadio.setChecked(True)


def setLevelMode():
    mode = 'mono' if monoRadio.isChecked() else 'rgba'
    hist.setLevelMode(mode)

Ejemplo n.º 18
0
    def initUI(self):
        self.ViewControl = xrftomo.ImageProcessControlsWidget()
        # self.imageView = xrftomo.ImageView(self)
        self.imageView = xrftomo.ImageView()
        self.actions = xrftomo.ImageProcessActions()
        self.sub_pixel_shift = 1

        self.file_name_title = QtWidgets.QLabel("_")
        lbl1 = QtWidgets.QLabel("x pos:")
        self.lbl2 = QtWidgets.QLabel("")
        lbl3 = QtWidgets.QLabel("y pos:")
        self.lbl4 = QtWidgets.QLabel("")
        self.lbl5 = QtWidgets.QLabel("Angle")
        lbl6 = QtWidgets.QLabel("pixel value:")
        self.lbl7 = QtWidgets.QLabel("")

        self.imageView.mouseMoveSig.connect(self.updatePanel)
        #get pixel value from Histogram widget's projview 

        self.sld = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
        self.lcd = QtWidgets.QLCDNumber(self)
        self.hist = pyqtgraph.HistogramLUTWidget()
        self.hist.setMinimumSize(120,120)
        self.hist.setMaximumWidth(120)
        self.hist.setImageItem(self.imageView.projView)

        # self.imgAndHistoWidget.setSizePolicy(QtWidgets.QSizePolicy.setHeightForWidth(True))

        # sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        # sizePolicy.setHorizontalStretch(0)
        # sizePolicy.setVerticalStretch(0)
        # sizePolicy.setHeightForWidth(True)
        # sizePolicy.setWidthForHeight(True)
        # self.imgAndHistoWidget.setSizePolicy(sizePolicy)

        # self.imgAndHistoWidget.resize(1000, 700)


        self.ViewControl.combo1.currentIndexChanged.connect(self.elementChanged)
        # self.ViewControl.combo2.currentIndexChanged.connect(self.elementChanged)
        self.ViewControl.reshapeBtn.clicked.connect(self.ViewControl.reshape_options.show)
        self.ViewControl.run_reshape.clicked.connect(self.reshape_params)
        self.ViewControl.padBtn.clicked.connect(self.ViewControl.padding_options.show)
        self.ViewControl.run_padding.clicked.connect(self.pad_params)
        self.ViewControl.cropBtn.clicked.connect(self.cut_params)
        # self.ViewControl.gaussian33Btn.clicked.connect(self.actions.gauss33)
        # self.ViewControl.gaussian55Btn.clicked.connect(self.actions.gauss55)
        self.ViewControl.captureBackground.clicked.connect(self.copyBG_params)
        self.ViewControl.setBackground.clicked.connect(self.pasteBG_params)
        self.ViewControl.deleteProjection.clicked.connect(self.exclude_params)
        # self.ViewControl.hist_equalize.clicked.connect(self.equalize_params)
        self.ViewControl.rm_hotspot.clicked.connect(self.rm_hotspot_params)
        self.ViewControl.Equalize.clicked.connect(self.histo_params)
        self.ViewControl.invert.clicked.connect(self.invert_params)
        # self.ViewControl.histogramButton.clicked.connect(self.histogram)

        self.imageView.keyPressSig.connect(self.keyProcess)
        # self.actions.dataSig.connect(self.send_data)
        # self.actions.thetaSig.connect(self.send_thetas)
        self.sld.valueChanged.connect(self.imageSliderChanged)

        self.x_shifts = None
        self.y_shifts = None
        self.centers = None
        self.data = None
        self.meanNoise = 0
        self.stdNoise = 0

        palette = self.lcd.palette()
        # foreground color
        palette.setColor(palette.WindowText, QtGui.QColor(85, 85, 255))
        # background color
        palette.setColor(palette.Background, QtGui.QColor(0, 170, 255))
        # "light" border
        palette.setColor(palette.Light, QtGui.QColor(255, 255, 0))
        # "dark" border
        palette.setColor(palette.Dark, QtGui.QColor(0, 0, 0))
        # set the palette
        self.lcd.setPalette(palette)
        self.imageView.projView.setScaledMode()
        
        hb0 = QtWidgets.QHBoxLayout()
        hb0.addWidget(lbl1)
        hb0.addWidget(self.lbl2)
        hb0.addWidget(lbl3)
        hb0.addWidget(self.lbl4)
        hb0.addWidget(lbl6)
        hb0.addWidget(self.lbl7)

        hb1 = QtWidgets.QHBoxLayout()
        hb1.addWidget(self.lbl5)
        hb1.addWidget(self.lcd)
        hb1.addWidget(self.sld)

        vb1 = QtWidgets.QVBoxLayout()
        vb1.addWidget(self.file_name_title)
        vb1.addLayout(hb0)
        vb1.addWidget(self.imageView)
        vb1.addLayout(hb1)

        hb2 = QtWidgets.QHBoxLayout()
        hb2.addWidget(self.ViewControl)
        hb2.addLayout(vb1)
        hb2.addWidget(self.hist, 10)

        self.setLayout(hb2)
Ejemplo n.º 19
0
    def __init__(self, ring):
        QtGui.QWidget.__init__(self)
        self.ring = ring

        self.wX = SpectrogramWidget(ring, 'x')
        self.wY = SpectrogramWidget(ring, 'y')
        self.wX.read_collected.connect(self.wX.update)
        self.wY.read_collected.connect(self.wY.update)
        """Customize the X-tick labels"""
        x = []
        for minute in range(-minutes, minutes / 10, 2):
            if minute == 0:
                x.append('Now')
            else:
                x.append(format('%s min') % minute)
        xt = [
            i for i in range(0,
                             updateFrequency * (minutes + 1) *
                             60, updateFrequency * 2 * 60)
        ]
        ticks = [list(zip(xt, x))]
        wXAxis = self.wX.getAxis('bottom')
        wYAxis = self.wY.getAxis('bottom')
        wXAxis.setTicks(ticks)
        wYAxis.setTicks(ticks)

        self.dStreamX = DataReader(self.wX.read_collected, ring, 'x')
        self.dStreamY = DataReader(self.wY.read_collected, ring, 'y')

        self.histX = pg.HistogramLUTWidget()
        self.histX.setImageItem(self.wX.img)
        self.histX.setMinimumWidth(150)
        self.histY = pg.HistogramLUTWidget()
        self.histY.setImageItem(self.wY.img)
        self.histY.setMinimumWidth(150)

        self.bpmHistLevelsX = (0.1, 0.3)
        self.bpmHistLevelsY = (0.1, 0.3)
        self.corHistLevelsX = (0.0, 0.0005)
        self.corHistLevelsY = (0.0, 0.0010)

        self.histX.setLevels(self.bpmHistLevelsX[0], self.bpmHistLevelsX[1])
        self.histX.setHistogramRange(0, 0.5)
        self.histY.setLevels(self.bpmHistLevelsY[0], self.bpmHistLevelsY[1])
        self.histY.setHistogramRange(0, 0.5)

        updateGolden = QtGui.QPushButton("Plot vs. Golden")
        updateGolden.clicked.connect(self.wX.plotGolden)
        updateGolden.clicked.connect(self.wY.plotGolden)
        updateGolden.setStyleSheet(activeStyle)
        updateGolden.setMinimumWidth(120)

        updateStored = QtGui.QPushButton("Plot vs. Stored")
        updateStored.clicked.connect(self.wX.plotStore)
        updateStored.clicked.connect(self.wY.plotStore)
        updateStored.setMinimumWidth(120)
        """Change the background color of the active reference orbit"""
        updateGolden.clicked.connect(
            lambda: updateGolden.setStyleSheet(activeStyle))
        updateGolden.clicked.connect(lambda: updateStored.setStyleSheet(""))
        updateStored.clicked.connect(lambda: updateGolden.setStyleSheet(""))
        updateStored.clicked.connect(
            lambda: updateStored.setStyleSheet(activeStyle))

        saveStored = QtGui.QPushButton("Store Current Positions")
        saveStored.clicked.connect(self.wX.saveStore)
        saveStored.clicked.connect(self.wY.saveStore)

        saveLab = QtGui.QLabel("Positions stored:\n" +
                               datetime.now().strftime('%y-%m-%d %H:%M:%S'))
        saveStored.clicked.connect(
            lambda: saveLab.setText("Positions stored:\n" + datetime.now().
                                    strftime('%y-%m-%d %H:%M:%S')))

        self.space = QtGui.QPushButton("BPM space")
        self.space.clicked.connect(self.wX.toggleSpace)
        self.space.clicked.connect(self.wY.toggleSpace)
        self.space.clicked.connect(self.toggleSpace)
        self.space.setMinimumWidth(120)
        self.space.setStyleSheet(bpmStyle)

        plotTraceX = QtGui.QPushButton("Plot trace X")
        plotTraceX.clicked.connect(self.wX.plotTrace)
        plotTraceY = QtGui.QPushButton("Plot trace Y")
        plotTraceY.clicked.connect(self.wY.plotTrace)

        saveMatButton = QtGui.QPushButton("Save .mat data")
        saveMatButton.clicked.connect(self.saveMat)

        self.pauseButton = QtGui.QPushButton("Pause")
        self.pauseButton.clicked.connect(self.pauseResume)
        self.pauseButton.setMinimumWidth(100)

        self.clockLab = QtGui.QLabel(
            datetime.now().strftime('%y-%m-%d %H:%M:%S'))

        hBox1 = QtGui.QHBoxLayout()
        hBox1.addWidget(self.wX)
        hBox1.addWidget(self.histX)

        hBox2 = QtGui.QHBoxLayout()
        hBox2.addWidget(self.wY)
        hBox2.addWidget(self.histY)

        hBox3 = QtGui.QHBoxLayout()
        hBox3.addWidget(updateGolden)
        hBox3.addWidget(updateStored)
        hBox3.addWidget(saveLab)
        hBox3.addWidget(saveStored)
        hBox3.addItem(
            QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Minimum))
        hBox3.addWidget(self.space)
        hBox3.addWidget(plotTraceX)
        hBox3.addWidget(plotTraceY)
        hBox3.addItem(
            QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Minimum))
        hBox3.addWidget(saveMatButton)
        hBox3.addWidget(self.pauseButton)
        hBox3.addWidget(self.clockLab)

        vBox = QtGui.QVBoxLayout()
        vBox.addLayout(hBox1)
        vBox.addLayout(hBox2)
        vBox.addLayout(hBox3)

        self.setLayout(vBox)
        self.setWindowTitle(ring.upper() + " BPM trends")
        self.setMinimumHeight(600)

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.dStreamX.read)
        self.timer.timeout.connect(self.dStreamY.read)
        self.timer.timeout.connect(self.clock)
        self.timer.start(1000 / updateFrequency)
        """Automatically update the reference orbit after a minute"""
        oneShot = QtCore.QTimer()
        oneShot.singleShot(1000 * 60, saveStored.click)
Ejemplo n.º 20
0
    def __init__(self):
        super(MainWindowImage, self).__init__()

        self.setMouseTracking(True)

        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)
        self.layout.setSpacing(0)

        self.pg_win = pg.GraphicsView()
        self.view = pg.ViewBox()
        self.view.setAspectLocked()
        self.pg_win.setCentralItem(self.view)
        self.layout.addWidget(self.pg_win, 0, 0, 3, 1)

        # add a slider
        self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)

        self.slider.valueChanged.connect(self.valuechange)

        self.slider.sliderReleased.connect(self.sliderReleased)

        self.setGeometry(300, 300, self.full_size, self.full_size)

        self.layout.addWidget(self.slider, 1, 0)

        self.slider.setRange(0, self.number_angles)

        # add a histogram

        self.hist = pg.HistogramLUTWidget()

        self.layout.addWidget(self.hist, 0, 1)

        self.hist.item.sigLevelsChanged.connect(self.histogram_updated)

        # add a drop box for LUT selection

        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.move(20, 20)
        self.comboBox.addItem('viridis')
        self.comboBox.addItem('plasma')
        self.comboBox.addItem('inferno')
        self.comboBox.addItem('magma')
        self.comboBox.addItem('cividis')
        self.comboBox.addItem('Greys')
        self.comboBox.addItem('Greens')
        self.comboBox.addItem('Oranges')
        self.comboBox.addItem('Reds')
        self.comboBox.addItem('bone')
        self.comboBox.addItem('Pastel1')

        self.comboBox.currentTextChanged.connect(self.updatedLUT)

        self.view.mousePressEvent = self.MousePress

        self.view.mouseMoveEvent = self.MouseMove

        self.view.mouseReleaseEvent = self.MouseRelease

        self.view.wheelEvent = self.WheelEvent

        self.apr_ref = None
        self.parts_ref = None
        self.tree_parts_ref = None
        self.raycaster_ref = None

        self.slider_aniso = CustomSlider(self, "z anisotropy")
        self.slider_aniso.maxBox.setMaximum(50)
        self.slider_aniso.maxBox.setValue(10)
        self.slider_aniso.slider.setValue(1)
        self.slider_aniso.move(200, 50)
        self.slider_aniso.connectSlider(self.valuechangeAniso)
Ejemplo n.º 21
0
    def __init__(self, parent=None):
        self.atlas = None
        self.label = None

        QtGui.QWidget.__init__(self, parent)
        self.scale = None
        self.resize(800, 800)
        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.w1 = pg.GraphicsLayoutWidget()
        self.w2 = pg.GraphicsLayoutWidget()
        self.view1 = self.w1.addViewBox()
        self.view2 = self.w2.addViewBox()
        self.view1.setAspectLocked()
        self.view2.setAspectLocked()
        self.view1.invertY(False)
        self.view2.invertY(False)
        self.layout.addWidget(self.w1, 0, 0)
        self.layout.addWidget(self.w2, 1, 0)

        self.img1 = LabelImageItem()
        self.img2 = LabelImageItem()
        self.img1.mouseHovered.connect(self.mouseHovered)
        self.img2.mouseHovered.connect(self.mouseHovered)
        self.img2.mouseClicked.connect(self.mouseClicked)
        self.view1.addItem(self.img1)
        self.view2.addItem(self.img2)

        self.target = Target()
        self.target.setZValue(5000)
        self.view2.addItem(self.target)
        self.target.setVisible(False)

        self.line_roi = RulerROI([.005, 0], [.008, 0],
                                 angle=90,
                                 pen=(0, 9),
                                 movable=False)
        self.view1.addItem(self.line_roi, ignoreBounds=True)
        self.line_roi.sigRegionChanged.connect(self.updateSlice)

        self.zslider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.zslider.valueChanged.connect(self.updateImage)
        self.layout.addWidget(self.zslider, 2, 0)

        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.slider.valueChanged.connect(self.sliderRotation)
        self.layout.addWidget(self.slider, 3, 0)

        self.lut = pg.HistogramLUTWidget()
        self.lut.setImageItem(self.img1.atlasImg)
        self.lut.sigLookupTableChanged.connect(self.histlutChanged)
        self.lut.sigLevelsChanged.connect(self.histlutChanged)
        self.layout.addWidget(self.lut, 0, 1, 3, 1)

        self.clipboard = QtGui.QApplication.clipboard()

        QtGui.QShortcut(QtGui.QKeySequence("Alt+Up"), self, self.slider_up)
        QtGui.QShortcut(QtGui.QKeySequence("Alt+Down"), self, self.slider_down)
        QtGui.QShortcut(QtGui.QKeySequence("Alt+Left"), self, self.tilt_left)
        QtGui.QShortcut(QtGui.QKeySequence("Alt+Right"), self, self.tilt_right)
        QtGui.QShortcut(QtGui.QKeySequence("Alt+1"), self, self.move_left)
        QtGui.QShortcut(QtGui.QKeySequence("Alt+2"), self, self.move_right)
Ejemplo n.º 22
0
    def initUI(self):
        self.ViewControl = xrftomo.ReconstructionControlsWidget()
        self.ReconView = xrftomo.ReconView(self)
        self.actions = xrftomo.ReconstructionActions()

        self.file_name_title = QtWidgets.QLabel("_")
        lbl1 = QtWidgets.QLabel("x pos:")
        self.lbl2 = QtWidgets.QLabel("")
        lbl3 = QtWidgets.QLabel("y pos:")
        self.lbl4 = QtWidgets.QLabel("")
        lbl5 = QtWidgets.QLabel("Slice")
        lbl6 = QtWidgets.QLabel("value:")
        self.lbl7 = QtWidgets.QLabel("")

        self.ReconView.mouseMoveSig.connect(self.updatePanel)
        #get pixel value from Histogram widget's projview

        self.sld = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
        self.lcd = QtWidgets.QLCDNumber(self)
        self.hist = pyqtgraph.HistogramLUTWidget()
        self.hist.setMinimumSize(120, 120)
        self.hist.setMaximumWidth(120)
        self.hist.setImageItem(self.ReconView.projView)

        self.ViewControl.combo1.currentIndexChanged.connect(
            self.elementChanged)
        self.ViewControl.btn.clicked.connect(self.reconstruct_params)
        self.ViewControl.btn2.clicked.connect(self.reconstruct_all_params)
        self.ViewControl.mulBtn.clicked.connect(self.call_reconMultiply)
        self.ViewControl.divBtn.clicked.connect(self.call_reconDivide)
        self.ViewControl.end_indx.editingFinished.connect(self.update_y_range)
        self.ViewControl.start_indx.editingFinished.connect(
            self.update_y_range)
        self.sld.valueChanged.connect(self.update_recon_image)

        self.x_shifts = None
        self.y_shifts = None
        self.centers = None
        self.recon = None
        self.data = None

        hb0 = QtWidgets.QHBoxLayout()
        hb0.addWidget(lbl1)
        hb0.addWidget(self.lbl2)
        hb0.addWidget(lbl3)
        hb0.addWidget(self.lbl4)
        hb0.addWidget(lbl6)
        hb0.addWidget(self.lbl7)

        hb1 = QtWidgets.QHBoxLayout()
        hb1.addWidget(lbl5)
        hb1.addWidget(self.lcd)
        hb1.addWidget(self.sld)

        vb1 = QtWidgets.QVBoxLayout()
        vb1.addWidget(self.file_name_title)
        vb1.addLayout(hb0)
        vb1.addWidget(self.ReconView)
        vb1.addLayout(hb1)

        hb2 = QtWidgets.QHBoxLayout()
        hb2.addWidget(self.ViewControl)
        hb2.addLayout(vb1)
        hb2.addWidget(self.hist, 10)

        self.setLayout(hb2)
Ejemplo n.º 23
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self, batch_btn=False, help="compare")
        vbox.addWidget(title)

        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(QtGui.QLabel("Compare "))
        self.d1_combo = OverlayCombo(self.ivm)
        self.d1_combo.currentIndexChanged.connect(self._update_data)
        hbox.addWidget(self.d1_combo)
        hbox.addWidget(QtGui.QLabel(" with "))
        self.d2_combo = OverlayCombo(self.ivm)
        self.d2_combo.currentIndexChanged.connect(self._update_data)
        hbox.addWidget(self.d2_combo)
        hbox.addStretch(1)
        vbox.addLayout(hbox)

        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(QtGui.QLabel("Within ROI "))
        self.roi_combo = OverlayCombo(self.ivm,
                                      rois=True,
                                      data=False,
                                      none_option=True)
        self.roi_combo.currentIndexChanged.connect(self._update_data)
        hbox.addWidget(self.roi_combo)
        hbox.addStretch(1)
        vbox.addLayout(hbox)

        hbox = QtGui.QHBoxLayout()
        gbox = QtGui.QGroupBox("Options")
        grid = QtGui.QGridLayout()
        gbox.setLayout(grid)

        self.id_cb = QtGui.QCheckBox("Include identity line")
        grid.addWidget(self.id_cb, 0, 0)
        self.sample_cb = QtGui.QCheckBox("Sample values")
        self.sample_cb.setChecked(True)
        self.sample_cb.stateChanged.connect(self._update_data)
        self.sample_cb.stateChanged.connect(self._update_gui)
        grid.addWidget(self.sample_cb, 1, 0)
        self.sample_spin = QtGui.QSpinBox()
        self.sample_spin.setMinimum(10)
        self.sample_spin.setMaximum(10000000)
        self.sample_spin.setSingleStep(100)
        self.sample_spin.setValue(1000)
        self.sample_spin.valueChanged.connect(self._update_data)
        grid.addWidget(self.sample_spin, 1, 1)
        self.warn_label = QtGui.QLabel(
            "WARNING: plotting all values may take a long time")
        self.warn_label.setStyleSheet("QLabel { color : red; }")
        self.warn_label.setVisible(False)
        grid.addWidget(self.warn_label, 2, 0)
        self.plot_mode = ChoiceOption("Plot mode",
                                      grid,
                                      3,
                                      choices=["Scatter", "Heat map"])
        self.plot_mode.combo.currentIndexChanged.connect(
            self._plot_mode_changed)
        self.bins = NumericOption("Bins",
                                  grid,
                                  3,
                                  xpos=2,
                                  minval=20,
                                  default=50,
                                  intonly=True)
        self.bins.label.setVisible(False)
        self.bins.spin.setVisible(False)
        self.run_btn = QtGui.QPushButton("Update")
        self.run_btn.clicked.connect(self._run)
        grid.addWidget(self.run_btn, 4, 0)
        hbox.addWidget(gbox)
        hbox.addStretch(1)
        vbox.addLayout(hbox)

        hbox = QtGui.QHBoxLayout()
        win = pg.GraphicsLayoutWidget()
        win.setBackground(background=None)
        self.plot = win.addPlot(enableAutoRange=True)
        self.plot.clear()  # Unsure why this is necessary
        hbox.addWidget(win)

        self.hist = pg.HistogramLUTWidget()
        self.hist.setVisible(False)
        self.hist.setBackground(None)
        self.hist.gradient.loadPreset("thermal")
        hbox.addWidget(self.hist)
        vbox.addLayout(hbox)

        self._update_gui()
        self._update_data()
Ejemplo n.º 24
0
    def __init__(self, slider_decimals=0):
        super(MainWindowImage, self).__init__()

        self.setMouseTracking(True)

        self.layout = Qt.QtGui.QGridLayout()
        self.setLayout(self.layout)
        self.layout.setSpacing(0)

        self.pg_win = pg.GraphicsView()
        self.view = pg.ViewBox()
        self.view.setAspectLocked()
        self.pg_win.setCentralItem(self.view)
        self.layout.addWidget(self.pg_win, 0, 0, 3, 1)

        # add a slider
        self.slider = Qt.QtWidgets.QSlider(Qt.QtCore.Qt.Horizontal, self)

        self.slider.valueChanged.connect(self.valuechange)

        self.setGeometry(300, 300, self.full_size, self.full_size)

        self.layout.addWidget(self.slider, 1, 0)

        # add a histogram

        self.hist = pg.HistogramLUTWidget()

        self.layout.addWidget(self.hist, 0, 1)

        self.hist.item.sigLevelsChanged.connect(self.histogram_updated)

        # add a QLabel giving information on the current slice and the APR
        self.slice_info = Qt.QtGui.QLabel(self)

        self.slice_info.move(20, 20)
        self.slice_info.setFixedWidth(250)

        # add a label for the current cursor position

        self.cursor = Qt.QtGui.QLabel(self)

        self.cursor.move(20, 40)
        self.cursor.setFixedWidth(250)

        # add parameter tuning

        # create push button
        self.exit_button = Qt.QtWidgets.QPushButton('Use Parameters', self)
        self.exit_button.setFixedWidth(300)
        self.exit_button.move(300, 10)
        self.exit_button.clicked.connect(self.exitPressed)

        self.max_label = Qt.QtWidgets.QLabel(self)
        self.max_label.setText("Slider Max")
        self.max_label.move(610, 50)

        self.slider_grad = CustomSlider(self,
                                        "gradient threshold",
                                        decimals=slider_decimals)
        self.slider_grad.move(200, 80)
        self.slider_grad.connectSlider(self.valuechangeGrad)

        self.slider_sigma = CustomSlider(self,
                                         "sigma threshold",
                                         decimals=slider_decimals)
        self.slider_sigma.move(200, 110)
        self.slider_sigma.connectSlider(self.valuechangeSigma)

        self.slider_Ith = CustomSlider(self,
                                       "intensity threshold",
                                       decimals=slider_decimals)
        self.slider_Ith.move(200, 140)
        self.slider_Ith.connectSlider(self.valuechangeIth)
Ejemplo n.º 25
0
    def __init__(self,parent=None,scaling_options=dict(scaled_xaxis=dict(label="",units=None,offset=0,scaling=1),scaled_yaxis=dict(label="",units=None,offset=0,scaling=1))):
        super(Viewer2D,self).__init__()
        #setting the gui
        self.ui=Ui_Form()
        self.ui.ROIs_widget=self.setup_Roi_widget()


        if parent is None:
            parent=QtWidgets.QWidget()

        self.ui.setupUi(parent)#it's a widget here
        self.ui.horizontalLayout.addWidget(self.ui.ROIs_widget)
        self.ui.ROIs_widget.setVisible(False)

        self.max_size_integrated = 200
        self.scaling_options = copy.deepcopy(scaling_options)
        self.viewer_type='Data2D' #☺by default
        self.title=""
        self.parent=parent
        self.image = None
        self.isdata=edict(blue=False,green=False,red=False)
        self.color_list=[(255,0,0),(0,255,0),(0,0,255),(14,207,189),(207,14,166),(207,204,14)]

        self.image_widget = ImageWidget()
        self.ui.plotitem = self.image_widget.plotitem # for backward compatibility
        self.ui.splitter_VLeft.replaceWidget(0, self.ui.graphicsView)


        self.autolevels=False
        self.ui.auto_levels_pb.clicked.connect(self.set_autolevels)

        self.scaled_yaxis=AxisItem_Scaled('right')
        self.scaled_xaxis=AxisItem_Scaled('top')

        self.image_widget.view.sig_double_clicked.connect(self.double_clicked)
        self.image_widget.plotitem.layout.addItem(self.scaled_xaxis, *(1,1))
        self.image_widget.plotitem.layout.addItem(self.scaled_yaxis, *(2,2))
        self.scaled_xaxis.linkToView(self.image_widget.view)
        self.scaled_yaxis.linkToView(self.image_widget.view)
        self.set_scaling_axes(self.scaling_options)
        self.image_widget.plotitem.vb.setAspectLocked(lock=True, ratio=1)
        self.ui.img_red = ImageItem()
        self.ui.img_green = ImageItem()
        self.ui.img_blue = ImageItem()
        #self.ui.img_red.sig_double_clicked.connect(self.double_clicked)
        self.ui.img_red.setCompositionMode( QtGui.QPainter.CompositionMode_Plus  )
        self.ui.img_green.setCompositionMode( QtGui.QPainter.CompositionMode_Plus  )
        self.ui.img_blue.setCompositionMode( QtGui.QPainter.CompositionMode_Plus  )
        self.ui.img_red.setOpts(axisOrder='row-major')
        self.ui.img_green.setOpts(axisOrder='row-major')
        self.ui.img_blue.setOpts(axisOrder='row-major')


        #selection area checkbox
        self.ui.blue_cb.setVisible(True)
        self.ui.blue_cb.setChecked(True)
        self.ui.blue_cb.clicked.connect(self.update_selection_area_visibility)
        self.ui.green_cb.setVisible(True)
        self.ui.green_cb.setChecked(True)
        self.ui.green_cb.clicked.connect(self.update_selection_area_visibility)
        self.ui.red_cb.setVisible(True)
        self.ui.red_cb.clicked.connect(self.update_selection_area_visibility)
        self.ui.red_cb.setChecked(True)

        self.image_widget.plotitem.addItem(self.ui.img_red)
        self.image_widget.plotitem.addItem(self.ui.img_green)
        self.image_widget.plotitem.addItem(self.ui.img_blue)
        self.ui.graphicsView.setCentralItem(self.image_widget.plotitem)

        ##self.ui.graphicsView.setCentralItem(self.image_widget.plotitem)
        #axis=pg.AxisItem('right',linkView=self.image_widget.view)
        #self.ui.graphicsView.addItem(axis)

        self.ui.aspect_ratio_pb.clicked.connect(self.lock_aspect_ratio)
        self.ui.aspect_ratio_pb.setChecked(True)

        #histograms
        histo_layout = QtWidgets.QHBoxLayout()
        self.ui.widget_histo.setLayout(histo_layout)
        self.ui.histogram_red=pg.HistogramLUTWidget()
        self.ui.histogram_red.setImageItem(self.ui.img_red)
        self.ui.histogram_green=pg.HistogramLUTWidget()
        self.ui.histogram_green.setImageItem(self.ui.img_green)
        self.ui.histogram_blue=pg.HistogramLUTWidget()
        self.ui.histogram_blue.setImageItem(self.ui.img_blue)
        histo_layout.addWidget(self.ui.histogram_red)
        histo_layout.addWidget(self.ui.histogram_green)
        histo_layout.addWidget(self.ui.histogram_blue)

        Ntick=3
        colors_red =[(int(r),0,0) for r in pg.np.linspace(0,255,Ntick)]
        colors_green=[(0,int(g),0) for g in pg.np.linspace(0,255,Ntick)]
        colors_blue=[(0,0,int(b)) for b in pg.np.linspace(0,255,Ntick)]
        cmap_red = pg.ColorMap(pos=pg.np.linspace(0.0, 1.0, Ntick), color=colors_red)
        cmap_green = pg.ColorMap(pos=pg.np.linspace(0.0, 1.0, Ntick), color=colors_green)
        cmap_blue = pg.ColorMap(pos=pg.np.linspace(0.0, 1.0, Ntick), color=colors_blue)
        self.ui.histogram_red.gradient.setColorMap(cmap_red)
        self.ui.histogram_green.gradient.setColorMap(cmap_green)
        self.ui.histogram_blue.gradient.setColorMap(cmap_blue)
        self.ui.histogram_red.setVisible(False)
        self.ui.histogram_green.setVisible(False)
        self.ui.histogram_blue.setVisible(False)
        self.ui.Show_histogram.clicked.connect(self.show_hide_histogram)


        #ROI selects an area and export its bounds as a signal
        self.ui.ROIselect=pg.RectROI([0,0],[10,10],centered=True,sideScalers=True)
        self.image_widget.plotitem.addItem(self.ui.ROIselect)
        self.ui.ROIselect.setVisible(False)
        self.ui.ROIselect.sigRegionChangeFinished.connect(self.selected_region_changed)
        self.ui.ROIselect_pb.clicked.connect(self.show_ROI_select)


        ## Isocurve drawing
        self.ui.iso = pg.IsocurveItem(level=0.8, pen='g',axisOrder='row-major')
        self.ui.iso.setParentItem(self.ui.img_red)
        self.ui.iso.setZValue(5)
        ## Draggable line for setting isocurve level
        self.ui.isoLine = pg.InfiniteLine(angle=0, movable=True, pen='g')
        self.ui.histogram_red.vb.addItem(self.ui.isoLine)
        self.ui.histogram_red.vb.setMouseEnabled(y=False) # makes user interaction a little easier
        self.ui.isoLine.setValue(0.8)
        self.ui.isoLine.setZValue(1000) # bring iso line above contrast controls
        self.ui.isocurve_pb.clicked.connect(self.show_hide_iso)
        self.ui.isocurve_pb.setChecked(False)
        self.show_hide_iso()
        # build isocurves from smoothed data
        self.ui.isoLine.sigDragged.connect(self.updateIsocurve)

        ##crosshair
        self.ui.crosshair=Crosshair(self.image_widget.plotitem)
        self.ui.crosshair_H_blue = self.ui.Lineout_H.plot(pen="b")
        self.ui.crosshair_H_green = self.ui.Lineout_H.plot(pen="g")
        self.ui.crosshair_H_red = self.ui.Lineout_H.plot(pen="r")
        self.ui.crosshair_V_blue = self.ui.Lineout_V.plot(pen="b")
        self.ui.crosshair_V_green = self.ui.Lineout_V.plot(pen="g")
        self.ui.crosshair_V_red = self.ui.Lineout_V.plot(pen="r")


        self.ui.crosshair.crosshair_dragged.connect(self.update_crosshair_data)
        self.ui.crosshair_pb.clicked.connect(self.crosshairClicked)
        self.crosshairClicked()

        #flipping
        self.ui.FlipUD_pb.clicked.connect(self.update_image_flip)
        self.ui.FlipLR_pb.clicked.connect(self.update_image_flip)
        self.ui.rotate_pb.clicked.connect(self.update_image_flip)

        ## ROI stuff
        self.ui.RoiCurve_H=edict()
        self.ui.RoiCurve_V=edict()
        self.ui.RoiCurve_integrated=edict()
        self.data_integrated_plot= edict()
        self.ui.ROIs=OrderedDict([])
        self.ui.roiBtn.clicked.connect(self.roiClicked)

        self.data_to_export=OrderedDict(data0D=OrderedDict(),data1D=OrderedDict(),data2D=OrderedDict())

        self._x_axis=None
        self._y_axis=None
        self.x_axis_scaled=None
        self.y_axis_scaled=None

        self.ui.Ini_plot_pb.clicked.connect(self.ini_plot)


        params = [ROIScalableGroup(name="ROIs")]
        self.roi_settings=Parameter.create(title='ROIs Settings', name='roissettings', type='group', children=params)
        self.ui.ROI_Tree.setParameters(self.roi_settings, showTop=False)
        self.roi_settings.sigTreeStateChanged.connect(self.roi_tree_changed)

        self.ui.save_ROI_pb.clicked.connect(self.save_ROI)
        self.ui.load_ROI_pb.clicked.connect(self.load_ROI)

        #self.roiClicked() ## initialize roi plot to correct shape / visibility
        ##splitter
        try:
            self.ui.splitter_VLeft.splitterMoved[int,int].connect(self.move_right_splitter)
            self.ui.splitter_VRight.splitterMoved[int,int].connect(self.move_left_splitter)
        except:
            pass
Ejemplo n.º 26
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.layout = QtGui.QGridLayout()
        self.layout.setSpacing(0)
        self.setLayout(self.layout)

        self.pg_win = pg.GraphicsView()
        self.view = pg.ViewBox()
        self.view.setAspectLocked()
        self.pg_win.setCentralItem(self.view)
        self.layout.addWidget(self.pg_win, 0, 0, 3, 1)

        # add a slider
        self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)

        self.slider.valueChanged.connect(self.valuechange)

        self.setGeometry(300, 300, self.full_size, self.full_size)

        self.layout.addWidget(self.slider, 1, 0)

        # add a histogram

        self.hist = pg.HistogramLUTWidget()

        self.layout.addWidget(self.hist, 0, 1)

        self.hist.item.sigLevelsChanged.connect(self.histogram_updated)

        # add a drop box for LUT selection

        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.move(20, 20)
        self.comboBox.addItem('bone')
        self.comboBox.addItem('viridis')
        self.comboBox.addItem('plasma')
        self.comboBox.addItem('inferno')
        self.comboBox.addItem('magma')
        self.comboBox.addItem('cividis')
        self.comboBox.addItem('Greys')
        self.comboBox.addItem('Greens')
        self.comboBox.addItem('Oranges')
        self.comboBox.addItem('Reds')
        self.comboBox.addItem('Pastel1')

        self.comboBox.currentTextChanged.connect(self.updatedLUT)

        # add a QLabel giving information on the current slice and the APR
        self.slice_info = QtGui.QLabel(self)

        self.slice_info.move(130, 20)
        self.slice_info.setFixedWidth(200)
        self.slice_info.setFixedHeight(45)

        # add a label for the current cursor position

        self.cursor = QtGui.QLabel(self)

        self.cursor.move(330, 20)
        self.cursor.setFixedWidth(260)
        self.cursor.setFixedHeight(45)
Ejemplo n.º 27
0
    def initUI(self):
        button1size = 250  #long button (1 column)
        button2size = 122.5  #mid button (2 column)
        button33size = 78.3
        button3size = 73.3  #small button (almost third)
        button4size = 58.75  #textbox size (less than a third)
        self.ViewControl = xrftomo.SinogramControlsWidget()
        self.sinoView = xrftomo.SinogramView()
        self.imageView = xrftomo.ImageView()
        self.diffView = xrftomo.differenceView()
        self.actions = xrftomo.SinogramActions()
        self.x_padding_hist = [0]
        self.y_padding_hist = [0]
        self.sub_pixel_shift = 1
        self.fnames = None

        self.view_options = QtWidgets.QComboBox()
        self.view_options.setFixedWidth(button2size)
        for j in ["sinogram view", "projection view", "difference view"]:
            self.view_options.addItem(j)

        self.sld = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)  #sino slider
        self.sld2 = QtWidgets.QSlider(QtCore.Qt.Horizontal,
                                      self)  #image slider
        self.sld3 = QtWidgets.QSlider(QtCore.Qt.Horizontal,
                                      self)  #image slider
        self.sld.setValue(1)
        self.lcd = QtWidgets.QLCDNumber(self)
        self.lcd2 = QtWidgets.QLCDNumber(self)
        self.lcd3 = QtWidgets.QLCDNumber(self)
        self.hist = pyqtgraph.HistogramLUTWidget()
        self.hist.setMinimumSize(120, 120)
        self.hist.setMaximumWidth(120)
        self.hist.setImageItem(self.sinoView.projView)
        self.hist.setImageItem(self.imageView.projView)
        self.hist.setImageItem(self.diffView.projView)
        self.data = np.ndarray(shape=(1, 10, 10, 10), dtype=float)
        self.x_shifts = None
        self.y_shifts = None
        self.centers = None
        self.data = None
        self.sinogramData = None

        self.ViewControl.btn1.clicked.connect(
            self.ViewControl.com_options.show)
        self.ViewControl.run_com.clicked.connect(self.centerOfMass_params)
        self.ViewControl.xcorsino.clicked.connect(self.xcorsino_params)
        self.ViewControl.opflow.clicked.connect(self.opFlow_params)
        self.ViewControl.fitPeaks.clicked.connect(self.fitPeaks_params)
        self.ViewControl.btn2.clicked.connect(self.crossCorrelate_params)
        self.ViewControl.xcorry.clicked.connect(self.xcorry_params)
        self.ViewControl.xcorrdy.clicked.connect(self.xcorrdy_params)
        self.ViewControl.btn3.clicked.connect(self.phaseCorrelate_params)
        self.ViewControl.btn6.clicked.connect(
            self.ViewControl.iter_parameters.show)
        self.ViewControl.run_iter_align.clicked.connect(self.iter_align_params)
        self.ViewControl.btn7.clicked.connect(self.alignFromText2_params)
        self.ViewControl.btn5.clicked.connect(self.ViewControl.move2edge.show)
        self.ViewControl.run_move2edge.clicked.connect(self.move2edge_params)
        self.ViewControl.btn9.clicked.connect(self.ViewControl.sino_manip.show)
        self.ViewControl.run_sino_adjust.clicked.connect(
            self.adjust_sino_params)
        self.ViewControl.move2center.clicked.connect(self.move2center_params)
        self.ViewControl.find_center_1.clicked.connect(
            self.center_tomopy_params)
        self.ViewControl.find_center_2.clicked.connect(
            self.center_Vacek_params)
        self.ViewControl.center.clicked.connect(
            self.ViewControl.center_parameters.show)
        self.ViewControl.center.clicked.connect(
            self.updateCenterFindParameters)
        self.ViewControl.rot_axis.clicked.connect(self.rot_axis_params)
        self.ViewControl.freq_sld.sliderReleased.connect(
            self.sinoCurvesldChanged)
        self.ViewControl.amp_sld.sliderReleased.connect(
            self.sinoCurvesldChanged)
        self.ViewControl.phase_sld.sliderReleased.connect(
            self.sinoCurvesldChanged)
        self.ViewControl.offst_sld.sliderReleased.connect(
            self.sinoCurvesldChanged)
        self.sld.valueChanged.connect(self.sinoSliderChanged)
        self.sld2.valueChanged.connect(self.imageSliderChanged)
        self.sld3.valueChanged.connect(self.diffSliderChanged)
        self.sinoView.keyPressSig.connect(self.shiftEvent_params)
        self.imageView.mousePressSig.connect(self.hotspot_event)
        self.ViewControl.combo1.currentIndexChanged.connect(
            self.elementChanged)
        self.view_options.currentIndexChanged.connect(self.display)
        self.ViewControl.amp.returnPressed.connect(self.updateSinoPlot)
        self.ViewControl.freq.returnPressed.connect(self.updateSinoPlot)
        self.ViewControl.phase.returnPressed.connect(self.updateSinoPlot)
        self.ViewControl.offst.returnPressed.connect(self.updateSinoPlot)
        self.ViewControl.set2line.clicked.connect(self.fit_curve)

        self.ViewControl.fit_line.clicked.connect(self.fitLine_params)
        self.ViewControl.fit_sine.clicked.connect(self.fitSine_params)
        self.ViewControl.fit_y.clicked.connect(self.fitY_params)
        self.ViewControl.clear_data.clicked.connect(self.clrHotspot_params)

        self.diffView.keyPressSig.connect(self.keyProcess)
        self.imageView.keyPressSig.connect(self.keyProcess)

        self.ViewControl.fit_line.setEnabled(False)
        self.ViewControl.fit_sine.setEnabled(False)
        self.ViewControl.fit_y.setEnabled(False)
        self.ViewControl.clear_data.setEnabled(False)

        self.stack1 = QtWidgets.QWidget()
        self.stack2 = QtWidgets.QWidget()
        self.stack3 = QtWidgets.QWidget()

        self.stack1UI()
        self.stack2UI()
        self.stack3UI()

        self.Stack = QtWidgets.QStackedWidget(self)
        self.Stack.addWidget(self.stack1)
        self.Stack.addWidget(self.stack2)
        self.Stack.addWidget(self.stack3)

        vb1 = QtWidgets.QVBoxLayout()
        vb1.addWidget(self.view_options)
        vb1.addWidget(self.Stack)
        vb1.maximumSize()

        sinoBox = QtWidgets.QHBoxLayout()
        sinoBox.addWidget(self.ViewControl)
        sinoBox.addLayout(vb1)
        sinoBox.addWidget(self.hist, 10)

        self.setLayout(sinoBox)

        palette = self.lcd.palette()
        # foreground color
        palette.setColor(palette.WindowText, QtGui.QColor(85, 85, 255))
        # background color
        palette.setColor(palette.Background, QtGui.QColor(0, 170, 255))
        # "light" border
        palette.setColor(palette.Light, QtGui.QColor(255, 255, 0))
        # "dark" border
        palette.setColor(palette.Dark, QtGui.QColor(0, 0, 0))
        # set the palette
        self.lcd.setPalette(palette)

        self.updateSinoPlot()
Ejemplo n.º 28
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        pg.setConfigOption('background', 'w')
        self.view = pg.GraphicsView()
        self.vb = pg.ViewBox(border='w')
        self.vb.setLimits(minXRange=1,
                          maxXRange=2048,
                          xMin=0,
                          xMax=2048,
                          minYRange=1,
                          maxYRange=100,
                          yMin=0,
                          yMax=100)
        self.img = None
        #        self.indexEnergyCurrent = 0
        self.view.setCentralItem(self.vb)
        self.histWidget = pg.HistogramLUTWidget()
        self.histWidget.item.gradient.loadPreset('bipolar')
        self.energySpinBox = QtGui.QSpinBox()
        self.energySpinBox.setMinimum(0)
        self.energySpinBox.setMaximum(0)
        self.slider = QtGui.QSlider()
        self.slider.setMinimum(0)
        self.slider.setMaximum(0)
        self.slider.setOrientation(QtCore.Qt.Horizontal)
        self.energyLabel = QtGui.QLabel("Energy:  %7.2f eV" % 0)
        self.slider.valueChanged.connect(self.energySpinBox.setValue)
        self.energySpinBox.valueChanged.connect(self.slider.setValue)
        self.energySpinBox.valueChanged.connect(self.setEnergyLabelText)
        #        self.energySpinBox.valueChanged.connect(data.setEnergyIndex)

        self.layout = QtGui.QGridLayout()
        self.layoutSelection = QtGui.QHBoxLayout()
        self.layout.addWidget(self.view, 0, 0)
        self.layout.addWidget(self.histWidget, 0, 1)
        self.layoutSelection.addWidget(self.energySpinBox)
        self.layoutSelection.addWidget(self.energyLabel)
        self.layoutSelection.addWidget(self.slider)
        self.layout.addLayout(self.layoutSelection, 1, 0, 1, 2)
        self.layout.setSpacing(0)
        self.setLayout(self.layout)

        data.fileLoaded.connect(self.onFileLoad)
        data.updateState.connect(self.updateImage)
        #        data.energyChanged.connect(self.energySpinBox.setValue)

        self.isoLine1 = pg.InfiniteLine(angle=90,
                                        movable=True,
                                        bounds=[1, 2046],
                                        pen=pg.mkPen(color=(150, 100, 150),
                                                     width=2))
        self.isoLine2 = pg.InfiniteLine(angle=90,
                                        movable=True,
                                        bounds=[1, 2046],
                                        pen=pg.mkPen(color=(150, 200, 0),
                                                     width=2))
        self.vb.addItem(self.isoLine1)
        self.vb.addItem(self.isoLine2)
        self.isoLine1.setValue(500)
        self.isoLine2.setValue(1500)
        self.isoLine1.setZValue(1001)  # bring iso line above
        self.isoLine2.setZValue(1000)  # bring iso line above
        self.isoLine1.sigPositionChanged.connect(self.onLine1PosChanged)
        self.isoLine2.sigPositionChanged.connect(self.onLine2PosChanged)
Ejemplo n.º 29
0
win.setWindowTitle('pyqtgraph example: Histogram LUT')

cw = QtGui.QWidget()
win.setCentralWidget(cw)

l = QtGui.QGridLayout()
cw.setLayout(l)
l.setSpacing(0)

v = pg.GraphicsView()
vb = pg.ViewBox()
vb.setAspectLocked()
v.setCentralItem(vb)
l.addWidget(v, 0, 0)

w = pg.HistogramLUTWidget()
l.addWidget(w, 0, 1)

data = pg.gaussianFilter(np.random.normal(size=(256, 256)), (20, 20))
for i in range(32):
    for j in range(32):
        data[i * 8, j * 8] += .1
img = pg.ImageItem(data)
# data2 = np.zeros((2,) + data.shape + (2,))
# data2[0,:,:,0] = data  ## make non-contiguous array for testing purposes
# img = pg.ImageItem(data2[0,:,:,0])
vb.addItem(img)
vb.autoRange()

w.setImageItem(img)
Ejemplo n.º 30
0
    def setupUi(self):
        self.graphicsLayout = pyqtgraph.GraphicsLayoutWidget(self)
        self.graphicsLayout.setGeometry(QtCore.QRect(0, 21, 1080, 500))
        export = self.graphicsLayout.sceneObj.contextMenu
        del export[:]

        layout = self.graphicsLayout.ci.layout
        layout.setColumnFixedWidth(0, 500)
        layout.setRowFixedHeight(0, 480)

        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)

        grey = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(150, 150, 150))
        brush.setStyle(QtCore.Qt.SolidPattern)
        grey.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)

        white = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(210, 210, 210))
        brush.setStyle(QtCore.Qt.SolidPattern)
        white.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)

        self.graphicsPlot = self.graphicsLayout.addPlot(row=0, col=0)
        self.graphicsPlot.setMenuEnabled(enableMenu=None)
        self.graphicsPlot.invertY()
        self.graphicsPlot.setAspectLocked()
        self.graphicsPlot.scene().sigMouseMoved.connect(self.mouseMoved)

        self.roi = pyqtgraph.PolyLineROI([[0, 0], [0, 50], [50, 50], [50, 0]],
                                         closed=True,
                                         pen=pyqtgraph.mkPen('b', width=2))
        self.roi.setZValue(10)

        self.histogram = pyqtgraph.HistogramLUTWidget(self.graphicsLayout)
        self.histogram.setGeometry(QtCore.QRect(510, 21, 150, 460))
        self.histogram.setObjectName("histogram")

        self.pixelValue = QtWidgets.QLabel(self)
        self.pixelValue.setGeometry(QtCore.QRect(0, 25, 510, 30))
        self.pixelValue.setObjectName("pixelValue")
        self.pixelValue.setStyleSheet(
            "background-color: rgb(0, 0, 0); padding-left: 10px;")
        self.pixelValue.setFont(font)
        self.pixelValue.setPalette(white)

        self.plotWidget = PlotWidget(self.graphicsLayout)
        self.plotWidget.setGeometry(QtCore.QRect(670, 25, 350, 200))
        self.plotWidget.setObjectName("plotWidget")

        self.LoadGraph = QtWidgets.QPushButton(self)
        self.LoadGraph.setGeometry(QtCore.QRect(830, 250, 80, 25))
        self.LoadGraph.setText("Load Graph")
        self.LoadGraph.setObjectName("LoadGraph")
        self.LoadGraph.clicked.connect(self.getROICoords)

        self.minLabel = QtWidgets.QLabel(self.graphicsLayout)
        self.minLabel.setGeometry(QtCore.QRect(750, 270, 50, 10))
        self.minLabel.setPalette(grey)
        self.minLabel.setText("Min:")

        self.meanLabel = QtWidgets.QLabel(self.graphicsLayout)
        self.meanLabel.setGeometry(QtCore.QRect(750, 285, 50, 10))
        self.meanLabel.setPalette(grey)
        self.meanLabel.setText("Mean:")

        self.medianLabel = QtWidgets.QLabel(self.graphicsLayout)
        self.medianLabel.setGeometry(QtCore.QRect(750, 300, 50, 10))
        self.medianLabel.setPalette(grey)
        self.medianLabel.setText("Median:")

        self.stdLabel = QtWidgets.QLabel(self.graphicsLayout)
        self.stdLabel.setGeometry(QtCore.QRect(910, 270, 50, 10))
        self.stdLabel.setPalette(grey)
        self.stdLabel.setText("StDev:")

        self.maxLabel = QtWidgets.QLabel(self.graphicsLayout)
        self.maxLabel.setGeometry(QtCore.QRect(910, 285, 50, 10))
        self.maxLabel.setPalette(grey)
        self.maxLabel.setText("Max:")

        self.countLabel = QtWidgets.QLabel(self.graphicsLayout)
        self.countLabel.setGeometry(QtCore.QRect(910, 300, 50, 10))
        self.countLabel.setPalette(grey)
        self.countLabel.setText("Count:")

        self.minValue = QtWidgets.QLabel(self.graphicsLayout)
        self.minValue.setGeometry(QtCore.QRect(810, 270, 50, 10))
        self.minValue.setPalette(grey)
        self.minValue.setText("null")

        self.meanValue = QtWidgets.QLabel(self.graphicsLayout)
        self.meanValue.setGeometry(QtCore.QRect(810, 285, 50, 10))
        self.meanValue.setPalette(grey)
        self.meanValue.setText("null")

        self.medianValue = QtWidgets.QLabel(self.graphicsLayout)
        self.medianValue.setGeometry(QtCore.QRect(810, 300, 50, 10))
        self.medianValue.setPalette(grey)
        self.medianValue.setText("null")

        self.stdValue = QtWidgets.QLabel(self.graphicsLayout)
        self.stdValue.setGeometry(QtCore.QRect(970, 270, 50, 10))
        self.stdValue.setPalette(grey)
        self.stdValue.setText("null")

        self.maxValue = QtWidgets.QLabel(self.graphicsLayout)
        self.maxValue.setGeometry(QtCore.QRect(970, 285, 50, 10))
        self.maxValue.setPalette(grey)
        self.maxValue.setText("null")

        self.countValue = QtWidgets.QLabel(self.graphicsLayout)
        self.countValue.setGeometry(QtCore.QRect(970, 300, 50, 10))
        self.countValue.setPalette(grey)
        self.countValue.setText("null")

        self.linkLabel = QtWidgets.QLabel(self.graphicsLayout)
        self.linkLabel.setGeometry(QtCore.QRect(790, 320, 170, 20))
        self.linkLabel.setText("Show S2 image on sensing date of:")
        self.linkLabel.setPalette(white)

        self.prev = QtWidgets.QPushButton(self.graphicsLayout)
        self.prev.setGeometry(QtCore.QRect(690, 385, 20, 20))
        self.prev.setText("\u276e")
        self.prev.setFont(QtGui.QFont("Segoe UI", 8, 50))
        self.prev.clicked.connect(self.prevClicked)
        self.prev.hide()

        self.next = QtWidgets.QPushButton(self.graphicsLayout)
        self.next.setGeometry(QtCore.QRect(1010, 385, 20, 20))
        self.next.setText("\u276f")
        self.next.setFont(QtGui.QFont("Segoe UI", 8, 50))
        self.next.clicked.connect(self.nextClicked)
        self.next.hide()

        self.Export = QtWidgets.QToolButton(self)
        self.Export.setGeometry(QtCore.QRect(830, 470, 80, 25))
        self.Export.setText("Export")
        self.Export.setObjectName("Export")
        self.Export.setCheckable(True)
        self.Export.clicked.connect(self.exportClicked)

        self.selectVI = self.menubar.addMenu("Select VI")
        self.group = QtWidgets.QActionGroup(self.selectVI)

        loadROI = self.menubar.addAction("Load ROI")
        loadROI.triggered.connect(self.loadGeoJSON)

        about = self.menubar.addAction("About")
        about.triggered.connect(self.infoAbout)

        menu = self.defineArea()
        vis = list(menu.keys())

        for vi in vis:
            areas = menu[vi]
            self.vi_menu = self.selectVI.addMenu(vi)
            for area in areas:
                self.area_menu = QtWidgets.QAction(area, self)
                self.area_menu.setCheckable(True)
                self.area_menu.setParent(self.vi_menu)
                self.title = self.area_menu.parent().title()
                self.area_menu.parentWidget().setAccessibleName(vi)
                self.vi_menu.addAction(self.area_menu)
                self.group.addAction(self.area_menu)
        self.group.setExclusive(True)
        self.selectVI.triggered[QtWidgets.QAction].connect(self.actionVI)