Guest User

Untitled

a guest
Sep 14th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. """
  2. Spindles-like Morlet wavelet.
  3. Useful for automatic spindles detection.
  4. ---
  5. Author: Raphael Vallat <raphaelvallat9@gmail.com>
  6. Date: September 14, 2018
  7. """
  8. import numpy as np
  9. import matplotlib.pyplot as plt
  10. from mne.time_frequency import morlet
  11.  
  12. # Parameters
  13. sf = 100 # Sampling rate of the signal
  14. cf = 13.5 # Central spindles frequency
  15. nc = 12 # Number of cycles in the spindles
  16.  
  17. # Compute the wavelet and its envelope
  18. wlt = morlet(sf, [cf], n_cycles=nc, zero_mean=True)[0]
  19. wlt_env = np.abs(wlt)
  20.  
  21. # Plot
  22. t = np.arange(wlt.size) / sf
  23. plt.plot(t, wlt)
  24. plt.plot(t, wlt_env, 'k')
  25. plt.xlabel('Time (seconds)')
  26. plt.ylabel('Amplitude')
  27. plt.show()
Add Comment
Please, Sign In to add comment