def __init__(self, host): AnalysisModule.__init__(self, host) self.dbIdentity = 'Explorer' self.dbCtrl = DBCtrl(host, self.dbIdentity) self.ctrl = PlotCtrl(host, self.dbIdentity) self._elements = OrderedDict([ ('Database', {'type': 'ctrl', 'object':self.dbCtrl, 'size': (200, 300), 'host': self}), ('Scatter Plot', {'type': 'plot', 'pos':('right',), 'size': (800, 600)}), ('Plot Opts', {'type': 'ctrl', 'object': self.ctrl, 'pos':('bottom', 'Database'), 'size':(200,300)}) ])
def __init__(self, host): AnalysisModule.__init__(self, host) self.dbIdentity = 'MapImager' ## how we identify to the database; this determines which tables we own modPath = os.path.abspath(os.path.split(__file__)[0]) self._elements_ = OrderedDict([ ('Database Query', {'type':'ctrl', 'object': DatabaseQueryWidget(self.dataManager()), 'size':(300,200), 'host':self}), ('File Loader', {'type':'fileInput', 'pos':('below', 'Database Query'), 'host':self, 'showFileTree':False}), ('Color Mapper', {'type':'ctrl', 'object': MapImagerColorMapper(filePath=os.path.join(modPath, "colorMaps"), host=self), 'size': (200,300), 'pos':('right', 'Database Query')}), ('Contour Plotter', {'type':'ctrl', 'object':ContourPlotter(host=self), 'pos':('below', 'Color Mapper')}), ('Canvas', {'type': 'canvas', 'pos': ('bottom', 'Color Mapper'), 'size': (700,600), 'allowTransforms': False, 'hideCtrl': True, 'args': {'name': 'MapImager'}}), ('Map Convolver', {'type':'ctrl', 'object': MapConvolver(), 'size': (200, 200), 'pos':('bottom', 'File Loader')}), ('Spatial Correlator', {'type':'ctrl', 'object':SpatialCorrelator(), 'size':(100,100), 'pos': ('bottom', 'Map Convolver')}) #('File Loader', {'type': 'fileInput', 'size': (100, 300), 'host': self, 'args': {'showFileTree': True}}), #('ctrl', {'type': 'ctrl', 'object': self.ctrlWidget, 'pos': ('bottom', 'File Loader'), 'size': (100, 100)}), #('Rs Plot', {'type': 'plot', 'pos':('right', 'File Loader'), 'size':(200, 600), 'labels':{'left':(None,'Ohms'), 'bottom':(None,'s')}}), #('Rm Plot', {'type': 'plot', 'pos':('bottom', 'Rs Plot'), 'size':(200, 600),'labels':{'left':(None,'Ohms'), 'bottom':(None,'s')}}), #('Ih Plot', {'type': 'plot', 'pos':('bottom', 'Rm Plot'), 'size':(200, 600), 'labels':{'left':(None,'A'), 'bottom':(None, 's')}}), #('Traces Plot', {'type': 'plot', 'pos':('right', 'ctrl'), 'size':(200, 600), 'labels':{'left':(None,'A'), 'bottom':(None,'s')}}), ]) self.initializeElements() for el in self.getAllElements(): self.getElement(el, create=True) ## reserve variables that will get set later self.imgItem = None self.spacing = None self.imgData = None self.dbquery = self.getElement("Database Query") self.canvas = self.getElement("Canvas") self.mapConvolver = self.getElement("Map Convolver") self.colorMapper = self.getElement("Color Mapper") self.spatialCorrelator = self.getElement("Spatial Correlator") self.contourPlotter = self.getElement("Contour Plotter") self.contourPlotter.setCanvas(self.canvas) #self.outline = self.spatialCorrelator.getOutline() #self.canvas.addGraphicsItem(self.outline) self.dbquery.sigTableChanged.connect(self.setData) self.mapConvolver.sigOutputChanged.connect(self.convolverOutputChanged) self.mapConvolver.sigFieldsChanged.connect(self.convolverFieldsChanged) self.spatialCorrelator.sigOutputChanged.connect(self.correlatorOutputChanged) self.colorMapper.sigChanged.connect(self.computeColors)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrlWidget = QtGui.QWidget() self.ctrl = ctrlTemplate.Ui_Form() self.ctrl.setupUi(self.ctrlWidget) ## Setup basic GUI self._elements_ = OrderedDict([ #('File Loader', {'type': 'fileInput', 'size': (200, 300), 'host': self}), #('IV Plot', {'type': 'plot', 'pos': ('right', 'File Loader'), 'size': (800, 300)}), #('Data Plot', {'type': 'plot', 'pos': ('bottom',), 'size': (800, 300)}), ('Canvas', {'type': 'canvas', 'size': (600,600)}), ('Ctrl', {'type': 'ctrl', 'object': self.ctrlWidget, 'pos': ('left', 'Canvas'), 'size': (200,600)}), ]) self.initializeElements()
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrlWidget = Qt.QWidget() self.ctrl = ctrlTemplate.Ui_Form() self.ctrl.setupUi(self.ctrlWidget) ## Setup basic GUI self._elements_ = OrderedDict([ #('File Loader', {'type': 'fileInput', 'size': (200, 300), 'host': self}), #('IV Plot', {'type': 'plot', 'pos': ('right', 'File Loader'), 'size': (800, 300)}), #('Data Plot', {'type': 'plot', 'pos': ('bottom',), 'size': (800, 300)}), ('Canvas', {'type': 'canvas', 'size': (600,600)}), ('Ctrl', {'type': 'ctrl', 'object': self.ctrlWidget, 'pos': ('left', 'Canvas'), 'size': (200,600)}), ]) self.initializeElements()
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrl = QtGui.QWidget() l = QtGui.QVBoxLayout() self.ctrl.setLayout(l) self.analyzeBtn = QtGui.QPushButton('Analyze') self.analyzeBtn.clicked.connect(self.updateProfiles) self.saveBtn = QtGui.QPushButton('Save') self.saveBtn.clicked.connect(self.save) l.addWidget(self.analyzeBtn) l.addWidget(self.saveBtn) # Setup basic GUI self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (100, 300), 'host': self, 'args': {'showFileTree': False}}), ('profiles', {'type': 'plot', 'pos': ('bottom', 'File Loader'), 'size': (300, 300)}), ('result table', {'type': 'table', 'pos': ('below', 'profiles')}), ('profile fits', {'type': 'plot', 'pos': ('below', 'result table'), 'size': (300, 300)}), #('view', {'type': 'viewBox', 'pos': ('right', 'File Loader'), 'size': (300,300), 'args': {'lockAspect': True, 'invertY': True}}), ('view', {'type': 'imageView', 'pos': ('right', 'File Loader'), 'size': (300,300)}), ('normalized', {'type': 'imageView', 'pos': ('right', 'view'), 'size': (300,300)}), ('total', {'type': 'plot', 'pos': ('right', 'profiles'), 'size': (300, 100)}), ('peak', {'type': 'plot', 'pos': ('bottom', 'total'), 'size': (300, 100)}), ('width', {'type': 'plot', 'pos': ('bottom', 'peak'), 'size': (300, 100)}), ('ctrl', {'type': 'ctrl', 'object': self.ctrl, 'pos': ('bottom', 'File Loader'), 'size': (100, 20)}), ]) self.initializeElements() self.image = None #self.imageItem = pg.ImageItem() self.view = self.getElement('view', create=True) #view.addItem(self.imageItem) self.dataRgn = pg.RectROI(pos=(120,0), size=(100,100), pen=(0,255,0)) self.dataRgn.addRotateHandle((1,0), (0.5, 0.5)) self.bgRgn = pg.ROI(pos=(0,0), size=(100,100), pen=(255, 0,0), parent=self.dataRgn) self.bgRgn.addRotateHandle((1,0), (0.5, 0.5)) self.bgRgn.addScaleHandle((1, 0.5), (0, 0.5)) #self.bgRgn.setParentItem(self.dataRgn) self.view.addItem(self.bgRgn) self.view.addItem(self.dataRgn) self.dataRgn.sigRegionChanged.connect(self.updateImage) self.bgRgn.sigRegionChanged.connect(self.updateImage)
def __init__(self, host): AnalysisModule.__init__(self, host) fcpath = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "flowcharts") confpath = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "configs") self.confWidget = QtGui.QWidget() self.confLoader = ConfLoader(self, confpath) self.fileLoader = DataLoader(self, host.dataManager()) self.addPlotBtn = QtGui.QPushButton('Add Plot') self.processWidget = QtGui.QWidget() self.processLayout = QtGui.QHBoxLayout() self.processWidget.setLayout(self.processLayout) self.processBtn = QtGui.QPushButton('Process') self.processCheck = QtGui.QCheckBox('Auto') self.processLayout.addWidget(self.processBtn) self.processLayout.addWidget(self.processCheck) self.confLayout = QtGui.QGridLayout() self.confWidget.setLayout(self.confLayout) self.confLayout.addWidget(self.confLoader, 0, 0) self.confLayout.addWidget(self.addPlotBtn, 1, 0) self.confLayout.addWidget(self.processWidget, 2, 0) self.plots = [] self.params = None self.data = None self.flowchart = fc.Flowchart(filePath=fcpath) self.flowchart.addInput('Input') self.flowchart.addOutput('Output') #self.flowchart.sigChartLoaded.connect(self.connectPlots) # Setup basic GUI self._elements_ = OrderedDict([ ('Configuration', {'type': 'ctrl', 'object': self.confWidget, 'size': (200,200)}), ('File Loader', {'type': 'ctrl', 'object': self.fileLoader, 'size': (200, 300), 'pos': ('bottom', 'Configuration')}), ('Flowchart', {'type': 'ctrl', 'object': self.flowchart.widget(), 'size': (300,500), 'pos': ('right',)}), ('Results', {'type': 'table', 'size': (500,200), 'pos': 'bottom'}), ]) self.initializeElements() self.addPlotBtn.clicked.connect(self.addPlotClicked) self.processBtn.clicked.connect(self.processClicked) self.flowchart.sigOutputChanged.connect(self.outputChanged) self.fileLoader.sigFileLoaded.connect(self.fileLoaded) self.fileLoader.sigSelectedFileChanged.connect(self.fileSelected)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrl = QtGui.QWidget() self.ui = Ui_Form() self.ui.setupUi(self.ctrl) self.atlas = None self.canvas = None # grab canvas information when loading files self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (200, 300), 'host': self}), ('Mosaic', {'type': 'ctrl', 'object': self.ctrl, 'pos': ('right',), 'size': (600, 200)}), ('Canvas', {'type': 'canvas', 'pos': ('bottom', 'Mosaic'), 'size': (600, 800), 'args': {'name': 'MosaicEditor'}}), ]) self.initializeElements() self.ui.canvas = self.getElement('Canvas', create=True) self.items = weakref.WeakKeyDictionary() self.files = weakref.WeakValueDictionary() self.cells = {} #addScanImagesBtn = QtGui.QPushButton() #addScanImagesBtn.setText('Add Scan Image') self.ui.fileLoader = self.getElement('File Loader', create=True) self.ui.fileLoader.ui.fileTree.hide() #self.ui.fileLoader.ui.verticalLayout_2.addWidget(addScanImagesBtn) try: self.ui.fileLoader.setBaseClicked() # get the currently selected directory in the DataManager except: pass for a in atlas.listAtlases(): self.ui.atlasCombo.addItem(a) self.ui.canvas.sigItemTransformChangeFinished.connect(self.itemMoved) #self.ui.exportSvgBtn.clicked.connect(self.exportSvg) self.ui.atlasCombo.currentIndexChanged.connect(self.atlasComboChanged) self.ui.normalizeBtn.clicked.connect(self.normalizeImages) self.ui.tileShadingBtn.clicked.connect(self.rescaleImages) self.ui.mosaicApplyScaleBtn.clicked.connect(self.updateScaling) self.ui.mosaicFlipLRBtn.clicked.connect(self.flipLR) self.ui.mosaicFlipUDBtn.clicked.connect(self.flipUD) self.imageMax = 0.0
def __init__(self, host, flowchartDir=None, dbIdentity="EventDetector", dbCtrl=None): AnalysisModule.__init__(self, host) if flowchartDir is None: flowchartDir = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "flowcharts") self.flowchart = Flowchart(filePath=flowchartDir) self.dbIdentity = dbIdentity ## how we identify to the database; this determines which tables we own #self.loader = FileLoader.FileLoader(host.dataManager()) #self.setCentralWidget(self.flowchart.widget()) #self.ui.chartDock1.setWidget(self.flowchart.widget()) self.flowchart.addInput("dataIn") self.flowchart.addOutput('events') #self.flowchart.addOutput('regions', multi=True) self.flowchart.sigChartLoaded.connect(self.connectPlots) if dbCtrl == None: self.dbCtrl = DBCtrl(self, identity=self.dbIdentity) self.dbCtrl.storeBtn.clicked.connect(self.storeClicked) else: self.dbCtrl = dbCtrl(self, identity=self.dbIdentity) #self.ctrl = QtGui.QLabel('LABEL') self.ctrl = self.flowchart.widget() self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (200, 300), 'host': self}), ('Database', {'type': 'ctrl', 'object': self.dbCtrl, 'size': (200,300), 'pos': ('bottom', 'File Loader')}), ('Data Plot', {'type': 'plot', 'pos': ('right',), 'size': (800, 300)}), ('Detection Opts', {'type': 'ctrl', 'object': self.ctrl, 'pos': ('bottom', 'Database'), 'size': (200, 500)}), ('Filter Plot', {'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (800, 300)}), ('Output Table', {'type': 'table', 'pos': ('bottom', 'Filter Plot'), 'optional': True, 'size': (800,200)}), ]) self.initializeElements() try: ## load default chart self.flowchart.loadFile(os.path.join(flowchartDir, 'default.fc')) except: debug.printExc('Error loading default flowchart:') self.flowchart.sigOutputChanged.connect(self.outputChanged)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrlWidget = Qt.QWidget() self.ctrl = CellHealthCtrlTemplate.Ui_widget() self.ctrl.setupUi(self.ctrlWidget) self.ctrlStateGroup = pg.WidgetGroup(self.ctrlWidget) self.ctrl.startSpin.setOpts(step=0.05, suffix='s', siPrefix=True, value=0.35, dec=False) self.ctrl.stopSpin.setOpts(step=0.05, suffix='s', siPrefix=True, value=0.5, dec=False) ## Setup basic GUI self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (100, 300), 'host': self, 'args': {'showFileTree': True}}), ('ctrl', {'type': 'ctrl', 'object': self.ctrlWidget, 'pos': ('bottom', 'File Loader'), 'size': (100, 100)}), ('Rs Plot', {'type': 'plot', 'pos':('right', 'File Loader'), 'size':(200, 600), 'labels':{'left':(None,'Ohms'), 'bottom':(None,'s')}}), ('Rm Plot', {'type': 'plot', 'pos':('bottom', 'Rs Plot'), 'size':(200, 600),'labels':{'left':(None,'Ohms'), 'bottom':(None,'s')}}), ('Ih Plot', {'type': 'plot', 'pos':('bottom', 'Rm Plot'), 'size':(200, 600), 'labels':{'left':(None,'A'), 'bottom':(None, 's')}}), ('Traces Plot', {'type': 'plot', 'pos':('right', 'ctrl'), 'size':(200, 600), 'labels':{'left':(None,'A'), 'bottom':(None,'s')}}), ]) self.initializeElements() for el in self.getAllElements(): self.getElement(el, create=True) self.tracesPlot = self.getElement('Traces Plot') self.measurementArray = np.zeros(1000, dtype=[ ('unixtime', float), ('time', float), ('Rs', float), ('Rm', float), ('Ih', float) ]) self.files = {} ## keys are dhs, values are {'data': array of time/Rs/Rm/Ih, 'ctrlState': state, 'traces': clampData} self.ctrl.processBtn.clicked.connect(self.processClicked) self.ctrl.saveBtn.clicked.connect(self.saveClicked)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrlWidget = QtGui.QWidget() self.ctrl = CellHealthCtrlTemplate.Ui_widget() self.ctrl.setupUi(self.ctrlWidget) self.ctrlStateGroup = pg.WidgetGroup(self.ctrlWidget) self.ctrl.startSpin.setOpts(step=0.05, suffix='s', siPrefix=True, value=0.35, dec=False) self.ctrl.stopSpin.setOpts(step=0.05, suffix='s', siPrefix=True, value=0.5, dec=False) ## Setup basic GUI self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (100, 300), 'host': self, 'args': {'showFileTree': True}}), ('ctrl', {'type': 'ctrl', 'object': self.ctrlWidget, 'pos': ('bottom', 'File Loader'), 'size': (100, 100)}), ('Rs Plot', {'type': 'plot', 'pos':('right', 'File Loader'), 'size':(200, 600), 'labels':{'left':(None,'Ohms'), 'bottom':(None,'s')}}), ('Rm Plot', {'type': 'plot', 'pos':('bottom', 'Rs Plot'), 'size':(200, 600),'labels':{'left':(None,'Ohms'), 'bottom':(None,'s')}}), ('Ih Plot', {'type': 'plot', 'pos':('bottom', 'Rm Plot'), 'size':(200, 600), 'labels':{'left':(None,'A'), 'bottom':(None, 's')}}), ('Traces Plot', {'type': 'plot', 'pos':('right', 'ctrl'), 'size':(200, 600), 'labels':{'left':(None,'A'), 'bottom':(None,'s')}}), ]) self.initializeElements() for el in self.getAllElements(): self.getElement(el, create=True) self.tracesPlot = self.getElement('Traces Plot') self.measurementArray = np.zeros(1000, dtype=[ ('unixtime', float), ('time', float), ('Rs', float), ('Rm', float), ('Ih', float) ]) self.files = {} ## keys are dhs, values are {'data': array of time/Rs/Rm/Ih, 'ctrlState': state, 'traces': clampData} self.ctrl.processBtn.clicked.connect(self.processClicked) self.ctrl.saveBtn.clicked.connect(self.saveClicked)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrl = QtGui.QWidget() self.ui = Ui_Form() self.ui.setupUi(self.ctrl) self.atlas = None self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (200, 300), 'host': self}), ('Mosaic', {'type': 'ctrl', 'object': self.ctrl, 'pos': ('right',), 'size': (600, 200)}), ('Canvas', {'type': 'canvas', 'pos': ('bottom', 'Mosaic'), 'size': (600, 800), 'args': {'name': 'MosaicEditor'}}), ]) self.initializeElements() self.ui.canvas = self.getElement('Canvas', create=True) self.items = weakref.WeakKeyDictionary() self.files = weakref.WeakValueDictionary() self.cells = {} #self.loaded = [] #addScanImagesBtn = QtGui.QPushButton() #addScanImagesBtn.setText('Add Scan Image') self.ui.fileLoader = self.getElement('File Loader', create=True) self.ui.fileLoader.ui.fileTree.hide() #self.ui.fileLoader.ui.verticalLayout_2.addWidget(addScanImagesBtn) try: self.ui.fileLoader.setBaseClicked() # get the currently selected directory in the DataManager except: pass for a in atlas.listAtlases(): self.ui.atlasCombo.addItem(a) self.ui.canvas.sigItemTransformChangeFinished.connect(self.itemMoved) #self.ui.exportSvgBtn.clicked.connect(self.exportSvg) self.ui.atlasCombo.currentIndexChanged.connect(self.atlasComboChanged)
def __init__(self, host, flowchartDir=None): AnalysisModule.__init__(self, host) self.dbIdentity = "IVCurveAnalyzer" ## how we identify to the database; this determines which tables we own if flowchartDir is None: flowchartDir = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "flowcharts") self.flowchart = Flowchart(filePath=flowchartDir) self.flowchart.addInput("dataIn") #self.flowchart.addOutput('events') self.flowchart.addOutput('regions', multi=True) #self.flowchart.sigChartLoaded.connect(self.connectPlots) ### DBCtrl class is from EventDetector -- need to make my own here #self.dbCtrl = DBCtrl(self, identity=self.dbIdentity) #self.dbCtrl.storeBtn.clicked.connect(self.storeClicked) self.ctrl = self.flowchart.widget() self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (200, 300), 'host': self}), #('Database', {'type': 'ctrl', 'object': self.dbCtrl, 'size': (200,300), 'pos': ('bottom', 'File Loader')}), ('Data Plot', {'type': 'plot', 'pos': ('right',), 'size': (800, 300)}), ('Detection Opts', {'type': 'ctrl', 'object': self.ctrl, 'pos': ('bottom', 'File Loader'), 'size': (200, 500)}), ('IV Plot', {'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (400, 300)}), ('Output Table', {'type': 'table', 'pos': ('bottom', 'IV Plot'), 'optional': True, 'size': (800,200)}), ('FI Plot', {'type': 'plot', 'pos': ('right', 'IV Plot'), 'size': (400, 300)}), ]) self.initializeElements() try: ## load default chart self.flowchart.loadFile(os.path.join(flowchartDir, 'default.fc')) except: debug.printExc('Error loading default flowchart:')
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrl = QtGui.QWidget() l = QtGui.QVBoxLayout() self.ctrl.setLayout(l) self.analyzeBtn = QtGui.QPushButton('Analyze') self.analyzeBtn.clicked.connect(self.updateProfiles) self.saveBtn = QtGui.QPushButton('Save') self.saveBtn.clicked.connect(self.save) l.addWidget(self.analyzeBtn) l.addWidget(self.saveBtn) # Setup basic GUI self._elements_ = OrderedDict([ ('File Loader', { 'type': 'fileInput', 'size': (100, 300), 'host': self, 'args': { 'showFileTree': False } }), ('profiles', { 'type': 'plot', 'pos': ('bottom', 'File Loader'), 'size': (300, 300) }), ('result table', { 'type': 'table', 'pos': ('below', 'profiles') }), ('profile fits', { 'type': 'plot', 'pos': ('below', 'result table'), 'size': (300, 300) }), #('view', {'type': 'viewBox', 'pos': ('right', 'File Loader'), 'size': (300,300), 'args': {'lockAspect': True, 'invertY': True}}), ('view', { 'type': 'imageView', 'pos': ('right', 'File Loader'), 'size': (300, 300) }), ('normalized', { 'type': 'imageView', 'pos': ('right', 'view'), 'size': (300, 300) }), ('total', { 'type': 'plot', 'pos': ('right', 'profiles'), 'size': (300, 100) }), ('peak', { 'type': 'plot', 'pos': ('bottom', 'total'), 'size': (300, 100) }), ('width', { 'type': 'plot', 'pos': ('bottom', 'peak'), 'size': (300, 100) }), ('ctrl', { 'type': 'ctrl', 'object': self.ctrl, 'pos': ('bottom', 'File Loader'), 'size': (100, 20) }), ]) self.initializeElements() self.image = None #self.imageItem = pg.ImageItem() self.view = self.getElement('view', create=True) #view.addItem(self.imageItem) self.dataRgn = pg.RectROI(pos=(120, 0), size=(100, 100), pen=(0, 255, 0)) self.dataRgn.addRotateHandle((1, 0), (0.5, 0.5)) self.bgRgn = pg.ROI(pos=(0, 0), size=(100, 100), pen=(255, 0, 0), parent=self.dataRgn) self.bgRgn.addRotateHandle((1, 0), (0.5, 0.5)) self.bgRgn.addScaleHandle((1, 0.5), (0, 0.5)) #self.bgRgn.setParentItem(self.dataRgn) self.view.addItem(self.bgRgn) self.view.addItem(self.dataRgn) self.dataRgn.sigRegionChanged.connect(self.updateImage) self.bgRgn.sigRegionChanged.connect(self.updateImage)
def __init__(self, host): AnalysisModule.__init__(self, host) if self.dataModel is None: raise Exception("Photostim analysis module requires a data model, but none is loaded yet.") self.dbIdentity = "Photostim" ## how we identify to the database; this determines which tables we own self.selectedSpot = None ## setup analysis flowchart modPath = os.path.abspath(os.path.split(__file__)[0]) flowchartDir = os.path.join(modPath, "analysis_fc") self.flowchart = Flowchart(filePath=flowchartDir) self.flowchart.addInput('events') self.flowchart.addInput('regions') self.flowchart.addInput('fileHandle') self.flowchart.addOutput('dataOut') self.analysisCtrl = self.flowchart.widget() ## color mapper self.mapper = ColorMapper.ColorMapper(filePath=os.path.join(modPath, "colormaps")) self.mapCtrl = QtGui.QWidget() self.mapLayout = QtGui.QVBoxLayout() self.mapCtrl.setLayout(self.mapLayout) self.mapLayout.splitter = QtGui.QSplitter() self.mapLayout.splitter.setOrientation(QtCore.Qt.Vertical) self.mapLayout.splitter.setContentsMargins(0,0,0,0) self.mapLayout.addWidget(self.mapLayout.splitter) self.mapLayout.splitter.addWidget(self.analysisCtrl) #self.mapLayout.splitter.addWidget(QtGui.QSplitter()) self.mapLayout.splitter.addWidget(self.mapper) #self.mapLayout.splitter.addWidget(self.recolorBtn) self.recolorLayout = QtGui.QHBoxLayout() self.recolorWidget = QtGui.QWidget() self.mapLayout.splitter.addWidget(self.recolorWidget) self.recolorWidget.setLayout(self.recolorLayout) self.recolorBtn = QtGui.QPushButton('Recolor') self.recolorLayout.addWidget(self.recolorBtn) self.recolorParallelCheck = QtGui.QCheckBox('Parallel') self.recolorParallelCheck.setChecked(True) self.recolorLayout.addWidget(self.recolorParallelCheck) ## scatter plot self.scatterPlot = ScatterPlotter() self.scatterPlot.sigClicked.connect(self.scatterPlotClicked) ## setup map DB ctrl self.dbCtrl = DBCtrl(self, self.dbIdentity) ## storage for map data #self.scanItems = {} self.scans = [] #self.seriesScans = {} self.maps = [] ## create event detector fcDir = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "detector_fc") self.detector = EventDetector.EventDetector(host, flowchartDir=fcDir, dbIdentity=self.dbIdentity+'.events') ## override some of its elements self.detector.setElement('File Loader', self) self.detector.setElement('Database', self.dbCtrl) ## Create element list, importing some gui elements from event detector elems = self.detector.listElements() self._elements_ = OrderedDict([ ('Database', {'type': 'ctrl', 'object': self.dbCtrl, 'size': (300, 600)}), ('Scatter Plot', {'type': 'ctrl', 'object': self.scatterPlot, 'pos': ('right',), 'size': (700,400)}), ('Canvas', {'type': 'canvas', 'pos': ('above', 'Scatter Plot'), 'size': (700,400), 'allowTransforms': False, 'hideCtrl': True, 'args': {'name': 'Photostim'}}), #('Maps', {'type': 'ctrl', 'pos': ('bottom', 'Database'), 'size': (200,200), 'object': self.mapDBCtrl}), ('Map Opts', {'type': 'ctrl', 'object': self.mapCtrl, 'pos': ('above', 'Database'), 'size': (300,600)}), ('Detection Opts', elems['Detection Opts'].setParams(pos=('above', 'Map Opts'), size= (300,600))), ('File Loader', {'type': 'fileInput', 'size': (300, 300), 'pos': ('above', 'Detection Opts'), 'host': self, 'showFileTree': False}), ('Data Plot', elems['Data Plot'].setParams(pos=('bottom', 'Canvas'), size=(700,200))), ('Filter Plot', elems['Filter Plot'].setParams(pos=('bottom', 'Data Plot'), size=(700,200))), ('Event Table', elems['Output Table'].setParams(pos=('below', 'Filter Plot'), size=(700,200))), ('Stats', {'type': 'dataTree', 'size': (700,200), 'pos': ('below', 'Event Table')}), ]) self.initializeElements() try: ## load default chart self.flowchart.loadFile(os.path.join(flowchartDir, 'default.fc')) except: debug.printExc('Error loading default flowchart:') self.detector.flowchart.sigOutputChanged.connect(self.detectorOutputChanged) self.flowchart.sigOutputChanged.connect(self.analyzerOutputChanged) self.detector.flowchart.sigStateChanged.connect(self.detectorStateChanged) self.flowchart.sigStateChanged.connect(self.analyzerStateChanged) self.recolorBtn.clicked.connect(self.recolor)
def quit(self): self.scans = [] self.maps = [] return AnalysisModule.quit(self)
def __init__(self, host): AnalysisModule.__init__(self, host) if self.dataModel is None: raise Exception( "MapAnalyzer module requires a data model, but none is loaded yet." ) self.currentMap = None self.analysisValid = False self.colorsValid = False self.ctrlLayout = pg.LayoutWidget() self.ctrl = ptree.ParameterTree(showHeader=False) self.ctrlLayout.addWidget(self.ctrl, row=0, col=0) self.recalcBtn = QtGui.QPushButton('Recalculate') self.ctrlLayout.addWidget(self.recalcBtn, row=1, col=0) self.storeBtn = pg.FeedbackButton('Store to DB') self.ctrlLayout.addWidget(self.storeBtn, row=2, col=0) self.loader = Loader(host=self, dm=host.dataManager()) modPath = os.path.abspath(os.path.dirname(__file__)) self.colorMapper = ColorMapper( filePath=os.path.join(modPath, "colorMaps")) self._elements_ = OrderedDict([ ('File Loader', { 'type': 'fileInput', 'size': (300, 300), 'host': self, 'showFileTree': False }), ('Map Loader', { 'type': 'ctrl', 'object': self.loader, 'size': (300, 300), 'pos': ('below', 'File Loader') }), ('Color Mapper', { 'type': 'ctrl', 'object': self.colorMapper, 'size': (800, 200), 'pos': ('right', 'Map Loader') }), ('Canvas', { 'type': 'canvas', 'size': (800, 400), 'pos': ('right', 'Color Mapper'), 'args': { 'name': 'MapAnalyzer' } }), ('Options', { 'type': 'ctrl', 'object': self.ctrlLayout, 'size': (300, 500), 'pos': ('bottom', 'Map Loader') }), ('Data Plot', { 'type': 'plot', 'pos': ('top', 'Color Mapper'), 'size': (800, 300) }), ('Score Histogram', { 'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (800, 300) }), ('Timeline', { 'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (800, 300) }), ('Stats Table', { 'type': 'dataTree', 'pos': ('bottom', 'Canvas'), 'size': (800, 300) }), ]) host.resize(1100, 800) self.initializeElements() self.filterStage = EventFilter() self.spontRateStage = SpontRateAnalyzer( plot=self.getElement('Timeline', create=True)) self.statsStage = EventStatisticsAnalyzer( histogramPlot=self.getElement('Score Histogram', create=True)) self.regions = RegionMarker(self.getElement('Canvas', create=True)) self.stages = [ self.filterStage, self.spontRateStage, self.statsStage, self.regions ] params = [ dict(name='Time Ranges', type='group', children=[ dict(name='Direct Start', type='float', value=0.498, suffix='s', step=0.001, siPrefix=True), dict(name='Stimulus', type='float', value=0.5, suffix='s', step=0.001, siPrefix=True), dict(name='Post Start', type='float', value=0.502, suffix='s', step=0.001, siPrefix=True), dict(name='Post Stop', type='float', value=0.700, suffix='s', step=0.001, siPrefix=True), ]), ] ## each processing stage comes with its own set of parameters for stage in self.stages: params.append(stage.parameters()) self.params = ptree.Parameter.create(name='options', type='group', children=params) self.ctrl.setParameters(self.params, showTop=False) canvas = self.getElement('Canvas', create=True) #self.scalebar = pg.ScaleBar(100e-6) #canvas.addGraphicsItem(self.scalebar, name="ScaleBar") self.scalebar = pg.ScaleBar(size=500e-6) self.scalebar.setParentItem(canvas.view) self.scalebar.anchor((1, 1), (1, 1), offset=(-20, -20)) ## Note: need to reconnect this!! #self.params.sigTreeStateChanged.connect(self.invalidate) self.recalcBtn.clicked.connect(self.recalcClicked) self.storeBtn.clicked.connect(self.storeToDB) self.params.param('Time Ranges').sigTreeStateChanged.connect( self.updateTimes) self.getElement('Color Mapper', create=True).sigChanged.connect(self.colorMapChanged) self.regions.sigRegionChanged.connect(self.processRegions)
def __init__(self, host): AnalysisModule.__init__(self, host)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ChR2 = ChR2.ChR2() # create instance of the analysis fcpath = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "flowcharts") confpath = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "configs") self.dbIdentity = "ChR2TraceAnalysis" ## how we identify to the database; this determines which tables we own self._sizeHint = (1024, 800) # try to establish size of window self.confWidget = Qt.QWidget() self.confLoader = ConfLoader(self, confpath) self.fileLoader = DataLoader(self, host.dataManager()) self.addPlotBtn = Qt.QPushButton('Add Plot') self.processWidget = Qt.QWidget() self.processLayout = Qt.QGridLayout() self.processWidget.setLayout(self.processLayout) self.processProtocolBtn = Qt.QPushButton('Process Protocol') self.processSliceBtn = Qt.QPushButton('Process Slice') self.processCellBtn = Qt.QPushButton('Process Cell') self.processCheck = Qt.QCheckBox('Auto') self.processLayout.addWidget(self.processSliceBtn, 0, 0) self.processLayout.addWidget(self.processCellBtn, 1, 0) self.processLayout.addWidget(self.processProtocolBtn, 2, 0) self.processLayout.addWidget(self.processCheck, 3, 0) self.confWidget = Qt.QWidget() self.confLayout = Qt.QGridLayout() self.confWidget.setLayout(self.confLayout) self.confLayout.addWidget(self.confLoader, 0, 0) self.confLayout.addWidget(self.addPlotBtn, 1, 0) self.confLayout.addWidget(self.processWidget, 2, 0) self.plots = [] self.params = None self.data = None ## setup map DB ctrl #self.dbCtrl = DBCtrl(self, self.dbIdentity) self.flowchart = fc.Flowchart(filePath=fcpath) self.flowchart.addInput('Input') self.flowchart.addOutput('Output') #self.flowchart.sigChartLoaded.connect(self.connectPlots) ## create event detector fcDir = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "detector_fc") # self.detector = EventDetector.EventDetector(host, flowchartDir=fcDir, dbIdentity=self.dbIdentity+'.events') self.flowchart.sigChartLoaded.connect(self.connectPlots) #elems = self.detector.listElements() #print elems # Setup basic GUI self._elements_ = OrderedDict([ ('Configuration', { 'type': 'ctrl', 'object': self.confWidget, 'size': (200, 200) }), ('File Loader', { 'type': 'ctrl', 'object': self.fileLoader, 'size': (200, 300), 'pos': ('above', 'Configuration') }), ('Flowchart', { 'type': 'ctrl', 'object': self.flowchart.widget(), 'size': (400, 500), 'pos': ('right', 'Configuration') }), ('Data Plot', { 'type': 'plot', 'pos': ('bottom', 'Flowchart'), 'size': (400, 300) }), ('PSP Plot', { 'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (400, 300) }), ('Scatter Plot1', { 'type': 'plot', 'pos': ('right', ), 'size': (300, 300) }), ('Scatter Plot2', { 'type': 'plot', 'pos': ('bottom', 'Scatter Plot1'), 'size': (300, 300) }), ('Scatter Plot3', { 'type': 'plot', 'pos': ('bottom', 'Scatter Plot2'), 'size': (300, 300) }), ('Results', { 'type': 'table', 'size': (500, 200), 'pos': 'bottom' }), ]) self.initializeElements() self.addPlotBtn.clicked.connect(self.addPlotClicked) self.processSliceBtn.clicked.connect(self.processSliceClicked) self.processCellBtn.clicked.connect(self.processCellClicked) self.processProtocolBtn.clicked.connect(self.processProtocolClicked) self.flowchart.sigOutputChanged.connect(self.outputChanged) self.fileLoader.sigFileLoaded.connect(self.fileLoaded) self.fileLoader.sigSelectedFileChanged.connect(self.fileSelected)
def __init__(self, host): AnalysisModule.__init__(self, host) if self.dataModel is None: raise Exception("MapAnalyzer module requires a data model, but none is loaded yet.") self.currentMap = None self.analysisValid = False self.colorsValid = False self.ctrlLayout = pg.LayoutWidget() self.ctrl = ptree.ParameterTree(showHeader=False) self.ctrlLayout.addWidget(self.ctrl, row=0, col=0) self.recalcBtn = QtGui.QPushButton('Recalculate') self.ctrlLayout.addWidget(self.recalcBtn, row=1, col=0) self.storeBtn = pg.FeedbackButton('Store to DB') self.ctrlLayout.addWidget(self.storeBtn, row=2, col=0) self.loader = Loader(host=self, dm=host.dataManager()) modPath = os.path.abspath(os.path.dirname(__file__)) self.colorMapper = ColorMapper(filePath=os.path.join(modPath, "colorMaps")) self._elements_ = OrderedDict([ ('File Loader', {'type': 'fileInput', 'size': (300, 300), 'host': self, 'showFileTree': False}), ('Map Loader', {'type': 'ctrl', 'object': self.loader, 'size': (300, 300), 'pos': ('below', 'File Loader')}), ('Color Mapper', {'type':'ctrl', 'object': self.colorMapper, 'size': (800,200), 'pos': ('right', 'Map Loader')}), ('Canvas', {'type': 'canvas', 'size': (800, 400), 'pos':('right', 'Color Mapper'), 'args': {'name': 'MapAnalyzer'}}), ('Options', {'type': 'ctrl', 'object': self.ctrlLayout, 'size': (300, 500), 'pos': ('bottom', 'Map Loader')}), ('Data Plot', {'type': 'plot', 'pos': ('top', 'Color Mapper'), 'size': (800, 300)}), ('Score Histogram', {'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (800, 300)}), ('Timeline', {'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (800, 300)}), ('Stats Table', {'type': 'dataTree', 'pos': ('bottom', 'Canvas'), 'size': (800,300)}), ]) host.resize(1100, 800) self.initializeElements() self.filterStage = EventFilter() self.spontRateStage = SpontRateAnalyzer(plot=self.getElement('Timeline', create=True)) self.statsStage = EventStatisticsAnalyzer(histogramPlot=self.getElement('Score Histogram', create=True)) self.regions = RegionMarker(self.getElement('Canvas', create=True)) self.stages = [self.filterStage, self.spontRateStage, self.statsStage, self.regions] params = [ dict(name='Time Ranges', type='group', children=[ dict(name='Direct Start', type='float', value=0.498, suffix='s', step=0.001, siPrefix=True), dict(name='Stimulus', type='float', value=0.5, suffix='s', step=0.001, siPrefix=True), dict(name='Post Start', type='float', value=0.502, suffix='s', step=0.001, siPrefix=True), dict(name='Post Stop', type='float', value=0.700, suffix='s', step=0.001, siPrefix=True), ]), ] ## each processing stage comes with its own set of parameters for stage in self.stages: params.append(stage.parameters()) self.params = ptree.Parameter.create(name='options', type='group', children=params) self.ctrl.setParameters(self.params, showTop=False) canvas = self.getElement('Canvas', create=True) #self.scalebar = pg.ScaleBar(100e-6) #canvas.addGraphicsItem(self.scalebar, name="ScaleBar") self.scalebar = pg.ScaleBar(size=500e-6) self.scalebar.setParentItem(canvas.view) self.scalebar.anchor((1, 1), (1, 1), offset=(-20, -20)) ## Note: need to reconnect this!! #self.params.sigTreeStateChanged.connect(self.invalidate) self.recalcBtn.clicked.connect(self.recalcClicked) self.storeBtn.clicked.connect(self.storeToDB) self.params.param('Time Ranges').sigTreeStateChanged.connect(self.updateTimes) self.getElement('Color Mapper', create=True).sigChanged.connect(self.colorMapChanged) self.regions.sigRegionChanged.connect(self.processRegions)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrlLayout = pg.LayoutWidget() self.reloadBtn = QtGui.QPushButton('Reload Data') self.ctrlLayout.addWidget(self.reloadBtn) self.ctrl = ptree.ParameterTree(showHeader=False) self.ctrlLayout.addWidget(self.ctrl, row='next', col=0) self.filterBtn = QtGui.QPushButton('Filter') self.ctrlLayout.addWidget(self.filterBtn, row='next', col=0) self.cellList = QtGui.QListWidget() self.cellList.setSelectionMode(self.cellList.ExtendedSelection) self.filterText = QtGui.QTextEdit("selected = data") self.ctrlLayout.addWidget(self.filterText, row='next', col=0) self.ctrlLayout.addWidget(self.cellList, row='next', col=0) ## 3D atlas self.atlas = CN.CNAtlasDisplayWidget() self.stimPoints = gl.GLScatterPlotItem() self.atlas.addItem(self.stimPoints) self.cellPoints = gl.GLScatterPlotItem() self.atlas.addItem(self.cellPoints) modPath = os.path.abspath(os.path.dirname(__file__)) self.colorMapper = ColorMapper(filePath=os.path.join(modPath, "colorMaps")) self._elements_ = OrderedDict([ #('Database Query', {'type':'ctrl', 'object': DatabaseQueryWidget(self.dataManager()), 'size':(300,200), 'pos': 'left'}), ('Options', {'type': 'ctrl', 'object': self.ctrlLayout, 'size': (300, 500), 'pos': 'left'}), ('Atlas', {'type': 'ctrl', 'object': self.atlas, 'size': (600,500), 'pos': 'right'}), ('Color Mapper', {'type': 'ctrl', 'object': self.colorMapper, 'size': (600,200), 'pos': ('bottom', 'Atlas')}), ]) host.resize(1100, 800) self.initializeElements() params = [ dict(name='Transform', type='group', children=[ dict(name='Mirror RL', type='bool', value=True), dict(name='Cell-centered', type='bool', value=False), ]), dict(name='Display', type='group', children=[ dict(name='Cells', type='bool', value=True), dict(name='Color by type', type='bool', value=True), dict(name='Stimulus Sites', type='bool', value=True), dict(name='Atlas', type='bool', value=False), dict(name='Grid', type='bool', value=True), ]), FilterList(name='Filter'), ] self.params = ptree.Parameter.create(name='options', type='group', children=params) self.ctrl.setParameters(self.params, showTop=False) #self.params.sigTreeStateChanged.connect(self.invalidate) #dbq = self.getElement('Database Query', create=True) #dbq.sigChanged.connect(self.dbDataChanged) #db = dbq.currentDatabase() db = self.dataManager().currentDatabase() self.tableName = 'map_site_view' if not db.hasTable(self.tableName): print "Creating DB views." db.createView(self.tableName, ['map_sites', 'photostim_maps', 'dirtable_cell', 'cochlearnucleus_protocol', 'cochlearnucleus_cell']) ## view creation SQL: ## select * from map_sites ## inner join photostim_maps on "photostim_maps"."rowid"="map_sites"."map" ## inner join dirtable_cell on "dirtable_cell"."rowid"="photostim_maps"."cell" ## inner join cochlearnucleus_protocol on cochlearnucleus_protocol.protocoldir=map_sites.firstsite ## inner join cochlearnucleus_cell on cochlearnucleus_cell.celldir=dirtable_cell.rowid; self.reloadData() self.reloadBtn.clicked.connect(self.reloadData) self.filterBtn.clicked.connect(self.refilter) self.cellList.itemSelectionChanged.connect(self.selectCells) self.colorMapper.sigChanged.connect(self.recolor) self.params.param('Display').sigTreeStateChanged.connect(self.updateDisplay) self.params.param('Transform').sigTreeStateChanged.connect(self.transform) self.transform() self.refilter()
def __init__(self, host): AnalysisModule.__init__(self, host) self.background = None #self.view = pg.GraphicsView() self.ctrl = Qt.QWidget() l = Qt.QGridLayout() self.ctrl.setLayout(l) self.ctrl.layout = l #self.loadBgBtn = Qt.QPushButton('load reference') #l.addWidget(self.loadBgBtn, 0, 0) self.addRoiBtn = Qt.QPushButton('add ROI') l.addWidget(self.addRoiBtn, 0, 0) s = Qt.QSpinBox() s.setMaximum(10) s.setMinimum(1) self.nsegSpin = s l.addWidget(s, 1, 0) self.rois = [] self.data = [] ## Setup basic GUI self._elements_ = OrderedDict([ ('File Loader', { 'type': 'fileInput', 'size': (200, 300), 'host': self, 'showFileTree': False }), ('Image', { 'type': 'imageView', 'pos': ('right', 'File Loader'), 'size': (800, 300) }), ('Time Plot', { 'type': 'plot', 'pos': ('bottom', ), 'size': (800, 300) }), ('Trial Plot', { 'type': 'plot', 'pos': ('bottom', 'Time Plot'), 'size': (800, 300) }), ('Line Scan', { 'type': 'imageView', 'pos': ('right', 'Time Plot'), 'size': (800, 300) }), #('Data Table', {'type': 'table', 'pos': ('below', 'Time Plot')}), ('Ctrl', { 'type': 'ctrl', 'pos': ('bottom', 'File Loader'), 'size': (200, 30), 'object': self.ctrl }), ]) self.initializeElements() #self.traces = None self.plot = self.getElement('Time Plot', create=True) self.plot2 = self.getElement('Trial Plot', create=True) self.lr = pg.LinearRegionItem([0, 1]) self.plot.addItem(self.lr) self.view = self.getElement('Image', create=True) ## Add a color scale ## removed for now--seems to be causing crashes :( #self.colorScale = pg.GradientLegend(self.plot1, (20, 150), (-10, -10)) #self.plot1.scene().addItem(self.colorScale) ## Plots are updated when the selected region changes self.lr.sigRegionChanged.connect(self.updateAnalysis) self.addRoiBtn.clicked.connect(self.addRoi) self.view.sigProcessingChanged.connect(self.processData)
def __init__(self, host): AnalysisModule.__init__(self, host) if self.dataModel is None: raise Exception( "Photostim analysis module requires a data model, but none is loaded yet." ) self.dbIdentity = "Photostim" ## how we identify to the database; this determines which tables we own self.selectedSpot = None ## setup analysis flowchart modPath = os.path.abspath(os.path.split(__file__)[0]) flowchartDir = os.path.join(modPath, "analysis_fc") self.flowchart = Flowchart(filePath=flowchartDir) self.flowchart.addInput('events') self.flowchart.addInput('regions') self.flowchart.addInput('fileHandle') self.flowchart.addOutput('dataOut') self.analysisCtrl = self.flowchart.widget() ## color mapper self.mapper = ColorMapper.ColorMapper( filePath=os.path.join(modPath, "colormaps")) self.mapCtrl = QtGui.QWidget() self.mapLayout = QtGui.QVBoxLayout() self.mapCtrl.setLayout(self.mapLayout) self.mapLayout.splitter = QtGui.QSplitter() self.mapLayout.splitter.setOrientation(QtCore.Qt.Vertical) self.mapLayout.splitter.setContentsMargins(0, 0, 0, 0) self.mapLayout.addWidget(self.mapLayout.splitter) self.mapLayout.splitter.addWidget(self.analysisCtrl) #self.mapLayout.splitter.addWidget(QtGui.QSplitter()) self.mapLayout.splitter.addWidget(self.mapper) #self.mapLayout.splitter.addWidget(self.recolorBtn) self.recolorLayout = QtGui.QHBoxLayout() self.recolorWidget = QtGui.QWidget() self.mapLayout.splitter.addWidget(self.recolorWidget) self.recolorWidget.setLayout(self.recolorLayout) self.recolorBtn = QtGui.QPushButton('Recolor') self.recolorLayout.addWidget(self.recolorBtn) self.recolorParallelCheck = QtGui.QCheckBox('Parallel') self.recolorParallelCheck.setChecked(True) self.recolorLayout.addWidget(self.recolorParallelCheck) ## scatter plot self.scatterPlot = ScatterPlotter() self.scatterPlot.sigClicked.connect(self.scatterPlotClicked) ## setup map DB ctrl self.dbCtrl = DBCtrl(self, self.dbIdentity) ## storage for map data #self.scanItems = {} self.scans = [] #self.seriesScans = {} self.maps = [] ## create event detector fcDir = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "detector_fc") self.detector = EventDetector.EventDetector( host, flowchartDir=fcDir, dbIdentity=self.dbIdentity + '.events') ## override some of its elements self.detector.setElement('File Loader', self) self.detector.setElement('Database', self.dbCtrl) ## Create element list, importing some gui elements from event detector elems = self.detector.listElements() self._elements_ = OrderedDict([ ('Database', { 'type': 'ctrl', 'object': self.dbCtrl, 'size': (300, 600) }), ('Scatter Plot', { 'type': 'ctrl', 'object': self.scatterPlot, 'pos': ('right', ), 'size': (700, 400) }), ('Canvas', { 'type': 'canvas', 'pos': ('above', 'Scatter Plot'), 'size': (700, 400), 'allowTransforms': False, 'hideCtrl': True, 'args': { 'name': 'Photostim' } }), #('Maps', {'type': 'ctrl', 'pos': ('bottom', 'Database'), 'size': (200,200), 'object': self.mapDBCtrl}), ('Map Opts', { 'type': 'ctrl', 'object': self.mapCtrl, 'pos': ('above', 'Database'), 'size': (300, 600) }), ('Detection Opts', elems['Detection Opts'].setParams(pos=('above', 'Map Opts'), size=(300, 600))), ('File Loader', { 'type': 'fileInput', 'size': (300, 300), 'pos': ('above', 'Detection Opts'), 'host': self, 'showFileTree': False }), ('Data Plot', elems['Data Plot'].setParams(pos=('bottom', 'Canvas'), size=(700, 200))), ('Filter Plot', elems['Filter Plot'].setParams(pos=('bottom', 'Data Plot'), size=(700, 200))), ('Event Table', elems['Output Table'].setParams(pos=('below', 'Filter Plot'), size=(700, 200))), ('Stats', { 'type': 'dataTree', 'size': (700, 200), 'pos': ('below', 'Event Table') }), ]) self.initializeElements() try: ## load default chart self.flowchart.loadFile(os.path.join(flowchartDir, 'default.fc')) except: debug.printExc('Error loading default flowchart:') self.detector.flowchart.sigOutputChanged.connect( self.detectorOutputChanged) self.flowchart.sigOutputChanged.connect(self.analyzerOutputChanged) self.detector.flowchart.sigStateChanged.connect( self.detectorStateChanged) self.flowchart.sigStateChanged.connect(self.analyzerStateChanged) self.recolorBtn.clicked.connect(self.recolor)
def __init__(self, host): AnalysisModule.__init__(self, host) flowchartDir = os.path.join( os.path.abspath(os.path.split(__file__)[0]), "flowcharts") self.flowchart = Flowchart(filePath=flowchartDir) self.flowchart.addInput('dataIn') self.flowchart.addOutput('results') self.flowchart.outputNode._allowAddInput = False ## make sure all data is coming out of output['results'] try: ## load default chart self.flowchart.loadFile(os.path.join(flowchartDir, 'default.fc')) except: debug.printExc('Error loading default flowchart:') tables = OrderedDict([(self.dbIdentity + '.traces', 'TimecourseAnalyzer_traces')]) self.dbGui = DatabaseGui(dm=host.dataManager(), tables=tables) self.ctrl = Qt.QWidget() self.ctrl.setLayout(Qt.QVBoxLayout()) self.analyzeBtn = Qt.QPushButton('Analyze') self.storeToDBBtn = Qt.QPushButton('Store to DB') self.ctrl.layout().addWidget(self.analyzeBtn) self.ctrl.layout().addWidget(self.storeToDBBtn) self._elements_ = OrderedDict([('Database', { 'type': 'ctrl', 'object': self.dbGui, 'size': (100, 100) }), ('Analysis Options', { 'type': 'ctrl', 'object': self.flowchart.widget(), 'pos': ('above', 'Database'), 'size': (100, 400) }), ('File Loader', { 'type': 'fileInput', 'size': (100, 100), 'pos': ('above', 'Analysis Options'), 'host': self }), ('Experiment Plot', { 'type': 'plot', 'pos': ('right', 'File Loader'), 'size': (400, 100) }), ('Traces Plot', { 'type': 'plot', 'pos': ('bottom', 'Experiment Plot'), 'size': (400, 200) }), ('Results Plot', { 'type': 'plot', 'pos': ('bottom', 'Traces Plot'), 'size': (400, 200) }), ('Results Table', { 'type': 'table', 'pos': ('bottom', 'Traces Plot'), 'size': (400, 200) }), ('Store Ctrl', { 'type': 'ctrl', 'object': self.ctrl, 'size': (100, 100), 'pos': ('bottom', 'File Loader') })]) self.initializeElements() self.fileLoader = self.getElement('File Loader', create=True) self.exptPlot = self.getElement('Experiment Plot', create=True) self.tracesPlot = self.getElement('Traces Plot', create=True) self.resultsTable = self.getElement('Results Table', create=True) self.resultsTable.setSortingEnabled(False) self.resultsPlot = self.getElement('Results Plot', create=True) self.resultsPlot.getViewBox().setXLink(self.exptPlot.getViewBox( )) ## link the x-axes of the exptPlot and the resultsPlot ### initialize variables self.expStart = 0 self.traces = np.array([], dtype=[('timestamp', float), ('data', object), ('fileHandle', object), ('results', object)]) self.files = [] self.traceSelectRgn = pg.LinearRegionItem() self.traceSelectRgn.setRegion([0, 60]) self.exptPlot.addItem(self.traceSelectRgn) self.traceSelectRgn.sigRegionChanged.connect(self.updateTracesPlot) #self.traceSelectRgn.sigRegionChangeFinished.connect(self.updateAnalysis) #self.flowchart.sigOutputChanged.connect(self.flowchartOutputChanged) #self.addRegionParam = pg.parametertree.Parameter.create(name="Add Region", type='action') #self.paramTree.addParameters(self.addRegionParam) #self.addRegionParam.sigActivated.connect(self.newRegionRequested) self.analyzeBtn.clicked.connect(self.analyzeBtnClicked) self.storeToDBBtn.clicked.connect(self.storeToDBBtnClicked) self.flowchart.sigChartLoaded.connect(self.connectPlots) self.fileLoader.sigClearRequested.connect(self.clearFilesRequested)
def __init__(self, host, flowchartDir=None, dbIdentity="EventDetector", dbCtrl=None): AnalysisModule.__init__(self, host) if flowchartDir is None: flowchartDir = os.path.join( os.path.abspath(os.path.split(__file__)[0]), "flowcharts") self.flowchart = Flowchart(filePath=flowchartDir) self.dbIdentity = dbIdentity ## how we identify to the database; this determines which tables we own #self.loader = FileLoader.FileLoader(host.dataManager()) #self.setCentralWidget(self.flowchart.widget()) #self.ui.chartDock1.setWidget(self.flowchart.widget()) self.flowchart.addInput("dataIn") self.flowchart.addOutput('events') #self.flowchart.addOutput('regions', multi=True) self.flowchart.sigChartLoaded.connect(self.connectPlots) if dbCtrl == None: self.dbCtrl = DBCtrl(self, identity=self.dbIdentity) self.dbCtrl.storeBtn.clicked.connect(self.storeClicked) else: self.dbCtrl = dbCtrl(self, identity=self.dbIdentity) #self.ctrl = QtGui.QLabel('LABEL') self.ctrl = self.flowchart.widget() self._elements_ = OrderedDict([ ('File Loader', { 'type': 'fileInput', 'size': (200, 300), 'host': self }), ('Database', { 'type': 'ctrl', 'object': self.dbCtrl, 'size': (200, 300), 'pos': ('bottom', 'File Loader') }), ('Data Plot', { 'type': 'plot', 'pos': ('right', ), 'size': (800, 300) }), ('Detection Opts', { 'type': 'ctrl', 'object': self.ctrl, 'pos': ('bottom', 'Database'), 'size': (200, 500) }), ('Filter Plot', { 'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (800, 300) }), ('Output Table', { 'type': 'table', 'pos': ('bottom', 'Filter Plot'), 'optional': True, 'size': (800, 200) }), ]) self.initializeElements() try: ## load default chart self.flowchart.loadFile(os.path.join(flowchartDir, 'default.fc')) except: debug.printExc('Error loading default flowchart:') self.flowchart.sigOutputChanged.connect(self.outputChanged)
def __init__(self, host): AnalysisModule.__init__(self, host) self.ctrlLayout = pg.LayoutWidget() self.reloadBtn = Qt.QPushButton('Reload Data') self.ctrlLayout.addWidget(self.reloadBtn) self.ctrl = ptree.ParameterTree(showHeader=False) self.ctrlLayout.addWidget(self.ctrl, row='next', col=0) self.filterBtn = Qt.QPushButton('Filter') self.ctrlLayout.addWidget(self.filterBtn, row='next', col=0) self.cellList = Qt.QListWidget() self.cellList.setSelectionMode(self.cellList.ExtendedSelection) self.filterText = Qt.QTextEdit("selected = data") self.ctrlLayout.addWidget(self.filterText, row='next', col=0) self.ctrlLayout.addWidget(self.cellList, row='next', col=0) ## 3D atlas self.atlas = CN.CNAtlasDisplayWidget() self.stimPoints = gl.GLScatterPlotItem() self.atlas.addItem(self.stimPoints) self.cellPoints = gl.GLScatterPlotItem() self.atlas.addItem(self.cellPoints) modPath = os.path.abspath(os.path.dirname(__file__)) self.colorMapper = ColorMapper( filePath=os.path.join(modPath, "colorMaps")) self._elements_ = OrderedDict([ #('Database Query', {'type':'ctrl', 'object': DatabaseQueryWidget(self.dataManager()), 'size':(300,200), 'pos': 'left'}), ('Options', { 'type': 'ctrl', 'object': self.ctrlLayout, 'size': (300, 500), 'pos': 'left' }), ('Atlas', { 'type': 'ctrl', 'object': self.atlas, 'size': (600, 500), 'pos': 'right' }), ('Color Mapper', { 'type': 'ctrl', 'object': self.colorMapper, 'size': (600, 200), 'pos': ('bottom', 'Atlas') }), ]) host.resize(1100, 800) self.initializeElements() params = [ dict(name='Transform', type='group', children=[ dict(name='Mirror RL', type='bool', value=True), dict(name='Cell-centered', type='bool', value=False), ]), dict(name='Display', type='group', children=[ dict(name='Cells', type='bool', value=True), dict(name='Color by type', type='bool', value=True), dict(name='Stimulus Sites', type='bool', value=True), dict(name='Atlas', type='bool', value=False), dict(name='Grid', type='bool', value=True), ]), FilterList(name='Filter'), ] self.params = ptree.Parameter.create(name='options', type='group', children=params) self.ctrl.setParameters(self.params, showTop=False) #self.params.sigTreeStateChanged.connect(self.invalidate) #dbq = self.getElement('Database Query', create=True) #dbq.sigChanged.connect(self.dbDataChanged) #db = dbq.currentDatabase() db = self.dataManager().currentDatabase() self.tableName = 'map_site_view' if not db.hasTable(self.tableName): print("Creating DB views.") db.createView(self.tableName, [ 'map_sites', 'photostim_maps', 'dirtable_cell', 'cochlearnucleus_protocol', 'cochlearnucleus_cell' ]) ## view creation SQL: ## select * from map_sites ## inner join photostim_maps on "photostim_maps"."rowid"="map_sites"."map" ## inner join dirtable_cell on "dirtable_cell"."rowid"="photostim_maps"."cell" ## inner join cochlearnucleus_protocol on cochlearnucleus_protocol.protocoldir=map_sites.firstsite ## inner join cochlearnucleus_cell on cochlearnucleus_cell.celldir=dirtable_cell.rowid; self.reloadData() self.reloadBtn.clicked.connect(self.reloadData) self.filterBtn.clicked.connect(self.refilter) self.cellList.itemSelectionChanged.connect(self.selectCells) self.colorMapper.sigChanged.connect(self.recolor) self.params.param('Display').sigTreeStateChanged.connect( self.updateDisplay) self.params.param('Transform').sigTreeStateChanged.connect( self.transform) self.transform() self.refilter()
def __init__(self, host): AnalysisModule.__init__(self, host=host) self.items = weakref.WeakKeyDictionary() self.files = weakref.WeakValueDictionary() self.ctrl = QtGui.QWidget() self.ui = Ui_Form() self.ui.setupUi(self.ctrl) self.atlas = None self.canvas = Canvas(name='MosaicEditor') self._elements_ = OrderedDict([ ('File Loader', { 'type': 'fileInput', 'size': (200, 300), 'host': self }), ('Mosaic', { 'type': 'ctrl', 'object': self.ctrl, 'pos': ('right', ), 'size': (600, 100) }), ('Canvas', { 'type': 'ctrl', 'object': self.canvas.ui.view, 'pos': ('bottom', 'Mosaic'), 'size': (600, 800) }), ('ItemList', { 'type': 'ctrl', 'object': self.canvas.ui.canvasCtrlWidget, 'pos': ('right', 'Canvas'), 'size': (200, 400) }), ('ItemCtrl', { 'type': 'ctrl', 'object': self.canvas.ui.canvasItemCtrl, 'pos': ('bottom', 'ItemList'), 'size': (200, 400) }), ]) for name, spec in self._extensions.items(): builder = spec.pop('builder', None) if builder is not None: spec['object'] = builder(self) self._elements_[name] = spec self.initializeElements() self.clear(ask=False) self.ui.fileLoader = self.getElement('File Loader', create=True) self.ui.fileLoader.ui.fileTree.hide() try: self.ui.fileLoader.setBaseClicked( ) # get the currently selected directory in the DataManager except: pass for a in atlas.listAtlases(): self.ui.atlasCombo.addItem(a) # Add buttons to the canvas control panel self.btnBox = QtGui.QWidget() self.btnLayout = QtGui.QGridLayout() self.btnLayout.setContentsMargins(0, 0, 0, 0) self.btnBox.setLayout(self.btnLayout) l = self.canvas.ui.gridLayout l.addWidget(self.btnBox, l.rowCount(), 0, 1, l.columnCount()) self.addCombo = QtGui.QComboBox() self.addCombo.currentIndexChanged.connect(self._addItemChanged) self.btnLayout.addWidget(self.addCombo, 0, 0, 1, 2) self.addCombo.addItem('Add item..') self.saveBtn = QtGui.QPushButton("Save ...") self.saveBtn.clicked.connect(self.saveClicked) self.btnLayout.addWidget(self.saveBtn, 1, 0) self.clearBtn = QtGui.QPushButton("Clear All") self.clearBtn.clicked.connect(lambda: self.clear(ask=True)) self.btnLayout.addWidget(self.clearBtn, 1, 1) self.canvas.sigItemTransformChangeFinished.connect(self.itemMoved) self.ui.atlasCombo.currentIndexChanged.connect(self.atlasComboChanged) self.ui.normalizeBtn.clicked.connect(self.normalizeImages) self.ui.tileShadingBtn.clicked.connect(self.rescaleImages) self.ui.mosaicApplyScaleBtn.clicked.connect(self.updateScaling) self.ui.mosaicFlipLRBtn.clicked.connect(self.flipLR) self.ui.mosaicFlipUDBtn.clicked.connect(self.flipUD) self.imageMax = 0.0 for menuString in self._addTypes: self.addCombo.addItem(menuString)
def __init__(self, host, flowchartDir=None): AnalysisModule.__init__(self, host) self.dbIdentity = "IVCurveAnalyzer" ## how we identify to the database; this determines which tables we own if flowchartDir is None: flowchartDir = os.path.join( os.path.abspath(os.path.split(__file__)[0]), "flowcharts") self.flowchart = Flowchart(filePath=flowchartDir) self.flowchart.addInput("dataIn") #self.flowchart.addOutput('events') self.flowchart.addOutput('regions', multi=True) #self.flowchart.sigChartLoaded.connect(self.connectPlots) ### DBCtrl class is from EventDetector -- need to make my own here #self.dbCtrl = DBCtrl(self, identity=self.dbIdentity) #self.dbCtrl.storeBtn.clicked.connect(self.storeClicked) self.ctrl = self.flowchart.widget() self._elements_ = OrderedDict([ ('File Loader', { 'type': 'fileInput', 'size': (200, 300), 'host': self }), #('Database', {'type': 'ctrl', 'object': self.dbCtrl, 'size': (200,300), 'pos': ('bottom', 'File Loader')}), ('Data Plot', { 'type': 'plot', 'pos': ('right', ), 'size': (800, 300) }), ('Detection Opts', { 'type': 'ctrl', 'object': self.ctrl, 'pos': ('bottom', 'File Loader'), 'size': (200, 500) }), ('IV Plot', { 'type': 'plot', 'pos': ('bottom', 'Data Plot'), 'size': (400, 300) }), ('Output Table', { 'type': 'table', 'pos': ('bottom', 'IV Plot'), 'optional': True, 'size': (800, 200) }), ('FI Plot', { 'type': 'plot', 'pos': ('right', 'IV Plot'), 'size': (400, 300) }), ]) self.initializeElements() try: ## load default chart self.flowchart.loadFile(os.path.join(flowchartDir, 'default.fc')) except: debug.printExc('Error loading default flowchart:')