This section demonstrates the features of multiscale principal components analysis provided in the Wavelet Toolbox™ software. The toolbox includes the wmspca function and a graphical user interface (GUI) available from wavemenu. This section describes the command-line and GUI methods, and information about transferring signal and parameter information between the disk and the GUI.
The aim of multiscale PCA is to reconstruct, starting from a multivariate signal and using a simple representation at each resolution level, a simplified multivariate signal. The multiscale principal components generalizes the normal PCA of a multivariate signal represented as a matrix by performing a PCA on the matrices of details of different levels simultaneously. A PCA is also performed on the coarser approximation coefficients matrix in the wavelet domain as well as on the final reconstructed matrix. By selecting the numbers of retained principal components, interesting simplified signals can be reconstructed.
Since you can perform multiscale PCA either from the command line or using the GUI, this section has subsections covering each method.
This example uses noisy test signals. In this section, you will:
Load a multivariate signal.
Perform a simple multiscale PCA.
Display the original and simplified signals.
Improve the obtained result by retaining less principal components.
load ex4mwden whos
The data stored in matrix x comes from two test signals, Blocks and HeavySine, and from their sum and difference, to which multivariate Gaussian white noise has been added.
The multiscale PCA combines noncentered PCA on approximations and details in the wavelet domain and a final PCA. At each level, the most significant principal components are selected.
First, set the wavelet parameters:
level= 5; wname = 'sym4';
Then, automatically select the number of retained principal components using Kaiser's rule by typing
npc = 'kais';
Finally, perform multiscale PCA:
[x_sim, qual, npc] = wmspca(x ,level, wname, npc);
kp = 0; for i = 1:4 subplot(4,2,kp+1), plot(x (:,i)); set(gca,'xtick',); axis tight; title(['Original signal ',num2str(i)]) subplot(4,2,kp+2), plot(x_sim(:,i)); set(gca,'xtick',); axis tight; title(['Simplified signal ',num2str(i)]) kp = kp + 2; end
The results from a compression perspective are good. The percentages reflecting the quality of column reconstructions given by the relative mean square errors are close to 100%.
qual qual = 98.0545 93.2807 97.1172 98.8603
The results can be improved by suppressing noise, because the details at levels 1 to 3 are composed essentially of noise with small contributions from the signal. Removing the noise leads to a crude, but large, denoising effect.
The output argument npc contains the numbers of retained principal components selected by Kaiser's rule:
npc npc = 1 1 1 1 1 2 2
For d from 1 to 5, npc(d) is the number of retained noncentered principal components (PCs) for details at level d. The number of retained noncentered PCs for approximations at level 5 is npc(6), and npc(7) is the number of retained PCs for final PCA after wavelet reconstruction. As expected, the rule keeps two principal components, both for the PCA approximations and the final PCA, but one principal component is kept for details at each level.
To suppress the details at levels 1 to 3, update the npc argument as follows:
npc(1:3) = zeros(1,3); npc npc = 0 0 0 1 1 2 2
Then, perform multiscale PCA again:
[x_sim, qual, npc] = wmspca(x, level, wname, npc);
kp = 0; for i = 1:4 subplot(4,2,kp+1), plot(x (:,i)); set(gca,'xtick',); axis tight; title(['Original signal ',num2str(i)]); set(gca,'xtick',); axis tight; subplot(4,2,kp+2), plot(x_sim(:,i)); set(gca,'xtick',); axis tight; title(['Simplified signal ',num2str(i)]) kp = kp + 2; end
As shown, the results are improved.
This section explores multiscale PCA using the GUIs.
Select File > Load Signals. In the Select dialog box, select the MAT-file ex4mwden.mat from the MATLAB folder toolbox/wavelet/wmultsig1d.
Click Open to load the multivariate signal into the GUI. The signal is a matrix containing four columns, where each column is a signal to be simplified.
These signals are noisy versions from simple combinations of the two original signals, Blocks and HeavySine and their sum and difference, each with added multivariate Gaussian white noise.
Use the default values for the Wavelet, the DWT Extension Mode, and the decomposition Level, and then click Decompose and Diagonalize. The tool displays the wavelet approximation and detail coefficients of the decomposition of each signal in the original basis.
To get more information about the new bases allowed for performing a PCA for each scale, click More on Adapted Basis. A new figure displays the corresponding eigenvectors and eigenvalues for the matrix of the detail coefficients at level 1.
You can change the level or select the coarser approximations or the reconstructed matrix to investigate the different bases. When you finish, click Close.
The initial values for PCA lead to retaining all the components. Select Kaiser from the Provide default using drop-down list, and click Apply.
The results are good from a compression perspective.
The results can be improved by suppressing the noise, because the details at levels 1 to 3 are composed essentially of noise with small contributions from the signal, as you can see by careful inspection of the detail coefficients. Removing the noise leads to a crude, but large, de-noising effect.
For D1, D2 and D3, select 0 as the Nb. of non-centered PC and click Apply.
The results are better than those previously obtained. The first signal, which is irregular, is still correctly recovered, while the second signal, which is more regular, is denoised better after this second stage of PCA. You can get more information by clicking Residuals.
The Multiscale Principal Components Analysis tool lets you save the simplified signals to disk. The toolbox creates a MAT-file in the current folder with a name of your choice.
To save the simplified signals from the previous section:
load s_ex4mwden whos
The simplified signals are in matrix x. The parameters of multiscale PCA are available in PCA_Params:
PCA_Params PCA_Params = 1x7 struct array with fields: pc variances npc
PCA_Params is a structure array of length d+2 (here, the maximum decomposition level d=5) such that PCA_Params(d).pc is the matrix of principal components. The columns are stored in descending order of the variances. PCA_Params(d).variances is the principal component variances vector, and PCA_Params(d).npc is the vector of selected numbers of retained principal components.