annotate util/sparco utils/genSampling.m @ 99:e22f8494c5ff

Merge
author Mark Plumbley <mark.plumbley@eecs.qmul.ac.uk>
date Tue, 12 Apr 2011 14:33:24 +0100
parents 62f20b91d870
children
rev   line source
ivan@77 1 function [minIntrVec,stat,actpctg] = genSampling(pdf,iter,tol)
ivan@77 2
ivan@77 3 %[mask,stat,N] = genSampling(pdf,iter,tol)
ivan@77 4 %
ivan@77 5 % a monte-carlo algorithm to generate a sampling pattern with
ivan@77 6 % minimum peak interference. The number of samples will be
ivan@77 7 % sum(pdf) +- tol
ivan@77 8 %
ivan@77 9 % pdf - probability density function to choose samples from
ivan@77 10 % iter - number of tries
ivan@77 11 % tol - the deviation from the desired number of samples in samples
ivan@77 12 %
ivan@77 13 % returns:
ivan@77 14 % mask - sampling pattern
ivan@77 15 % stat - vector of min interferences measured each try
ivan@77 16 % actpctg - actual undersampling factor
ivan@77 17 %
ivan@77 18 % (c) Michael Lustig 2007
ivan@77 19
ivan@77 20 % This file is used with the kind permission of Michael Lustig
ivan@77 21 % (mlustig@stanford.edu), and originally appeared in the
ivan@77 22 % SparseMRI toolbox, http://www.stanford.edu/~mlustig/ .
ivan@77 23 %
ivan@77 24 % $Id: genSampling.m 1040 2008-06-26 20:29:02Z ewout78 $
ivan@77 25
ivan@77 26 % h = waitbar(0);
ivan@77 27
ivan@77 28 pdf(find(pdf>1)) = 1;
ivan@77 29 K = sum(pdf(:));
ivan@77 30
ivan@77 31 minIntr = 1e99;
ivan@77 32 minIntrVec = zeros(size(pdf));
ivan@77 33
ivan@77 34 for n=1:iter
ivan@77 35 tmp = zeros(size(pdf));
ivan@77 36 while abs(sum(tmp(:)) - K) > tol
ivan@77 37 tmp = rand(size(pdf))<pdf;
ivan@77 38 end
ivan@77 39
ivan@77 40 TMP = ifft2(tmp./pdf);
ivan@77 41 if max(abs(TMP(2:end))) < minIntr
ivan@77 42 minIntr = max(abs(TMP(2:end)));
ivan@77 43 minIntrVec = tmp;
ivan@77 44 end
ivan@77 45 stat(n) = max(abs(TMP(2:end)));
ivan@77 46 % waitbar(n/iter,h);
ivan@77 47 end
ivan@77 48
ivan@77 49 actpctg = sum(minIntrVec(:))/prod(size(minIntrVec));
ivan@77 50
ivan@77 51 % close(h);
ivan@77 52
ivan@77 53