def update(self): pos = self.dev.getPosition() for i in range(3): if i not in self.posLabels: continue text = pg.siFormat(pos[i], suffix='m', precision=5) self.posLabels[i].setText(text)
def valueString(self, param): units = param.opts.get('units', None) if isinstance(units, basestring) and len(units) > 0: val = pg.siFormat(param.value(), suffix=units, space='*', precision=5, allowUnicode=False) else: val = '%0.5g' % param.value() return val
def update(self): pos = self.dev.getPosition() #for i in [0,1,2]: #if pos[i] < self.limit text = [pg.siFormat(x, suffix='m', precision=5) for x in pos] self.ui.xPosLabel.setText(text[0]) self.ui.yPosLabel.setText(text[1]) self.ui.zPosLabel.setText(text[2])
def sendStatusMessage(self, iter, maxIter, depthIndex, depths): if maxIter == 0: itermsg = 'iter=%d' % (iter+1) else: itermsg = 'iter=%d/%s' % (iter+1, maxIter) if depthIndex is None: depthmsg = '' else: depthstr = pg.siFormat(depths[depthIndex], suffix='m') depthmsg = 'depth=%s %d/%d' % (depthstr, depthIndex+1, len(depths)) self.sigMessage.emit('[ running %s %s ]' % (itermsg, depthmsg))
def updateLimits(self): limits = self.dev.getLimits() cap = self.dev.capabilities() for axis in (0, 1, 2): if not cap['limits'][axis]: continue for i, limit in enumerate(limits[axis]): check = self.limitChecks[axis][i] pfx = ('Min:', 'Max:')[i] if limit is None: check.setText(pfx) check.setChecked(False) else: check.setText(pfx + ' %s' % pg.siFormat(limit, suffix='m')) check.setChecked(True)
def paint(self, p, *args): pg.LineSegmentROI.paint(self, p, *args) h1 = self.handles[0]['item'].pos() h2 = self.handles[1]['item'].pos() p1 = p.transform().map(h1) p2 = p.transform().map(h2) vec = pg.Point(h2) - pg.Point(h1) length = vec.length() angle = vec.angle(pg.Point(1, 0)) pvec = p2 - p1 pvecT = pg.Point(pvec.y(), -pvec.x()) pos = 0.5 * (p1 + p2) + pvecT * 40 / pvecT.length() p.resetTransform() txt = pg.siFormat(length, suffix='m') + '\n%0.1f deg' % angle p.drawText(QtCore.QRectF(pos.x() - 50, pos.y() - 50, 100, 100), QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter, txt)
def update(self): pos = self.dev.getPosition() text = [pg.siFormat(x, suffix='m', precision=5) for x in pos] self.label.setText(", ".join(text))
def valueChanged(self, param, val): strs = tuple([pg.siFormat(x, suffix='m') for x in val]) self.setText(1, '[%s, %s, %s]' % strs)
def update(self): pos = self.dev.getPosition() for i in range(3): text = pg.siFormat(pos[i], suffix="m", precision=5) self.posLabels[i].setText(text)
def showErrorAnalysis(self): if not hasattr(self, 'errorMap'): filename = self.dev.configFileName('error_map.np') self.errorMap = np.load(open(filename, 'rb'))[np.newaxis][0] err = self.errorMap imx = pg.image(err['err'][..., 0].transpose(1, 0, 2), title='X error') imy = pg.image(err['err'][..., 1], title='Y error') imz = pg.image(err['err'][..., 2], title='Z error') # get N,3 array of offset values used to randomize hysteresis off = np.vstack(err['offsets']) sh = err['err'].shape # Get N,3 array of measured position errors errf = err['err'].reshape(sh[0] * sh[1] * sh[2], 3)[err['order']] # Display histogram of errors win = pg.GraphicsWindow(title="%s error" % self.dev.name()) # subtract out slow drift normErr = errf - scipy.ndimage.gaussian_filter(errf, (20, 0)) # calculate magnitude of error absErr = (normErr**2).sum(axis=1)**0.5 # errPlot.plot(absErr) title = "Error Histogram (mean=%s)" % pg.siFormat(absErr.mean(), suffix='m') errPlot = win.addPlot(row=0, col=0, title=title, labels={'bottom': ('Position error', 'm')}) hist = np.histogram(absErr, bins=50) errPlot.plot(hist[1], hist[0], stepMode=True) # display drift and hysteresis plots driftPlot = win.addPlot(row=0, col=1, rowspan=1, colspan=2, title="Pipette Drift", labels={ 'left': ('Position error', 'm'), 'bottom': ('Time', 's') }) driftPlot.plot(np.linspace(0, err['time'], errf.shape[0]), errf[:, 0], pen='r') driftPlot.plot(np.linspace(0, err['time'], errf.shape[0]), errf[:, 1], pen='g') driftPlot.plot(np.linspace(0, err['time'], errf.shape[0]), errf[:, 2], pen='b') xhplot = win.addPlot(row=1, col=0, title='X Hysteresis', labels={ 'left': ('Position error', 'm'), 'bottom': ('Last pipette movement', 'm') }) xhplot.plot(-off[:, 0], errf[:, 0], pen=None, symbol='o') yhplot = win.addPlot(row=1, col=1, title='Y Hysteresis', labels={ 'left': ('Position error', 'm'), 'bottom': ('Last pipette movement', 'm') }) yhplot.plot(-off[:, 1], errf[:, 1], pen=None, symbol='o') zhplot = win.addPlot(row=1, col=2, title='Z Hysteresis', labels={ 'left': ('Position error', 'm'), 'bottom': ('Last pipette movement', 'm') }) zhplot.plot(-off[:, 2], errf[:, 2], pen=None, symbol='o') # Print best fit for manipulator axes expPos = err['inds'] * err['stepSize'] measPos = expPos + off guess = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]], dtype='float') def errFn(v): return ((measPos - np.dot(expPos, v.reshape(3, 4))[:, :3])**2).sum() fit = scipy.optimize.minimize(errFn, guess) print("Pipette position transform:", fit) self.errorMapAnalysis = (imx, imy, imz, win)
def __init__(self, dev): self.dev = dev Qt.QWidget.__init__(self) self.layout = Qt.QVBoxLayout() self.setLayout(self.layout) chans = self.dev.listChannels() self.widgets = {} #self.uis = {} self.defaults = {} row = 0 for ch in chans: wid = Qt.QWidget() ui = DeviceTemplate.Ui_Form() ui.setupUi(wid) self.layout.addWidget(wid) ui.analogCtrls = [ ui.scaleDefaultBtn, ui.scaleSpin, ui.offsetDefaultBtn, ui.offsetSpin, ui.scaleLabel, ui.offsetLabel ] #ui.channel = ch for s in dir(ui): i = getattr(ui, s) if isinstance(i, Qt.QWidget): i.channel = ch self.widgets[ch] = ui ui.nameLabel.setText(str(ch)) ui.channelCombo.addItem("%s (%s)" % (ch, chans[ch]['channel'])) holding = chans[ch].get('holding', 0) if chans[ch]['type'] in ['ao', 'ai']: ui.inputRadio.setEnabled(False) ui.outputRadio.setEnabled(False) ui.invertCheck.hide() scale = chans[ch].get('scale', 1) units = chans[ch].get('units', 'V') offset = chans[ch].get('offset', 0) ui.offsetSpin.setOpts(suffix='V', siPrefix=True, dec=True, step=1.0, minStep=1e-4) ui.offsetSpin.setValue(offset) ui.offsetSpin.sigValueChanged.connect(self.offsetSpinChanged) ui.offsetDefaultBtn.setText("Default (%s)" % siFormat(offset, suffix='V')) ui.offsetDefaultBtn.clicked.connect( self.offsetDefaultBtnClicked) if chans[ch]['type'] == 'ao': ui.outputRadio.setChecked(True) ui.scaleDefaultBtn.setText( "Default (%s)" % siFormat(scale, suffix='V/' + units)) ui.scaleSpin.setOpts(suffix='V/' + units, siPrefix=True, dec=True, step=1.0, minStep=1e-9) ui.holdingSpin.setOpts(suffix=units, siPrefix=True, step=0.01) ui.holdingSpin.setValue(holding) ui.holdingSpin.sigValueChanged.connect( self.holdingSpinChanged) elif chans[ch]['type'] == 'ai': ui.inputRadio.setChecked(True) ui.holdingLabel.hide() ui.holdingSpin.hide() ui.scaleDefaultBtn.setText( "Default (%s)" % siFormat(scale, suffix=units + '/V')) #ui.scaleDefaultBtn.clicked.connect(self.scaleDefaultBtnClicked) ui.scaleSpin.setOpts(suffix=units + '/V', siPrefix=True, dec=True) ui.scaleSpin.setValue(scale) ui.scaleDefaultBtn.clicked.connect(self.scaleDefaultBtnClicked) ui.scaleSpin.sigValueChanged.connect(self.scaleSpinChanged) self.defaults[ch] = {'scale': scale, 'offset': offset} elif chans[ch]['type'] in ['do', 'di']: for item in ui.analogCtrls: item.hide() if chans[ch].get('invert', False): ui.invertCheck.setChecked(True) if chans[ch]['type'] == 'do': ui.outputRadio.setChecked(True) ui.holdingSpin.setOpts(bounds=[0, 1], step=1) ui.holdingSpin.setValue(holding) ui.holdingSpin.sigValueChanged.connect( self.holdingSpinChanged) elif chans[ch]['type'] == 'di': ui.inputRadio.setChecked(True) ui.holdingLabel.hide() ui.holdingSpin.hide() ui.invertCheck.toggled.connect(self.invertToggled) #Qt.QObject.connect(self.dev, Qt.SIGNAL('holdingChanged'), self.holdingChanged) self.dev.sigHoldingChanged.connect(self.holdingChanged)
def showCell(**kwds): pw2.clear() reloadData = kwds.get('reloadData', False) #global lock #if lock: #return #lock = True Qt.QApplication.processEvents() ## prevents double-spin #lock = False cell = cells[cellCombo.currentIndex() - 1] dh = cell #db.getDir('Cell', cell) loadCell(dh, reloadData=reloadData) try: image.setImage(dh['morphology.png'].read()) gv.setRange(image.sceneBoundingRect()) except: image.setImage(np.zeros((2, 2))) pass ev, numExSites, numInSites = events[cell] ev2 = select(ev, ex=True) ev3 = select(ev, ex=False) if colorCheck.isChecked(): sp1.hide() sp2.hide() sp3.hide() sp4.show() start = postRgnStart() stop = postRgnStop() ev2post = ev2[(ev2['fitTime'] > start) * (ev2['fitTime'] < stop)] ev3post = ev3[(ev3['fitTime'] > start) * (ev3['fitTime'] < stop)] ev4 = np.concatenate([ev2post, ev3post]) yMax = ev4['dorsal'].max() yMin = ev4['dorsal'].min() brushes = [] for i in range(len(ev4)): hue = 0.6 * ((ev4[i]['dorsal'] - yMin) / (yMax - yMin)) brushes.append(pg.hsvColor(hue, 1.0, 1.0, 0.3)) #pts.append({ #'pos': (ev4[i]['fitDecayTau'], ev4[i]['fitAmplitude']), #'brush': pg.hsvColor(hue, 1, 1, 0.3), #'data': ev4[i] #}) sp4.setData(x=ev4['fitDecayTau'], y=ev4['fitAmplitude'], symbolBrush=brushes, data=ev4) else: sp1.show() sp2.show() #sp3.show() sp4.hide() ## excitatory if separateCheck.isChecked(): pre = ev2[ev2['fitTime'] < preRgnStop()] post = ev2[(ev2['fitTime'] > postRgnStart()) * (ev2['fitTime'] < postRgnStop())] else: pre = ev2 sp1.setData(x=pre['fitDecayTau'], y=pre['fitAmplitude'], data=pre) #print "Cell ", cell #print " excitatory:", np.median(ev2['fitDecayTau']), np.median(ev2['fitAmplitude']) ## inhibitory if separateCheck.isChecked(): pre = ev3[ev3['fitTime'] < preRgnStop()] post2 = ev3[(ev3['fitTime'] > postRgnStart()) * (ev3['fitTime'] < postRgnStop())] post = np.concatenate([post, post2]) else: pre = ev3 sp2.setData(x=pre['fitDecayTau'], y=pre['fitAmplitude'], data=pre) #print " inhibitory:", np.median(ev2['fitDecayTau']), np.median(ev2['fitAmplitude']) if separateCheck.isChecked(): sp3.setData(x=post['fitDecayTau'], y=post['fitAmplitude'], data=post) sp3.show() else: sp3.hide() try: typ = ev2[0]['CellType'] except: typ = ev3[0]['CellType'] sr = spontRate(ev2, numExSites) sri = spontRate(ev3, numInSites) title = "%s -- %s --- <span style='color: #99F;'>ex:</span> %s %s %s %0.1fHz --- <span style='color: #F99;'>in:</span> %s %s %s %0.1fHz" % ( dh.name(relativeTo=dh.parent().parent().parent()), typ, pg.siFormat(np.median(ev2['fitTimeToPeak']), error=np.std(ev2['fitTimeToPeak']), space=False, suffix='s'), pg.siFormat(np.median(ev2['fitDecayTau']), error=np.std(ev2['fitDecayTau']), space=False, suffix='s'), pg.siFormat(np.median(ev2['fitAmplitude']), error=np.std(ev2['fitAmplitude']), space=False, suffix='A'), sr, pg.siFormat(np.median(ev3['fitTimeToPeak']), error=np.std(ev3['fitTimeToPeak']), space=False, suffix='s'), pg.siFormat(np.median(ev3['fitDecayTau']), error=np.std(ev3['fitDecayTau']), space=False, suffix='s'), pg.siFormat(np.median(ev3['fitAmplitude']), error=np.std(ev3['fitAmplitude']), space=False, suffix='A'), sri) print(re.sub(r'<[^>]+>', '', title)) pw1.setTitle(title) ### show cell in atlas #rec = db.select('CochlearNucleus_Cell', where={'CellDir': cell}) #pts = [] #if len(rec) > 0: #pos = (rec[0]['right'], rec[0]['anterior'], rec[0]['dorsal']) #pts = [{'pos': pos, 'size': 100e-6, 'color': (0.7, 0.7, 1.0, 1.0)}] ### show event positions evSpots = {} for rec in ev: p = (rec['right'], rec['anterior'], rec['dorsal']) evSpots[p] = None pos = np.array(list(evSpots.keys())) atlasPoints.setData(pos=pos, )
def update(self): pos = self.dev.getPosition() text = [pg.siFormat(x, suffix="m", precision=5) for x in pos] self.label.setText(", ".join(text))
def __init__(self, dev): self.dev = dev QtGui.QWidget.__init__(self) self.layout = QtGui.QVBoxLayout() self.setLayout(self.layout) chans = self.dev.listChannels() self.widgets = {} #self.uis = {} self.defaults = {} row = 0 for ch in chans: wid = QtGui.QWidget() ui = DeviceTemplate.Ui_Form() ui.setupUi(wid) self.layout.addWidget(wid) ui.analogCtrls = [ui.scaleDefaultBtn, ui.scaleSpin, ui.offsetDefaultBtn, ui.offsetSpin, ui.scaleLabel, ui.offsetLabel] #ui.channel = ch for s in dir(ui): i = getattr(ui, s) if isinstance(i, QtGui.QWidget): i.channel = ch self.widgets[ch] = ui ui.nameLabel.setText(str(ch)) ui.channelCombo.addItem("%s (%s)" % (ch, chans[ch]['channel'])) holding = chans[ch].get('holding', 0) if chans[ch]['type'] in ['ao', 'ai']: ui.inputRadio.setEnabled(False) ui.outputRadio.setEnabled(False) ui.invertCheck.hide() scale = chans[ch].get('scale', 1) units = chans[ch].get('units', 'V') offset = chans[ch].get('offset', 0) ui.offsetSpin.setOpts(suffix = 'V', siPrefix=True, dec=True, step=1.0, minStep=1e-4) ui.offsetSpin.setValue(offset) ui.offsetSpin.sigValueChanged.connect(self.offsetSpinChanged) ui.offsetDefaultBtn.setText("Default (%s)" % siFormat(offset, suffix='V')) ui.offsetDefaultBtn.clicked.connect(self.offsetDefaultBtnClicked) if chans[ch]['type'] == 'ao': ui.outputRadio.setChecked(True) ui.scaleDefaultBtn.setText("Default (%s)" % siFormat(scale, suffix='V/'+units)) ui.scaleSpin.setOpts(suffix= 'V/'+units, siPrefix=True, dec=True, step=1.0, minStep=1e-9) ui.holdingSpin.setOpts(suffix=units, siPrefix=True, step=0.01) ui.holdingSpin.setValue(holding) ui.holdingSpin.sigValueChanged.connect(self.holdingSpinChanged) elif chans[ch]['type'] == 'ai': ui.inputRadio.setChecked(True) ui.holdingLabel.hide() ui.holdingSpin.hide() ui.scaleDefaultBtn.setText("Default (%s)" % siFormat(scale, suffix=units+'/V')) #ui.scaleDefaultBtn.clicked.connect(self.scaleDefaultBtnClicked) ui.scaleSpin.setOpts(suffix= units+'/V', siPrefix=True, dec=True) ui.scaleSpin.setValue(scale) ui.scaleDefaultBtn.clicked.connect(self.scaleDefaultBtnClicked) ui.scaleSpin.sigValueChanged.connect(self.scaleSpinChanged) self.defaults[ch] = { 'scale': scale, 'offset': offset} elif chans[ch]['type'] in ['do', 'di']: for item in ui.analogCtrls: item.hide() if chans[ch].get('invert', False): ui.invertCheck.setChecked(True) if chans[ch]['type'] == 'do': ui.outputRadio.setChecked(True) ui.holdingSpin.setOpts(bounds=[0,1], step=1) ui.holdingSpin.setValue(holding) ui.holdingSpin.sigValueChanged.connect(self.holdingSpinChanged) elif chans[ch]['type'] == 'di': ui.inputRadio.setChecked(True) ui.holdingLabel.hide() ui.holdingSpin.hide() ui.invertCheck.toggled.connect(self.invertToggled) #QtCore.QObject.connect(self.dev, QtCore.SIGNAL('holdingChanged'), self.holdingChanged) self.dev.sigHoldingChanged.connect(self.holdingChanged)
def handleNewFrame(self, frame): prof = Profiler('PatchWindow.handleNewFrame', disabled=True) with self.paramLock: mode = self.params['mode'] data = frame['data'][self.clampName] if mode == 'vc': self.ui.patchPlot.setLabel('left', units='A') else: self.ui.patchPlot.setLabel('left', units='V') prof.mark('1') self.patchCurve.setData(data.xvals('Time'), data['primary']) prof.mark('2') if self.redrawCommand > 0: self.redrawCommand -= 1 #print "set command curve" self.commandCurve.setData(data.xvals('Time'), data['command']) if mode == 'vc': self.ui.commandPlot.setLabel('left', units='V') else: self.ui.commandPlot.setLabel('left', units='A') prof.mark('3') #self.ui.patchPlot.replot() #self.ui.commandPlot.replot() if frame['analysis']['fitTrace'] is not None: self.patchFitCurve.show() self.patchFitCurve.setData(data.xvals('Time'), frame['analysis']['fitTrace']) else: self.patchFitCurve.hide() prof.mark('4') for k in self.analysisItems: if k in frame['analysis']: self.analysisData[k].append(frame['analysis'][k]) prof.mark('5') for r in ['input', 'access']: res = r + 'Resistance' label = getattr(self.ui, res + 'Label') resistance = frame['analysis'][res] label.setText(siFormat(resistance) + u'Ω') prof.mark('6') self.ui.restingPotentialLabel.setText( siFormat(frame['analysis']['restingPotential'], error=frame['analysis']['restingPotentialStd'], suffix='V')) self.ui.restingCurrentLabel.setText( siFormat(frame['analysis']['restingCurrent'], error=frame['analysis']['restingCurrentStd'], suffix='A')) self.ui.capacitanceLabel.setText( '%sF' % siFormat(frame['analysis']['capacitance'])) self.ui.fitErrorLabel.setText('%7.2g' % frame['analysis']['fitError']) prof.mark('7') start = data._info[-1]['DAQ']['command']['startTime'] if self.startTime is None: self.startTime = start if self.ui.recordBtn.isChecked() and self.storageFile is not None: self.storageFile.setInfo({'startTime': self.startTime}) self.analysisData['time'].append(start - self.startTime) prof.mark('8') self.updateAnalysisPlots() prof.mark('9') ## Record to disk if requested. if self.ui.recordBtn.isChecked(): arr = self.makeAnalysisArray(lastOnly=True) #print "appending array", arr.shape if self.storageFile is None: self.newFile(arr) else: arr.write(self.storageFile.name(), appendAxis='Time') prof.mark('10') prof.finish()
def handleNewFrame(self, frame): prof = Profiler('PatchWindow.handleNewFrame', disabled=True) with self.paramLock: mode = self.params['mode'] data = frame['data'][self.clampName] if mode == 'vc': self.ui.patchPlot.setLabel('left', units='A') else: self.ui.patchPlot.setLabel('left', units='V') prof.mark('1') self.patchCurve.setData(data.xvals('Time'), data['primary']) prof.mark('2') if self.redrawCommand > 0: self.redrawCommand -= 1 #print "set command curve" self.commandCurve.setData(data.xvals('Time'), data['command']) if mode == 'vc': self.ui.commandPlot.setLabel('left', units='V') else: self.ui.commandPlot.setLabel('left', units='A') prof.mark('3') #self.ui.patchPlot.replot() #self.ui.commandPlot.replot() if frame['analysis']['fitTrace'] is not None: self.patchFitCurve.show() self.patchFitCurve.setData(data.xvals('Time'), frame['analysis']['fitTrace']) else: self.patchFitCurve.hide() prof.mark('4') for k in self.analysisItems: if k in frame['analysis']: self.analysisData[k].append(frame['analysis'][k]) prof.mark('5') for r in ['input', 'access']: res = r+'Resistance' label = getattr(self.ui, res+'Label') resistance = frame['analysis'][res] label.setText(siFormat(resistance) + u'Ω') prof.mark('6') self.ui.restingPotentialLabel.setText(siFormat(frame['analysis']['restingPotential'], error=frame['analysis']['restingPotentialStd'], suffix='V')) self.ui.restingCurrentLabel.setText(siFormat(frame['analysis']['restingCurrent'], error=frame['analysis']['restingCurrentStd'], suffix='A')) self.ui.capacitanceLabel.setText('%sF' % siFormat(frame['analysis']['capacitance'])) self.ui.fitErrorLabel.setText('%7.2g' % frame['analysis']['fitError']) prof.mark('7') start = data._info[-1]['DAQ']['command']['startTime'] if self.startTime is None: self.startTime = start if self.ui.recordBtn.isChecked() and self.storageFile is not None: self.storageFile.setInfo({'startTime': self.startTime}) self.analysisData['time'].append(start - self.startTime) prof.mark('8') self.updateAnalysisPlots() prof.mark('9') ## Record to disk if requested. if self.ui.recordBtn.isChecked(): arr = self.makeAnalysisArray(lastOnly=True) #print "appending array", arr.shape if self.storageFile is None: self.newFile(arr) else: arr.write(self.storageFile.name(), appendAxis='Time') prof.mark('10') prof.finish()
def showCell(**kwds): pw2.clear() reloadData = kwds.get('reloadData', False) #global lock #if lock: #return #lock = True QtGui.QApplication.processEvents() ## prevents double-spin #lock = False cell = cells[cellCombo.currentIndex()-1] dh = cell #db.getDir('Cell', cell) loadCell(dh, reloadData=reloadData) try: image.setImage(dh['morphology.png'].read()) gv.setRange(image.sceneBoundingRect()) except: image.setImage(np.zeros((2,2))) pass ev, numExSites, numInSites = events[cell] ev2 = select(ev, ex=True) ev3 = select(ev, ex=False) if colorCheck.isChecked(): sp1.hide() sp2.hide() sp3.hide() sp4.show() start = postRgnStart() stop = postRgnStop() ev2post = ev2[(ev2['fitTime']>start) * (ev2['fitTime']<stop)] ev3post = ev3[(ev3['fitTime']>start) * (ev3['fitTime']<stop)] ev4 = np.concatenate([ev2post, ev3post]) yMax = ev4['dorsal'].max() yMin = ev4['dorsal'].min() brushes = [] for i in range(len(ev4)): hue = 0.6*((ev4[i]['dorsal']-yMin) / (yMax-yMin)) brushes.append(pg.hsvColor(hue, 1.0, 1.0, 0.3)) #pts.append({ #'pos': (ev4[i]['fitDecayTau'], ev4[i]['fitAmplitude']), #'brush': pg.hsvColor(hue, 1, 1, 0.3), #'data': ev4[i] #}) sp4.setData(x=ev4['fitDecayTau'], y=ev4['fitAmplitude'], symbolBrush=brushes, data=ev4) else: sp1.show() sp2.show() #sp3.show() sp4.hide() ## excitatory if separateCheck.isChecked(): pre = ev2[ev2['fitTime']< preRgnStop()] post = ev2[(ev2['fitTime'] > postRgnStart()) * (ev2['fitTime'] < postRgnStop())] else: pre = ev2 sp1.setData(x=pre['fitDecayTau'], y=pre['fitAmplitude'], data=pre); #print "Cell ", cell #print " excitatory:", np.median(ev2['fitDecayTau']), np.median(ev2['fitAmplitude']) ## inhibitory if separateCheck.isChecked(): pre = ev3[ev3['fitTime']< preRgnStop()] post2 = ev3[(ev3['fitTime'] > postRgnStart()) * (ev3['fitTime'] < postRgnStop())] post = np.concatenate([post, post2]) else: pre = ev3 sp2.setData(x=pre['fitDecayTau'], y=pre['fitAmplitude'], data=pre); #print " inhibitory:", np.median(ev2['fitDecayTau']), np.median(ev2['fitAmplitude']) if separateCheck.isChecked(): sp3.setData(x=post['fitDecayTau'], y=post['fitAmplitude'], data=post) sp3.show() else: sp3.hide() try: typ = ev2[0]['CellType'] except: typ = ev3[0]['CellType'] sr = spontRate(ev2, numExSites) sri = spontRate(ev3, numInSites) title = "%s -- %s --- <span style='color: #99F;'>ex:</span> %s %s %s %0.1fHz --- <span style='color: #F99;'>in:</span> %s %s %s %0.1fHz" % ( dh.name(relativeTo=dh.parent().parent().parent()), typ, pg.siFormat(np.median(ev2['fitTimeToPeak']), error=np.std(ev2['fitTimeToPeak']), space=False, suffix='s'), pg.siFormat(np.median(ev2['fitDecayTau']), error=np.std(ev2['fitDecayTau']), space=False, suffix='s'), pg.siFormat(np.median(ev2['fitAmplitude']), error=np.std(ev2['fitAmplitude']), space=False, suffix='A'), sr, pg.siFormat(np.median(ev3['fitTimeToPeak']), error=np.std(ev3['fitTimeToPeak']), space=False, suffix='s'), pg.siFormat(np.median(ev3['fitDecayTau']), error=np.std(ev3['fitDecayTau']), space=False, suffix='s'), pg.siFormat(np.median(ev3['fitAmplitude']), error=np.std(ev3['fitAmplitude']), space=False, suffix='A'), sri) print re.sub(r'<[^>]+>', '', title) pw1.setTitle(title) ### show cell in atlas #rec = db.select('CochlearNucleus_Cell', where={'CellDir': cell}) #pts = [] #if len(rec) > 0: #pos = (rec[0]['right'], rec[0]['anterior'], rec[0]['dorsal']) #pts = [{'pos': pos, 'size': 100e-6, 'color': (0.7, 0.7, 1.0, 1.0)}] ### show event positions evSpots = {} for rec in ev: p = (rec['right'], rec['anterior'], rec['dorsal']) evSpots[p] = None pos = np.array(evSpots.keys()) atlasPoints.setData(pos=pos, )