def GenStartMetadata(self, mdh): if self.active: #we are active -> write metadata self.GetStatus() mdh.setEntry('Camera.Name', 'Andor IXon DV97') mdh.setEntry('Camera.Model', self.GetHeadModel()) mdh.setEntry('Camera.SerialNumber', self.GetSerialNumber()) mdh.setEntry('Camera.IntegrationTime', self.tExp) mdh.setEntry('Camera.CycleTime', self.tKin) mdh.setEntry('Camera.EMGain', self.GetEMGain()) mdh.setEntry('Camera.ROIPosX', self.GetROIX1()) mdh.setEntry('Camera.ROIPosY', self.GetROIY1()) mdh.setEntry('Camera.ROIWidth', self.GetROIX2() - self.GetROIX1()) mdh.setEntry('Camera.ROIHeight', self.GetROIY2() - self.GetROIY1()) mdh.setEntry('Camera.StartCCDTemp', self.GetCCDTemp()) #these should really be read from a configuration file #hard code them here until I get around to it #current values are at 10Mhz using e.m. amplifier np = noiseProperties[self.GetSerialNumber()] mdh.setEntry('Camera.ReadNoise', np['ReadNoise']) mdh.setEntry('Camera.NoiseFactor', 1.41) mdh.setEntry('Camera.ElectronsPerCount', np['ElectronsPerCount']) realEMGain = ccdCalibrator.getCalibratedCCDGain( self.GetEMGain(), self.GetCCDTempSetPoint()) if not realEMGain == None: mdh.setEntry('Camera.TrueEMGain', realEMGain)
def GenStartMetadata(self, mdh): self.GetStatus() mdh.setEntry('Camera.Name', 'Simulated EM CCD Camera') mdh.setEntry('Camera.IntegrationTime', self.GetIntegTime()) mdh.setEntry('Camera.CycleTime', self.GetIntegTime()) mdh.setEntry('Camera.EMGain', self.GetEMGain()) mdh.setEntry('Camera.ROIPosX', self.GetROIX1()) mdh.setEntry('Camera.ROIPosY', self.GetROIY1()) mdh.setEntry('Camera.ROIWidth', self.GetROIX2() - self.GetROIX1()) mdh.setEntry('Camera.ROIHeight', self.GetROIY2() - self.GetROIY1()) #mdh.setEntry('Camera.StartCCDTemp', self.GetCCDTemp()) mdh.setEntry('Camera.ReadNoise', self.noiseMaker.ReadoutNoise) mdh.setEntry('Camera.NoiseFactor', 1.41) mdh.setEntry('Camera.ElectronsPerCount', self.noiseMaker.ElectronsPerCount) mdh.setEntry('Camera.ADOffset', self.noiseMaker.ADOffset) #mdh.setEntry('Simulation.Fluorophores', self.fluors.fl) #mdh.setEntry('Simulation.LaserPowers', self.laserPowers) realEMGain = ccdCalibrator.getCalibratedCCDGain( self.GetEMGain(), self.GetCCDTempSetPoint()) if not realEMGain == None: mdh.setEntry('Camera.TrueEMGain', realEMGain) #if 'spec' in self.fluors.fl.dtype.fields.keys(): #set the splitter parameters if self.fluors and 'spec' in self.fluors.fl.dtype.fields.keys(): mdh['Splitter.Channel0ROI'] = [0, 0, 128, 256] mdh['Splitter.Channel1ROI'] = [128, 0, 128, 256] mdh['Splitter.Flip'] = False
def GenStartMetadata(self, mdh): self.GetStatus() mdh.setEntry('Camera.Name', 'Simulated EM CCD Camera') mdh.setEntry('Camera.IntegrationTime', self.GetIntegTime()) mdh.setEntry('Camera.CycleTime', self.GetIntegTime()) mdh.setEntry('Camera.EMGain', self.GetEMGain()) mdh.setEntry('Camera.ROIPosX', self.GetROIX1()) mdh.setEntry('Camera.ROIPosY', self.GetROIY1()) mdh.setEntry('Camera.ROIWidth', self.GetROIX2() - self.GetROIX1()) mdh.setEntry('Camera.ROIHeight', self.GetROIY2() - self.GetROIY1()) #mdh.setEntry('Camera.StartCCDTemp', self.GetCCDTemp()) mdh.setEntry('Camera.ReadNoise', self.noiseMaker.ReadoutNoise) mdh.setEntry('Camera.NoiseFactor', 1.41) mdh.setEntry('Camera.ElectronsPerCount', self.noiseMaker.ElectronsPerCount) mdh.setEntry('Camera.ADOffset', self.noiseMaker.ADOffset) #mdh.setEntry('Simulation.Fluorophores', self.fluors.fl) #mdh.setEntry('Simulation.LaserPowers', self.laserPowers) realEMGain = ccdCalibrator.getCalibratedCCDGain(self.GetEMGain(), self.GetCCDTempSetPoint()) if not realEMGain == None: mdh.setEntry('Camera.TrueEMGain', realEMGain) #if 'spec' in self.fluors.fl.dtype.fields.keys(): #set the splitter parameters if self.fluors and 'spec' in self.fluors.fl.dtype.fields.keys(): mdh['Splitter.Channel0ROI'] = [0,0,128, 256] mdh['Splitter.Channel1ROI'] = [128,0,128, 256] mdh['Splitter.Flip'] = False
def GenStartMetadata(self, mdh): if self.active: #we are active -> write metadata self.GetStatus() mdh.setEntry('Camera.Name', 'Andor IXon DV97') mdh.setEntry('Camera.Model', self.GetHeadModel()) mdh.setEntry('Camera.SerialNumber', self.GetSerialNumber()) mdh.setEntry('Camera.IntegrationTime', self.tExp) mdh.setEntry('Camera.CycleTime', self.tKin) mdh.setEntry('Camera.EMGain', self.GetEMGain()) mdh.setEntry('Camera.ROIPosX', self.GetROIX1()) mdh.setEntry('Camera.ROIPosY', self.GetROIY1()) mdh.setEntry('Camera.ROIWidth', self.GetROIX2() - self.GetROIX1()) mdh.setEntry('Camera.ROIHeight', self.GetROIY2() - self.GetROIY1()) mdh.setEntry('Camera.StartCCDTemp', self.GetCCDTemp()) #these should really be read from a configuration file #hard code them here until I get around to it #current values are at 10Mhz using e.m. amplifier np = noiseProperties[self.GetSerialNumber()] mdh.setEntry('Camera.ReadNoise', np['ReadNoise']) mdh.setEntry('Camera.NoiseFactor', 1.41) mdh.setEntry('Camera.ElectronsPerCount', np['ElectronsPerCount']) realEMGain = ccdCalibrator.getCalibratedCCDGain(self.GetEMGain(), self.GetCCDTempSetPoint()) if not realEMGain == None: mdh.setEntry('Camera.TrueEMGain', realEMGain)
def OnEMGainTextChange(self, event): calEMGain = ccdCalibrator.getCalibratedCCDGain(float(self.tEMGain.GetValue()), self.cam.GetCCDTempSetPoint()) if calEMGain == None: self.stTrueEMGain.SetLabel('True Gain = ????') self.stTrueEMGain.SetForegroundColour(wx.RED) else: self.stTrueEMGain.SetLabel('True Gain = %3.2f' % calEMGain) self.stTrueEMGain.SetForegroundColour(wx.BLUE)
def GenStartMetadata(self, mdh): self.GetStatus() mdh.setEntry('Camera.Name', 'Simulated EM CCD Camera') mdh.setEntry('Camera.IntegrationTime', self.GetIntegTime()) mdh.setEntry('Camera.CycleTime', self.GetIntegTime()) mdh.setEntry('Camera.EMGain', self.GetEMGain()) #mdh.setEntry('Camera.ROIPosX', self.GetROIX1()) #mdh.setEntry('Camera.ROIPosY', self.GetROIY1()) x1, y1, x2, y2 = self.GetROI() mdh.setEntry('Camera.ROIOriginX', x1) mdh.setEntry('Camera.ROIOriginY', y1) mdh.setEntry('Camera.ROIWidth', x2 - x1) mdh.setEntry('Camera.ROIHeight', y2 - y1) #mdh.setEntry('Camera.StartCCDTemp', self.GetCCDTemp()) mdh.setEntry('Camera.ReadNoise', self.noiseMaker.ReadoutNoise) mdh.setEntry('Camera.NoiseFactor', 1.41) mdh.setEntry('Camera.ElectronsPerCount', self.noiseMaker.ElectronsPerCount) mdh.setEntry('Camera.ADOffset', np.mean(self.noiseMaker.ADOffset)) #mdh.setEntry('Simulation.Fluorophores', self.fluors.fl) #mdh.setEntry('Simulation.LaserPowers', self.laserPowers) realEMGain = ccdCalibrator.getCalibratedCCDGain( self.GetEMGain(), self.GetCCDTempSetPoint()) if not realEMGain is None: mdh.setEntry('Camera.TrueEMGain', realEMGain) if self.fluors and 'spec' in self.fluors.fl.dtype.fields.keys( ): #set the splitter parameters mdh['Splitter.Channel0ROI'] = [0, 0, 128, 256] mdh['Splitter.Channel1ROI'] = [128, 0, 128, 256] mdh['Splitter.Flip'] = False chan_specs = getattr(self, '_chan_specs', None) if not chan_specs is None: nChans = len(chan_specs) x_pixels = len(self.XVals) x_chan_pixels = x_pixels / nChans y_pixels = len(self.YVals) mdh['Multiview.NumROIs'] = nChans mdh['Multiview.ROISize'] = [x_chan_pixels, y_pixels] mdh['Multiview.ChannelColor'] = list(chan_specs) for i in range(nChans): mdh['Multiview.ROI%dOrigin' % i] = [i * x_chan_pixels, 0] mdh['Splitter.Channel%dROI' % i] = [i * x_chan_pixels, 0, x_chan_pixels, y_pixels]
def draw( self ): """Draw data.""" #matplotlib.interactive(False) if not 'vsp' in dir(self.scope): # can't do anything #self.figure.show() #matplotlib.interactive(True) return emGainSettings = np.arange(0, 220, 5) emGains = ccdCalibrator.getCalibratedCCDGain(emGainSettings, self.scope.cam.GetCCDTempSetPoint()) if emGains == None: # can't do anything #self.figure.show() #matplotlib.interactive(True) return matplotlib.interactive(False) if not hasattr( self, 'spEMGain' ): self.spEMSNR = self.figure.add_axes([.15,.55,.7,.3]) self.spEMHeadroom = self.figure.add_axes([.15,.55,.7,.3], axisbg=None, frameon=False, label='headroom') self.spIntSNR = self.figure.add_axes([.15,.1,.7,.3]) self.spIntFrameRate = self.spIntSNR.twinx()#self.figure.add_axes([.15,.1,.7,.3], axisbg=None, frameon=False, label='framerate') #a, ed = numpy.histogram(self.fitResults['tIndex'], self.Size[0]/2) self.spEMSNR.cla() self.spEMHeadroom.cla() self.spIntSNR.cla() self.spIntFrameRate.cla() currEMGain = ccdCalibrator.getCalibratedCCDGain(self.scope.cam.GetEMGain(), self.scope.cam.GetCCDTempSetPoint()) Imin = self.scope.vsp.dmin Imax = self.scope.vsp.dmax Imean = self.scope.vsp.dmean off = self.scope.cam.ADOffset #snrMin = EMCCDTheory.SNR((np.minimum(Imin - off, 1)/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, emGains, self.scope.cam.NGainElements) snrMean = EMCCDTheory.SNR(((Imean - off)/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, emGains, self.scope.cam.NGainElements) snrMax = EMCCDTheory.SNR(((Imax - off)/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, emGains, self.scope.cam.NGainElements) #self.spEMSNR.plot(np.log10(emGains), 10*np.log10(snrMin), color='b') self.spEMSNR.plot(np.log10(emGains), 10*np.log10(snrMean), color='b', lw=2) self.spEMSNR.plot(np.log10(emGains), 10*np.log10(snrMax), color='b', lw=2) xticks = [1, 10, 100, 1000] self.spEMSNR.set_xticks(np.log10(xticks)) self.spEMSNR.set_xticklabels([str(t) for t in xticks]) self.spEMSNR.set_xlim(np.log10(emGains).min(), np.log10(emGains).max()) self.spEMSNR.set_xlabel('True EM Gain') self.spEMSNR.set_ylabel('SNR [dB]', color = 'b') for t in self.spEMSNR.get_yticklabels(): t.set_color('b') self.spEMHeadroom.yaxis.tick_right() self.spEMHeadroom.yaxis.set_label_position('right') self.spEMHeadroom.xaxis.tick_top() self.spEMHeadroom.xaxis.set_label_position('top') self.spEMHeadroom.semilogy(np.log10(emGains), np.maximum((self.scope.cam.SaturationThreshold - off)/((Imax - off)*emGains/currEMGain), 1), color='r', lw=2) #self.spEMHeadroom.xaxis.tick_top() xticks = [0, 50, 100, 150, 200] self.spEMHeadroom.set_xticks(np.log10(ccdCalibrator.getCalibratedCCDGain(xticks, self.scope.cam.GetCCDTempSetPoint()))) self.spEMHeadroom.set_xticklabels([str(t) for t in xticks]) self.spEMHeadroom.set_xlim(np.log10(emGains).min(), np.log10(emGains).max()) self.spEMHeadroom.set_xlabel('EM Gain Setting') self.spEMHeadroom.set_ylabel('Headroom - Isat/Imax', color = 'r') self.spEMHeadroom.set_ylim(ymin=1) for t in self.spEMHeadroom.get_yticklabels(): t.set_color('r') iTimes = np.logspace(-3, 0, 50) iScale = iTimes/self.scope.cam.GetIntegTime() #snrMeanI = EMCCDTheory.SNR((iScale*(Imean - off)/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, currEMGain, self.scope.cam.NGainElements) snrMaxI = EMCCDTheory.SNR((iScale*(Imax - off)/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, currEMGain, self.scope.cam.NGainElements,(iScale*(Imean - off)/currEMGain)*self.scope.cam.ElectronsPerCount) evtI = (Imax - Imean)/scipy.special.gammainc(1, self.scope.cam.GetIntegTime()/self.eventDuration) snrFlash = EMCCDTheory.SNR(((scipy.special.gammainc(1, iTimes/self.eventDuration)*evtI + iScale*(Imean - off))/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, currEMGain, self.scope.cam.NGainElements,(iScale*(Imean - off)/currEMGain)*self.scope.cam.ElectronsPerCount) evtI = (Imax - Imean)/scipy.special.gammainc(1, self.scope.cam.GetIntegTime()*5/self.eventDuration) snrFlash02 = EMCCDTheory.SNR(((scipy.special.gammainc(1, iTimes*5/self.eventDuration)*evtI + iScale*(Imean - off))/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, currEMGain, self.scope.cam.NGainElements,(iScale*(Imean - off)/currEMGain)*self.scope.cam.ElectronsPerCount) evtI = (Imax - Imean)/scipy.special.gammainc(1, self.scope.cam.GetIntegTime()/(self.eventDuration*5)) snrFlash5 = EMCCDTheory.SNR(((scipy.special.gammainc(1, iTimes/(self.eventDuration*5))*evtI + iScale*(Imean - off))/currEMGain)*self.scope.cam.ElectronsPerCount, self.scope.cam.ReadoutNoise, currEMGain, self.scope.cam.NGainElements,(iScale*(Imean - off)/currEMGain)*self.scope.cam.ElectronsPerCount) #self.spIntSNR.plot(np.log10(iTimes), 10*np.log10(snrMeanI), color='b', lw=2) #self.spIntSNR.plot(np.log10(iTimes), 10*np.log10(snrMaxI), color='b', lw=2) self.spIntSNR.plot(np.log10(iTimes), 10*np.log10(snrFlash), color='b', lw=2) self.spIntSNR.plot(np.log10(iTimes), 10*np.log10(snrFlash02), color='b', lw=2, ls=';') self.spIntSNR.plot(np.log10(iTimes), 10*np.log10(snrFlash5), color='b', lw=2, ls='--') xticks = [1, 10, 100, 1000] self.spIntSNR.set_xticks(np.log10(np.array(xticks)*1e-3)) self.spIntSNR.set_xticklabels([str(t) for t in xticks]) self.spIntSNR.set_xlim(np.log10(iTimes).min(), np.log10(iTimes).max()) self.spIntSNR.set_xlabel('Integration Time [ms]') self.spIntSNR.set_ylabel('SNR [dB]', color = 'b') for t in self.spIntSNR.get_yticklabels(): t.set_color('b') self.spIntFrameRate.yaxis.tick_right() self.spIntFrameRate.yaxis.set_label_position('right') tFrame = np.maximum(iTimes, (1e-6/self.scope.cam.HorizShiftSpeeds[0][0][self.scope.cam.HSSpeed]*self.scope.cam.GetPicWidth()*self.scope.cam.GetPicHeight())) tFrame += self.scope.cam.GetCCDHeight()*self.scope.cam.vertShiftSpeeds[self.scope.cam.VSSpeed]*1e-6 self.spIntFrameRate.plot(np.log10(iTimes), 1./tFrame, color='g', lw=2) xticks = [1, 10, 100, 1000] #self.spIntSNR.set_xticks(np.log10(np.array(xticks)*1e-3)) #self.spIntSNR.set_xticklabels([str(t) for t in xticks]) #self.spIntSNR.set_xlim(np.log10(iTimes).min(), np.log10(iTimes).max()) #self.spIntSNR.set_xlabel('Integration Time [ms]') self.spIntFrameRate.set_ylabel('FPS', color = 'g') for t in self.spIntFrameRate.get_yticklabels(): t.set_color('g') #self.subplot1.set_yticks([0, a.max()]) #self.subplot2.plot(ed[:-1], numpy.cumsum(a), color='g' ) #self.subplot2.set_xticks([0, ed.max()]) #self.subplot2.set_yticks([0, a.sum()]) #self.figure.show() matplotlib.interactive(True)