def __init__(self): QtGui.QWidget.__init__(self) self.resize(800, 1000) self.layout = QtGui.QGridLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) self.gw = pg.GraphicsLayoutWidget() self.layout.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.RectROI([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.base_time_rgn = pg.LinearRegionItem([0.0, 0.1]) self.test_time_rgn = pg.LinearRegionItem([0.1, 0.11]) 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) 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()
def __init__(self, mosaic_editor): self.mosaic_editor = mosaic_editor QtGui.QWidget.__init__(self) self.layout = QtGui.QGridLayout() self.setLayout(self.layout) self.load_btn = QtGui.QPushButton("Download 20x") self.layout.addWidget(self.load_btn, 0, 0) self.load_btn.clicked.connect(self.load_clicked) self.submit_btn = pg.FeedbackButton("Submit cell positions to LIMS") self.layout.addWidget(self.submit_btn, 1, 0) self.submit_btn.clicked.connect(self.submit)
def __init__(self): QtGui.QWidget.__init__(self) self.layout = QtGui.QGridLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) # Set up filter buttons self.btns = OrderedDict() row, col = 0, 0 for name in ['Mean', 'Max', 'Max w/Gaussian', 'Max w/Median', 'Edge']: btn = QtGui.QPushButton(name) self.btns[name] = btn btn.setCheckable(True) self.layout.addWidget(btn, row, col) btn.clicked.connect(self.filterBtnClicked) col += 1 if col > 1: col = 0 row += 1 # show flowchart control panel inside a collapsible group box self.fcGroup = pg.GroupBox('Filter Settings') fgl = QtGui.QVBoxLayout() self.fcGroup.setLayout(fgl) fgl.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.fcGroup, row + 1, 0, 1, 2) self.fc = pg.flowchart.Flowchart(terminals={ 'dataIn': { 'io': 'in' }, 'dataOut': { 'io': 'out' } }) fgl.addWidget(self.fc.widget()) self.fcGroup.setCollapsed(True) self.fc.sigStateChanged.connect(self.sigStateChanged)
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)
def __init__(self, image=None, **opts): ## If no image was specified, check for a file handle.. if image is None: image = opts.get('handle', None) item = None self.data = None if isinstance(image, QtGui.QGraphicsItem): item = image elif isinstance(image, np.ndarray): self.data = image elif isinstance(image, DataManager.FileHandle): opts['handle'] = image self.handle = image self.data = self.handle.read() if 'name' not in opts: opts['name'] = self.handle.shortName() try: if 'transform' in self.handle.info(): tr = pg.SRTTransform3D(self.handle.info()['transform']) tr = pg.SRTTransform(tr) ## convert to 2D opts['pos'] = tr.getTranslation() opts['scale'] = tr.getScale() opts['angle'] = tr.getRotation() else: ## check for older info formats if 'imagePosition' in self.handle.info(): opts['scale'] = self.handle.info()['pixelSize'] opts['pos'] = self.handle.info()['imagePosition'] elif 'Downsample' in self.handle.info(): ### Needed to support an older format stored by 2p imager if 'pixelSize' in self.handle.info(): opts['scale'] = self.handle.info()['pixelSize'] if 'microscope' in self.handle.info(): m = self.handle.info()['microscope'] opts['pos'] = m['position'][0:2] else: info = self.data._info[-1] opts['pos'] = info.get('imagePosition', None) elif hasattr(self.data, '_info'): info = self.data._info[-1] opts['scale'] = info.get('pixelSize', None) opts['pos'] = info.get('imagePosition', None) else: opts['defaultUserTransform'] = {'scale': (1e-5, 1e-5)} opts['scalable'] = True except: debug.printExc( 'Error reading transformation for image file %s:' % image.name()) if item is None: item = pg.ImageItem() CanvasItem.__init__(self, item, **opts) self.splitter = QtGui.QSplitter() self.splitter.setOrientation(QtCore.Qt.Vertical) self.layout.addWidget(self.splitter, self.layout.rowCount(), 0, 1, 2) self.filterGroup = pg.GroupBox("Image Filter") fgl = QtGui.QGridLayout() fgl.setContentsMargins(3, 3, 3, 3) fgl.setSpacing(1) self.filterGroup.setLayout(fgl) self.filter = ImageFilterWidget() self.filter.sigStateChanged.connect(self.filterStateChanged) fgl.addWidget(self.filter) self.splitter.addWidget(self.filterGroup) self.histogram = pg.HistogramLUTWidget() self.histogram.setImageItem(self.graphicsItem()) # addWidget arguments: row, column, rowspan, colspan self.splitter.addWidget(self.histogram) self.imgModeCombo = QtGui.QComboBox() self.imgModeCombo.addItems( ['SourceOver', 'Overlay', 'Plus', 'Multiply']) self.layout.addWidget(self.imgModeCombo, self.layout.rowCount(), 0, 1, 1) self.imgModeCombo.currentIndexChanged.connect(self.imgModeChanged) self.autoBtn = QtGui.QPushButton("Auto") self.autoBtn.setCheckable(True) self.autoBtn.setChecked(True) self.layout.addWidget(self.autoBtn, self.layout.rowCount() - 1, 1, 1, 1) self.timeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) self.layout.addWidget(self.timeSlider, self.layout.rowCount(), 0, 1, 2) self.timeSlider.valueChanged.connect(self.timeChanged) # ## controls that only appear if there is a time axis self.timeControls = [self.timeSlider] if self.data is not None: if isinstance(self.data, pg.metaarray.MetaArray): self.filter.setInput(self.data.asarray()) else: self.filter.setInput(self.data) self.updateImage() # Needed to ensure selection box wraps the image properly tr = self.saveTransform() self.resetUserTransform() self.restoreTransform(tr)
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()