Beispiel #1
0
    def __init__(self, manager, name, config):
        Module.__init__(self, manager, name, config)
        #self.dm = self.manager.dataManager
        self.dm = getDataManager()
        self.win = Window()
        mp = os.path.dirname(__file__)
        self.win.setWindowIcon(QtGui.QIcon(os.path.join(mp, 'icon.png')))
        self.win.dm = self  ## so embedded widgets can find the module easily
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self.win)
        self.ui.analysisWidget = FileAnalysisView.FileAnalysisView(
            self.ui.analysisTab, self)
        self.ui.analysisTab.layout().addWidget(self.ui.analysisWidget)
        self.ui.logWidget = FileLogView.FileLogView(self.ui.logTab, self)
        self.ui.logTab.layout().addWidget(self.ui.logWidget)

        self.win.show()
        w = self.ui.splitter.width()
        self.ui.splitter.setSizes([int(w * 0.4), int(w * 0.6)])
        self.ui.logDock.hide()
        self.dialog = FileDialog()
        self.dialog.setFileMode(QtGui.QFileDialog.DirectoryOnly)
        self.ui.fileTreeWidget.setSelectionMode(
            QtGui.QAbstractItemView.ExtendedSelection)
        ## Load values into GUI
        #self.model = DMModel(self.manager.getBaseDir())
        #self.ui.fileTreeView.setModel(self.model)
        self.baseDirChanged()
        self.currentDirChanged()
        self.selFile = None
        self.updateNewFolderList()

        ## Make all connections needed
        self.ui.selectDirBtn.clicked.connect(self.showFileDialog)
        self.ui.setCurrentDirBtn.clicked.connect(self.setCurrentClicked)
        self.dialog.filesSelected.connect(self.setBaseDir)
        self.manager.sigBaseDirChanged.connect(self.baseDirChanged)
        self.manager.sigCurrentDirChanged.connect(self.currentDirChanged)
        self.manager.sigConfigChanged.connect(self.updateNewFolderList)
        self.manager.sigLogDirChanged.connect(self.updateLogDir)
        self.ui.setLogDirBtn.clicked.connect(self.setLogDir)
        self.ui.newFolderList.currentIndexChanged.connect(self.newFolder)
        self.ui.fileTreeWidget.itemSelectionChanged.connect(
            self.fileSelectionChanged)
        #self.ui.logEntryText.returnPressed.connect(self.logEntry)
        self.ui.fileDisplayTabs.currentChanged.connect(self.tabChanged)
        self.win.sigClosed.connect(self.quit)
        self.ui.analysisWidget.sigDbChanged.connect(self.analysisDbChanged)

        #self.logBtn = LogButton('Log')
        self.win.setStatusBar(StatusBar())
Beispiel #2
0
    def __init__(self, dataManager=None, dataModel=None, module=None):
        Qt.QMainWindow.__init__(self)
        self.dm = dataManager
        self.dataModel = dataModel
        self.mod = None
        self.dockArea = dockarea.DockArea()
        self.setCentralWidget(self.dockArea)
        
        #self.logBtn = LogButton('Log')
        #self.statusBar().addPermanentWidget(self.logBtn)
        self.setStatusBar(StatusBar())
        
        if module is not None:
            self.loadModule(module)

        self.show()
Beispiel #3
0
    def __init__(self, dm, config):
        clampName = config['clampDev']
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle(clampName)
        self.startTime = None
        self.redrawCommand = 1

        self.analysisItems = {
            'inputResistance': u'Ω',
            'accessResistance': u'Ω',
            'capacitance': 'F',
            'restingPotential': 'V',
            'restingCurrent': 'A',
            'fitError': ''
        }

        self.params = {
            'mode': 'vc',
            'rate': config.get('sampleRate', 100000),
            'downsample': config.get('downsample', 3),
            'cycleTime': .2,
            'recordTime': 0.1,
            'delayTime': 0.03,
            'pulseTime': 0.05,
            'icPulse': -30e-12,
            'vcPulse': -10e-3,
            'icHolding': 0,
            'vcHolding': -65e-3,
            'icHoldingEnabled': False,
            'icPulseEnabled': True,
            'vcHoldingEnabled': False,
            'vcPulseEnabled': True,
            'drawFit': True,
            'average': 1,
        }

        self.paramLock = Mutex(QtCore.QMutex.Recursive)

        self.manager = dm
        self.clampName = clampName
        self.thread = PatchThread(self)
        self.cw = QtGui.QWidget()
        self.setCentralWidget(self.cw)
        self.ui = Ui_Form()
        self.ui.setupUi(self.cw)
        #self.logBtn = LogButton("Log")
        #self.statusBar().addPermanentWidget(self.logBtn)
        self.setStatusBar(StatusBar())

        self.stateFile = os.path.join('modules', self.clampName + '_ui.cfg')
        uiState = Manager.getManager().readConfigFile(self.stateFile)
        if 'geometry' in uiState:
            geom = QtCore.QRect(*uiState['geometry'])
            self.setGeometry(geom)
        if 'window' in uiState:
            ws = QtCore.QByteArray.fromPercentEncoding(uiState['window'])
            self.restoreState(ws)

        self.ui.splitter_2.setSizes([self.width() / 4, self.width() * 3. / 4.])
        self.ui.splitter.setStretchFactor(0, 30)
        self.ui.splitter.setStretchFactor(1, 10)

        self.plots = {}
        for k in self.analysisItems:
            p = PlotWidget()
            p.setLabel('left', text=k, units=self.analysisItems[k])
            self.ui.plotLayout.addWidget(p)
            self.plots[k] = p
        irp = self.plots['inputResistance']
        irp.setLogMode(y=True, x=False)
        irp.setYRange(6, 11)

        self.ui.icPulseSpin.setOpts(dec=True,
                                    step=1,
                                    minStep=1e-12,
                                    bounds=[None, None],
                                    siPrefix=True,
                                    suffix='A')
        self.ui.vcPulseSpin.setOpts(dec=True,
                                    step=1,
                                    minStep=1e-3,
                                    bounds=[None, None],
                                    siPrefix=True,
                                    suffix='V')
        self.ui.icHoldSpin.setOpts(dec=True,
                                   step=1,
                                   minStep=1e-12,
                                   bounds=[None, None],
                                   siPrefix=True,
                                   suffix='A')
        self.ui.vcHoldSpin.setOpts(dec=True,
                                   step=1,
                                   minStep=1e-3,
                                   bounds=[None, None],
                                   siPrefix=True,
                                   suffix='V')
        self.ui.cycleTimeSpin.setOpts(dec=True,
                                      step=1,
                                      minStep=1e-6,
                                      bounds=[0, None],
                                      siPrefix=True,
                                      suffix='s')
        self.ui.pulseTimeSpin.setOpts(dec=True,
                                      step=1,
                                      minStep=1e-6,
                                      bounds=[0, 1.],
                                      siPrefix=True,
                                      suffix='s')
        self.ui.delayTimeSpin.setOpts(dec=True,
                                      step=1,
                                      minStep=1e-6,
                                      bounds=[0, 1.],
                                      siPrefix=True,
                                      suffix='s')

        self.stateGroup = WidgetGroup([
            (self.ui.icPulseSpin, 'icPulse'),
            (self.ui.vcPulseSpin, 'vcPulse'),
            (self.ui.icHoldSpin, 'icHolding'),
            (self.ui.vcHoldSpin, 'vcHolding'),
            (self.ui.icPulseCheck, 'icPulseEnabled'),
            (self.ui.vcPulseCheck, 'vcPulseEnabled'),
            (self.ui.icHoldCheck, 'icHoldingEnabled'),
            (self.ui.vcHoldCheck, 'vcHoldingEnabled'),
            (self.ui.cycleTimeSpin, 'cycleTime'),
            (self.ui.pulseTimeSpin, 'pulseTime'),
            (self.ui.delayTimeSpin, 'delayTime'),
            (self.ui.drawFitCheck, 'drawFit'),
            (self.ui.averageSpin, 'average'),
        ])
        self.stateGroup.setState(self.params)

        self.ui.patchPlot.setLabel('left', text='Primary', units='A')
        self.patchCurve = self.ui.patchPlot.plot(
            pen=QtGui.QPen(QtGui.QColor(200, 200, 200)))
        self.patchFitCurve = self.ui.patchPlot.plot(
            pen=QtGui.QPen(QtGui.QColor(0, 100, 200)))
        self.ui.commandPlot.setLabel('left', text='Command', units='V')
        self.commandCurve = self.ui.commandPlot.plot(
            pen=QtGui.QPen(QtGui.QColor(200, 200, 200)))

        self.ui.startBtn.clicked.connect(self.startClicked)
        self.ui.recordBtn.clicked.connect(self.recordClicked)
        self.ui.bathModeBtn.clicked.connect(self.bathMode)
        self.ui.patchModeBtn.clicked.connect(self.patchMode)
        self.ui.cellModeBtn.clicked.connect(self.cellMode)
        self.ui.monitorModeBtn.clicked.connect(self.monitorMode)
        self.ui.resetBtn.clicked.connect(self.resetClicked)
        self.thread.finished.connect(self.threadStopped)
        self.thread.sigNewFrame.connect(self.handleNewFrame)
        self.ui.vcModeRadio.toggled.connect(self.updateParams)
        self.stateGroup.sigChanged.connect(self.updateParams)

        ## Configure analysis plots, curves, and data arrays
        self.analysisCurves = {}
        self.analysisData = {'time': []}
        for n in self.analysisItems:
            w = getattr(self.ui, n + 'Check')
            w.clicked.connect(self.showPlots)
            p = self.plots[n]
            self.analysisCurves[n] = p.plot(
                pen=QtGui.QPen(QtGui.QColor(200, 200, 200)))
            for suf in ['', 'Std']:
                self.analysisData[n + suf] = []
        self.showPlots()
        self.updateParams()
        self.show()
        self.bathMode()
Beispiel #4
0
    def __init__(self, module):
        self.hasQuit = False
        self.module = module # handle to the rest of the application
        
        self.interfaces = OrderedDict()  # owner: widget
        self.docks = OrderedDict()       # owner: dock
        
        # Start building UI
        Qt.QMainWindow.__init__(self)
        self.setWindowTitle('Camera')
        self.cw = dockarea.DockArea()
        self.setCentralWidget(self.cw)
        self.gv = pg.GraphicsView()
        self.gvDock = dockarea.Dock(name="View", widget=self.gv, hideTitle=True, size=(600,600))
        self.cw.addDock(self.gvDock)
        
        # set up ViewBox
        self.view = pg.ViewBox()
        self.view.enableAutoRange(x=False, y=False)
        self.view.setAspectLocked(True)
        self.gv.setCentralItem(self.view)
        
        # And a plot area for displaying depth-related information
        self.depthPlot = pg.PlotWidget(labels={'left': ('Depth', 'm')})
        self.depthPlot.setYRange(0, 1e-3)
        self.depthPlot.setXRange(-1, 1)
        self.depthPlot.hideAxis('bottom')
        self.depthPlot.setMouseEnabled(x=False)
        self.depthDock = pg.dockarea.Dock(name='Depth', widget=self.depthPlot)
        self.cw.addDock(self.depthDock, 'right')
        self.depthDock.hide()

        # Add a group that will track to the center of the view
        # self.trackedGroup = pg.GroupItem()
        # self.view.addItem(self.trackedGroup)

        # search for all devices that provide a cameraModuleInterface() method
        man = Manager.getManager()
        devices = [man.getDevice(dev) for dev in man.listDevices()]
        ifaces = OrderedDict([(dev.name(), dev.cameraModuleInterface(self)) for dev in devices if hasattr(dev, 'cameraModuleInterface')])
        
        # add each device's control panel in ots own dock
        haveDevs = False
        for dev, iface in ifaces.items():
            if iface is not None:
                haveDevs = True
                self.addInterface(dev, iface)
        
        # Add explanatory label if no devices were found
        if not haveDevs:
            label = Qt.QLabel("No imaging devices available")
            label.setAlignment(Qt.Qt.AlignHCenter | Qt.Qt.AlignVCenter)
            dock = dockarea.Dock(name="nocamera", widget=label, size=(100, 500), hideTitle=True)
            self.cw.addDock(dock, 'left', self.gvDock)

        # Add a dock with ROI buttons and plot
        self.roiWidget = ROIPlotter(self)
        self.roiDock = dockarea.Dock(name='ROI Plot', widget=self.roiWidget, size=(400, 10))
        self.cw.addDock(self.roiDock, 'bottom', self.gvDock)

        # Add timelapse / z stack / mosaic controls
        self.sequencerWidget = ImageSequencer(self)
        self.sequencerDock = dockarea.Dock(name='Image Sequencer', widget=self.sequencerWidget, size=(200, 10))
        self.cw.addDock(self.sequencerDock, 'right', self.roiDock)
        
        #grid = pg.GridItem()
        #self.view.addItem(grid)
        
        #Scale bar
        self.scaleBar = pg.ScaleBar(100e-6, offset=(-20,-20))
        self.scaleBar.setParentItem(self.view)
        
        ## Set up status bar labels
        self.recLabel = Qt.QLabel()
        self.rgnLabel = Qt.QLabel()
        self.xyLabel = Qt.QLabel()
        self.tLabel = Qt.QLabel()
        self.vLabel = Qt.QLabel()
        self.vLabel.setFixedWidth(50)
        self.setStatusBar(StatusBar())
        font = self.xyLabel.font()
        font.setPointSize(8)
        labels = [self.recLabel, self.xyLabel, self.rgnLabel, self.tLabel, self.vLabel]
        for label in labels:
            label.setFont(font)
            self.statusBar().insertPermanentWidget(0, label)

        # Load previous window state
        self.stateFile = os.path.join('modules', self.module.name + '_ui.cfg')
        uiState = module.manager.readConfigFile(self.stateFile)
        if 'geometry' in uiState:
            geom = Qt.QRect(*uiState['geometry'])
            self.setGeometry(geom)
        if 'window' in uiState:
            ws = Qt.QByteArray.fromPercentEncoding(uiState['window'])
            self.restoreState(ws)
        if 'docks' in uiState:
            self.cw.restoreState(uiState['docks'], missing='ignore')
        
        # done with UI
        self.show()
        self.centerView()
        
        self.gv.scene().sigMouseMoved.connect(self.updateMouse)
Beispiel #5
0
    def __init__(self, manager, name, config):
        Module.__init__(self, manager, name, config)
        self.lastProtoTime = None
        self.loopEnabled = False
        self.devListItems = {}

        self.docks = {}
        self.firstDock = None  # all new docks should stack here
        self.analysisDocks = {}
        self.deleteState = 0
        self.ui = Ui_MainWindow()
        self.win = Window(self)

        g = self.win.geometry()
        self.ui.setupUi(self.win)
        self.win.setGeometry(g)
        self.win.setStatusBar(StatusBar())

        self.ui.protoDurationSpin.setOpts(dec=True,
                                          bounds=[1e-3, None],
                                          step=1,
                                          minStep=1e-3,
                                          suffix='s',
                                          siPrefix=True)
        self.ui.protoLeadTimeSpin.setOpts(dec=True,
                                          bounds=[0, None],
                                          step=1,
                                          minStep=10e-3,
                                          suffix='s',
                                          siPrefix=True)
        self.ui.protoCycleTimeSpin.setOpts(dec=True,
                                           bounds=[0, None],
                                           step=1,
                                           minStep=1e-3,
                                           suffix='s',
                                           siPrefix=True)
        self.ui.seqCycleTimeSpin.setOpts(dec=True,
                                         bounds=[0, None],
                                         step=1,
                                         minStep=1e-3,
                                         suffix='s',
                                         siPrefix=True)
        self.protoStateGroup = pg.WidgetGroup([
            (self.ui.protoContinuousCheck, 'continuous'),
            (self.ui.protoDurationSpin, 'duration'),
            (self.ui.protoLeadTimeSpin, 'leadTime'),
            (self.ui.protoLoopCheck, 'loop'),
            (self.ui.protoCycleTimeSpin, 'loopCycleTime'),
            (self.ui.seqCycleTimeSpin, 'cycleTime'),
            (self.ui.seqRepetitionSpin, 'repetitions', 1),
        ])

        try:
            try:
                taskDir = config['taskDir']
            except KeyError:
                taskDir = self.manager.config[
                    'protocolDir']  # for backward compatibility
            self.taskList = Loader(self, taskDir)
        except KeyError:
            raise HelpfulException(
                "Config is missing 'taskDir'; cannot load task list.")

        self.ui.LoaderDock.setWidget(self.taskList)

        self.currentTask = None  ## pointer to current task object

        for m in analysisModules.MODULES:
            item = Qt.QListWidgetItem(m, self.ui.analysisList)
            item.setFlags(Qt.Qt.ItemIsSelectable | Qt.Qt.ItemIsEnabled
                          | Qt.Qt.ItemIsUserCheckable)
            item.setCheckState(Qt.Qt.Unchecked)

        self.taskThread = TaskThread(self)

        self.newTask()

        self.ui.testSingleBtn.clicked.connect(self.testSingleClicked)
        self.ui.runTaskBtn.clicked.connect(self.runSingleClicked)
        self.ui.testSequenceBtn.clicked.connect(self.testSequence)
        self.ui.runSequenceBtn.clicked.connect(self.runSequenceClicked)
        self.ui.stopSingleBtn.clicked.connect(self.stopSingle)
        self.ui.stopSequenceBtn.clicked.connect(self.stopSequence)
        self.ui.pauseSequenceBtn.toggled.connect(self.pauseSequence)
        self.ui.deviceList.itemClicked.connect(self.deviceItemClicked)
        self.taskList.sigCurrentFileChanged.connect(
            self.fileChanged
        )  ## called if loaded task file is renamed or moved
        self.taskThread.finished.connect(self.taskThreadStopped)
        self.taskThread.sigNewFrame.connect(self.handleFrame)
        self.taskThread.sigPaused.connect(self.taskThreadPaused)
        self.taskThread.sigTaskStarted.connect(self.taskStarted)
        self.taskThread.sigExitFromError.connect(self.taskErrored)
        self.protoStateGroup.sigChanged.connect(self.protoGroupChanged)
        self.win.show()
        self.ui.sequenceParamList.itemChanged.connect(self.updateSeqReport)
        self.ui.analysisList.itemClicked.connect(self.analysisItemClicked)