Best Basis

Cost functions and computations

Public API

WaveletsExt.BestBasis.tree_costsFunction
tree_costs(X, method)

Returns the cost of each node in a binary tree in order to find the best basis.

Arguments

  • X::AbstractArray{T} where T<:AbstractFloat: A set of decomposed signals, of sizes (n,L,k) for 1D signals or (n,m,L,k) for 2D signals, where:
    • n: Length of signal (1D) or vertical length of signal (2D).
    • m: Horizontal length of signal (2D).
    • L: Number of decomposition levels plus 1 (for standard wavelet decomposition) or number of nodes in the tree (for redundant transforms such as ACWT and SWT).
    • k: Number of signals.
  • method::BestBasisType: Type of best basis, ie. BB(), JBB() or LSDB().
Note

For standard best basis (BB()), only one signal is processed each time, and therefore the inputs X should have dimensions (n,L) or (n,m,L) instead.

Returns

  • Vector{T}: A vector containing the costs at each node.

Examples

using Wavelets, WaveletsExt

X = generatesignals(:heavisine, 6) |> x -> duplicatesignals(x, 5, 2, true)
wt = wavelet(WT.db4)
Xw = wpdall(X, wt)

tree_costs(Xw, JBB())
tree_costs(Xw, LSDB())

See also: bestbasistree, bestbasis_treeselection

source

Private API

WaveletsExt.BestBasis.coefcostFunction
coefcost(x, et[, nrm])

Arguments

  • x::AbstractArray{T} where T<:AbstractFloat: An array of values to compute the cost.
  • et::CostFunction: Type of cost function.
  • nrm::T where T<:AbstractFloat: The norm of the x. Only applicable when et is a BBCost.

Returns

  • ::T: Cost of x.

See also: bestbasistree

source

Best Basis Tree Selection

Private API

WaveletsExt.BestBasis.bestbasis_treeselectionFunction
bestbasis_treeselection(costs, n[, type])
bestbasis_treeselection(costs, n, m[, type])

Computes the best basis tree based on the given cost vector.

Arguments

  • costs::AbstractVector{T}: Vector containing costs for each node.
  • n::Integer: Length of signals (for 1D cases) or vertical length of signals (for 2D cases).
  • m::Integer: Horizontal length of signals (for 2D cases).
  • type::Symbol: (Default: :min) Criterion used to select the best tree. Supported types are :min and :max. Eg. Setting type = :min results in a basis tree with the lowest cost to be selected.

Returns

  • ::BitVector: Best basis tree selected based on cost.

See also: bestbasistree, tree_costs

source

Best basis computation

Public API

WaveletsExt.BestBasis.LSDBType
LSDB([; cost, redundant])

Least Statistically Dependent Basis (LSDB).

Keyword Arguments

  • cost::LSDBCost: (Default: DifferentialEntropyCost()) Cost function for LSDB.
  • redundant::Bool: (Default: false) Whether the performed wavelet transform is redundant. Set redundant=true when running LSDB with redundant wavelet transforms such as SWT or ACWT.

See also: BestBasisType, JBB, BB

source
WaveletsExt.BestBasis.JBBType
JBB([; cost, redundant])

Joint Best Basis (JBB).

Keyword Arguments

  • cost::JBBCost: (Default: LoglpCost(2)) Cost function for JBB.
  • redundant::Bool: (Default: false) Whether the performed wavelet transform is redundant. Set redundant=true when running LSDB with redundant wavelet transforms such as SWT or ACWT.

See also: BestBasisType, LSDB, BB

source
WaveletsExt.BestBasis.BBType
BB([; cost, redundant])

Standard Best Basis (BB).

Keyword Arguments

  • cost::BBCost: (Default: ShannonEntropyCost()) Cost function for BB.
  • redundant::Bool: (Default: false) Whether the performed wavelet transform is redundant. Set redundant=true when running LSDB with redundant wavelet transforms such as SWT or ACWT.

See also: BestBasisType, LSDB, JBB

source
Wavelets.Threshold.bestbasistreeFunction
bestbasistree(X[, method])

Extension to the best basis tree function from Wavelets.jl. Given a set of decomposed signals, returns different types of best basis trees based on the methods specified. Available methods are the joint best basis (JBB), least statistically dependent basis (LSDB), and individual regular best basis (BB).

Arguments

  • X::AbstractArray{T} where T<:AbstractFloat: A set of decomposed signals, of sizes (n,L,k) for 1D signals or (n,m,L,k) for 2D signals, where:
    • n: Length of signal (1D) or vertical length of signal (2D).
    • m: Horizontal length of signal (2D).
    • L: Number of decomposition levels plus 1 (for standard wavelet decomposition) or number of nodes in the tree (for redundant transforms such as ACWT and SWT).
    • k: Number of signals.
  • method::BestBasisType: Type of best basis, ie. BB(), JBB() or LSDB().
Tip

For standard best basis (BB()), this current function can only process one signal at a time, ie. the input X should have dimensions (n,L) or (n,m,L). To process multiple signals using one function, see bestbasistreeall.

Returns

  • ::BitVector: Best basis tree.

Examples

using Wavelets, WaveletsExt

X = generatesignals(:heavisine, 6) |> x -> duplicatesignals(x, 5, 2, true)
wt = wavelet(WT.db4)
Xw = wpdall(X, wt)

bestbasistree(Xw, JBB())
bestbasistree(Xw, LSDB())

See also: getbasiscoef, getbasiscoefall, tree_costs, delete_subtree!

source
WaveletsExt.BestBasis.bestbasistreeallFunction
bestbasistreeall(X, method)

Compute the standard best basis tree of a set of signals.

Arguments

  • X::AbstractArray{T} where T<:AbstractFloat: A set of decomposed signals, of sizes (n,L,k) for 1D signals or (n,m,L,k) for 2D signals, where:
    • n: Length of signal (1D) or vertical length of signal (2D).
    • m: Horizontal length of signal (2D).
    • L: Number of decomposition levels plus 1 (for standard wavelet decomposition) or number of nodes in the tree (for redundant transforms such as ACWT and SWT).
    • k: Number of signals.
  • method::BB: Standard best basis method, eg. BB().

Returns

  • ::BitMatrix: (nₜ,k) matrix where each column corresponds to a tree.

Examples

using Wavelets, WaveletsExt

X = generatesignals(:heavisine, 6) |> x -> duplicatesignals(x, 5, 2, true)
wt = wavelet(WT.db4)

Xw = wpdall(X, wt)
bestbasistreeall(Xw, BB())

Xw = swpdall(X, wt)
bestbasistree(Xw, BB(redundant=true))

See also: bestbasistree

source