This is a static copy of a profile report

Home

FindHighestGaussian_2 (12 calls, 0.262 sec)
Generated 14-Nov-2016 07:47:12 using cpu time.
function in file /home/user/dev/ymap/scripts_seqModules/FindHighestGaussian_2.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
FindGaussianCutoffs_3function12
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
13
fit(c) = G{c}.a*exp(-0.5*((i-G...
74000.111 s42.3%
14
if (fit(c) == 0)
74000.030 s11.5%
12
for c = 1:curve_count
24000.030 s11.5%
11
if (curve_count > 0)
24000.020 s7.7%
61
if (which(j) == 0) && ...
23760.010 s3.8%
All other lines  0.060 s23.1%
Totals  0.262 s100% 
Children (called functions)
No children
Code Analyzer results
Line numberMessage
13The variable 'fit' appears to change size on every loop iteration. Consider preallocating for speed.
19The variable 'which' appears to change size on every loop iteration. Consider preallocating for speed.
21The variable 'fit' appears to change size on every loop iteration. Consider preallocating for speed.
22The variable 'which' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
Show coverage for parent directory
Total lines in function74
Non-code lines (comments, blank lines)12
Code lines (lines that can run)62
Code lines that did run35
Code lines that did not run27
Coverage (did run/can run)56.45 %
Function listing
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.