Table Of Contents

Previous topic

PyMP Tutorial 3. Greedy decomposition variants

Next topic

Classes Package Documentation:

This Page

MP routines Documentation

Main Module providing MP methods

Module mp

Greedy algorithms using the pymp objects

PyMP.mp.mp(orig_signal, dictionary, target_srr, max_it_num, debug=0, pad=True, clean=False, silent_fail=False, debug_iteration=-1, unpad=False, max_thread_num=None)

Matching Pursuit Decomposition

This is the original, plain Matching Pursuit Algorithm

Parameters :

orig_signal : Signal

the original signal (as a Signal object) to decompose

dictionary : BaseDico

the dictionary (as a Dico object) on which to decompose orig_signal

target_srr : float

a target Signal to Residual Ratio (SRR)

max_it_num : int

the maximum number of iteration allowed

debug : int, optional

requested debug level, default is 0

pad : bool, optional

whether to pad the signal’s edges with zeroes

Returns :

approx : Approx

A Approx object encapsulating the approximant

decay : list

A list of residual’s energy across iterations

Other Parameters:
 

clean : bool, optional

whether perform on the fly cleaning of atom’s waveforms to limit memory consumption

silent_fail : bool, optional

whether to allow energy increase when subtracting atoms

debug_iteration : int, optional

specify a specific iteration number at which the debug level should be raised to maximum

unpad : bool, optional

whether to remove added edges zeroes after decomposition

max_thread_num : int, optional

the maximum number of threads allocated

Raises :

ValueError :

If a selected atom causes the residual signal’s energy to increase, see Signal.subtract()

See also

greedy
a decomposition method where the update strategy (MP, OMP, GP or CMP) can be set as a parameter

Notes

This is the original Matching Pursuit Algorithm transcribed to work with PyMP objects encapsulating signals and dictionaries It builds an approximant of as a linear combination of atoms from

Examples

For decomposing the signal x on the Dictionary D at either SRR of 10 dB or using 1000 atoms: x must be a Signal and D a Dico object

>>> approx, decay = mp.mp(x, D, 10, 1000)
PyMP.mp.greedy(orig_signal, dictionary, target_srr, max_it_num, debug=0, pad=True, clean=False, silent_fail=False, debug_iteration=-1, unpad=False, update='mp', max_thread_num=None)

Common Greedy Pursuit Loop Options are detailed below:

Parameters :

orig_signal : Signal

the original signal (as a Signal object) to decompose

dictionary : BaseDico

the dictionary (as a Dico object) on which to decompose orig_signal

target_srr : float

a target Signal to Residual Ratio (SRR)

max_it_num : int

the maximum number of iteration allowed

debug : int, optional

requested debug level, default is 0

pad : bool, optional

whether to pad the signal’s edges with zeroes

update : {‘mp’, ‘omp’, ‘locomp’, ‘locgp’}, optional

choice of update loop to consider

Returns :

approx : Approx

A Approx object encapsulating the approximant

decay : list

A list of residual’s energy across iterations

Other Parameters:
 

clean : bool, optional

whether perform on the fly cleaning of atom’s waveforms to limit memory consumption

silent_fail : bool, optional

whether to allow energy increase when subtracting atoms

debug_iteration : int, optional

specify a specific iteration number at which the debug level should be raised to maximum

unpad : bool, optional

whether to remove added edges zeroes after decomposition

max_thread_num : int, optional

the maximum number of threads allocated

Raises :

ValueError :

If a selected atom causes the residual signal’s energy to increase, see Signal.subtract()

See also

mp
a decomposition method with plain mp only

Examples

For decomposing the signal x on the Dictionary D at either SRR of 10 dB or using 1000 atoms: x must be a Signal and D a Dico object

>>> approx, decay = mp.greedy(x, D, 10, 1000, 'mp')

Alternative: Command Line utility

Module mp_cmd

PyPursuit command line arguments looks as follow:

-h or –help : print this help

-f [filePath] : specifies the path to the audiofile, only wav files supported for now

-w : flag for writing the output (approx and recomposedSignal) to output files

-o [outPutFilePath] : path for the output

-m [maxAtomNumber] : specifies the maximum number of selected atoms

-s [SRR] : specifies the target Signal-To-Residual Ratio

-d [dictionarySizes] : specifies the sizes: e.g -d 128,1024,8192

-t or –type [‘mp’ | ‘LOMP’] : specify the chosen decomposition algorithm

–debug=[0|1|2|3] : debug level. Default is 0

-a or –pad pad signal with zeroes , default is 1

-p or –plot plots the approximation using matplotib

-l [segmentDuration] : length of the segments

Example:

>>> python MPcmd.py -f sndFile.wav -m 100 -s 10 -d 128,1024,8192 --debug=1 -a -p