wolffd@0: function [cPCAarg, Pdata, Pproto] = som_projections(D,sM,bmus) wolffd@0: wolffd@0: % SOM_PROJECTIONS Makes different kinds of projections for the data and the prototypes. wolffd@0: % wolffd@0: % [cPCAarg, Pdata, Pproto] = som_projections(D,sM,[bmus]) wolffd@0: % wolffd@0: % sD (struct) data struct wolffd@0: % (matrix) size dlen x dim wolffd@0: % sM (struct) map struct wolffd@0: % (matrix) size munits x dim: prototype vectors wolffd@0: % [bmus] (vector) BMU for each data vector (calculated if not specified) wolffd@0: % wolffd@0: % cPCAarg (cell array) PCA arguments: {V, me, l} from pcaproj function wolffd@0: % Pdata (matrix) size dlen x 7, consisting of 3 projection coordinates from PCA, wolffd@0: % 1 residual from the rest of the PCA-projection coordinates, wolffd@0: % and 3 color components wolffd@0: % Pproto (matrix) size dlen x 7, consisting of 3 projection coordinates from PCA, wolffd@0: % 1 residual from the rest of the PCA-projection coordinates, wolffd@0: % 3 color components, and 3 projection coordinates from CCA wolffd@0: % wolffd@0: % See also PCAPROJ, CCA, SAMMON, SOM_PROJECTIONS_PLOT, SOM_COLORING, SOM_COLORCODE, wolffd@0: % SOM_CLUSTERCOLOR, SOM_KMEANCOLOR. wolffd@0: wolffd@0: if isstruct(D), wolffd@0: cn = D.comp_names; wolffd@0: D = D.data; wolffd@0: end wolffd@0: [dlen dim] = size(D); wolffd@0: if nargin<3, bmus = som_bmus(sM,D); end wolffd@0: wolffd@0: % projection of data wolffd@0: wolffd@0: [P0,V,me,l] = pcaproj(D,dim); wolffd@0: D1 = som_fillnans(D,sM); wolffd@0: P1 = pcaproj(D1,V,me); wolffd@0: Res4 = zeros(dlen,1); wolffd@0: if dim<=3, wolffd@0: Res4 = zeros(dlen,1); wolffd@0: else wolffd@0: Res4 = sqrt(sum(P1(:,4:end).*P1(:,4:end),2)); wolffd@0: end wolffd@0: P1 = P1(:,1:min(3,dim)); wolffd@0: if dim<3, P1 = [P1, zeros(dlen,3-dim)]; end wolffd@0: wolffd@0: % projection of codebook vectors wolffd@0: wolffd@0: P1_m = pcaproj(sM,V,me); wolffd@0: Res4_m = zeros(dlen,1); wolffd@0: if dim<=3, wolffd@0: Res4_m = zeros(dlen,1); wolffd@0: else wolffd@0: Res4_m = sum(P1_m(:,4:end).*P1_m(:,4:end),2); wolffd@0: end wolffd@0: P1_m = P1_m(:,1:min(3,dim)); wolffd@0: if dim<3, P1_m = [P1_m, zeros(size(P1_m,1),3-dim)]; end wolffd@0: wolffd@0: P2_m = cca(sM,P1_m,20); wolffd@0: wolffd@0: PCol_m = som_coloring(sM); wolffd@0: wolffd@0: PCol = PCol_m(bmus,:); wolffd@0: wolffd@0: % output wolffd@0: wolffd@0: cPCAarg = {V,me,l}; wolffd@0: Pdata = [P1, Res4, PCol]; wolffd@0: Pproto = [P1_m, Res4_m, PCol_m, P2_m]; wolffd@0: wolffd@0: return; wolffd@0: