Previous topic

pyrem.visualization module

Next topic

pyrem.feature_families module

This Page

pyrem.wavelet_decomposition module

pyrem.wavelet_decomposition.decompose_signal(signal, levels=(1, 2, 3, 4, 5), wavelet='db4', resample_before=None, mode='per', keep_a=True)[source]

A wrapper around wavedec(). It performs discrete wavelet decomposition and return the coefficients as a pyrem.polygram.Polygram. It allows to select the wavelet coefficients to keep and can perform preliminary resampling of the signal. In the resulting polygram, the names of the coefficients will be suffixed by an an identifier describing their respective levels (i.e. cD_1, cD_2, ..., cD_N, cA_N). The sampling frequency of coefficients will also be automatically computed.

>>> import numpy as np
>>> import pyrem as pr
>>> noise = np.random.normal(size=int(1e6))
>>> sig = pr.time_series.Signal(noise, 256.0,
>>>      name="channel_1")
>>>      name="channel_1")
>>> pol = pr.wavelet_decomposition decompose_signal(sig)
>>> pol
    Polygram
    ----
    Duration:       1:05:06.250000 (HH:mm:ss)
    N signals:      6
    N annotations:  0
    Metadata:
            None
    ----
    Channel information:
                 Name  Type fs(Hz)        Duration
    0  channel_1_cA_5  None    8.0  1:05:06.250000
    1  channel_1_cD_1  None  128.0  1:05:06.250000
    2  channel_1_cD_2  None   64.0  1:05:06.250000
    3  channel_1_cD_3  None   32.0  1:05:06.250000
    4  channel_1_cD_4  None   16.0  1:05:06.250000
    5  channel_1_cD_5  None    8.0  1:05:06.250000
Parameters:
  • signal (pyrem.time_series.Signal) – the time series to be decomposed
  • levels (list([int])) – the levels to keep (e.g. [1,2,3,5]) will not return the coeficient cD_4
  • wavelet (str) – the type of wavelet (see wavedec())
  • resample_before (float) – the sampling frequency at which to resample the signal before the decomposition
  • mode (str) – (see wavedec())
  • keep_a – whether to keep the last coefficient (cA_N)
Returns:

A polygram with all the requested coefficients

Return type:

pyrem.polygram.Polygram