Main Content

scattergram

Visualize joint time-frequency scattering coefficients

Since R2024b

    Description

    scattergram(jtfn,cfs,meta) plots the spin-up and spin-down coefficients of the joint time-frequency scattering (JTFS) transform cfs using the coefficient metadata meta and the JTFS network jtfn. The scattergram function undocks and plots the JTFS coefficients in the current figure. cfs and meta are outputs of scatteringTransform.

    Note

    By default, scattergram assumes the spin-up and spin-down coefficients are in cfs.

    scattergram(___,Name=Value) specifies options using one or more name-value arguments. You can add these arguments to the previous input syntax. For example, to plot the first-order time scattering coefficients filtered with the frequency lowpass filter, set PlotType to "S1FreqLowpass".

    example

    Examples

    collapse all

    Use the helper function helperEchirp to generate a two-channel chirp with 2048 samples in single precision. The first channel contains an up-chirp, and the second channel contains a down-chirp.

    len = 2048;
    chirpRising = helperEchirp(10,400,len);
    chirpFalling = helperEchirp(400,10,len);
    multiChirp = single([chirpRising' chirpFalling']);

    Create a JTFS network appropriate for the single-precision signal. Specify a time invariance scale of 32 samples and a quality factor of 16 for the first-order time wavelet filter bank. For the frequency wavelet filter bank, specify 2 octaves and an invariance scale of 2.

    jtfn = timeFrequencyScattering(SignalLength=len, ...
        FilterDataType="single", ...
        TimeInvarianceScale=32, ...
        TimeQualityFactor=16, ...
        NumFrequencyOctaves=2, ...
        FrequencyInvarianceScale=2);

    Obtain the JTFS transform of the signal.

    [cfs,meta] = scatteringTransform(jtfn,multiChirp);

    Visualize the spinned coefficients of both channels. The spin-up coefficients preferentially localize the up-chirp in the first channel, while the spin-down coefficients preferentially localize the down-chirp in the second channel. Because the frequency spacing in JTFS is logarithmic, the chirps appear linear.

    scattergram(jtfn,cfs,meta,NumChannel=1)

    Figure contains 64 axes objects. Axes object 1 with xlabel 0.1 contains an object of type image. Axes object 2 contains an object of type image. Axes object 3 contains an object of type image. Axes object 4 contains an object of type image. Axes object 5 with xlabel 0.05 contains an object of type image. Axes object 6 contains an object of type image. Axes object 7 contains an object of type image. Axes object 8 contains an object of type image. Axes object 9 with xlabel 0.025 contains an object of type image. Axes object 10 contains an object of type image. Axes object 11 contains an object of type image. Axes object 12 contains an object of type image. Axes object 13 with xlabel 0.013 contains an object of type image. Axes object 14 contains an object of type image. Axes object 15 contains an object of type image. Axes object 16 contains an object of type image. Axes object 17 with xlabel 0.0063 contains an object of type image. Axes object 18 contains an object of type image. Axes object 19 contains an object of type image. Axes object 20 contains an object of type image. Axes object 21 with xlabel 0.0031 contains an object of type image. Axes object 22 contains an object of type image. Axes object 23 contains an object of type image. Axes object 24 contains an object of type image. Axes object 25 with xlabel 0.0016 contains an object of type image. Axes object 26 contains an object of type image. Axes object 27 contains an object of type image. Axes object 28 contains an object of type image. Axes object 29 with xlabel 0.00078, ylabel +0.4 contains an object of type image. Axes object 30 with ylabel +0.2 contains an object of type image. Axes object 31 with ylabel +0.1 contains an object of type image. Axes object 32 with ylabel +0.05 contains an object of type image. Axes object 33 contains an object of type image. Axes object 34 contains an object of type image. Axes object 35 contains an object of type image. Axes object 36 contains an object of type image. Axes object 37 contains an object of type image. Axes object 38 contains an object of type image. Axes object 39 contains an object of type image. Axes object 40 contains an object of type image. Axes object 41 contains an object of type image. Axes object 42 contains an object of type image. Axes object 43 contains an object of type image. Axes object 44 contains an object of type image. Axes object 45 contains an object of type image. Axes object 46 contains an object of type image. Axes object 47 contains an object of type image. Axes object 48 contains an object of type image. Axes object 49 contains an object of type image. Axes object 50 contains an object of type image. Axes object 51 contains an object of type image. Axes object 52 contains an object of type image. Axes object 53 contains an object of type image. Axes object 54 contains an object of type image. Axes object 55 contains an object of type image. Axes object 56 contains an object of type image. Axes object 57 contains an object of type image. Axes object 58 contains an object of type image. Axes object 59 contains an object of type image. Axes object 60 contains an object of type image. Axes object 61 with ylabel -0.4 contains an object of type image. Axes object 62 with ylabel -0.2 contains an object of type image. Axes object 63 with ylabel -0.1 contains an object of type image. Axes object 64 with ylabel -0.05 contains an object of type image.

    figure
    scattergram(jtfn,cfs,meta,NumChannel=2)

    Figure contains 64 axes objects. Axes object 1 with xlabel 0.1 contains an object of type image. Axes object 2 contains an object of type image. Axes object 3 contains an object of type image. Axes object 4 contains an object of type image. Axes object 5 with xlabel 0.05 contains an object of type image. Axes object 6 contains an object of type image. Axes object 7 contains an object of type image. Axes object 8 contains an object of type image. Axes object 9 with xlabel 0.025 contains an object of type image. Axes object 10 contains an object of type image. Axes object 11 contains an object of type image. Axes object 12 contains an object of type image. Axes object 13 with xlabel 0.013 contains an object of type image. Axes object 14 contains an object of type image. Axes object 15 contains an object of type image. Axes object 16 contains an object of type image. Axes object 17 with xlabel 0.0063 contains an object of type image. Axes object 18 contains an object of type image. Axes object 19 contains an object of type image. Axes object 20 contains an object of type image. Axes object 21 with xlabel 0.0031 contains an object of type image. Axes object 22 contains an object of type image. Axes object 23 contains an object of type image. Axes object 24 contains an object of type image. Axes object 25 with xlabel 0.0016 contains an object of type image. Axes object 26 contains an object of type image. Axes object 27 contains an object of type image. Axes object 28 contains an object of type image. Axes object 29 with xlabel 0.00078, ylabel +0.4 contains an object of type image. Axes object 30 with ylabel +0.2 contains an object of type image. Axes object 31 with ylabel +0.1 contains an object of type image. Axes object 32 with ylabel +0.05 contains an object of type image. Axes object 33 contains an object of type image. Axes object 34 contains an object of type image. Axes object 35 contains an object of type image. Axes object 36 contains an object of type image. Axes object 37 contains an object of type image. Axes object 38 contains an object of type image. Axes object 39 contains an object of type image. Axes object 40 contains an object of type image. Axes object 41 contains an object of type image. Axes object 42 contains an object of type image. Axes object 43 contains an object of type image. Axes object 44 contains an object of type image. Axes object 45 contains an object of type image. Axes object 46 contains an object of type image. Axes object 47 contains an object of type image. Axes object 48 contains an object of type image. Axes object 49 contains an object of type image. Axes object 50 contains an object of type image. Axes object 51 contains an object of type image. Axes object 52 contains an object of type image. Axes object 53 contains an object of type image. Axes object 54 contains an object of type image. Axes object 55 contains an object of type image. Axes object 56 contains an object of type image. Axes object 57 contains an object of type image. Axes object 58 contains an object of type image. Axes object 59 contains an object of type image. Axes object 60 contains an object of type image. Axes object 61 with ylabel -0.4 contains an object of type image. Axes object 62 with ylabel -0.2 contains an object of type image. Axes object 63 with ylabel -0.1 contains an object of type image. Axes object 64 with ylabel -0.05 contains an object of type image.

    Helper Function

    helperEchirp — Generate a chirp

    function y = helperEchirp(f0,f1,N)
    % This function is only intended to support examples in the Wavelet
    % Toolbox. It may be changed or removed in a future release.
    t = 0:1/1e3:(N*1e-3)-1e-3;
    t1 = 2;
    phi = 0;
    tempVector = (f1/f0).^(t./t1);
    instPhi = (t1/log(f1/f0)*f0)*(tempVector-1);
    y = cos(2*pi*(instPhi+phi/360));
    end

    Input Arguments

    collapse all

    Joint time-frequency scattering network, specified as a timeFrequencyScattering object.

    Joint time-frequency scattering transform, specified as a dictionary object. cfs is the output of scatteringTransform.

    Joint time-frequency scattering transform metadata, specified as a cell array of tables. meta is the output of scatteringTransform.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: scattergram(jtfn,cfs,meta,NumChannel=2,NumBatch=3) plots the spinned, that is, spin-up and spin-down, coefficients of the second channel in the third batch.

    Coefficients to plot, specified as one of the following:

    • "Spinned" — Second-order time scattering coefficients with spin-up ("SpinUp") and spin-down ("SpinDown") wavelets

    • "S1FreqLowpass" — First-order time scattering coefficients filtered with the frequency lowpass filter

    • "S1SpinUpFreqLowpass" — First-order time scattering coefficients with the spin-up frequency wavelets

    • "SpinUp" — Second-order time scattering coefficients with spin-up wavelets

    • "SpinDown" — Second-order time scattering coefficients with spin-down wavelets

    • "U2JointLowpass" — Second-order time scattering coefficients filtered with joint lowpass filters

    Coefficient channel to plot, specified as a positive integer. NumChannel is greater than or equal to 1 and less than or equal to the size of the channel dimension in the coefficients array.

    Coefficient batch to plot, specified as a positive integer. NumBatch is greater than or equal to 1 and less than or equal to the size of the batch dimension in the coefficients array.

    Version History

    Introduced in R2024b