Boundary handling modes#

As is typical the algorithms in this toolbox are designed to be applied to signal tensors of finite size. This requires some handling of the signal boundaries to apply the wavelet transform convolutions.

This toolbox implements two different approaches to boundary handling:

  • signal extension via padding

  • using boundary filters for coeffients on the signal boundary

Signal extension via padding#

Signal extensions by padding are applied using torch.nn.functional.pad(). The following modes of padding are supported:

ptwt.constants.BoundaryMode#

This is a type literal for the way of padding used at boundaries.

  • reflect: Refection padding reflects samples at the border:

    ... x3  x2 | x1 x2 ... xn | xn-1  xn-2 ...
    
  • zero: Zero padding extends the signal with zeros:

    ... 0  0 | x1 x2 ... xn | 0  0 ...
    
  • constant: Constant padding replicates border values:

    ... x1 x1 | x1 x2 ... xn | xn xn ...
    
  • periodic: Periodic padding cyclically repeats samples:

    ... xn-1 xn | x1 x2 ... xn | x1 x2 ...
    
  • symmetric: Symmetric padding mirrors samples along the border:

    ... x2 x1 | x1 x2 ... xn | xn xn-1 ...
    

Boundary wavelets#

Boundary filters are another way to deal with signals of finite length. The getting started section of the docs provide and introduction to the main concepts.

ptwt.constants.ExtendedBoundaryMode#

This is a type literal for the way of handling signal boundaries.

This is either a form of padding (see ptwt.constants.BoundaryMode for padding options) or boundary to use boundary wavelets.

alias of Literal[‘boundary’] | Literal[‘constant’, ‘zero’, ‘reflect’, ‘periodic’, ‘symmetric’]

ptwt.constants.PaddingMode#

The padding mode is used when construction convolution matrices.

alias of Literal[‘full’, ‘valid’, ‘same’, ‘sameshift’]

ptwt.constants.OrthogonalizeMethod#

The method for orthogonalizing a matrix.

  1. qr relies on pytorch’s dense QR implementation, it is fast but memory hungry.

  2. gramschmidt option is sparse, memory efficient, and slow.

Choose gramschmidt if qr runs out of memory.