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