def phasicTonic(self,m1=None,m2=None,chunkMs=<NUM_LIT:50>,quietPercentile=<NUM_LIT:10>,<EOL>histResolution=<NUM_LIT>,plotToo=False,rmsExpected=<NUM_LIT:5>):
<EOL>m1=<NUM_LIT:0> if m1 is None else m1*self.pointsPerSec<EOL>m2=len(abf.sweepY) if m2 is None else m2*self.pointsPerSec<EOL>m1,m2=int(m1),int(m2)<EOL>padding=<NUM_LIT:200> <EOL>chunkPoints=int(chunkMs*self.pointsPerMs)<EOL>histBins=int((padding*<NUM_LIT:2>)/histResolution)<EOL>Y=self.sweepY[m1:m2]<EOL>hist,bins=np.histogram(Y,bins=<NUM_LIT:2>*padding)<EOL>Yoffset=bins[np.where(hist==max(hist))[<NUM_LIT:0>][<NUM_LIT:0>]]<EOL>Y=Y-Yoffset <EOL>nChunks=int(len(Y)/chunkPoints)<EOL>hist,bins=np.histogram(Y,bins=histBins,range=(-padding,padding))<EOL>hist=hist/len(Y) <EOL>Xs=bins[<NUM_LIT:1>:]<EOL>chunks=np.reshape(Y[:nChunks*chunkPoints],(nChunks,chunkPoints))<EOL>variances=np.var(chunks,axis=<NUM_LIT:1>)<EOL>percentiles=np.empty(len(variances))<EOL>for i,variance in enumerate(variances):<EOL><INDENT>percentiles[i]=sorted(variances).index(variance)/len(variances)*<NUM_LIT:100><EOL><DEDENT>blData=chunks[np.where(percentiles<=quietPercentile)[<NUM_LIT:0>]].flatten()<EOL>sigma=np.sqrt(np.var(blData))<EOL>center=np.average(blData)+histResolution/<NUM_LIT:2><EOL>blCurve=mlab.normpdf(Xs,center,sigma)<EOL>blCurve=blCurve*max(hist)/max(blCurve)<EOL>diff=hist-blCurve<EOL>ignrCenter=len(Xs)/<NUM_LIT:2><EOL>ignrPad=rmsExpected/histResolution<EOL>ignr1,ignt2=int(ignrCenter-ignrPad),int(ignrCenter+ignrPad)<EOL>diff[ignr1:ignt2]=<NUM_LIT:0><EOL>return diff/len(Y)*abf.pointsPerSec<EOL>
chunkMs should be ~50 ms or greater.
bin sizes must be equal to or multiples of the data resolution.
transients smaller than the expected RMS will be silenced.