def analyzeSweep(abf, plotToo=True, color=None, label=None): Y = abf.sweepYsmartbase()[abf.pointsPerSec * .5:] #Y=abf.sweepY[abf.pointsPerSec*.5:] AV, SD = np.average(Y), np.std(Y) dev = 5 # number of stdevs from the avg to set the range R1, R2 = [(AV - SD) * dev, (AV + SD) * dev] nBins = 1000 hist, bins = np.histogram(Y, bins=nBins, range=[R1, R2], density=True) histSmooth = abf.convolve(hist, cm.kernel_gaussian(nBins / 5)) peakI = np.where(histSmooth == max(histSmooth))[0][0] peakX = bins[peakI] # center the peak at 0 pA hist = np.roll(hist, int(nBins / 2 - peakI)) histSmooth = np.roll(histSmooth, int(nBins / 2 - peakI)) hist, histSmooth = hist / max(histSmooth), histSmooth / max( histSmooth) # normalize height to 1 if plotToo: plt.plot(bins[1:], hist, '.', color=color, alpha=.2, ms=10) plt.plot(bins[1:], histSmooth, '-', color=color, lw=5, alpha=.5, label=label) return
def analyzeSweep(abf, plotToo=True, color=None, label=None): Y = abf.sweepYsmartbase()[abf.pointsPerSec * .5:] AV, SD = np.average(Y), np.std(Y) dev = 5 # number of stdevs from the avg to set the range R1, R2 = [(AV - SD) * dev, (AV + SD) * dev] nBins = 1000 hist, bins = np.histogram(Y, bins=nBins, range=[R1, R2], density=True) histSmooth = abf.convolve(hist, cm.kernel_gaussian(nBins / 5)) if plotToo: plt.plot(bins[1:], hist, '.', color=color, alpha=.2, ms=10) plt.plot(bins[1:], histSmooth, '-', color=color, lw=5, alpha=.5, label=label) return
def analyzeSweep(abf): Y = abf.sweepYsmartbase()[abf.pointsPerSec * .5:] #Y=abf.sweepY[abf.pointsPerSec*.5:] AV, SD = np.average(Y), np.std(Y) dev = 5 # number of stdevs from the avg to set the range R1, R2 = [(AV - SD) * dev, (AV + SD) * dev] nBins = 1000 hist, bins = np.histogram(Y, bins=nBins, range=[R1, R2], density=True) histSmooth = abf.convolve(hist, cm.kernel_gaussian(nBins / 5)) peakI = np.where(histSmooth == max(histSmooth))[0][0] # center the peak at 0 pA hist = np.roll(hist, int(nBins / 2 - peakI)) histSmooth = np.roll(histSmooth, int(nBins / 2 - peakI)) # normalize height to 1 hist, histSmooth = hist / max(histSmooth), histSmooth / max(histSmooth) # separate EPSC and IPSC by splitting data at the peak EPSC, IPSC = np.split(histSmooth, 2) return np.sum(EPSC), np.sum(IPSC), np.sum(EPSC) / np.sum(IPSC)