Esempio n. 1
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)
        
        self.view = pg.ImageView()
        self.layout.addWidget(self.view, 0, 0)
        
        self.ctrlWidget = QtGui.QWidget()
        self.layout.addWidget(self.ctrlWidget, 0, 1)
        
        self.maskItem = pg.ImageItem()
        self.maskItem.setZValue(10)
        self.maskItem.setCompositionMode(QtGui.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)
Esempio n. 2
0
    def __init__(self):
        QtGui.QSplitter.__init__(self, QtCore.Qt.Horizontal)
        self.resize(800, 1000)

        self.params = pg.parametertree.Parameter(
            name='params',
            type='group',
            children=[
                dict(name='sequence',
                     type='group',
                     children=[
                         dict(name='analysis',
                              type='list',
                              values=['dF / F', 'SNR', 'noise']),
                     ]),
            ])
        self.ptree = pg.parametertree.ParameterTree()
        self.ptree.setParameters(self.params)
        self.params.child('sequence').sigTreeStateChanged.connect(
            self.update_sequence_analysis)

        self.leftPanel = QtGui.QWidget()
        self.addWidget(self.leftPanel)
        self.layout = QtGui.QGridLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.leftPanel.setLayout(self.layout)

        self.layout.addWidget(self.ptree, 0, 0)

        self.gw = pg.GraphicsLayoutWidget()
        self.addWidget(self.gw)

        self.vb1 = self.gw.addViewBox()
        self.img1 = pg.ImageItem()
        self.vb1.addItem(self.img1)

        self.vb2 = self.gw.addViewBox(row=1, col=0)
        self.img2 = pg.ImageItem()
        self.vb2.addItem(self.img2)

        for vb in (self.vb1, self.vb2):
            vb.invertY()
            vb.setAspectLocked(True)

        self.plt1 = self.gw.addPlot(row=2, col=0)
        self.plt1.setLabels(bottom=('time', 's'))
        self.plt1_items = []

        self.rois = [
            pg.EllipseROI([0, 0], [10, 10], pen=(i, 4)) for i in range(2)
        ]
        for roi in self.rois:
            self.vb1.addItem(roi)
            roi.sigRegionChangeFinished.connect(self.roi_changed)
        self.ignore_roi_change = False

        self.plt2 = self.gw.addPlot(row=3, col=0)
        self.plt2.setXLink(self.plt1)
        self.plt2.setLabels(bottom=('time', 's'))

        self.noise_time_rgn = pg.LinearRegionItem([0.01, 0.02],
                                                  brush=(255, 0, 0, 30))
        self.base_time_rgn = pg.LinearRegionItem([0.025, 0.95],
                                                 brush=(0, 255, 0, 30))
        self.test_time_rgn = pg.LinearRegionItem([0.1, 0.11],
                                                 brush=(0, 0, 255, 30))
        for time_rgn in (self.base_time_rgn, self.test_time_rgn,
                         self.noise_time_rgn):
            self.plt1.addItem(time_rgn)
            time_rgn.sigRegionChangeFinished.connect(self.time_rgn_changed)
            time_rgn.sigRegionChangeFinished.connect(
                self.update_sequence_analysis)
        self.clamp_plots = []

        self.plt3 = self.gw.addPlot(row=4, col=0)
        self.plt3.setLabels(left="dF / F", bottom="trial")

        self.show()