WDF2Classify
-
class WDF2Classify : public tsa::AlgoBase
Time domain detection of transients based on wavelet transform.
Setters
-
void SetBases(const std::string &names)
Replace the candidate bases of the competition.
Every window is transformed in each candidate and the one whose thresholded coefficients have the largest norm on their own noise scale wins; on a tie the later candidate wins, so the order is part of the definition. A name is an orthonormal mother (Haar, DaubC4 to DaubC20, Sym4, Sym8, Coif1, Coif2, or a long one: DaubC24, DaubC32, DaubC40, Sym10, Sym12, Sym16, Sym20, Coif3, Coif4, Coif5) for its pyramidal transform, or a mother followed by “P” and a depth D, as “Coif1P6”, for the uniform level D of its wavelet-packet tree, whose coefficient layout is described at WaveletTransform’s packet constructor. The trigger records the winner’s name, which is what a reader needs to place and invert its coefficients.
“LocalCos” followed by a segment length M, a power of 2 (as “LocalCos128”), is the orthonormal local cosine basis of segment M (WaveletTransform’s LocalCos: Coifman-Meyer bell of half-width M / 2, periodic window edges, DCT-IV per segment), written frequency-major so that it has the layout of the packet level of depth log2 M: row k is DCT-IV bin k, centre (k + 1/2) fs / (2M), over the N / M segments in time order. No LocalCos is in the default list.
Under the block rule the blocks of a packet basis are cut band by band (see WaveletThreshold::SetLayout), so a packet depth D is accepted only while each band of window / 2^D coefficients holds one full block of L = round(ln window): for a window of 512, L = 6 and D is at most 6. The same holds for the rows of LocalCos M, D = log2 M: M <= 64 at a window of 512, M <= 128 at 1024 (L = 7), M <= 256 at 2048 (L = 8).
The default list is DefaultWaveletBases(); SetBases(LegacyWaveletBases()) restores the competition of releases 3.0.0 to 3.3.0 (see WaveletBases.hpp). WDF2Reconstruct takes the same names and the same default.
- Parameters:
names – comma-separated candidate names
- Throws:
std::invalid_argument – on an unknown or repeated name, a packet depth above log2 of the window, an empty list, or, under the block rule, a packet band shorter than one block.
-
inline void SetMinFrequency(double fHz, double fs)
Leave the coefficients at or below fHz out of the competition.
Every candidate drops the coefficients whose tile’s upper frequency edge is <= fHz, read on its own layout (pyramid levels, packet bands, LocalCos rows; see WaveletThreshold::SetMinFrequency): they are out of the window’s sigma, out of the block rule and out of EnWDF, and the trigger’s coefficients hold zero there. At window 1024 and fs 2048, fHz 16 drops pyramid indices 0-15 and LocalCos128 rows 0-1. fHz <= 0, the default, keeps every coefficient and leaves the classifier bit for bit as without it.
- Parameters:
fHz – minimum frequency in Hz, <= 0 for none
fs – sampling rate of the searched stream in Hz
- Throws:
std::invalid_argument – when fs <= 0 with fHz > 0, or fHz >= fs / 2
-
inline double GetMinFrequency() const
The minimum frequency in Hz, 0 when every coefficient is kept.
-
inline void SetBlockRemainder(const std::string &mode)
How the block rule judges a block shorter than L = round(ln window), in every candidate (see WaveletThreshold::BlockRemainder): “legacy” (the default, bit for bit as before) like a full block against lambda n sigma^2; “merge” joins the remainder of a run to the block before it (7 + 1 = one block of 8); “scaled” judges a block of n < L at a full block’s false-alarm probability, Qinv_{chi2_n}(Q_{chi2_L}(lambda L)) sigma^2. Other rules ignore it.
- Throws:
std::invalid_argument – on an unknown name
-
inline void SetBlockRemainder(enum WaveletThreshold::BlockRemainder mode)
The same, by enum value.
-
inline enum WaveletThreshold::BlockRemainder GetBlockRemainder() const
The block remainder mode in force.
-
inline void SetBlock(unsigned int length, double lambda)
The block rule’s parameters in every candidate (see WaveletThreshold::SetBlock): the block length L in coefficients, 0 for round(ln window), Cai’s choice and the default, and the energy threshold lambda in units of L sigma^2, 4.505 by default (calibrated for L of about 7). Under the block rule every band (row) of the current candidates must still hold one full block of the new length, the check SetBases makes.
- Throws:
std::invalid_argument – if lambda is not positive, or a candidate’s bands are shorter than the new block length
-
inline unsigned int GetBlockLength()
The block length L in force, in coefficients.
-
inline double GetBlockLambda()
The block rule’s lambda in force.
Operations
-
inline void operator<<(SeqViewDouble &Data)
-
inline void operator()(SeqViewDouble &Data, double sigma)
-
inline int operator()(EventFullFeatured &Ev)
Getters
-
unsigned int GetDataVector(double &abov, double &sigmaWin, Dvector &Cmax, int &levelR, std::string &Wave)
Execute method.
-
inline void GetEvent(EventFullFeatured &Ev)
-
int GetDataNeeded()
Get the number of data needed in order to be able to call GetData successfully. If the returned value is less or equal than zero no data are needed.
- Returns:
the needed data
-
std::string GetBases() const
The candidate bases, comma-separated, in the order they compete.
Public Functions
-
WDF2Classify(unsigned int window, unsigned int overlap, double thresh, double sigma, unsigned int ncoeff, enum WaveletThreshold::WaveletThresholding WTh = DefaultWaveletThresholding())
Constructor
-
WDF2Classify(const WDF2Classify &from)
Copy constructor. Explicit (not compiler-generated): mBases holds unique_ptr<WaveletTransform>, so a deep copy has to rebuild each basis’s WaveletTransform rather than copy the pointer.
-
~WDF2Classify()
Destructor
-
WDF2Classify &operator=(const WDF2Classify &from)
Assignement operator
- Parameters:
from – The instance to be assigned from
- Returns:
a reference to a new object
-
void SetBases(const std::string &names)