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)[source]
See morlet(m,w)
This applies post-processing such that the sum absolute magnitued of the wavelet is 1
- 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=0.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 nfreqs
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
nfreqs
frquencies uniformly betweenfa
andfb
, 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
nfreqs
frquencies logarithmically betweenfa
andfb
, 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