# and labeled as the peaks and troughs, respectively. from bycycle.filt import bandpass_filter from bycycle.cyclepoints import _fzerorise, _fzerofall, find_extrema # Narrowband filter signal N_seconds_theta = .75 signal_narrow = bandpass_filter(signal, Fs, f_theta, remove_edge_artifacts=False, N_seconds=N_seconds_theta) # Find rising and falling zerocrossings (narrowband) zeroriseN = _fzerorise(signal_narrow) zerofallN = _fzerofall(signal_narrow) #################################################################################################### # Find peaks and troughs (this function also does the above) Ps, Ts = find_extrema(signal_low, Fs, f_theta, filter_kwargs={'N_seconds': N_seconds_theta}) tlim = (12, 15) tidx = np.logical_and(t >= tlim[0], t < tlim[1]) tidxPs = Ps[np.logical_and(Ps > tlim[0] * Fs, Ps < tlim[1] * Fs)] tidxTs = Ts[np.logical_and(Ts > tlim[0] * Fs, Ts < tlim[1] * Fs)] plt.figure(figsize=(12, 2))
# individual cycles. To do this, the signal is first narrow-bandpass filtered in order to estimate # "zero-crossings." Then, in between these zerocrossings, the absolute maxima and minima are found # and labeled as the peaks and troughs, respectively. # Narrowband filter signal n_seconds_theta = .75 sig_narrow = filter_signal(sig, fs, 'bandpass', f_theta, n_seconds=n_seconds_theta, remove_edges=False) # Find rising and falling zerocrossings (narrowband) zerorise_narrow = _fzerorise(sig_narrow) zerofall_narrow = _fzerofall(sig_narrow) #################################################################################################### # Find peaks and troughs (this function also does the above) peaks, troughs = find_extrema(sig_low, fs, f_theta, filter_kwargs={'n_seconds': n_seconds_theta}) plot_cyclepoints_array(sig_low, fs, peaks=peaks, troughs=troughs, xlim=(12, 15))