idamnjanovic@51: function [minIntrVec,stat,actpctg] = genSampling(pdf,iter,tol) idamnjanovic@51: idamnjanovic@51: %[mask,stat,N] = genSampling(pdf,iter,tol) idamnjanovic@51: % idamnjanovic@51: % a monte-carlo algorithm to generate a sampling pattern with idamnjanovic@51: % minimum peak interference. The number of samples will be idamnjanovic@51: % sum(pdf) +- tol idamnjanovic@51: % idamnjanovic@51: % pdf - probability density function to choose samples from idamnjanovic@51: % iter - number of tries idamnjanovic@51: % tol - the deviation from the desired number of samples in samples idamnjanovic@51: % idamnjanovic@51: % returns: idamnjanovic@51: % mask - sampling pattern idamnjanovic@51: % stat - vector of min interferences measured each try idamnjanovic@51: % actpctg - actual undersampling factor idamnjanovic@51: % idamnjanovic@51: % (c) Michael Lustig 2007 idamnjanovic@51: idamnjanovic@51: % This file is used with the kind permission of Michael Lustig idamnjanovic@51: % (mlustig@stanford.edu), and originally appeared in the idamnjanovic@51: % SparseMRI toolbox, http://www.stanford.edu/~mlustig/ . idamnjanovic@51: % idamnjanovic@51: % $Id: genSampling.m 1040 2008-06-26 20:29:02Z ewout78 $ idamnjanovic@51: idamnjanovic@51: % h = waitbar(0); idamnjanovic@51: idamnjanovic@51: pdf(find(pdf>1)) = 1; idamnjanovic@51: K = sum(pdf(:)); idamnjanovic@51: idamnjanovic@51: minIntr = 1e99; idamnjanovic@51: minIntrVec = zeros(size(pdf)); idamnjanovic@51: idamnjanovic@51: for n=1:iter idamnjanovic@51: tmp = zeros(size(pdf)); idamnjanovic@51: while abs(sum(tmp(:)) - K) > tol idamnjanovic@51: tmp = rand(size(pdf))