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