Main Content

featureMatrix

Scattering feature matrix

Description

smat = featureMatrix(sf,x) returns the scattering coefficient matrix for the wavelet time scattering network sf and the real-valued input data x. x is a vector, matrix, or 3-D array.

The precision of smat depends on the precision specified in the scattering network sf.

[smat,u] = featureMatrix(sf,x) returns the scalogram coefficients in the cell array of cell arrays, u. The number of elements in u is equal to the order of the scattering network. The ith element of u contains the scalogram coefficients for the (i-1)th order of the scattering coefficients.

example

smat = featureMatrix(___,Name,Value) returns the scattering feature matrix with additional options specified by one or more Name,Value pair arguments.

Examples

collapse all

This example shows how to obtain the scattering feature matrix for a wavelet time scattering network and how to compare the matrix with scattering coefficients.

Load an ECG signal sampled at 180 Hz. Create a wavelet time scattering network that can be used with the signal.

load wecg
Fs = 180;
sf = waveletScattering('SignalLength',numel(wecg),...
    'SamplingFrequency',Fs);

Calculate the scattering feature matrix using the log transformation. Display the dimensions of the matrix.

smat = featureMatrix(sf,wecg,'Transform','Log');
size(smat)
ans = 1×2

   147     8

Now calculate the scattering transform of the signal. Obtain the scattering coefficients. The output is a cell array with three elements. Each element is a table. Confirm the total number of rows in the tables is equal to the number of rows in the matrix.

S = scatteringTransform(sf,wecg);
t1rows = size(S{1},1);
t2rows = size(S{2},1);
t3rows = size(S{3},1);
disp(['Total Number of Rows: ',num2str(t1rows+t2rows+t3rows)])
Total Number of Rows: 147

Display the base-2 log resolution of the zeroth-order scattering coefficients.

disp(['Resolution: ',num2str(S{1}.resolution(1))])
Resolution: -8

Obtain the natural logarithm of the zeroth-order scattering coefficients. Compare the scattering coefficients with the first row in the feature matrix. The number of coefficients in each equals the absolute value of the base-2 log resolution.

logS = log(sf,S);
logScat = logS{1}.signals{1};
[smat(1,:)' logScat]
ans = 8×2

   -1.2914   -1.2914
   -2.4682   -2.4682
   -1.6368   -1.6368
   -1.2716   -1.2716
   -1.6818   -1.6818
   -4.3701   -4.3701
   -1.3199   -1.3199
   -1.0542   -1.0542

Input Arguments

collapse all

Wavelet time scattering network, specified as a waveletScattering object.

Input data, specified as a real-valued vector, matrix, or 3-D array. If x is a vector, the number of samples in x must equal the SignalLength value of sf. If x is a matrix or 3-D array, the number of rows in x must equal the SignalLength value of sf. If x is 2-D, the first dimension is assumed to be time and the columns of x are assumed to be separate channels. If x is 3-D, the dimensions of x are Time-by-Channel-by-Batch.

Data Types: single | double

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: smat = featureMatrix(sf,x,'Transform','log','Normalization','parent')

Type of normalization to apply to the scattering coefficients, specified as 'none' or 'parent'. If specified as 'parent', scattering coefficients of order greater than 0 are normalized by their parents along the scattering path.

Type of transformation to apply to the scattering coefficients, specified as 'none' or 'log'.

Output Arguments

collapse all

Scattering coefficients, returned as a real-valued matrix or array. If x is a vector, smat is an Npath-by-Nscat matrix, where Npath is the number of scattering paths and Nscat is the number of scattering coefficients in each path, or the resolution of the scattering coefficients. If x is a matrix, smat is Npath-by-Nscat-by-Nchan, where Nchan is the number of columns in x. If x is 3-D, then smat is Npath-by-Nscat-by-Nchan-by-Nbatch.

The precision of smat depends on the precision specified in the scattering network sf.

Data Types: single | double

Scalogram coefficients, returned in a cell array of cell arrays. The number of elements in u is equal to the order of the scattering network. The ith element of u contains the scalogram coefficients for the (i-1)th order of the scattering coefficients.

Note that u{1}{1} contains the original data.

Data Types: single | double

Tips

  • The scatteringTransform function calls featureMatrix to generate the scattering and scalogram coefficients. If you only require the coefficients themselves, for improved performance the recommended approach is to use featureMatrix. Use scatteringTransform if you are also interested in the coefficients metadata.

Compatibility Considerations

expand all

Not recommended starting in R2021a

Extended Capabilities

Introduced in R2018b