Esempio n. 1
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    filename = osp.join(osp.dirname(__file__), "brain.png")
    image = make.image(filename=filename, title="Original", colormap="gray")

    win = ImageDialog(
        edit=False,
        toolbar=True,
        wintitle="Contrast test",
        options=dict(show_contrast=True),
    )
    plot = win.get_plot()
    plot.add_item(image)
    win.resize(600, 600)
    win.show()
    try:
        plot.save_widget("contrast.png")
    except IOError:
        # Skipping this part of the test
        # because user has no write permission on current directory
        pass
    win.exec_()
Esempio n. 2
0
def create_window():
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="Cross sections test",
                      options=dict(show_xsection=True, show_ysection=True))
    win.resize(600, 600)
    return win
Esempio n. 3
0
def test():
    filename = osp.join(osp.dirname(__file__), "mr-brain.dcm")
    image = make.image(filename=filename, title="DICOM img", colormap='gray')
    win = ImageDialog(edit=False, toolbar=True, wintitle="DICOM I/O test",
                      options=dict(show_contrast=True))
    plot = win.get_plot()
    plot.add_item(image)
    plot.select_item(image)
    contrast = win.get_contrast_panel()
    contrast.histogram.eliminate_outliers(54.)
    win.resize(600, 700)
    return win
Esempio n. 4
0
def test():
    filename = osp.join(osp.dirname(__file__), "mr-brain.dcm")
    image = make.image(filename=filename, title="DICOM img", colormap='gray')
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="DICOM I/O test",
                      options=dict(show_contrast=True))
    plot = win.get_plot()
    plot.add_item(image)
    plot.select_item(image)
    contrast = win.get_contrast_panel()
    contrast.histogram.eliminate_outliers(54.)
    win.resize(600, 700)
    return win
Esempio n. 5
0
def plotImage(x,y,z,wintitle="Contour Plot",options={"lock_aspect_ratio":False,"yreverse":False}):
    options.update(dict(show_xsection=True, show_ysection=True))
    """Test"""
    # -- Create QApplication    
    _app = guidata.qapplication()
    # --
    win = ImageDialog(edit=True, toolbar=True, wintitle=wintitle,
                      options=options)
    win.resize(1500, 1000)
    item = make.xyimage(x, y, z,interpolation="linear")    
    plot = win.get_plot()
    plot.add_item(item)        
    win.plot_widget.xcsw_splitter.setSizes([400,600])
    win.show()
    return win
Esempio n. 6
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    filename = osp.join(osp.dirname(__file__), "brain.png")
    image = make.image(filename=filename, title="Original", colormap='gray')

    win = ImageDialog(edit=False, toolbar=True, wintitle="Contrast test",
                      options=dict(show_contrast=True))
    plot = win.get_plot()
    plot.add_item(image)
    win.resize(600, 600)
    win.show()
    try:
        plot.save_widget('contrast.png')
    except IOError:
        # Skipping this part of the test
        # because user has no write permission on current directory
        pass
    win.exec_()
Esempio n. 7
0
def plotImage(x,
              y,
              z,
              wintitle="Contour Plot",
              options={
                  "lock_aspect_ratio": False,
                  "yreverse": False
              }):
    options.update(dict(show_xsection=True, show_ysection=True))
    """Test"""
    # -- Create QApplication
    _app = guidata.qapplication()
    # --
    win = ImageDialog(edit=True,
                      toolbar=True,
                      wintitle=wintitle,
                      options=options)
    win.resize(1500, 1000)
    item = make.xyimage(x, y, z, interpolation="linear")
    plot = win.get_plot()
    plot.add_item(item)
    win.plot_widget.xcsw_splitter.setSizes([400, 600])
    win.show()
    return win
Esempio n. 8
0
def create_window():
    win = ImageDialog(edit=False, toolbar=True, wintitle="Cross sections test",
                      options=dict(show_xsection=True, show_ysection=True,
                                   show_itemlist=True))
    win.resize(800, 600)
    return win
Esempio n. 9
0
class MTEAcqu(QWidget):
    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        self.base_path = os.path.realpath(os.path.curdir)
        self.threadAcq = ThreadAcq(self)
        self.configMTE = QSettings('configMTE.ini', QSettings.IniFormat)

        self.setup()

        self.win = ImageDialog(edit=False,
                               toolbar=True,
                               wintitle="Visu Data",
                               options=dict(show_xsection=True,
                                            show_ysection=True,
                                            show_contrast=True,
                                            show_itemlist=False))
        self.win.resize(800, 1000)
        data = np.ones((1300, 1340))
        self.item_data = make.image(data, colormap='hot')
        self.plot = self.win.get_plot()
        self.plot.add_item(self.item_data)

    def setup(self):
        self.setWindowTitle('MTE acquisition')

        self.name_file = QLineEdit('filename.tif')

        self.showParam = QPushButton('Show Param')
        self.showParam.clicked.connect(self.show_all_param)

        self.com_conf = QComboBox()
        self.com_conf.insertItems(0, self.configMTE.childGroups())
        self.but_load_conf = QPushButton('load conf')
        self.but_load_conf.clicked.connect(self.load_conf)

        hlayout3 = QHBoxLayout()
        hlayout3.addWidget(self.but_load_conf)

        self.check_bck = QCheckBox('Substract BCK')
        self.but_tool = QToolButton()
        self.but_tool.setText('...')
        self.but_tool.clicked.connect(self.load_BCK)
        self.name_bck = QLineEdit('filename_BCK.tif')
        self.name_bck.setDisabled(True)

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.check_bck)
        hlayout.addWidget(self.but_tool)

        self.lin_base_path = QLineEdit('default path')
        self.lin_base_path.setText(self.base_path)
        self.lin_base_path.setDisabled(True)
        self.but_base_path = QToolButton()
        self.but_base_path.setText('...')
        self.but_base_path.clicked.connect(self.ch_base_path)

        hlayout2 = QHBoxLayout()
        hlayout2.addWidget(self.lin_base_path)
        hlayout2.addWidget(self.but_base_path)

        self.startAcq = QPushButton('Start Acq')
        self.startAcq.clicked.connect(self.start_acq)

        self.but_show = QPushButton('Show data')
        self.but_show.clicked.connect(self.show_data)

        vlayout = QVBoxLayout(self)
        vlayout.addWidget(self.showParam)
        vlayout.addSpacing(25)
        vlayout.addWidget(self.com_conf)
        vlayout.addLayout(hlayout3)
        vlayout.addSpacing(25)
        vlayout.addLayout(hlayout)
        vlayout.addWidget(self.name_bck)
        vlayout.addSpacing(25)
        vlayout.addLayout(hlayout2)
        vlayout.addWidget(self.name_file)
        vlayout.addWidget(self.startAcq)
        vlayout.addSpacing(25)
        vlayout.addWidget(self.but_show)
        vlayout.addStretch()
        self.setLayout(vlayout)

    def ch_base_path(self):
        self.base_path = QFileDialog.getExistingDirectory(self)
        self.lin_base_path.setText(self.base_path)
        print('Base path is set to : %s' % self.base_path)

    def load_BCK(self):
        path_bck = QFileDialog.getOpenFileName(self)
        self.name_bck.setText(path_bck)
        print('Background file is set to : %s' % path_bck)

        import PIL
        img_pil = PIL.Image.open(path_bck)

        self.array_bck = np.array(img_pil)

    def start_acq(self):
        self.mte = self.parent.widCON.mte
        self.threadAcq.start()

    def show_all_param(self):
        self.mte.printAvailableParameters()
        param = ['ExposureTime', 'ShutterTimingMode']

        print('#### MTE parameters ####')
        for p in param:
            print(p, self.mte.getParameter(p))

    def show_data(self):
        self.win.show()

    def load_conf(self):
        conf = self.com_conf.currentText()
        self.configMTE = QSettings('configMTE.ini', QSettings.IniFormat)
        print('Loading configuration: %s' % conf)

        x0 = int(self.configMTE.value(conf + '/x0'))
        w = int(self.configMTE.value(conf + '/w'))
        y0 = int(self.configMTE.value(conf + '/y0'))
        h = int(self.configMTE.value(conf + '/h'))
        CleanCycleCount = int(self.configMTE.value(conf + '/CleanCycleCount'))
        ExposureTime = int(self.configMTE.value(conf + '/ExposureTime'))
        TriggerResponse = int(self.configMTE.value(conf + '/TriggerResponse'))

        self.mte = self.parent.widCON.mte
        self.mte.setParameter("CleanCycleCount", CleanCycleCount)
        self.mte.setParameter("ExposureTime", ExposureTime)
        self.mte.setParameter("TriggerResponse", TriggerResponse)
        self.mte.setROI(x0, w, 1, y0, h, 1)
        self.mte.sendConfiguration()