annotate DL/RLS-DLA/private/genSampling.m @ 65:55faa9b5d1ac

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