def phasicTonic(self,m1=None,m2=None,chunkMs=<NUM_LIT:10>,<EOL>quietPercentile=<NUM_LIT:10>,histResolution=<NUM_LIT>,<EOL>plotToo=False):
<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>self.kernel=self.kernel_gaussian(<NUM_LIT>)<EOL>Y=self.sweepYsmartbase()<EOL>padding=<NUM_LIT:50> <EOL>chunkPoints=int(chunkMs*self.pointsPerMs)<EOL>nChunks=int(len(Y)/chunkPoints)<EOL>histBins=int((padding*<NUM_LIT:2>)/histResolution)<EOL>hist,bins=np.histogram(Y,bins=histBins,range=(-padding,padding))<EOL>hist=hist.astype(np.float)<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)<EOL>blCurve=mlab.normpdf(bins[:-<NUM_LIT:1>],center,sigma)<EOL>blCurve=blCurve/max(blCurve)<EOL>blCurve=blCurve*max(hist)<EOL>blankPoints=int(<NUM_LIT:2>*sigma/histResolution)<EOL>centerI=int(len(hist)/<NUM_LIT:2>)<EOL>for i in range(blankPoints):<EOL><INDENT>hist[centerI-i]=np.nan<EOL>hist[centerI+i]=np.nan<EOL><DEDENT>diff=hist-blCurve<EOL>if plotToo:<EOL><INDENT>plt.figure(figsize=(<NUM_LIT:7>,<NUM_LIT:7>))<EOL>plt.subplot(<NUM_LIT>)<EOL>plt.title(abf.ID+"<STR_LIT>")<EOL>plt.ylabel("<STR_LIT>")<EOL>plt.plot(bins[:-<NUM_LIT:1>],hist,'<STR_LIT:.>',alpha=<NUM_LIT>)<EOL>plt.plot(bins[:-<NUM_LIT:1>],blCurve,lw=<NUM_LIT:3>,alpha=<NUM_LIT>,color='<STR_LIT:r>')<EOL>plt.margins(<NUM_LIT:0>,<NUM_LIT>)<EOL>plt.subplot(<NUM_LIT>)<EOL>plt.title("<STR_LIT>")<EOL>plt.ylabel("<STR_LIT>")<EOL>plt.xlabel("<STR_LIT>"%abf.units)<EOL>plt.plot(bins[:-<NUM_LIT:1>],diff,'<STR_LIT:.>',alpha=<NUM_LIT>,color='<STR_LIT:b>')<EOL>plt.axhline(<NUM_LIT:0>,lw=<NUM_LIT:3>,alpha=<NUM_LIT>,color='<STR_LIT:r>')<EOL>plt.axvline(<NUM_LIT:0>,lw=<NUM_LIT:3>,alpha=<NUM_LIT>,color='<STR_LIT:r>')<EOL>plt.margins(<NUM_LIT:0>,<NUM_LIT>)<EOL>plt.tight_layout()<EOL>plt.show()<EOL><DEDENT>
IMPORTANT: do this first!!
self.kernel=self.kernel_gaussian(250)