WaveletThreshold

class WaveletThreshold

Perform threshold on wavelet coefficients

Setters

inline void SetSigma(double sigma)
inline void SetBlock(unsigned int length, double lambda)

The block rule’s parameters: the block length in coefficients, 0 for the natural logarithm of N, Cai’s choice, and the energy threshold in units of L sigma^2, whose calibrated value for that length is 4.505.

inline unsigned int GetBlockLength()
inline double GetBlockLambda()
inline void SetBlockRemainder(enum BlockRemainder mode)

How a block shorter than L is judged (see BlockRemainder); legacy, the default, is the rule as it was, bit for bit. The string form takes “legacy”, “merge” or “scaled”.

Throws:

std::invalid_argument – on an unknown name

inline void SetBlockRemainder(const std::string &mode)

The same, by name: “legacy”, “merge” or “scaled”.

inline enum BlockRemainder GetBlockRemainder() const

The block remainder mode in force.

inline double GetBlockEnergyThreshold(unsigned int n)

The energy, in units of sigma^2, above which a block of n coefficients is kept under the current length, lambda and remainder mode: lambda n, except under scaled for n < L, where it is Qinv_{chi2_n}(Q_{chi2_L}(lambda L)). It does not depend on the layout: under merge a block of L + r is simply asked for n = L + r.

inline void SetLayout(unsigned int packetDepth)

The coefficient layout the block rule cuts into blocks: 0 for the pyramid, whose levels are index 0, index 1 and [2^k, 2^(k+1)), or the depth D of a uniform wavelet-packet level, whose 2^D bands are [f N / 2^D, (f+1) N / 2^D) (see WaveletTransform’s packet constructor). Either way each run is cut into blocks of L from its first index, so a block never crosses a level or band edge. The other rules judge coefficients one by one and ignore the layout.

Throws:

std::invalid_argument – when 2^D exceeds N

inline unsigned int GetLayout() const

The packet depth of the layout, 0 for the pyramid.

inline void SetMinFrequency(double fHz, double fs)

Leave out the coefficients whose tile lies at or below fHz.

A coefficient is dropped when the upper frequency edge of its run in the layout (see SetLayout) is <= fHz. That edge is (fs / 2) e / N, with e the index just past the run: for the pyramid index 0 reaches fs / 2N, index 1 fs / N and the level [2^k, 2^(k+1)) reaches 2^k fs / N; for packet depth D (and the local cosine of segment M = 2^D, whose rows have the same layout) band f reaches (f + 1) fs / 2^(D+1). At N 1024, fs 2048 and fHz 16 this drops pyramid indices 0-15, packet depth 6 band 0 (16 Hz wide) and LocalCos128 rows 0-1 (8 Hz wide).

A dropped coefficient is zeroed before thresholding, so it is out of sigma (the median of |coefficient| is taken over the kept ones), out of the block rule, out of the largest coefficient (GetLevel, GetCm) and out of any energy read afterwards (WDF’s EnWDF). The universal threshold of dohonojohnston and cuoco counts the kept coefficients, sqrt(2 ln n_kept).

fHz <= 0 switches the cut off (the default): the coefficients go through the original code path, bit for bit.

Throws:

std::invalid_argument – when fs <= 0 with fHz > 0, or when fHz is at or above fs / 2 (nothing would be kept)

inline double GetMinFrequency() const

The minimum frequency in Hz, 0 when every coefficient is kept.

inline bool IsKept(unsigned int i) const

Whether coefficient i is kept under the current layout and minimum frequency (always true with the cut off).

Operations

void operator()(SeqViewDouble &WT, enum WaveletThresholding t, enum ThresholdingMode m = hard)

Brief documentation for the execute method.

Start of the long documentation for execute method.

Declaration of execute operation

Throws:

An – exception

Parameters:

a – parameter

Pre:

A precondition

Post:

A postcondition

Returns:

a returned value

void operator()(Dmatrix &WT, enum WaveletThresholding t, enum ThresholdingMode m = hard)

Getters

inline double GetSigma()
inline double GetLevel()
inline double GetCm()

Public Types

enum WaveletThresholding

How the coefficients of one window are selected.

dohonojohnston keeps each coefficient on its own against the universal threshold sqrt(2 ln N) sigma, with sigma read from the median of the window’s own coefficients; cuoco applies the same threshold with the sigma given from outside (WDF2Reconstruct’s default up to release 3.3.0, and the fixed rule of WavReconstruction); highest keeps the largest coefficients by count.

block judges contiguous coefficients of one level together (Cai 1999): a block of L coefficients is kept whole when its energy exceeds lambda L sigma^2, and zeroed whole otherwise. A signal spread over neighbouring coefficients, each below the universal threshold, survives as a block where no single coefficient would; a lone noise excursion does not carry its block over the line. sigma is read as for dohonojohnston.

Values:

enumerator highest
enumerator dohonojohnston
enumerator cuoco
enumerator block
enum ThresholdingMode

How a coefficient above the threshold is treated.

hard leaves it unchanged, so its amplitude is unbiased and the energy of the surviving set is the energy of the signal. soft shrinks every survivor by the threshold: that minimises the mean square error of a denoised reconstruction, but biases amplitudes low by an amount that grows with the number of coefficients the signal is spread over.

A detection statistic and a parameter estimate are both read off the amplitude, so hard is the default.

Values:

enumerator hard
enumerator soft
enum BlockRemainder

How the block rule judges a block shorter than L: the remainder of 1 … L-1 coefficients at the end of a run, or a whole run shorter than L (the pyramid’s coarse levels of 1, 1, 2 and 4).

legacy (the default) judges it like a full block, against lambda n sigma^2 for its n coefficients. Its false-alarm probability grows as n falls: a single coefficient survives at |c| > sqrt(lambda) sigma, P(chi2_1 > 4.505) = 3.4 % in noise, against P(chi2_7 > 31.5) = 5e-5 for a full block of 7.

merge joins a remainder to the block before it in the same run, so the run ends on one block of L + r (7 + 1 = 8), judged against lambda (L + r) sigma^2. A run shorter than L has no block before it and stays one short block, judged as in legacy.

scaled keeps the partition of legacy but judges every block of n < L coefficients at the false-alarm probability of a full block: with p = Q_{chi2_L}(lambda L), the upper tail of a chi-square of L degrees of freedom at lambda L, the block is kept when its energy exceeds Qinv_{chi2_n}(p) sigma^2 (gsl_cdf_chisq_Q and gsl_cdf_chisq_Qinv). Blocks of L are judged as in legacy.

Values:

enumerator legacy
enumerator merge
enumerator scaled

Public Functions

WaveletThreshold(unsigned int N, unsigned int ncoeff = 0, double sigma = 1.0)

Constructor

~WaveletThreshold()

Destructor

WaveletThreshold(const WaveletThreshold&) = default

Copy constructor and assignment: the work buffers are owned by value, so a copy has its own and shares nothing with the original.

WaveletThreshold &operator=(const WaveletThreshold&) = default