Skip to content

Commit

Permalink
README; docs; better references; icwt arg fix
Browse files Browse the repository at this point in the history
  • Loading branch information
OverLordGoldDragon authored Apr 19, 2023
1 parent f709cfd commit 7cc8844
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- `istft` edge case with `dtype='float32'`, time-localized `window`, and large `hop_len`
- `istft` default `N` was supposed to be "largest possible" but wasn't; fixed
- `istft` division by window norm now accounts for values below float `tiny`
- `icwt` defaults args fix
- fixed Ridge Extraction README
- fixed important typo in `ridge_extraction.py`
- fixed `nv` criterion for ignoring sanity check
Expand All @@ -29,6 +30,8 @@
- simplify `p2up`
- `nan_checks` now defaults to `True` only for NumPy inputs
- CI changes: conda -> micromamba
- docstring references improved
- README section added


### 0.6.3 (1-23-2022): QoL, cleanups, fixes
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ imshow(Sx, **ikw, yticks=freqs_stft)
Also see ridge extraction [README](https://github.com/OverLordGoldDragon/ssqueezepy/tree/master/examples/ridge_extraction).


## Interesting use cases (with code)

1. [Identify abrupt changes in audio](https://dsp.stackexchange.com/a/87512/50076) - `ssq_cwt` and `ssq_stft` used together to solve an ML problem without ML

Feel free to share yours [here](https://github.com/OverLordGoldDragon/ssqueezepy/issues/9).


## Learning resources

1. [Continuous Wavelet Transform, & vs STFT](https://ccrma.stanford.edu/~unjung/mylec/WTpart1.html)
Expand Down
42 changes: 24 additions & 18 deletions ssqueezepy/_cwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def cwt(x, wavelet='gmw', scales='log-piecewise', fs=None, t=None, nv=32,
l1_norm: bool (default True)
Whether to L1-normalize the CWT, which yields a more representative
distribution of energies and component amplitudes than L2 (see [3]).
If False (default True), uses L2 norm.
distribution of energies and component amplitudes than L2 (see [3],
[6]). If False (default True), uses L2 norm.
derivative: bool (default False)
Whether to compute and return `dWx`. Requires `fs` or `t`.
Expand Down Expand Up @@ -138,9 +138,8 @@ def cwt(x, wavelet='gmw', scales='log-piecewise', fs=None, t=None, nv=32,
E. Brevdo, N.-S. Fučkar, and H.-T. Wu.
https://arxiv.org/abs/1105.0010
3. Rectification of the Bias in the Wavelet Power Spectrum.
Y. Liu, X. S. Liang, R. H. Weisberg.
http://ocg6.marine.usf.edu/~liu/Papers/Liu_etal_2007_JAOT_wavelet.pdf
3. How to validate a wavelet filterbank (CWT)? John Muradeli.
https://dsp.stackexchange.com/a/86069/50076
4. The Exponential Accuracy of Fourier and Chebyshev Differencing Methods.
E. Tadmor.
Expand All @@ -149,6 +148,10 @@ def cwt(x, wavelet='gmw', scales='log-piecewise', fs=None, t=None, nv=32,
5. Synchrosqueezing Toolbox, (C) 2014--present. E. Brevdo, G. Thakur.
https://github.com/ebrevdo/synchrosqueezing/blob/master/synchrosqueezing/
cwt_fw.m
6. Rectification of the Bias in the Wavelet Power Spectrum.
Y. Liu, X. S. Liang, R. H. Weisberg.
http://ocg6.marine.usf.edu/~liu/Papers/Liu_etal_2007_JAOT_wavelet.pdf
"""
def _vectorized(xh, scales, wavelet, derivative, cache_wavelet):
if cache_wavelet:
Expand Down Expand Up @@ -307,7 +310,7 @@ def _process_args(x, scales, nv, fs, t, nan_checks, wavelet, cache_wavelet):


def icwt(Wx, wavelet='gmw', scales='log-piecewise', nv=None, one_int=True,
x_len=None, x_mean=0, padtype='zero', rpadded=False, l1_norm=True):
x_len=None, x_mean=0, padtype='reflect', rpadded=False, l1_norm=True):
"""The inverse Continuous Wavelet Transform of `Wx`, via double or
single integral.
Expand All @@ -332,8 +335,8 @@ def icwt(Wx, wavelet='gmw', scales='log-piecewise', nv=None, one_int=True,
one_int: bool (default True)
Whether to use one-integral iCWT or double.
Current one-integral implementation performs best.
- True: Eq 2.6, modified, of [3]. Explained in [4].
- False: Eq 4.67 of [1]. Explained in [5].
- True: Eq 2.6, modified, of [6]. Explained in [1].
- False: Eq 4.67 of [3]. Explained in [2].
x_len: int / None. Length of `x` used in forward CWT, if different
from Wx.shape[1] (default if None).
Expand All @@ -356,25 +359,28 @@ def icwt(Wx, wavelet='gmw', scales='log-piecewise', nv=None, one_int=True,
The signal, as reconstructed from Wx.
# References:
1. Wavelet Tour of Signal Processing, 3rd ed. S. Mallat.
1. One integral inverse CWT. John Muradeli.
https://dsp.stackexchange.com/a/76239/50076
2. Inverse CWT derivation. John Muradeli.
https://dsp.stackexchange.com/a/71148/50076
3. Wavelet Tour of Signal Processing, 3rd ed. S. Mallat.
https://www.di.ens.fr/~mallat/papiers/WaveletTourChap1-2-3.pdf
2. The Synchrosqueezing algorithm for time-varying spectral analysis:
4. Why iCWT may be inexact. John Muradeli.
https://dsp.stackexchange.com/a/87104/50076
5. The Synchrosqueezing algorithm for time-varying spectral analysis:
robustness properties and new paleoclimate applications. G. Thakur,
E. Brevdo, N.-S. Fučkar, and H.-T. Wu.
https://arxiv.org/abs/1105.0010
3. Synchrosqueezed Wavelet Transforms: a Tool for Empirical Mode
6. Synchrosqueezed Wavelet Transforms: a Tool for Empirical Mode
Decomposition. I. Daubechies, J. Lu, H.T. Wu.
https://arxiv.org/pdf/0912.2437.pdf
4. One integral inverse CWT. OverLordGoldDragon.
https://dsp.stackexchange.com/a/71274/50076
5. Inverse CWT derivation. OverLordGoldDragon.
https://dsp.stackexchange.com/a/71148/50076
6. Synchrosqueezing Toolbox, (C) 2014--present. E. Brevdo, G. Thakur.
7. Synchrosqueezing Toolbox, (C) 2014--present. E. Brevdo, G. Thakur.
https://github.com/ebrevdo/synchrosqueezing/blob/master/synchrosqueezing/
synsq_cwt_fw.m
"""
Expand Down
2 changes: 1 addition & 1 deletion ssqueezepy/ridge_extraction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Authors: David Bondesson, OverLordGoldDragon
"""Authors: David Bondesson, John Muradeli
Ridge extraction from time-frequency representations (STFT, CWT, synchrosqueezed).
"""
Expand Down
7 changes: 6 additions & 1 deletion ssqueezepy/ssqueezing.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ def _process_args(Wx, w, fs, t, transform, squeezing, scales, maprange,
"tuple with `maprange = 'maximal'` "
"(got %s)" % str(maprange))
ssq_freqs = _compute_associated_frequencies(
scales, N, wavelet, ssq_scaletype, maprange, was_padded, dt, transform)
scales, N, wavelet, ssq_scaletype, maprange, was_padded, dt,
transform)
elif transform == 'stft':
# removes warning per issue with `infer_scaletype`
# future TODO: shouldn't need this
ssq_scaletype = 'linear'
else:
ssq_scaletype, _ = infer_scaletype(ssq_freqs)

Expand Down

0 comments on commit 7cc8844

Please sign in to comment.