function [Y,M] = resynth_nmf(X, W, H, I)
% [Y,M] = resynth_nmf(X, W, H, I)
%     Resynthesize audio from NMF decomposition.
%     X is the original STFT; W and H are the NMF model;
%     I is the index of a subset of the NMF dimensions.
%     Y returns the resynthesized audio; 
%     M returns the actual STFT-domain mask that was applied
% 2013-04-29 Dan Ellis [email protected]

% Scale original STFT by ratio of partial NMF reconstruction to whole thing
M = (W(:,I)*H(I,:)) ./ (W*H);
Y = istft(X .* M);