Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 def __init__(self, manager, name, config):
     Module.__init__(self, manager, name, config)
     self.ui = multipatch_nwb_viewer.MultipatchNwbViewer()
     self.ui.resize(1600, 900)
     self.ui.show()
     
     self.load_from_dm_btn = QtGui.QPushButton("load from data manager")
     self.ui.vsplit.insertWidget(0, self.load_from_dm_btn)
     self.load_from_dm_btn.clicked.connect(self.load_from_dm_clicked)
Ejemplo n.º 3
0
 def __init__(self, manager, name, config):
     Module.__init__(self, manager, name, config)
     self.ui = submit_expt.ExperimentSubmitUi()
     self.ui.resize(1600, 900)
     self.ui.show()
     
     self.load_from_dm_btn = QtGui.QPushButton("load from data manager")
     self.ui.left_layout.insertWidget(0, self.load_from_dm_btn)
     self.load_from_dm_btn.clicked.connect(self.load_from_dm_clicked)
Ejemplo n.º 4
0
    def __init__(self, manager, name, config):
        Module.__init__(self, manager, name, config)
        self.ui = vimaging.VImagingAnalyzer()
        self.ui.resize(1600, 900)
        self.ui.show()

        self.load_from_dm_btn = QtGui.QPushButton("load from data manager")
        self.ui.layout.addWidget(self.load_from_dm_btn,
                                 self.ui.layout.rowCount(), 0)
        self.load_from_dm_btn.clicked.connect(self.load_from_dm_clicked)
Ejemplo n.º 5
0
    def __init__(self, manager, name, config):
        Module.__init__(self, manager, name, config)
        self.ui = vimaging.VImagingAnalyzer2()
        self.ui.resize(1600, 900)
        self.ui.show()

        self.load_from_dm_btn = QtGui.QPushButton("load from data manager")
        self.load_from_dm_btn.setParent(self.ui)
        self.load_from_dm_btn.resize(160, 30)
        self.load_from_dm_btn.show()
        self.load_from_dm_btn.clicked.connect(self.load_from_dm_clicked)
Ejemplo n.º 6
0
    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()
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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 = []
Ejemplo n.º 10
0
    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)
    # make a few variables available from the console
    console.localNamespace.update({'man': m, 'view': v, 'nwb': None, 'sweeps': [], 'analyzer': None})

    # make selected sweeps / analyzer available as well
    def update_namespace():
        console.localNamespace.update({'sweeps': v.selected_sweeps(), 'analyzer': v.selected_analyzer()})

    v.analyzer_changed.connect(update_namespace)
    v.explorer.selection_changed.connect(update_namespace)

    # Set up code reloading shortcut
    def reload_all():
        acq4.pyqtgraph.reload.reloadAll(verbose=True)

    reload_shortcut = QtGui.QShortcut(QtGui.QKeySequence('Ctrl+r'), v)
    reload_shortcut.setContext(QtCore.Qt.ApplicationShortcut)
    reload_shortcut.activated.connect(reload_all)

    # load file or set base directory from argv
    for arg in sys.argv[1:]:
        if not os.path.exists(arg):
            from aisynphys.experiment_list import cached_experiments
            expts = cached_experiments()
            try:
                expt = expts[arg]
            except Exception:
                print("Could not find experiment %s" % arg)
                sys.exit(-1)
            arg = expt.nwb_file
Ejemplo n.º 12
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()
Ejemplo n.º 13
0
    def __init__(self, image=None, **opts):
        """
        CanvasItem displaying an image. 
        The image may be 2 or 3-dimensional.
        Options:
            image: May be a fileHandle, ndarray, or GraphicsItem.
            handle: May optionally be specified in place of image

        """

        ## If no image was specified, check for a file handle..
        if image is None:
            image = opts.get('handle', None)

        item = None
        self.data = None
        self.currentT = 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']
                            print 'm: ', m
                            print 'mpos: ', m['position']
                            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.histogram = pg.PlotWidget()
        self.blockHistogram = False
        self.histogram.setMaximumHeight(100)
        self.levelRgn = pg.LinearRegionItem()
        self.histogram.addItem(self.levelRgn)
        self.updateHistogram(autoLevels=True)

        # addWidget arguments: row, column, rowspan, colspan
        self.layout.addWidget(self.histogram, self.layout.rowCount(), 0, 1, 3)

        self.timeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
        #self.timeSlider.setMinimum(0)
        #self.timeSlider.setMaximum(self.data.shape[0]-1)
        self.layout.addWidget(self.timeSlider, self.layout.rowCount(), 0, 1, 3)
        self.timeSlider.valueChanged.connect(self.timeChanged)
        self.timeSlider.sliderPressed.connect(self.timeSliderPressed)
        self.timeSlider.sliderReleased.connect(self.timeSliderReleased)
        thisRow = self.layout.rowCount()

        self.edgeBtn = QtGui.QPushButton('Edge')
        self.edgeBtn.clicked.connect(self.edgeClicked)
        self.layout.addWidget(self.edgeBtn, thisRow, 0, 1, 1)

        self.meanBtn = QtGui.QPushButton('Mean')
        self.meanBtn.clicked.connect(self.meanClicked)
        self.layout.addWidget(self.meanBtn, thisRow + 1, 0, 1, 1)

        self.tvBtn = QtGui.QPushButton('tv denoise')
        self.tvBtn.clicked.connect(self.tvClicked)
        self.layout.addWidget(self.tvBtn, thisRow + 2, 0, 1, 1)

        self.maxBtn = QtGui.QPushButton('Max no Filter')
        self.maxBtn.clicked.connect(self.maxClicked)
        self.layout.addWidget(self.maxBtn, thisRow, 1, 1, 1)

        self.maxBtn2 = QtGui.QPushButton('Max w/Gaussian')
        self.maxBtn2.clicked.connect(self.max2Clicked)
        self.layout.addWidget(self.maxBtn2, thisRow + 1, 1, 1, 1)

        self.maxMedianBtn = QtGui.QPushButton('Max w/Median')
        self.maxMedianBtn.clicked.connect(self.maxMedianClicked)
        self.layout.addWidget(self.maxMedianBtn, thisRow + 2, 1, 1, 1)

        self.filterOrder = QtGui.QComboBox()
        self.filterLabel = QtGui.QLabel('Order')
        for n in range(1, 11):
            self.filterOrder.addItem("%d" % n)
        self.layout.addWidget(self.filterLabel, thisRow + 3, 2, 1, 1)
        self.layout.addWidget(self.filterOrder, thisRow + 3, 3, 1, 1)

        self.zPlanes = QtGui.QComboBox()
        self.zPlanesLabel = QtGui.QLabel('# planes')
        for s in ['All', '1', '2', '3', '4', '5']:
            self.zPlanes.addItem("%s" % s)
        self.layout.addWidget(self.zPlanesLabel, thisRow + 3, 0, 1, 1)
        self.layout.addWidget(self.zPlanes, thisRow + 3, 1, 1, 1)

        ## controls that only appear if there is a time axis
        self.timeControls = [
            self.timeSlider, self.edgeBtn, self.maxBtn, self.meanBtn,
            self.maxBtn2, self.maxMedianBtn, self.filterOrder, self.zPlanes
        ]

        if self.data is not None:
            self.updateImage(self.data)

        self.graphicsItem().sigImageChanged.connect(self.updateHistogram)
        self.levelRgn.sigRegionChanged.connect(self.levelsChanged)
        self.levelRgn.sigRegionChangeFinished.connect(
            self.levelsChangeFinished)