spkit.wavelet_filtering_win

spkit.wavelet_filtering_win(x, winsize=128, wv='db3', threshold='optimal', filter_out_below=True, k=1.5, mode='elim', wpd_mode='symmetric', wpd_maxlevel=None, packetwise=False, WPD=True, lvl=[], verbose=False, sf=1, hopesize=None, wintype='hamming', windowing_before=False, IPR=[0.25, 0.75])

Wavelet Filtering window-wise

Wavelet Filtering applied to smaller windows

Same as wavelet_filtering fumction, applied to smaller overlapping windows and reconstructed by overlap-add method

for documentation, check help(wavelet_filtering)

Parameters:
x: 1d array
winsize: int deafult=128
  • size of window to apply wavelet filtering

hopesize: int, deafult=None
  • shift factor, if winsize=128, and hopesize=64, then 50% overlap windowing is used.

  • if None, hopesize = winsize//2

Threshold Computation method:
threshold: ‘str’ or float, default - ‘optimal’
  • if str, method to compute threshold, example : ‘optimal’, ‘sd’, ‘iqr’

  • ‘optimal’: threshold = sig*sqrt(2logN), sig = median(|w|)/0.6745

  • ‘sd’ : threshold = k*SD(w)

  • ‘iqr’: threshold = q3+kr, threshold_l =q1-kr, where r = IQR(w) #Tukey’s fences

  • ‘ttt’: Modified Thompson Tau test (ttt) # TODO

mode: str, default = ‘elim’
  • ‘elim’ - remove the coeeficient (by zering out),

  • ‘clip’ - cliping the coefficient to threshold

filter_out_below: bool, default True,
  • if true, wavelet coefficient below threshold are eliminated else obove threshold

Wavelet Decomposition modes:
wpd_mode = [‘zero’, ‘constant’, ‘symmetric’, ‘periodic’, ‘smooth’, ‘periodization’]

default ‘symmetric’

wpd_maxlevel: level of decomposition, if None, max level posible is used
Wavelet family:
wv = [‘db3’…..’db38’, ‘sym2…..sym20’, ‘coif1…..coif17’, ‘bior1.1….bior6.8’, ‘rbio1.1…rbio6.8’, ‘dmey’]

:’db3’(default)

packetwise: bool, if true,
  • thresholding is applied to each packet/level individually, else globally

WPD: if true,
  • WPD is applied as wavelet transform

lvl: list

list of levels/packets apply the thresholding, if empty, applied to all the levels/packets

show: bool, deafult=False,
  • if to plot figure, it True, following are used

figsize: default=(11,6), size of figure plot_abs_coef: bool, deafult=False,

if True,plot abs coefficient value, else signed

Returns:
xR: filtered signal, same size as x

See also

spkit

#TODO

Notes

#TODO

References

  • wikipedia -

Examples

import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
x = sp.create_signal_1d(n=1000,seed=1,sg_polyorder=5, sg_winlen=11)
x = x + 0.1*np.random.randn(len(x))
t = np.arange(len(x))/100
xr = sp.wavelet_filtering_win(x.copy(),winsize=128,wv='db3',threshold='optimal')
plt.figure(figsize=(12,3))
plt.plot(t,x, label='x: noisy signal')
plt.plot(t,xr, label='x: filtered signal')
plt.xlim([t[0],t[-1]])
plt.xlabel('time (s)')
plt.ylabel('amplitude')
plt.grid()
plt.show()
../../_images/spkit-wavelet_filtering_win-1.png