# mswcmpscr

Multisignal 1-D wavelet compression scores

## Syntax

```[THR,L2SCR,NOSCR,IDXSORT] = mswcmpscr(DEC) ```

## Description

`[THR,L2SCR,NOSCR,IDXSORT] = mswcmpscr(DEC)` computes four matrices: thresholds `THR`, compression scores `L2SCR` and `NOSCR`, and indices `IDXSORT`. The decomposition `DEC` corresponds to a matrix of wavelet coefficients `CFS` obtained by concatenation of detail and (optionally) approximation coefficients, where

`CFS = [cd{DEC.level}, ... , cd{1}]` or ```CFS = [ca, cd{DEC.level}, ... , cd{1}]```

The concatenation is made row-wise if `DEC.dirDec` is equal to `'r'` or column-wise if `DEC.dirDec` is equal to `'c'`.

If `NbSIG` is the number of original signals and `NbCFS` the number of coefficients for each signal (all or only the detail coefficients), then `CFS` is an `NbSIG`-by-`NbCFS` matrix. Therefore,

• `THR`, `L2SCR`, `NOSCR` are `NbSIG`-by-(`NbCFS+1`) matrices

• `IDXSORT` is an `NbSIG`-by-`NbCFS` matrix

• `THR(:,2:end)` is equal to `CFS` sorted by row in ascending order with respect to the absolute value.

• For each row, `IDXSORT` contains the order of coefficients and `THR(:,1)=0`.

For the ith signal:

• `L2SCR(i,j)` is the percentage of preserved energy (L2-norm), corresponding to a threshold equal to `CFS(i,j-1)` (`2``j``NbCFS`), and `L2SCR(:,1)=100`.

• `N0SCR(i,j)` is the percentage of zeros corresponding to a threshold equal to `CFS(i,j-1)` (`2``j``NbCFS`), and `N0SCR(:,1)=0`.

Three more optional inputs may be used:

`[...] = mswcmpscr(...,S_OR_H,KEEPAPP,IDXSIG)`

• `S_OR_H ('s' or 'h')` stands for soft or hard thresholding (see `mswthresh` for more details).

• `KEEPAPP (true or false)` indicates whether to keep approximation coefficients (`true`) or not (`false`).

• `IDXSIG` is a vector that contains the indices of the initial signals, or `'all'`.

The defaults are, respectively, `'h'`, false and `'all'`.

## Examples

collapse all

Load the 23 channel EEG data `Espiga3` [4]. The channels are arranged column-wise. The data is sampled at 200 Hz.

`load Espiga3`

Perform a decomposition at level 2 using the `db2` wavelet.

`dec = mdwtdec('c',Espiga3,2,'db2')`
```dec = struct with fields: dirDec: 'c' level: 2 wname: 'db2' dwtFilters: [1x1 struct] dwtEXTM: 'sym' dwtShift: 0 dataSize: [995 23] ca: [251x23 double] cd: {[499x23 double] [251x23 double]} ```

Compute the compression performances for soft and hard thresholding.

```[THR_S,L2SCR_S,N0SCR_S] = mswcmpscr(dec,'s'); [THR_H,L2SCR_H,N0SCR_H] = mswcmpscr(dec,'h');```

## References

[1] Daubechies, I. Ten Lectures on Wavelets, CBMS-NSF Regional Conference Series in Applied Mathematics. Philadelphia, PA: SIAM Ed, 1992.

[2] Mallat, S. G. “A Theory for Multiresolution Signal Decomposition: The Wavelet Representation,” IEEE Transactions on Pattern Analysis and Machine Intelligence. Vol. 11, Issue 7, July 1989, pp. 674–693.

[3] Meyer, Y. Wavelets and Operators. Translated by D. H. Salinger. Cambridge, UK: Cambridge University Press, 1995.

[4] Mesa, Hector. “Adapted Wavelets for Pattern Detection.” In Progress in Pattern Recognition, Image Analysis and Applications, edited by Alberto Sanfeliu and Manuel Lazo Cortés, 3773:933–44. Berlin, Heidelberg: Springer Berlin Heidelberg, 2005. https://doi.org/10.1007/11578079_96.

## Version History

Introduced in R2007a