Пример #1
0
    def makeObject(self, host):

        typ = self.type()
        args = self.args()
        if typ == 'plot':
            obj = pg.PlotWidget(name=self.name(), **args)
        elif typ == 'imageView':
            obj = pg.ImageView(**args)
        elif typ == 'canvas':
            obj = Canvas.Canvas(**args)
        elif typ == 'fileInput':
            obj = FileLoader.FileLoader(host.dataManager(), **args)
        #elif typ == 'database':
        #obj = DatabaseGui.DatabaseGui(host.dataManager(), **args)
        elif typ == 'table':
            obj = pg.TableWidget(**args)
        elif typ == 'dataTree':
            obj = pg.DataTreeWidget(**args)
        elif typ == 'parameterTree':
            obj = pg.parametertree.ParameterTree(**args)
        elif typ == 'graphicsView':
            obj = pg.GraphicsView(**args)
        elif typ == 'graphicsLayout':
            obj = pg.GraphicsLayoutWidget(**args)
        elif typ == 'viewBox':
            obj = pg.GraphicsView()
            obj.setCentralItem(pg.ViewBox(**args))
        else:
            raise Exception(
                "Cannot automatically create element '%s' (type=%s)" %
                (self.name, typ))
        #self.setObject(obj)  ## handled indirectly..
        return obj
Пример #2
0
    def __init__(self, parent=None):
        Qt.QWidget.__init__(self, parent)
        self.layout = Qt.QGridLayout()
        self.setLayout(self.layout)

        self.view = pg.ImageView()
        self.layout.addWidget(self.view, 0, 0)

        self.ctrlWidget = Qt.QWidget()
        self.layout.addWidget(self.ctrlWidget, 0, 1)

        self.maskItem = pg.ImageItem()
        self.maskItem.setZValue(10)
        self.maskItem.setCompositionMode(Qt.QPainter.CompositionMode_Multiply)
        lut = np.zeros((256, 3), dtype='ubyte')
        lut[:, 0:2] = np.arange(256).reshape(256, 1)
        self.maskItem.setLookupTable(lut)

        kern = np.fromfunction(
            lambda x, y: np.clip(((5 - (x - 5)**2 +
                                   (y - 5)**2)**0.5 * 255), 0, 255), (11, 11))
        self.maskItem.setDrawKernel(kern, mask=kern, center=(5, 5), mode='add')

        self.view.addItem(self.maskItem)

        self.view.sigTimeChanged.connect(self.updateMaskImage)
Пример #3
0
    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.layout = QtGui.QVBoxLayout()
        self.setLayout(self.layout)
        self.imv1 = pg.ImageView()
        self.layout.addWidget(self.imv1)

        self.plt1 = pg.PlotWidget()
        self.layout.addWidget(self.plt1)

        self.base_time_rgn = pg.LinearRegionItem([0.07, 0.099])
        self.test_time_rgn = pg.LinearRegionItem([0.104, 0.112])
        for time_rgn in (self.base_time_rgn, self.test_time_rgn):
            self.plt1.addItem(time_rgn)
            time_rgn.sigRegionChangeFinished.connect(self.time_rgn_changed)

        self.plot_data = []
Пример #4
0
    def __init__(self, *args):
        AnalysisModule.__init__(self, *args)
        self.layout = Qt.QGridLayout()
        self.setLayout(self.layout)
        self.splitter = Qt.QSplitter()
        self.layout.addWidget(self.splitter)
        self.ptree = ParameterTree()
        self.splitter.addWidget(self.ptree)
        self.imageView = pg.ImageView()
        self.splitter.addWidget(self.imageView)
        
        self.params = Parameter(name='imager', children=[
            dict(name='scanner', type='interface', interfaceTypes=['scanner']),
            dict(name='detectors', type='group', addText="Add detector.."),
            dict(name='decomb', type='float', readonly=False, value=20e-6, suffix='s', siPrefix=True, bounds=[0, 1e-3], step=1e-6, decimals=5, children=[
                dict(name='auto', type='action'),
                dict(name='subpixel', type='bool', value=False),
                ]),
            dict(name='downsample', type='int', value=1, suffix='x', bounds=[1,None]),
            dict(name='display', type='bool', value=True),
            dict(name='scanProgram', type='list', values=[]),
            dict(name='Objective', type='str', value='Unknown', readonly=True),
            dict(name='Filter', type='str', value='Unknown', readonly=True),
            ])
        self.ptree.setParameters(self.params, showTop=False)
        self.params.sigTreeStateChanged.connect(self.update)
        self.params.child('detectors').sigAddNew.connect(self.addDetectorClicked)
        self.params.child('decomb', 'auto').sigActivated.connect(self.autoDecomb)

        self.man = getManager()
        self.scannerDev = self.man.getDevice(self.params['scanner'])
        # find first scope device that is parent of scanner
        dev = self.scannerDev
        while dev is not None and not isinstance(dev, Microscope):
            dev = dev.parentDevice()
        self.scopeDev = dev
                
        self.lastFrame = None
        # self.SUF = SUFA.ScannerUtilities()
        # self.ui.alphaSlider.valueChanged.connect(self.imageAlphaAdjust)        
        self.img = pg.ImageItem()  ## image shown in camera module
        self.img.setLookupTable(self.imageView.ui.histogram.getLookupTable)  # image fetches LUT from the ImageView
        self.imageView.ui.histogram.sigLevelsChanged.connect(self._updateCamModImage)
        self.imageView.imageItem.setAutoDownsample(True)
Пример #5
0
    def setCurrentFile(self, file):
        #print "=============== set current file ============"
        if file is self.current:
            return

        ## What if we just want to update the data display?
        #self.clear()

        if file is None:
            self.current = None
            return

        if file.isDir():
            ## Sequence or not?
            return
        else:
            typ = file.fileType()
            if typ is None:
                return
            else:
                image = False
                with pg.BusyCursor():
                    data = file.read()
                if typ == 'ImageFile':
                    image = True
                elif typ == 'MetaArray':
                    if data.ndim == 2 and not data.axisHasColumns(
                            0) and not data.axisHasColumns(1):
                        image = True
                    elif data.ndim > 2:
                        image = True
                else:
                    return

        with pg.BusyCursor():
            if image:
                if self.currentType == 'image' and len(self.widgets) > 0:
                    try:
                        self.widgets[0].setImage(data, autoRange=False)
                    except:
                        print "widget types:", map(type, self.widgets)
                        raise
                else:
                    self.clear()
                    w = pg.ImageView(self)
                    #print "add image:", w.ui.roiPlot.plotItem
                    #self.plots = [weakref.ref(w.ui.roiPlot.plotItem)]
                    self.addWidget(w)
                    w.setImage(data)
                    self.widgets.append(w)
                self.currentType = 'image'
            else:
                self.clear()
                w = pg.MultiPlotWidget(self)
                self.addWidget(w)
                w.plot(data)
                self.currentType = 'plot'
                self.widgets.append(w)
                #print "add mplot:", w.mPlotItem.plots

                #self.plots = [weakref.ref(p[0]) for p in w.mPlotItem.plots]

        if (hasattr(data, 'implements') and data.implements('MetaArray')):
            if self.dictWidget is None:
                w = DictView(data._info)
                self.dictWidget = w
                #w.setText(str(data._info[-1]))
                self.addWidget(w)
                self.widgets.append(w)
                h = self.size().height()
                self.setSizes([h * 0.8, h * 0.2])
            else:
                self.dictWidget.setData(data._info)
Пример #6
0
    def __init__(self, mod, dev, mode, recordDir):
        self.mod = weakref.ref(mod)
        self.dev = dev
        self.mode = mode
        self.writable = mode != None
        self.recordDir = recordDir.getDir(self.dev, create=self.writable)
        if self.writable:
            self.recordDir.setInfo(mode=mode)
        else:
            mode = self.recordDir.info()['mode']

        if mode[0] == 'v':
            self.units = 'A'
        else:
            self.units = 'V'

        self.rawDataFile = None
        self.envelopeFile = None
        self.spectrogramFile = None
        self.resetDisplay = True
        self.showNewRecords = True

        Qt.QSplitter.__init__(self, Qt.Qt.Vertical)

        self.plot = pg.PlotWidget(labels={
            'left': ('Primary', self.units),
            'bottom': ('Time', 's')
        },
                                  title="%s (%s)" % (dev, mode))
        self.plot.setDownsampling(auto=True)
        self.plot.setClipToView(True)
        self.addWidget(self.plot)

        self.envelopePlot = pg.PlotWidget(labels={
            'left': ('Mean, Stdev, Peaks', self.units),
            'bottom': ('Time', 's')
        })
        self.addWidget(self.envelopePlot)

        self.specView = pg.PlotItem(labels={
            'left': ('Frequency', 'Hz'),
            'bottom': ('Time', 's')
        })
        self.spectrogram = pg.ImageView(view=self.specView)
        self.specView.setAspectLocked(False)
        self.spectrogram.imageItem.setAutoDownsample(True)
        self.addWidget(self.spectrogram)

        self.setStretchFactor(0, 10)
        self.setStretchFactor(1, 15)
        self.setStretchFactor(2, 30)

        self.specLine = pg.InfiniteLine()
        self.spectrogram.addItem(self.specLine)

        self.envLine = pg.InfiniteLine(movable=True)
        self.envelopePlot.addItem(self.envLine)
        self.envLine.sigDragged.connect(self.lineDragged)

        if not self.writable:
            # Load previously collected data
            self.loadRecord()