def quietParts(data,percentile=<NUM_LIT:10>):
nChunks=int(len(Y)/CHUNK_POINTS)<EOL>chunks=np.reshape(Y[:nChunks*CHUNK_POINTS],(nChunks,CHUNK_POINTS))<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>selected=chunks[np.where(percentiles<=percentile)[<NUM_LIT:0>]].flatten()<EOL>return selected<EOL>
Given some data (Y) break it into chunks and return just the quiet ones.
Returns data where the variance for its chunk size is below the given percentile.
CHUNK_POINTS should be adjusted so it's about 10ms of data.