Ejemplo n.º 1
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.º 2
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)