Main Content

# tqwt

Tunable Q-factor wavelet transform

Since R2021b

## Syntax

``wt = tqwt(x)``
``wt = tqwt(x,Name=Value)``
``[wt,info] = tqwt(___)``

## Description

````wt = tqwt(x)` returns the tunable Q-factor wavelet transform (TQWT) of `x`. The TQWT is computed to the maximum decomposition level with a quality factor of 1. For more information, see TQWT Decomposition Levels.As implemented, the `tqwt` function uses a redundancy of 3. For more information, see Redundancy. ```

example

````wt = tqwt(x,Name=Value)` specifies one or more additional name-value arguments. For example, ```wt = tqwt(x,QualityFactor=2)``` specifies a quality factor of 2.```
````[wt,info] = tqwt(___)` returns the structure array, `info`, with information about the tunable Q-factor wavelet transform.```

example

## Examples

collapse all

Load a multichannel EEG signal. The signal has 23 channels.

```load Espiga3 size(Espiga3,2)```
```ans = 23 ```

Obtain the tunable Q-factor wavelet transform of the multisignal to the maximum level using the default quality factor of 1.

```wt = tqwt(Espiga3); numel(wt)```
```ans = 12 ```

For 1 ≤ i`numel(wt)`-1, the ith element of `wt` contains the wavelet transform coefficients for the ith subband. The last element of `wt` contains the lowpass subband coefficients. Confirm the number of columns of any element of `wt` is equal to the number of channels.

```k = 7; size(wt{k},2)```
```ans = 23 ```

Reconstruct the multisignal and demonstrate perfect reconstruction.

```xrec = itqwt(wt,size(Espiga3,1)); max(abs(xrec(:)-Espiga3(:)))```
```ans = 5.1159e-13 ```

Load an ECG signal. Obtain the TQWT of the signal down to level 5 with a quality factor of 2. Also obtain information of the TQWT.

```load wecg lvl = 5; qf = 2; [wt,info] = tqwt(wecg,Level=lvl,QualityFactor=qf);```

Plot the original signal and compare with the lowpass subband coefficients.

```subplot(2,1,1) plot(wecg) title("Original Signal") axis tight subplot(2,1,2) plot(wt{end}) title("Lowpass Subband Coefficients") axis tight```

Inspect the TQWT information structure. For each subband, confirm that the ratio of the center frequency to the approximate bandwidth equals the quality factor.

`info`
```info = struct with fields: CenterFrequencies: [0.3333 0.2593 0.2016 0.1568 0.1220] Bandwidths: [0.1667 0.1296 0.1008 0.0784 0.0610] Level: 5 Alpha: 0.7778 Beta: 0.6667 ```
`info.CenterFrequencies./info.Bandwidths`
```ans = 1×5 2.0000 2.0000 2.0000 2.0000 2.0000 ```

As implemented, the `tqwt` function uses the redundancy $r=3$. Confirm the highpass and lowpass scaling factors, `info.Beta` and `info.Alpha` respectively, satisfy the relation $r=\frac{\beta }{1-\alpha }$.

`info.Beta/(1-info.Alpha)`
```ans = 3 ```

## Input Arguments

collapse all

Input signal, specified as a single- or double-precision vector, matrix, or 3-D array. If `x` is a matrix or 3-D array, the TQWT is computed along the columns of `x`. For 3-D arrays, `tqwt` interprets the first dimension as time, the second dimension as channels, and the third dimension as a batch.

The TQWT is defined for even-length signals. If the number of samples in `x` is odd, the last sample of `x` is repeated to obtain an even-length signal.

Data Types: `single` | `double`
Complex Number Support: Yes

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: `wt = tqwt(x,Level=3,QualityFactor=2)`

Decomposition level of the TQWT, specified as a positive integer between 1 and the maximum level. The maximum level depends on the signal length and quality factor. For more information, see TQWT Decomposition Levels.

Example: `wt = tqwt(x,Level=3)` specifies a decomposition level of 3.

Data Types: `single` | `double`

Quality factor, specified as a real-valued scalar greater than or equal to 1. The quality factor is the ratio of the center frequency to the bandwidth of the filters. If unspecified, the quality factor defaults to 1.

Example: `wt = tqwt(x,QualityFactor=1.5)` specifies a quality factor of 1.5.

Data Types: `single` | `double`

## Output Arguments

collapse all

Tunable Q-factor wavelet transform, returned as a cell array. `wt` is a cell array with length equal to the maximum level of the TQWT plus one. The ith element of `wt` contains the TQWT coefficients for the ith subband. The subbands are ordered by decreasing center frequency. The final element of `wt` contains the lowpass subband coefficients. The wavelet coefficients in `wt` match `x` in data type and complexity.

• If `x` is a row vector, each element of `wt` is a column vector containing the TQWT coefficients.

• If `x` is a matrix or 3-D array, the column and page sizes of each element of `wt` match the column and page sizes of `x`.

Data Types: `single` | `double`

Transform information, returned as a structure array. `info` has five fields:

• `CenterFrequencies` — The normalized center frequencies (cycles/sample) of the wavelet subbands in the TQWT of `x`. To convert the frequencies to hertz, multiply `CenterFrequencies` by the sample rate.

• `Bandwidths` — The approximate bandwidths of the wavelet subbands in normalized frequency (cycles/sample). To convert the bandwidths to hertz, multiply `Bandwidths` by the sample rate.

• `Level` — Level of the TQWT. Note that `info.Level` may be different from your specified level if you specify a level greater than the maximum supported level for your signal length and quality factor.

• `Beta` — Highpass scaling factor. The highpass scaling factor is computed from the quality factor as `2/(QualityFactor+1)`. Accordingly, `0 < Beta ≤ 1`.

• `Alpha` — Lowpass scaling factor. The lowpass scaling factor is computed from the highpass scaling factor as `1-Beta/3`. Accordingly, `2/3 ≤ Alpha < 1`.

Data Types: `struct`

## More About

collapse all

### TQWT Decomposition Levels

The TQWT minimum and maximum decomposition levels depend on the signal length, N, and quality factor, Q. In the description that follows, the signal length, N, is one sample larger than the input length for odd-length signals.

The maximum decomposition level is

`$⌊\mathrm{log}\left(\frac{N}{4Q+4}\right)/\mathrm{log}\left(\frac{3Q+3}{3Q+1}\right)⌋,$`

where the ⌊ ⌋ symbols denote the floor function.

The minimum level also depends on the signal length and quality factor. The logarithm of N, $\mathrm{log}\left(N\right),$ must satisfy the following inequality:

`$\mathrm{log}\left(N\right)\ge \mathrm{log}\left(4Q+4\right)-\mathrm{log}\left(3Q+1\right)+\mathrm{log}\left(3Q+3\right).$`

If $\mathrm{log}\left(N\right)<\mathrm{log}\left(4Q+4\right)-\mathrm{log}\left(3Q+1\right)+\mathrm{log}\left(3Q+3\right),$ the maximum level is less than 1 and `tqwt` throws an error.

### Redundancy

The TQWT algorithm depends on scaling in the frequency domain:

• lowpass scaling — frequency-domain scaling by α that preserves low-frequency content

• highpass scaling — frequency-domain scaling by β that preserves high-frequency content

The redundancy is defined to be

`$r=\frac{\beta }{1-\alpha }.$`

For more information, see Tunable Q-factor Wavelet Transform.

## References

[1] Selesnick, Ivan W. “Wavelet Transform With Tunable Q-Factor.” IEEE Transactions on Signal Processing 59, no. 8 (August 2011): 3560–75. https://doi.org/10.1109/TSP.2011.2143711.

## Version History

Introduced in R2021b