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