Skip to main content

A statistical signal processing package

Project description

Statistical Processing: A Python Statistical Signal Processing Package

A package that construct an interface for filtering wavelet coefficients (using PyWavelets) with statistical methods

Getting started

First you can import some modules like:

    import pywt
    import numpy as np

    import statsWaveletFilt.filtration as fil
    import statsWaveletFilt.signals as sig
    import statsWaveletFilt.miscellaneous as misc

And follow some steps to make your filtrations:

First step: Signal modelling

In many test for filtration and/or estimation of error, showed in articles, are supose an known ideal signal, how show the code above:

    import matplotlib.pyplot as plt

    dimension = 1024

    t, idealSignal = sig.dopplerFunction(dimension)
    plt.plot(t, idealSignal, 'k-')
    plt.show()

This package also gives a support for anothers three ideal signal: the heavsine (sig.heavsineFunction()), bump (sig.bumpFunction()) and block (sig.blockFunction()).

And add to this a kind of noise, generally gaussian or, also called, normal.

    noise = np.random.normal(0, .02, size=dimension)
    noisySignal = idealSignal + noise

    plt.plot(t, noisySignal, 'k-')
    plt.show()

Second step: Wavelet transformation

Let's do this using the pywt.wavedec function. With this you can 1) make a wavelet transform of your noisy signal, 2) choice wich wavelet function is used ('haar', 'db', 'gaus', 'mexh' among others) and 3) choice any levels you want to evaluate the transform.

    noisyCoeff = pywt.wavedec(noisySignal, 'db8', level=5)

The first position = noiseCoeff[0] has the scale coefficents of the last nível. The consecutive elements = noiseCoeff[1:] has the wavelet coefficients of the last to the first level of transform.

Using misc.showWaveletCoeff function you can show all coefficients returned of the transform.

    misc.showWaveletCoeff(noisyCoeff, title='Noisy Coefficients')

Thirth step: Filtration

With the fil.filtration function you can put yours 1) coefficients for filtration, 2) choice the method ('visu', 'sure', 'bayes', 'spc') and, if necessary, 3) set method own parameters (more details in documentation).

    filtrateCoeff, limiars = fil.filtration(noisyCoeff, method='visu')

And, again, you can show the wavelet coefficients before and after the filtration, with the limiar used using the misc.showWaveletCoeff function.

    misc.showWaveletCoeff(noisyCoeff, threshold_value=limiars, title='Noisy Coefficients')
    print('==============================================================')
    misc.showWaveletCoeff(filtrateCoeff, threshold_value=limiars, title='Filtered Coefficients')

Fourth step: Recovery wavelet transformation

Using the pywt.waverec function we can revovery the signal.

    filtrateSignal = pywt.waverec(filtrateCoeff, 'db8')

    plt.plot(t, filtrateSignal, 'k-')
    plt.show()

Fifth step: Figures of merith

Using sig.differential_snr_dB we can avaliate the filtration using some figures of merith of different forms of evaluate the snr or cnr (see more in Documentation) of the signal.

    sig.differential_snr_dB(noisySignal, filtratedSignal, method='variances', idealSignal=idealSignal)

Appendix: Miscelaneous

  • The misc.generateData function generate data using the signals showed here with different variances of noise and save in format .npy.
  • The misc.normalizeData function normalize a data between a min and max value, this function is used in all signals modeled in sig module.

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

statsWaveletFilt-0.0.4.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

statsWaveletFilt-0.0.4-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file statsWaveletFilt-0.0.4.tar.gz.

File metadata

  • Download URL: statsWaveletFilt-0.0.4.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for statsWaveletFilt-0.0.4.tar.gz
Algorithm Hash digest
SHA256 09bae509851962537f100a6cbe1178f1009d3b00abbd13eae7837dff4e773e1a
MD5 106c8da5c8f0169e60ecb8cd734d42a7
BLAKE2b-256 85f92d2b9d4c0d95dc54ca4cc1e6f9829bb39ec4440f2425a3b4a62647adcfa0

See more details on using hashes here.

File details

Details for the file statsWaveletFilt-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: statsWaveletFilt-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for statsWaveletFilt-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 866c63e6d4c62a3db8d2382a7fdc0eb755347c38e3490091fecc3d9ab2237627
MD5 9b19c53d3931125cf87ffd58a0aae927
BLAKE2b-256 8ec880b9782b36253b883c1b1b4099cf2e3c97b4d176bd27c83e6cc5866e9faf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page