Matching pursuit for 1D signals

Performs Matching Pursuit on 1d (temporal) signals with custom basis
4K Downloads
Aktualisiert 22. Sep 2011

Lizenz anzeigen

Performs matching pursuit (MP) on a one-dimensional (temporal) signal y with a custom basis B.

Matching pursuit (Mallat and Zhang 1993) is a greedy algorithm to obtain a sparse representation of a signal y in terms of a weighted sum (w) of dictionary elements D (y ~ Dw). Sparse means that most elements are equal to 0 (nnz(w) << length(y)). Such a sparse representation is useful in many different scenarios: to obtain time-frequency spectrograms, denoise signals, compress signals, etc.

For temporal signals, it's natural to use a dictionary of elements D composed of basis elements B shifted to every possible time point. In this case, the weights form of a convolutional or shift-invariant sparse code in a highly overcomplete dictionary:

y ~ r
r = sum_i conv(ws(:,i),B(:,i),'same')
and nnz(ws(:)) << length(y)

If B is equal to a bunch of windowed sinusoids, this representation forms a time-frequency decomposition of the signal. One application of this decomposition is EEG/MEG and LFP analysis (http://www.scholarpedia.org/article/Matching_pursuit).

Another application is expressing a sound signal as a sum of gammatone-like functions (Smith and Lewicki 2006) or chords (Blumensath and Davies 2006).

This implementation should be efficient enough for practical use. It precomputes all convolutions using the FFT and does not perform convolutions in the main loop. It uses a 3-level tree to search for the maximum correlation, and each iteration is O(sqrt(length(y))).

Function signature:
[ws,r] = temporalMP(y,B,nonnegative,maxiter,maxr2)

Arguments:
y: a mx1 signal
B: an nxp basis. n is the length of each basis function and p is
the number of such basis functions
nonnegative (optional): if true, uses a variant of MP where ws are
forced to be >= 0 (default false)
maxiter and maxr2 (optional): specifies when to stop iterating,
when #iterations > maxiter or the R^2 between y and r
is greater than maxr, whichever comes first (defaults: maxiter:
10000, maxr2: .999)

Returns:
ws: an mxn matrix of weights
r: the approximation of y in terms of the weights and basis
functions

Example use:
sig = load('gong.mat'); %included in matlab

%Build a basis of Gabors
rg = (-500:500)';
sigmas = exp(log(2):.3:log(200));
gabors = exp(-.5*(rg.^2)*sigmas.^(-2)).*cos(rg*sigmas.^(-1)*2*pi*2);

%Express signal as a sparse sum of Gabors
[ws,r] = temporalMP(sig.y,gabors,false,5000);

%See TryTemporalMP.m for more examples

Zitieren als

Patrick Mineault (2024). Matching pursuit for 1D signals (https://www.mathworks.com/matlabcentral/fileexchange/32426-matching-pursuit-for-1d-signals), MATLAB Central File Exchange. Abgerufen.

Kompatibilität der MATLAB-Version
Erstellt mit R2009b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Quellenangaben

Inspiriert von: FFT-based convolution

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.3.0.0

Added "deadzone" feature

1.1.0.0

Corrected bug with edges, increase efficiency by adding a level to the current maximum correlation search tree

1.0.0.0