time | calls | line |
---|
| | 1 | function [which] = FindHighestGaussian_2(G)
|
| | 2 | % FindHighestGaussian determines which of called Gaussians is the highest
|
| | 3 | % across a 1:200 vector. This is used to determine which Gaussians
|
| | 4 | % were meaningful in the multi-Gaussian fit.
|
| 12 | 5 | curve_count = length(G);
|
| 12 | 6 | which = [];
|
| | 7 | % finds highest Gaussian for each of [0..200].
|
| 12 | 8 | for i = 1:200
|
0.01 | 2400 | 9 | fit = [];
|
0.01 | 2400 | 10 | num_zeros = 0;
|
0.02 | 2400 | 11 | if (curve_count > 0)
|
0.03 | 2400 | 12 | for c = 1:curve_count
|
0.11 | 7400 | 13 | fit(c) = G{c}.a*exp(-0.5*((i-G{c}.b)./G{c}.c).^2);
|
0.03 | 7400 | 14 | if (fit(c) == 0)
|
| 553 | 15 | num_zeros = num_zeros+1;
|
| 553 | 16 | end;
|
0.01 | 7400 | 17 | end;
|
0.01 | 2400 | 18 | if (num_zeros == curve_count)
|
| | 19 | which(i) = 0;
|
| 2400 | 20 | else
|
0.01 | 2400 | 21 | fit(fit~=max(fit)) = 0;
|
| 2400 | 22 | which(i) = find(fit);
|
0.01 | 2400 | 23 | end;
|
| 2400 | 24 | end;
|
| 2400 | 25 | end;
|
| | 26 | % if the first [which] is zero, finds the nearest available [which] of not zero.
|
| 12 | 27 | if (which(1) == 0)
|
| | 28 | last_valid = 0;
|
| | 29 | for i = 200:-1:1
|
| | 30 | if (which(i) ~= 0)
|
| | 31 | last_valid = which(i);
|
| | 32 | end;
|
| | 33 | end;
|
| | 34 | which(i) = last_valid;
|
| | 35 | end;
|
| | 36 | % if the last [which] is zero, finds the nearest available [which] of not zero.
|
| 12 | 37 | if (which(200) == 0)
|
| | 38 | last_valid = 0;
|
| | 39 | for i = 1:1:200
|
| | 40 | if (which(i) ~= 0)
|
| | 41 | last_valid = which(i);
|
| | 42 | end;
|
| | 43 | end;
|
| | 44 | which(200) = last_valid;
|
| | 45 | end;
|
| | 46 | % fills [which] gaps of zeros.
|
| 12 | 47 | zero_count = 1;
|
| 12 | 48 | while (zero_count ~= 0)
|
| 12 | 49 | which2 = which;
|
| 12 | 50 | zero_count = 0;
|
| 12 | 51 | for j = 2:199
|
| 2376 | 52 | if (which(j) == 0)
|
| | 53 | zero_count = zero_count+1;
|
| | 54 | end;
|
| 2376 | 55 | if (which(j) == 0) && (which(j-1) ~= 0) && (which(j+1) == 0)
|
| | 56 | which2(j) = which(j-1);
|
| | 57 | end;
|
| 2376 | 58 | if (which(j) == 0) && (which(j-1) == 0) && (which(j+1) ~= 0)
|
| | 59 | which2(j) = which(j+1);
|
| | 60 | end;
|
0.01 | 2376 | 61 | if (which(j) == 0) && (which(j-1) ~= 0) && (which(j+1) ~= 0)
|
| | 62 | %if (random('uniform',0,1) >= 0.5)
|
| | 63 | which2(j) = which(j-1);
|
| | 64 | %else
|
| | 65 | % which2(j) = which(j+1);
|
| | 66 | %end;
|
| | 67 | end;
|
| 2376 | 68 | end;
|
| 12 | 69 | which = which2;
|
| 12 | 70 | if (zero_count == 198)
|
| | 71 | zero_count = 0;
|
| | 72 | end;
|
| 12 | 73 | end;
|
| 12 | 74 | end
|
Other subfunctions in this file are not included in this listing.