Shift Invariant Wavelet Packet Decomposition

Data Structures

WaveletsExt.SIWT.ShiftInvariantWaveletTransformNodeType
ShiftInvariantWaveletTransformNode{N, T₁<:Integer, T₂<:AbstractFloat}

Data structure to hold the index, coefficients, and cost value of an SIWT node.

Parameters

  • Depth::T₁: The depth of current node. Root node has depth 0.
  • IndexAtDepth::T₁: The node index at current depth. Index starts from 0 at each depth.
  • TransformShift::T₁: The type of shift operated on the parent node before computing the transform. Accepted type of shift values are:
    • 0: Coefficients of parent node are not shifted prior to transform.
    • 1: For both 1D and 2D signals, coefficients of parent node are circularly shifted to the left by 1 index.
    • 2: For 2D signals, coefficients of parent node are circularly shifted from bottom to top by 1 index. Not available for 1D signals.
    • 3: For 2D signals, coefficients of parent node are circularly shifted from bottom to top and right to left by 1 index each. Not available for 1D signals.
  • Cost::T₂: The ShannonEntropyCost of current node.
  • Value::Array{T₂,N}: Coefficients of current node.

See also: ShiftInvariantWaveletTransformObject

source
WaveletsExt.SIWT.ShiftInvariantWaveletTransformNodeMethod
ShiftInvariantWaveletTransformNode(data, depth, indexAtDepth, transformShift)

Outer constructor of SIWT node.

Arguments

  • data::Array{T} where T<:AbstractFloat: Array of coefficients.
  • depth::S where S<:Integer: Depth of current node.
  • indexAtDepth::S where S<:Integer: Node index at current depth.
  • transformShift::S where S<:Integer: The type of shift operated on the parent node before computing the transform.
  • nrm::T where T<:AbstractFloat: (Default: norm(data)) Norm of the signal.
source
WaveletsExt.SIWT.ShiftInvariantWaveletTransformObjectType
ShiftInvariantWaveletTransformObject{N, T₁<:Integer, T₂<:AbstractFloat}

Data structure to hold all shift-invariant wavelet transform (SIWT) information of a signal.

Parameters

  • Nodes::Dict{NTuple{3,T₁}, ShiftInvariantWaveletTransformNode{N,T₁,T₂}}: Dictionary containing the information of each node within a tree.
  • SignalSize::Union{T₁, NTuple{N,T₁}}: Size of the original signal.
  • MaxTransformLevel::T₁: Maximum levels of transform set for signal.
  • Wavelet::OrthoFilter: A discrete wavelet for transform purposes.
  • MinCost::Union{T₂, Nothing}: The current minimum ShannonEntropyCost cost of the decomposition tree.
Note

MinCost parameter will contain the cost of the root node by default. To compute the true minimum cost of the decomposition tree, one will need to first compute the SIWT best basis by calling bestbasistree.

  • BestTree::Vector{NTuple{3,T₁}}: A collection of node indices that belong in the best basis tree.
Note

BestTree parameter will contain all the nodes by default, ie. the full decomposition will be the best tree. To get the SIWT best basis tree that produce the minimum cost, one will neeed to call bestbasistree.

See also: ShiftInvariantWaveletTransformNode

source
WaveletsExt.SIWT.ShiftInvariantWaveletTransformObjectMethod
ShiftInvariantWaveletTransformObject(signal, wavelet)

Outer constructor and initialization of SIWT object.

Arguments

  • signal::Array{T} where T<:AbstractFloat: Input signal.
  • wavelet::OrthoFilter: Wavelet filter.
  • maxTransformLevel::S where S<:Integer: (Default: 0) Max transform level.
  • maxShiftedTransformLevel::S where S<:Integer: (Default: 0) Max shifted transform levels.
source

Signal Transform and Reconstruction

Public API

WaveletsExt.SIWT.siwpdFunction
siwpd(x, wt[, L, d])

Computes the Shift-Invariant Wavelet Packet Decomposition originally developed by Cohen, Raz & Malah on the vector x using the discrete wavelet filter wt for L levels with depth d.

Arguments

  • x::AbstractVector{T} where T<:AbstractFloat: 1D-signal.
  • wt::OrthoFilter: Wavelet filter.
  • L::S where S<:Integer: (Default: maxtransformlevels(x)) Number of transform levels.
  • d::S where S<:Integer: (Default: L) Depth of shifted transform for each node. Value of d must be strictly less than or equal to L.

Returns

  • ShiftInvariantWaveletTransformObject containing node and tree details.

Examples

using Wavelets, WaveletsExt

# Setup
x = generatesignals(:heavysine)
wt = wavelet(WT.haar)

# SIWPD
siwpd(x, wt)        
siwpd(x, wt, 4)     # level 4 decomposition, where each decomposition has 4 levels of shifted decomposition.
siwpd(x, wt, 4, 2)  # level 4 decomposition, where each decomposition has 2 levels of shifted decomposition.

See also: isiwpd, siwpd_subtree!

source
WaveletsExt.SIWT.isiwpdFunction
isiwpd(siwtObj)

Computes the Inverse Shift-Invariant Wavelet Packet Decomposition originally developed by Cohen, Raz & Malah.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N,T₁<:Integer,T₂<:AbstractFloat: SIWT object.

Returns

  • Vector{T₂}: Reconstructed signal.

Examples

using Wavelets, WaveletsExt

# Setup
x = generatesignals(:heavysine)
wt = wavelet(WT.haar)

# SIWPD
siwtObj = siwpd(x, wt)

# ISIWPD
isiwpd(siwtObj)

See also: siwpd, isiwpd_subtree!

source

Private API

WaveletsExt.SIWT.siwpd_subtree!Function
siwpd_subtree!(siwtObj, index, h, g, remainingRelativeDepth4ShiftedTransform[; signalNorm])

Runs the recursive computation of Shift-Invariant Wavelet Transform (SIWT) at each node index.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N,T₁<:Integer,T₂<:AbstractFloat: SIWT object.
  • index::NTuple{3,T₁} where T₁<:Integer: Index of current node to be decomposed.
  • h::Vector{T₃} where T₃<:AbstractFloat: High pass filter.
  • g::Vector{T₃} where T₃<:AbstractFloat: Low pass filter.
  • remainingRelativeDepth4ShiftedTransform::T₁ where T₁<:Integer: Remaining relative depth for shifted transform.

Keyword Arguments

  • signalNorm::T₂ where T₂<:AbstractFloat: (Default: norm(siwtObj.Nodes[(0,0,0)].Value)) Signal Euclidean-norm.

See also: isiwpd_subtree!

source
WaveletsExt.SIWT.isiwpd_subtree!Function
isiwpd_subtree!(siwtObj, index, h, g)

Runs the recursive computation of Inverse Shift-Invariant Wavelet Transform (SIWT) at each node index.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N,T₁<:Integer,T₂<:AbstractFloat: SIWT object.
  • index::NTuple{3,T₁} where T₁<:Integer: Index of current node to be decomposed.
  • h::Vector{T₃} where T₃<:AbstractFloat: High pass filter.
  • g::Vector{T₃} where T₃<:AbstractFloat: Low pass filter.

See also: siwpd_subtree!

source

Public API

WaveletsExt.SIWT.bestbasistree!Function
bestbasistree!(siwtObj)

Computes the best basis tree of an SIWT object and discards all nodes that are not part of the best basis tree.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N, T₁<:Integer, T₂<:AbstractFloat}: SIWT object.

Examples

using Wavelets, WaveletsExt

# Setup
x = generatesignals(:heavysine)
wt = wavelet(WT.haar)

# SIWPD
siwtObj = siwpd(x, wt)

# Best basis tree
bestbasistree!(siwtObj)

See also: bestbasis_treeselection!, isvalidtree

source

Private API

WaveletsExt.SIWT.bestbasis_treeselection!Function
bestbasis_treeselection!(siwtObj, index)

Recursive call to select the best basis tree based on the Shannon entropy cost of the index node and its children (shifted and non-shifted).

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N, T₁<:Integer, T₂<:AbstractFloat}: SIWT object.
  • index::NTuple{3,T₁} where T₁<:Integer: Node index for subtree selection.

See also: bestbasistree!,

source

Single Step Transforms

Private API

WaveletsExt.SIWT.sidwt_step!Function
sidwt_step!(siwtObj, index, h, g, shiftedTransform[; signalNorm])

Computes one step of the SIWT decomposition on the node index.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N,T₁<:Integer,T₂<:AbstractFloat: SIWT object.
  • index::NTuple{3,T₁} where T₁<:Integer: Index of current node to be decomposed.
  • h::Vector{T₃} where T₃<:AbstractFloat: High pass filter.
  • g::Vector{T₃} where T₃<:AbstractFloat: Low pass filter.
  • shiftedTransform::Bool: Whether a shifted transform should be performed.

Keyword Arguments

  • signalNorm::T₂ where T₂<:AbstractFloat: (Default: norm(siwtObj.Nodes[(0,0,0)].Value) Signal Euclidean-norm.

Returns

  • child1Index::NTuple{3,T₁}: Child 1 index.
  • child2Index::NTuple{3,T₁}: Child 2 index.

See also: isidwt_step!

source
sidwt_step!(w₁, w₂, v, h, g, s)

Computes one step of the SIWT decomposition on the node v.

Arguments

  • w₁::AbstractVector{T} where T<:AbstractFloat: Vector allocation for output from low pass filter.
  • w₂::AbstractVector{T} where T<:AbstractFloat: Vector allocation for output from high pass filter.
  • v::AbstractVector{T} where T<:AbstractFloat: Vector of coefficients from a node at level d.
  • h::Vector{S} where S<:AbstractFloat: High pass filter.
  • g::Vector{S} where S<:AbstractFloat: Low pass filter.
  • s::Bool: Whether a shifted transform should be performed.

Returns

  • w₁::Vector{T}: Output from the low pass filter.
  • w₂::Vector{T}: Output from the high pass filter.
source
WaveletsExt.SIWT.isidwt_step!Function
isidwt_step!(siwtObj, index, child1Index, child2Index, h, g)

Computes one step of the inverse SIWT decomposition on the node index.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N,T₁<:Integer,T₂<:AbstractFloat: SIWT object.
  • index::NTuple{3,T₁} where T₁<:Integer: Index of current node to be decomposed.
  • child1Index::NTuple{T,T₁} where T₁<:Integer: Index of child 1.
  • child2Index::NTuple{T,T₁} where T₁<:Integer: Index of child 2.
  • h::Vector{T₃} where T₃<:AbstractFloat: High pass filter.
  • g::Vector{T₃} where T₃<:AbstractFloat: Low pass filter.

See also: sidwt_step!

source
isidwt_step!(v, w₁, w₂, h, g, s)

Computes one step of the inverse SIWT decomposition on the node w₁ and w₂.

Arguments

  • v::AbstractVector{T} where T<:AbstractFloat: Vector allocation for reconstructed coefficients.
  • w₁::AbstractVector{T} where T<:AbstractFloat: Vector allocation for output from low pass filter.
  • w₂::AbstractVector{T} where T<:AbstractFloat: Vector allocation for output from high pass filter.
  • h::Vector{S} where S<:AbstractFloat: High pass filter.
  • g::Vector{S} where S<:AbstractFloat: Low pass filter.
  • s::Bool: Whether a shifted inverse transform should be performed.

Returns

  • v::Vector{T}: Reconstructed coefficients.
source

Other Utils

Private API

Wavelets.Util.isvalidtreeMethod
Wavelets.Util.isvalidtree(siwtObj)

Checks if tree within SIWT object is a valid tree.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject: SIWT object.

Returns

  • bool: true if tree is valid, false otherwise.
Note

isvalidtree checks the criteria that each node has a parent (except root node) and one set of children. A node can have either non-shifted or shifted children, but not both. Using this function on a decomposed siwtObj prior to its best basis search will return false.

Examples

using Wavelets, WaveletsExt

# Setup
x = generatesignals(:heavysine)
wt = wavelet(WT.haar)

# SIWPD
siwtObj = siwpd(x, wt)
isvalidtree(siwtObj)        # Returns false

# Best basis tree
bestbasistree!(siwtObj)
isvalidtree(siwtObj)        # Returns true
source
WaveletsExt.SIWT.delete_node!Function
delete_node!(siwtObj, index)

Deletes a node and all its children from an SIWT object.

Arguments

  • siwtObj::ShiftInvariantWaveletTransformObject{N,T₁,T₂} where {N, T₁<:Integer, T₂<:AbstractFloat}: SIWT object.
  • index::NTuple{3,T₁} where T₁<:Integer: Index of node to be deleted.
source