Esempio n. 1
0
	def _openchanstats(self, curr):
		"""
			Estimate the mean, standard deviation and slope of 
			the channel's open state current using self.blockSizeSec of data. 			
			Args:
				curr:			numpy array to use for calculating statistics
			Returns:
				meanOpenCurr	mean open channel current
				sdOpenCurr		standard deviation of open channel current
				slopeOpenCurr	slope of the open channel current (measure of drift)
								in pA/s
			Errors:
				None
		"""
		n=len(curr)

		#curr=self.trajDataObj.previewdata(nPoints)
		t=1./self.FsHz
		tstamp=np.arange(0, n*t, t, dtype=np.float64)[:n]

		#print "nPoints=", n, "len(tstamp)=", len(tstamp), "type(curr)", type(curr)
		
		# Calculate the mean and standard deviation of the open state
		mu, sig=OpenCurrentDist(curr, 0.5, self.minBaseline, self.maxBaseline)

		# Fit the data to a straight line to calculate the slope
		slope, intercept, r_value, p_value, std_err=scipy.stats.linregress(tstamp, curr)

		# self.logger.debug(_d("mu={0}, sigma={1}, slope={2}", mu, sig, slope ))

		# Return stats

		return [ mu, sig, slope ]
Esempio n. 2
0
    def _openchanstats(self, curr):
        """
			Estimate the mean, standard deviation and slope of 
			the channel's open state current using self.blockSizeSec of data. 			
			Args:
				curr:			numpy array to use for calculating statistics
			Returns:
				meanOpenCurr	mean open channel current
				sdOpenCurr		standard deviation of open channel current
				slopeOpenCurr	slope of the open channel current (measure of drift)
								in pA/s
			Errors:
				None
		"""
        n = len(curr)

        #curr=self.trajDataObj.previewdata(nPoints)
        t = 1. / self.trajDataObj.FsHz
        tstamp = np.arange(0, n * t, t, dtype=np.float64)[:n]

        #print "nPoints=", n, "len(tstamp)=", len(tstamp), "type(curr)", type(curr)

        # Calculate the mean and standard deviation of the open state
        mu, sig = OpenCurrentDist(curr, 0.5)

        # Fit the data to a straight line to calculate the slope
        # ft[0]: slope
        # ft[1]: y-intercept (mean current)
        ft = np.polyfit(tstamp, curr, 1)

        # Return stats
        return [mu, sig, ft[0]]
Esempio n. 3
0
    def _openChanStats(self, ydat):
        try:
            mu, sigma = OpenCurrentDist(ydat, 0.5)
        except:
            mu = 0
            sigma = 0

        self.returnMessageJSON['currMeanAuto'] = round(mu, 3)
        self.returnMessageJSON['currSigmaAuto'] = round(sigma, 3)
Esempio n. 4
0
    def _calculateThreshold(self, dat):
        if float(self.datadict["meanOpenCurr"]) == -1 or float(
                self.datadict["sdOpenCurr"]) == -1:
            try:
                self.mu, self.sd = OpenCurrentDist(dat, 0.5)
                if self.thrCurrPicoA == 0.:
                    self.thr = float(self.datadict["eventThreshold"])

                    # if eventThresholdpA is not set, the program was initialized with
                    # baseline auto. Store the threshold current in pA in self.thrCurrPicoA.
                    # The settings window will then pick it up on the first controls update.
                    self.thrCurrPicoA = self.mu - self.sd * self.thr
                else:
                    # If self.thrCurrPicoA is set, then calculate a new threshold in SD
                    # so as to keep self.thrCurrPicoA constant.
                    self.thr = (self.mu - self.thrCurrPicoA) / self.sd
            except AttributeError:
                self.mu, self.sd = OpenCurrentDist(dat, 0.5)
                self.thr = (self.mu - self.thrCurrPicoA) / self.sd
        else:
            self.mu = abs(float(self.datadict["meanOpenCurr"]))
            self.sd = float(self.datadict["sdOpenCurr"])
            self.thr = (self.mu - self.thrCurrPicoA) / self.sd
Esempio n. 5
0
 def currentStats(self, curr):
     return OpenCurrentDist(curr, 0.5)