neurotools.signal.morlet module
Coherence measures based on the Morlet wavelength.
This allows adjusting the spectral and temporal nfreqss depending on frequency.
- neurotools.signal.morlet.normalized_morlet(m, w, s=1.0)[source]
See morlet(m,w); This applies post-processing such that the sum absolute magnitued of the wavelet is 1.
- Parameters:
m (int) – Length of the wavelet in samples
w (float) – Wavelet central frequency ω0
s (float, default 1.) – Scaling factor, windowed ±s2π
- neurotools.signal.morlet.normalized_morlet_physical_units(N, w, scale=1.0, Fs=1000)[source]
- Parameters:
N (int) – Length in samples
w (float) – Wavelet central frequency ω0 in Hz
s (float, default 1.) – Scaling factor in seconds
Fs (float, default 1000) – Sample rate in samples per second
- neurotools.signal.morlet.prepare_wavelet_fft_basis(fa, fb, nfreqs, L, w, Fs=1000)[source]
- Parameters:
fa (positive float) – Low-frequency cutoff in Hz
fb (positive float) – High-frequency cutoff in Hz
nfreqs (positive int) – Specral sampling nfreqs
L (positive int) – Number of samples
w (float) – Base frequency, passed as second argument to morlet()
Fs (positive int; default 1000) – Sampling rate
- Returns:
freqs – FFT frequencies
basis – Fourier transform of Morlet wavelets for each band.
- neurotools.signal.morlet.fft_cwt(data, fa, fb, w=4.0, nfreqs=0.1, Fs=1000)[source]
Wavelet transform.
- Parameters:
data – NTIMES × NCHANNELS np.array
w (positive float; default 4.0) – Wavelet base frequency; Controls the time-frequency tradeoff
nfreqs (positive float; default 0.1) – Frequency sampling nfreqs
Fs (positive int; default 1000) – Sample rate
- Returns:
freqs – Frequencies of each band, in Hz
result (NCHANNELS × NFREQS × NTIMES np.array) – wavelet transform
- neurotools.signal.morlet.geometric_window(c, w)[source]
Gemoetrically centered frequency window.
- Parameters:
c (float) – Center of frequency window
w (float) – width of frequency window
- Returns:
fa (float) – low-frequency cutoff
fb (float) – high-frequency cutoff
- neurotools.signal.morlet.logfreqs(fa, fb, nfreq)[source]
- Parameters:
fa (positive float) – Low-frequency cutoff in Hz
fb (positive float) – High-frequency cutoff in Hz
nfreq (positive int) – Number of frequency bands
- Returns:
freqs – list of logarithmically-spaced frequencies between fa and fb.
- Return type:
np.array
- neurotools.signal.morlet.prepare_wavelet_fft_basis_logspace(fa, fb, nfreq, L, w, Fs=1000)[source]
- Parameters:
fa (positive float) – Low-frequency cutoff in Hz
fb (positive float) – High-frequency cutoff in Hz
nfreq (positive int) – Number of frequency bands
L (positive int) – Number of samples
w (float) – Base frequency, passed as second argument to morlet()
Fs (positive int; default 1000) – Sampling rate
- Returns:
freqs – FFT frequencies
basis – Fourier transform of Morlet wavelets for each band.
- neurotools.signal.morlet.population_synchrony_spectrum(lfp, fa, fb, w=4.0, nfreqs=1, Fs=1000)[source]
Use Morlet wavelets to compute short-timescale synchrony.
- Parameters:
lfp (np.array) – First dimension is nchannels, second is time.
w (positive float; default 4.0) – Wavelet base frequency; Controls the time-frequency tradeoff
nfreqs (positive float; default 0.1) – Frequency sampling resolution
Fs (positive int; default 1000) – Sample rate
- Returns:
freqs (NFREQS np.array) – Frequencies of each band, in Hz
synchrony – NCHANNELS × NFREQS × NTIMES np.array
- neurotools.signal.morlet.fft_cwt_transposed(data, fa, fb, w=4.0, nfreqs=1000, Fs=1000.0, threads=1)[source]
Compute morelet spectrogam of a list of time-domain signals (possibly in parallel if you have a threaded installation of the FFTW library available).
This version spaces
nfreqsfrquencies uniformly betweenfaandfb, inclusive. For logarithmic spacing, seefft_cwt_transposed_logspaced().- Parameters:
data (numeric) – NCH x Ntimes list of signals to transform
fa (float) – Lowest frequency to extract
fb (float) – Highest frequency to extract
4 (float; default 4.0) – Time/frequency morlet width parameter
nfreqs (int; default 1000) – Number of frequency components to use
Fs (float; default 1000.0) – Sample rate in Hz
threads (int; default 1) – Number of threads to use
- Returns:
freqs (float) – frequencies
result (wavelt transforms) – Nch x Nfreq x Ntimes
- neurotools.signal.morlet.fft_cwt_transposed_logspaced(data, fa, fb, w=4.0, nfreqs=None, Fs=1000.0, threads=1)[source]
Compute morelet spectrogam of a list of time-domain signals (possibly in parallel if you have a threaded installation of the FFTW library available).
This version spaces
nfreqsfrquencies logarithmically betweenfaandfb, inclusive. For uniform spacing, seefft_cwt_transposed().- Parameters:
data (NCHANNELS × NTIMES np.array)
fa (positive float) – Low-frequency cutoff in Hz
fb (positive float) – High-frequency cutoff in Hz
w (positive float; default 4.0) – Wavelet base frequency; Controls the time-frequency tradeoff
nfreqs (positive float; default 0.1) – Frequency sampling nfreqs
Fs (positive int; default 1000) – Sample rate
threads (positive int; default 1) – Number of CPU threads to use
- Returns:
freqs – Frequencies of each band, in Hz
result (NCHANNELS × NFREQS × NTIMES np.array) – wavelet transform
- neurotools.signal.morlet.convenient_morlet(N, f0, sigma_ms, Fs)[source]
- Parameters:
N (int) – Number of samples
f0 (float) – Morlet frequency Hz
sigma_ms (float) – Standard deviation in ms
Fs (float) – Sample rate
- neurotools.signal.morlet.get_gentle_morlets_ft(N, flo=2, f0=15, fhi=45, sigma_lo=166.66666666666666, sigma_md=100, nfreqs=100, Fs=1000)[source]
- Parameters:
N (int) – Number of samples
flo (float, default 2) – Low frequency cutoff in Hz
f0 (float, default 15) – Log-central frequency in Hz
fhi (float, default 45) – High frequency cutoff in Hz
sigma_lo (float, default 1000/6) – Lowest temporal resolution in ms
sigma_md (float, default 100) – Target temporal resoltion at f0
nfreqs (float, default 100) – № frequency bins (linearly spaced)
Fs (float, default 1000) – Sample rate
- Returns:
wavelet frequencies wft (array): wavelet basis
- Return type:
ff (array)