comparison Problems/private/genSampling.m @ 61:42fcbcfca132

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