Table Of Contents

Previous topic

Classes Package Documentation:

This Page

Union of MDCT basis Classes documentation :

Classes for Standard Algorithm

Module mdct.atom

This class inherits from Atom and is used to represent and manipulate MDCT atoms. Atom Objects can either be constructed or recovered from Xml using fromXml()

class PyMP.mdct.atom.Atom(scale=0, amp=0, timePos=0, freqBin=0, Fs=0, mdctCoeff=0)

MDCT atom class : implement real domain MDCT atoms of scale defined by the atom length

An MDCT atom is defined for a length L, a frequency localization k and a frame parameter p by:

Additionnal attributes are:

  • freq_bin : MDCT frequency bin index (default is 0)
  • frame : the frame index of the atom
  • reduced_frequency: corresponding sampling frequency (default is 0)
  • mdct_value : the atom mdct coefficient

Additionnal parameters for time-shifted atoms:

  • time_shift: time shift in samples related to the closest MDCT grid index*
  • proj_score: useful when atom is reprojected using say.. LOMP algorithm

Attributes

Methods

copy()

copycat routine

get_tf_info(Fs)

returns energy centroids and spread in the time frequency plane

get_waveform()

Retrieve the atom waveform

inner_prod(otherAtom)

DEPRECATED returns the inner product between current atom and the other one This method should be as fast as possible

synthesize(value=None)

synthesizes the waveform Specifies the amplitude, otherwise it will be initialiazed as unit-normed

synthesize_ifft(newValue=None)

DEPRECATED synthesis using Python fftw3 wrapper but no waveform server... a lot slower

Module mdct.block

This class inherits from BaseBlock and is used to represent and manipulate MDCT atoms. mdct.Atom Objects can either be constructed or recovered from Xml using mdct.Atom.fromXml()

MDCT Blocks are the objects encapsulating the actual atomic projections and the selection step of MP

This module describes 3 kind of blocks:
  • Block is a block based on the standard MDCT transform. Which means atoms localizations

    are constrained by the scale of the transform The atom selected is simple the one that maximizes the correlation with the residual it is directly indexes by the max absolute value of the MDCT bin No further optimization of the selected atom is performed

  • LOBlock is a block that performs a local optimization of the time localization of the selected atom

  • FullBlock this block simulates a dictionary where atoms at all time localizations are available

    This kind of dictionary can be thought of as a Toeplitz matrix BEWARE: memory consumption and CPU load will be very high! only use with very small signals (e.g. 1024 samples or so) Fairly intractable at higher dimensions

class PyMP.mdct.block.Block(length=0, resSignal=None, frameLen=0, useC=True, forceHF=False, debug_level=None)

This class is a basic MDCT block. It handles a set of routines that allows greedy decomposition algorithms (MP, OMP , GP ...) to iteratively project the ongoing residual onto a specified MDCT base and to retrieve the maximum inner product

IMPORTANT: the computation of the inner products relies on a C-written module parallelProjections
that needs being compiled first on whatever your plateform. Run the test file: parallelProjections/install_and_test.py in order to compile it and perform some basic execution tests

Attributes

Methods

compute_transform(startingFrame=1, endFrame=-1)

inner product computation through MDCT

find_max()

Search among the inner products the one that maximizes correlation the best candidate for each frame is already stored in the best_score_tree

get_max_atom(HF=False)

construct the atom that best correlates with the signal

initialize()

Compute mdct of the residual and instantiate various windows and twiddle coefficients

synthesize_atom(value=None)

synthesizes the best atom through ifft computation (much faster than closed form) New version uses the PyWinServer to serve waveforms

update(new_res_signal, startFrameIdx=0, stopFrameIdx=-1)

update the part of the residual that has been changed and update inner products

class PyMP.mdct.block.LOBlock(length=0, resSignal=None, frameLen=0, tinvOptim=True, useC=True, forceHF=False)

Class that inherit classic MDCT block class and deals with local optimization This is the main class for differentiating LOMP from MP

Attributes

Methods

Module mdct.dico

This class inherits from BaseDico and is used to represent and manipulate multiscale MDCT dictionaries. Dictionaries are mostly implemented as a collection of pymp_MDCTBlock of various kind, according to the nature of pursuit that is seeked.

This module describes 3 kind of blocks:
  • Dico is a Dico based on the standard MDCT transform. Which means atoms localizations

    are constrained by the scale of the transform The atom selected is simple the one that maximizes the correlation with the residual it is directly indexes by the max absolute value of the MDCT bin No further optimization of the selected atom is performed

  • LODico is a dictionary that performs a local optimization of the time localization of the selected atom

  • FullDico this object simulates a dictionary where atoms at all time localizations are available

    This kind of dictionary can be thought of as a Toeplitz matrix BEWARE: memory consumption and CPU load will be very high! only use with very small signals (e.g. 1024 samples or so) Fairly intractable at higher dimensions

class PyMP.mdct.dico.Dico(sizes=[], useC=True, forceHF=False, debug_level=None)

class to handle multiscale MDCT dictionaries using MDCT blocks

Attributes

Methods

compute_touched_zone(previousBestAtom, panic=False)

update zone computed from the previously selected atom

find_block_by_scale(size)

Returns the index of the block corresponding to the given size or None if not found

get_atom_key(atom, sigLength)

Get the atom index in the dictionary

get_projections(indexes, sigLength)

additional method provided for Gradient Pursuits indexes formalism: key as in the py_pursuit_Approx Object : int(block*self.length + frame*float(atom.length /2) + atom.frequencyBin)

init_proj_matrix(itNumbers)

method used for monitoring the projection along iterations ONLY for DEV purposes

initialize(residual_signal)

Create the collection of blocks specified by the MDCT sizes

update(residualSignal, iteratioNumber=0, debug=0)

Update the projections in each block, only where it needs to be done as specified

update_proj_matrix(projMatrix, iterationNumber, normedProj=False)

method used for monitoring the projection along iterations ONLY for DEV purposes

class PyMP.mdct.dico.LODico(sizes=[], hrsizes=None, useC=True, debug_level=None)

Shift invariant MDCT dictionary Only difference is in the constructor and initialization: need to use LOBlocks

Attributes

Methods

get_projections(indexes, sigLength)

additional method provided for Gradient Pursuits indexes formalism: key as in the py_pursuit_Approx Object : int(block*self.length + frame*float(atom.length /2) + atom.frequencyBin)

class PyMP.mdct.dico.FullDico(sizes=[])

This class handles blocks were MDCT products are computed for each and every possible time localization. Therefore Iterations are very slow but convergence should be optimum

Attributes

Methods

init_proj_matrix(itNumbers)

method used for monitoring the projection along iterations

update_proj_matrix(projMatrix, iterationNumber, normedProj=False)

method used for monitoring the projection along iterations

Classes for Random Matching Pursuit

class PyMP.mdct.rand.block.SequenceBlock(length=0, resSignal=None, frameLen=0, randomType='random', nbSim=1, windowType=None, seed=None)

block implementing the Randomized Pursuit

Attributes

sequence_type: str
The type of time-shift sequence, available choices are
scale random gaussian binom dicho jump binary

default is random which use a uniform pseudo-random generator

shift_list: array-like The actual sequence of subdictionary time-shifts
current_shift: int The current time-shift
nbSim: int Number of consecutive iterations with the same time-shift (default is 1)

Methods

update(new_res_signal, startFrameIdx=0, stopFrameIdx=-1, iteration_number=0)

Same as superclass except that at each update, one need to pick a time shift from the sequence

Module PyMP.mdct.rand.dico

This file handle dctionaries that are used in Randomized Matching Pursuits see [1] for details.

[1] M. Moussallam, L. Daudet, et G. Richard, “Matching Pursuits with Random Sequential Subdictionaries” Signal Processing, vol. 92, pp. 2532-2544 2012.

class PyMP.mdct.rand.dico.SequenceDico(sizes=[], seq_type='random', nbSame=1, windowType=None, seed=None)

This dictionary implements a sequence of subdictionaries that are shifted in time at each iteration in a pre-defined manner the shifts are controlled by the different blocks.

Attributes

Methods