Main Content

waveletScattering

Wavelet time scattering

Description

Use the waveletScattering object to create a network for a wavelet time scattering decomposition using the Gabor (analytic Morlet) wavelet. The network uses wavelets and a lowpass scaling function to generate low-variance representations of real-valued time series data. Wavelet time scattering yields representations insensitive to translations in the input signal without sacrificing class discriminability. You can use the representations as inputs to a classifier. You can specify the duration of translation invariance and the number of wavelet filters per octave. The scattering network also supports time × channel × batch (T×C×B) inputs.

Creation

Description

example

sf = waveletScattering creates a wavelet time scattering network with two filter banks. The first filter bank has a quality (Q) factor of eight wavelets per octave. The second filter bank has a Q factor of one wavelet per octave. By default, waveletScattering assumes a signal input length of 1024 samples. The scale invariance length is 512 samples. By default, waveletScattering uses periodic boundary conditions.

example

sf = waveletScattering(Name,Value) creates a network for wavelet scattering, sf, with Properties specified by one or more Name,Value arguments. Properties can be specified in any order as Name1,Value1,...,NameN,ValueN. Enclose each property name in quotes.

Note

After you create a scattering network, you can change the value of the OversamplingFactor property. Depending on the precision of the network and the input signal, the value of the Precision property can also change. All other network property values remain fixed.

Properties

expand all

Signal length in samples, specified as a positive integer ≥ 16. If the input to the scattering network is a row vector, SignalLength must match the number of columns in the input data. If the input to the scattering network is a column vector, matrix, or 3-D array, SignalLength must match the number of rows in the data.

Data Types: double

Sampling frequency in hertz, specified as a positive scalar. If unspecified, frequencies are in cycles/sample and the Nyquist frequency is ½.

Data Types: double

Scattering transform invariance scale, specified as a positive scalar. InvarianceScale specifies the translation invariance of the scattering transform. If you do not specify SamplingFrequency, InvarianceScale is measured in samples. If you specify SamplingFrequency, InvarianceScale is measured in seconds.

InvarianceScale cannot exceed SignalLength in samples.

Example: sf = waveletScattering('SignalLength',1000,'SamplingFrequency',200,'InvarianceScale',5) has the largest possible invariance scale.

Data Types: double

Scattering filter bank Q factors, specified as a positive integer or a vector of positive integers. A filter bank Q factor is the number of wavelet filters per octave. Q factors must be less than or equal to 32 and greater than or equal to 1.

If QualityFactors is specified as a vector, the elements of QualityFactors must be strictly decreasing.

Example: sf = waveletScattering('QualityFactors',[8 2 1]) creates a wavelet scattering network with three filter banks.

Data Types: double

Signal extension method to apply at the boundary:

  • 'periodic' — Extend signal periodically to length 2^ceil(log2(N)), where N is the signal length.

  • 'reflection' — Extend signal by reflection to length 2^ceil(log2(2 N)), where N is the signal length.

The signal is extended to match the length of the wavelet filters. The length of the filters are powers of two.

The signal extension method is for internal operations. Results are downsampled back onto the scale of the original signal before being returned.

Numeric precision of wavelet scattering network:

  • 'double' — Double precision

  • 'single' — Single precision

If you construct a scattering network with double-precision filters and apply the network to single-precision data, the filters are cast internally to single-precision. Subsequent filtering is done with single precision until a new network is created regardless of input data type. For more information, see the example Wavelet Time Scattering Network Precision.

Specifying Precision as 'single' at construction is useful if you want to use the object with single-precision data and reduce the memory footprint of the scattering network.

Oversampling factor, specified as a nonnegative integer or Inf. The factor specifies how much the scattering coefficients are oversampled with respect to the critically downsampled values. The factor is on a log2 scale. By default, OversamplingFactor is set to 0, which corresponds to critically downsampling the coefficients. You can use numCoefficients to determine the number of coefficients obtained for a scattering network. To obtain a fully undecimated scattering transform, set OversamplingFactor to Inf.

Setting OversamplingFactor to a value that would result in more coefficients than samples is equivalent to setting OversamplingFactor to Inf. Increasing the OversamplingFactor significantly increases the computational complexity and memory requirements of the scattering transform.

Example: If sf = waveletScattering('OversamplingFactor',2), the scattering transform returns 22 times as many coefficients for each scattering path with respect to the critically sampled number.

Optimize scattering transform logical which determines whether the scattering transform reduces the number of scattering paths to compute based on a bandwidth consideration, specified as a numeric or logical 1 (true) or 0 (false).

If you specify OptimizePath as true, the scattering transform excludes scattering paths of order 2 and greater which do not satisfy the following criterion: The center frequency minus ½ the 3-dB bandwidth of the wavelet filter in the (i+1)th filter bank must overlap 0 (DC) plus ½ the 3-dB bandwidth of the wavelet filter in the ith filter bank. If this criterion is not satisfied, the higher-order path is excluded. Setting OptimizePath to true can significantly reduce the number of scattering paths and computational complexity of the scattering transform for most networks.

You can use the paths object function to determine which and how many scattering paths are computed.

Object Functions

scatteringTransformWavelet 1-D scattering transform
featureMatrixScattering feature matrix
logNatural logarithm of scattering transform
filterbankWavelet time scattering filter banks
littlewoodPaleySumLittlewood-Paley sum
scattergramVisualize scattering or scalogram coefficients
centerFrequenciesWavelet scattering bandpass center frequencies
numordersNumber of scattering orders
numfilterbanksNumber of scattering filter banks
numCoefficientsNumber of wavelet scattering coefficients
pathsScattering network paths
gatherCollect scattering network properties into local workspace

Examples

collapse all

Create a wavelet time scattering network with default values.

sf = waveletScattering
sf = 
  waveletScattering with properties:

          SignalLength: 1024
       InvarianceScale: 512
        QualityFactors: [8 1]
              Boundary: 'periodic'
     SamplingFrequency: 1
             Precision: 'double'
    OversamplingFactor: 0
          OptimizePath: 0

Plot the wavelet filters used in the first and second filter banks.

[filters,f] = filterbank(sf);
plot(f,filters{2}.psift)
title('First Filter Bank')
xlabel('Cycles/Sample')
ylabel('Magnitude')
grid on

Figure contains an axes object. The axes object with title First Filter Bank, xlabel Cycles/Sample, ylabel Magnitude contains 41 objects of type line.

figure
plot(f,filters{3}.psift)
title('Second Filter Bank')
xlabel('Cycles/Sample')
ylabel('Magnitude')
grid on

Figure contains an axes object. The axes object with title Second Filter Bank, xlabel Cycles/Sample, ylabel Magnitude contains 7 objects of type line.

Plot the Littlewood-Paley sums of the filter banks.

[lpsum,f] = littlewoodPaleySum(sf);
figure
plot(f,lpsum)
legend('1st Filter Bank','2nd Filter Bank')
xlabel('Cycles/Sample')
grid on

Figure contains an axes object. The axes object with xlabel Cycles/Sample contains 2 objects of type line. These objects represent 1st Filter Bank, 2nd Filter Bank.

This example shows how to create and apply a wavelet time scattering network with three filter banks to data.

Load in a data set. Create a scattering network with three filter banks that can be applied to the data.

load handel
disp(['Data Sampling Frequency: ',num2str(Fs),' Hz'])
Data Sampling Frequency: 8192 Hz
sf = waveletScattering('SignalLength',numel(y),...
    'SamplingFrequency',Fs,...
    'QualityFactors',[4 2 1])
sf = 
  waveletScattering with properties:

          SignalLength: 73113
       InvarianceScale: 4.4625
        QualityFactors: [4 2 1]
              Boundary: 'periodic'
     SamplingFrequency: 8192
             Precision: 'double'
    OversamplingFactor: 0
          OptimizePath: 0

Inspect the network. Plot the wavelet filters used in the third filter bank.

[filters,f] = filterbank(sf);
plot(f,filters{4}.psift)
title('Third Filter Bank')
xlabel('Hertz')
ylabel('Magnitude')
grid on

Plot the Littlewood-Paley sums of the three filter banks.

[lpsum,f] = littlewoodPaleySum(sf);
figure
plot(f,lpsum)
xlabel('Hertz')
grid on
legend('1st Filter Bank','2nd Filter Bank','3rd Filter Bank')

Calculate the wavelet 1-D scattering transform of the data for sf. Visualize the scattergram of the scalogram coefficients for the first filter bank.

[S,U] = scatteringTransform(sf,y);
figure
scattergram(sf,U,'FilterBank',1)

This example shows how single-precision input changes the default numeric precision of a wavelet scattering network.

Create a wavelet time scattering network with default values. The precision of the network is double.

sf = waveletScattering
sf = 
  waveletScattering with properties:

          SignalLength: 1024
       InvarianceScale: 512
        QualityFactors: [8 1]
              Boundary: 'periodic'
     SamplingFrequency: 1
             Precision: 'double'
    OversamplingFactor: 0
          OptimizePath: 0

Use the filterbank object function to obtain the scattering filter banks. The filterbank function returns the filter banks in a cell array. Confirm the filters are double precision.

sfFilters = filterbank(sf);
precType = "double";
fprintf("Checking precision: %s\n",precType)
Checking precision: double
fprintf("sfFilters{1}.phift: %d\n",isa(sfFilters{1}.phift,precType))
sfFilters{1}.phift: 1
for k=2:numel(sfFilters)
    fprintf("sfFilters{%d}.phift: %d\n",k,isa(sfFilters{k}.phift,precType))
    fprintf("sfFilters{%d}.psift: %d\n",k,isa(sfFilters{k}.psift,precType))
end
sfFilters{2}.phift: 1
sfFilters{2}.psift: 1
sfFilters{3}.phift: 1
sfFilters{3}.psift: 1

Load the noisy Doppler signal. The signal is double precision.

load noisdopp
isa(noisdopp,"double")
ans = logical
   1

Use the featureMatrix object function to obtain the scattering coefficient matrix for the scattering network and the signal. Confirm the precision of the matrix is double.

smat = featureMatrix(sf,noisdopp);
isa(smat,"double")
ans = logical
   1

Convert the signal to single precision. Obtain the scattering coefficient matrix of the single-precision signal using the scattering network. Confirm the matrix precision is single.

noisdoppSingle = single(noisdopp);
smatSingle = featureMatrix(sf,noisdoppSingle);
isa(smatSingle,"single")
ans = logical
   1

Confirm that by using single-precision input, the numeric precision of the scattering network has changed to single.

sf
sf = 
  waveletScattering with properties:

          SignalLength: 1024
       InvarianceScale: 512
        QualityFactors: [8 1]
              Boundary: 'periodic'
     SamplingFrequency: 1
             Precision: 'single'
    OversamplingFactor: 0
          OptimizePath: 0

Use the featureMatrix function to obtain the scattering coefficient matrix for the scattering network and the double-precision signal. Because the numeric precision of the network is now single, the matrix precision is single.

smatSingle2 = featureMatrix(sf,noisdopp);
isa(smatSingle2,"single")
ans = logical
   1

Use the filterbank function to obtain the filter banks. Confirm the filters have changed to single precision.

sfFiltersSingle = filterbank(sf);
precType = "single";
fprintf("Checking precision: %s\n",precType)
Checking precision: single
fprintf("sfFiltersSingle{1}.phift: %d\n",isa(sfFiltersSingle{1}.phift,precType))
sfFiltersSingle{1}.phift: 1
for k=2:numel(sfFilters)
    fprintf("sfFiltersSingle{%d}.phift: %d\n",k,isa(sfFiltersSingle{k}.phift,precType))
    fprintf("sfFiltersSingle{%d}.psift: %d\n",k,isa(sfFiltersSingle{k}.psift,precType))
end
sfFiltersSingle{2}.phift: 1
sfFiltersSingle{2}.psift: 1
sfFiltersSingle{3}.phift: 1
sfFiltersSingle{3}.psift: 1

More About

expand all

References

[1] Andén, Joakim, and Stéphane Mallat. “Deep Scattering Spectrum.” IEEE Transactions on Signal Processing 62, no. 16 (August 2014): 4114–28. https://doi.org/10.1109/TSP.2014.2326991.

[2] Mallat, Stéphane. “Group Invariant Scattering.” Communications on Pure and Applied Mathematics 65, no. 10 (October 2012): 1331–98. https://doi.org/10.1002/cpa.21413.

Extended Capabilities

Version History

Introduced in R2018b

expand all