spkit.wavelet_decomposed_signals

spkit.wavelet_decomposed_signals(x, wv='db3', L=3, WPD=False, threshold=inf, plot_final=True, plot_each=False, fs=100, show=True, figsize=(10, 8))

Decomposing signal into signals of wavelet components

\[ \begin{align}\begin{aligned}x(t) &= x_{w_0}(t) + x_{w_1}(t) + x_{w_2}(t) + \cdots + x_{w_{K-1}}(t)\\x(t) &= \sum_{k=0}^{K-1} x_{w_k}(t)\end{aligned}\end{align} \]

Decomposing signal into different levels of ‘wavalet based signals’

‘wavalet based signal’ is reconstructed signal from wavelet coefficients such that some of all the decomposed signal is equal to original signals

Parameters:
x: 1d signal array
wv: wavelet type, default = ‘db3’
Lint, default=3
  • number of level for decomposition

  • if WPA False, then L+1 decomposed signals are returned

  • if WPA is True, then 2**L decomposed signals are returned

threshold: scalar, deafult=’np.inf’
  • to apply wavelet filtering

  • if ‘np.inf’, no filtering is applied

plot_each: bool, default=False
  • plot of each decomposed part is shown.

  • USE only to analyse, it slow down the computations

WPD: bool, default False
  • if True, Wavelet Packet Decomposition is applied,resultings 2**L decomposed signals

  • if False, Wavelet Transform is applied,resultings L+1 decomposed signals

fs: int, default=100,
  • sampling frequency, only used for plot labeling

show: bool, deafult=True
  • if True, plt.show() is executed for plot, else not. Useful to edit plot later

figsize:tuple defualt =(10,8)
  • figure size

Returns:
XR: (n,K) array,
  • K decomposed signals

  • n, same as length of signal

Notes

#TODO

References

Examples

#sp.wavelet_decomposed_signals
#Example 1: Wavelet Transform
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
x,fs,lead_names = sp.data.ecg_sample_12leads(sample=2)
x = x[:int(fs*5),5]
x = sp.filterDC_sGolay(x, window_length=fs//3+1)
t = np.arange(len(x))/fs
XR = sp.wavelet_decomposed_signals(x,wv='db3',L=3,plot_each=False,WPD=False)
plt.show()
../../_images/spkit-wavelet_decomposed_signals-1_00_00.png
#################################
#Example 2: Wavelet Packet Decomposition
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
x,fs,lead_names = sp.data.ecg_sample_12leads(sample=2)
x = x[:int(fs*5),5]
x = sp.filterDC_sGolay(x, window_length=fs//3+1)
t = np.arange(len(x))/fs
XR = sp.wavelet_decomposed_signals(x,wv='db3',L=3,plot_each=False,WPD=True)
plt.show()
../../_images/spkit-wavelet_decomposed_signals-1_01_00.png

Examples using spkit.wavelet_decomposed_signals

Release Highlights for spkit 0.0.9.7

Release Highlights for spkit 0.0.9.7