Shift Invariant Wavelet Packet Decomposition
WaveletsExt.SIWT.ShiftInvariantWaveletTransformNode
WaveletsExt.SIWT.ShiftInvariantWaveletTransformNode
WaveletsExt.SIWT.ShiftInvariantWaveletTransformObject
WaveletsExt.SIWT.ShiftInvariantWaveletTransformObject
WaveletsExt.SIWT.bestbasis_treeselection!
WaveletsExt.SIWT.bestbasistree!
WaveletsExt.SIWT.delete_node!
WaveletsExt.SIWT.isidwt_step!
WaveletsExt.SIWT.isiwpd
WaveletsExt.SIWT.isiwpd_subtree!
WaveletsExt.SIWT.sidwt_step!
WaveletsExt.SIWT.siwpd
WaveletsExt.SIWT.siwpd_subtree!
Data Structures
WaveletsExt.SIWT.ShiftInvariantWaveletTransformNode
— TypeShiftInvariantWaveletTransformNode{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₂
: TheShannonEntropyCost
of current node.Value::Array{T₂,N}
: Coefficients of current node.
See also: ShiftInvariantWaveletTransformObject
WaveletsExt.SIWT.ShiftInvariantWaveletTransformNode
— MethodShiftInvariantWaveletTransformNode(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.
WaveletsExt.SIWT.ShiftInvariantWaveletTransformObject
— TypeShiftInvariantWaveletTransformObject{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 minimumShannonEntropyCost
cost of the decomposition tree.
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.
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
WaveletsExt.SIWT.ShiftInvariantWaveletTransformObject
— MethodShiftInvariantWaveletTransformObject(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.
Signal Transform and Reconstruction
Public API
WaveletsExt.SIWT.siwpd
— Functionsiwpd(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 ofd
must be strictly less than or equal toL
.
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!
WaveletsExt.SIWT.isiwpd
— Functionisiwpd(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!
Private API
WaveletsExt.SIWT.siwpd_subtree!
— Functionsiwpd_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!
WaveletsExt.SIWT.isiwpd_subtree!
— Functionisiwpd_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!
Best Basis Search
Public API
WaveletsExt.SIWT.bestbasistree!
— Functionbestbasistree!(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
Private API
WaveletsExt.SIWT.bestbasis_treeselection!
— Functionbestbasis_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!
,
Single Step Transforms
Private API
WaveletsExt.SIWT.sidwt_step!
— Functionsidwt_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!
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 leveld
.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.
WaveletsExt.SIWT.isidwt_step!
— Functionisidwt_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!
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.
Other Utils
Private API
Wavelets.Util.isvalidtree
— MethodWavelets.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.
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
WaveletsExt.SIWT.delete_node!
— Functiondelete_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.