def analyzeSweep(abf,sweep,m1=None,m2=None,plotToo=False):
abf.setsweep(sweep)<EOL>if m1 is None: m1=<NUM_LIT:0><EOL>else: m1=m1*abf.pointsPerSec<EOL>if m2 is None: m2=-<NUM_LIT:1><EOL>else: m2=m2*abf.pointsPerSec<EOL>Yorig=abf.sweepY[int(m1):int(m2)]<EOL>X=np.arange(len(Yorig))/abf.pointsPerSec<EOL><INDENT>Klpf=kernel_gaussian(size=abf.pointsPerMs*<NUM_LIT:10>,forwardOnly=True)<EOL>Ylpf=np.convolve(Yorig,Klpf,mode='<STR_LIT>')<EOL>Y=Ylpf <EOL><DEDENT>Kmb=kernel_gaussian(size=abf.pointsPerMs*<NUM_LIT:10>,forwardOnly=True)<EOL>Ymb=np.convolve(Yorig,Kmb,mode='<STR_LIT>')<EOL>Y=Yorig-Ymb <EOL>thresh=<NUM_LIT:5> <EOL>hitPos=np.where(Y>thresh)[<NUM_LIT:0>] <EOL>hitNeg=np.where(Y<-thresh)[<NUM_LIT:0>] <EOL>hitPos=np.concatenate((hitPos,[len(Y)-<NUM_LIT:1>])) <EOL>hitNeg=np.concatenate((hitNeg,[len(Y)-<NUM_LIT:1>])) <EOL>hitsPos=hitPos[np.where(np.abs(np.diff(hitPos))><NUM_LIT:10>)[<NUM_LIT:0>]] <EOL>hitsNeg=hitNeg[np.where(np.abs(np.diff(hitNeg))><NUM_LIT:10>)[<NUM_LIT:0>]] <EOL>hitsNeg=hitsNeg[<NUM_LIT:1>:] <EOL>if plotToo:<EOL><INDENT>plt.figure(figsize=(<NUM_LIT:10>,<NUM_LIT:5>))<EOL>ax1=plt.subplot(<NUM_LIT>)<EOL>plt.title("<STR_LIT>"%(sweep,len(hitsPos),len(hitsNeg)))<EOL>plt.ylabel("<STR_LIT>")<EOL>plt.grid()<EOL>plt.plot(X,Yorig,color='<STR_LIT:k>',alpha=<NUM_LIT>)<EOL>for hit in hitsPos:<EOL><INDENT>plt.plot(X[hit],Yorig[hit]+<NUM_LIT:20>,'<STR_LIT>',ms=<NUM_LIT:20>,alpha=<NUM_LIT>)<EOL><DEDENT>for hit in hitsNeg:<EOL><INDENT>plt.plot(X[hit],Yorig[hit]-<NUM_LIT:20>,'<STR_LIT>',ms=<NUM_LIT:20>,alpha=<NUM_LIT>)<EOL><DEDENT>plt.margins(<NUM_LIT:0>,<NUM_LIT>)<EOL>plt.subplot(<NUM_LIT>,sharex=ax1)<EOL>plt.title("<STR_LIT>")<EOL>plt.ylabel("<STR_LIT>")<EOL>plt.grid()<EOL>plt.axhline(thresh,color='<STR_LIT:r>',ls='<STR_LIT>',alpha=<NUM_LIT>,lw=<NUM_LIT:3>)<EOL>plt.axhline(-thresh,color='<STR_LIT:r>',ls='<STR_LIT>',alpha=<NUM_LIT>,lw=<NUM_LIT:3>)<EOL>plt.plot(X,Y,color='<STR_LIT:b>',alpha=<NUM_LIT>)<EOL>plt.axis([X[<NUM_LIT:0>],X[-<NUM_LIT:1>],-thresh*<NUM_LIT>,thresh*<NUM_LIT>])<EOL>plt.tight_layout()<EOL>if type(plotToo) is str and os.path.isdir(plotToo):<EOL><INDENT>print('<STR_LIT>'%(plotToo,sweep))<EOL>plt.savefig(plotToo+"<STR_LIT>"%sweep)<EOL><DEDENT>else:<EOL><INDENT>plt.show()<EOL><DEDENT>plt.close('<STR_LIT:all>')<EOL><DEDENT>return [len(hitsPos),len(hitsNeg)]<EOL>
m1 and m2, if given, are in seconds.
returns [# EPSCs, # IPSCs]