bss_eval_mix.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function [MER,perm]=bss_eval_mix(Ae,A)
  2. % BSS_EVAL_MIX Ordering and measurement of the quality of an estimated
  3. % (possibly frequency-dependent) mixing matrix
  4. %
  5. % [MER,perm]=bss_eval_mix(Ae,A)
  6. %
  7. % Inputs:
  8. % Ae: either a nchan x nsrc estimated mixing matrix (for instantaneous
  9. % mixtures) or a nchan x nsrc x nbin estimated frequency-dependent mixing
  10. % matrix (for convolutive mixtures)
  11. % A: the true nchan x nsrc or nchan x nsrc x nbin mixing matrix
  12. %
  13. % Outputs:
  14. % MER: nsrc x 1 vector of Mixing Error Ratios (SNR-like criterion averaged
  15. % over frequency and expressed in decibels, allowing arbitrary scaling for
  16. % each source in each frequency bin)
  17. % perm: nsrc x 1 vector containing the best ordering of estimated sources
  18. % in the maximum MER sense (estimated source number perm(j) corresponds to
  19. % true source number j)
  20. %
  21. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  22. % Copyright 2008 Emmanuel Vincent
  23. % This software is distributed under the terms of the GNU Public License
  24. % version 3 (http://www.gnu.org/licenses/gpl.txt)
  25. % If you find it useful, please cite the following reference:
  26. % Emmanuel Vincent, Shoko Araki and Pau Bofill, "The 2008 Signal Separation
  27. % Evaluation Campaign: A community-based approach to large-scale
  28. % evaluation," In Proc. Int. Conf. on Independent Component Analysis and
  29. % Signal Separation (ICA), pp. 734-741, 2009.
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. %%% Errors %%%
  32. if nargin<2, error('Not enough input arguments.'); end
  33. [nchan,nsrc,nbin]=size(Ae);
  34. [nchan2,nsrc2,nbin2]=size(A);
  35. if ~((nchan2==nchan)&&(nsrc2==nsrc)&&(nbin2==nbin)), error('The estimated and true mixing matrix must have the same size.'); end
  36. %%% Performance criterion %%%
  37. % Computation of the criterion for all possible pair matches
  38. MER=zeros(nsrc,nsrc,nbin);
  39. for f=1:nbin,
  40. for jest=1:nsrc,
  41. for jtrue=1:nsrc,
  42. Aproj=A(:,jtrue,f)'*Ae(:,jest,f)/sum(abs(A(:,jtrue,f)).^2)*A(:,jtrue,f);
  43. MER(jest,jtrue,f)=10*log10(sum(abs(Aproj).^2)/sum(abs(Ae(:,jest,f)-Aproj).^2));
  44. end
  45. end
  46. end
  47. MER=mean(MER,3);
  48. % Selection of the best ordering
  49. perm=perms(1:nsrc);
  50. nperm=size(perm,1);
  51. meanMER=zeros(nperm,1);
  52. for p=1:nperm,
  53. meanMER(p)=mean(MER((0:nsrc-1)*nsrc+perm(p,:)));
  54. end
  55. [meanMER,popt]=max(meanMER);
  56. perm=perm(popt,:).';
  57. MER=MER((0:nsrc-1).'*nsrc+perm);
  58. return;