ANNOUNCEMENT: This package has been integrated in scikit-ued. Improvements made in scikit-ued's baseline subpackage will not be backported to dualtree
Python package, based on PyWavelets, implementing Nick Kingsbury's dual-tree complex wavelet transform.
The purpose of implementing the dual-tree complex wavelet transform was for it's use in baseline-removal of digital signals. This package is provided as part of the research published in the following article:
- L. P. René de Cotret and B. J. Siwick, A general method for baseline-removal in ultrafast electron powder diffraction data using the dual-tree complex wavelet transform, Struct. Dyn. 4 (2017) DOI: 10.1063/1.4972518.
From the package docstrings:
Dual-tree complex wavelet transform (and its inverse) implemented using PyWavelets. Implementation tricks from [1], such as first stage filtering and filter swapping at later stages, are also included.
Decomposition and recomposition of signals using only approximate or detail coefficients.
Maximal decomposition level of the dual-tree complex wavelet transform.
Baseline determination of signals using the dual-tree complex wavelet transform. Modified algorithm from [2].
Pair of real and imaginary wavelet that forms a complex wavelet appropriate for the dual-tree complex wavelet transform.
Pair of real and imaginary wavelet, shifted by one sample with respect to one another, forming a complex wavelet appropriate for first-stage filtering during the dual-tree complex wavelet transform.
We start with the base:
>>> from dualtree import dualtre, idualtree, baseline
>>> import matplotlib.pyplot as plt
Here is an example of getting the dual-tree complex wavelet transform coefficients from real data:
>>> signal = n.load('~\data\diffraction.npy') # Included example electron diffraction data
>>> coeffs = dualtree(signal, wavelet = 'qshift3', level = 4)
>>> reconstructed = idualtree(coeffs = coeffs, wavelet = 'qshift3') # level is inferred
>>> n.allclose(signal, reconstructed) # Check perfect reconstruction
True
Example of algorithm (baseline-determination) on a NumPy array:
>>> signal = n.load('~\data\diffraction.npy')
>>> background = baseline(signal, wavelet = 'qshift3', max_iter = 100) # Might not be optimal parameters
>>> plt.plot(signal, '.k', background, '.r')
-
Selesnick, I. W. et al. The Dual-tree Complex Wavelet Transform, IEEE Signal Processing Magazine pp. 123 - 151, November 2005.
-
Galloway et al. An Iterative Algorithm for Background Removal in Spectroscopy by Wavelet Transforms, Applied Spectroscopy pp. 1370 - 1376, September 2009.