home *** CD-ROM | disk | FTP | other *** search
/ ftp.disi.unige.it / 2015-02-11.ftp.disi.unige.it.tar / ftp.disi.unige.it / pub / .person / BarlaA / sw / matlab / Cromwell / monotoneMinimum.m < prev    next >
Text File  |  2007-12-04  |  1KB  |  43 lines

  1. function base = monotoneMinimim(slider, saturate)
  2. % baseline = monotoneMinimum(smoothSpectrum, saturationEnd)
  3. %
  4. % This function estimates the baseline of a smooth spectrum as a monotone
  5. % minimum. It starts at the maximum level reached during the saturation
  6. % period. Everything before this maximum is reached is removed from the
  7. % spectrum. Everything after this is computed as a decreasing function
  8. % that always takes on the minimum value seen so far. The baseline curve
  9. % is returned.
  10.  
  11. % Copyright (c) 2003, 2004 UT M.D. Anderson Cancer Center. All rights reserved.
  12. % See the accompanying file "license.txt" for details.
  13.  
  14. if nargin < 2,
  15.    saturate = length(slider);
  16. end
  17. if saturate < 1,
  18.    saturate = 1;
  19. end
  20. if saturate > length(slider),
  21.    saturate =length(slider);
  22. end
  23.  
  24.  
  25. m = max(slider(1:saturate));
  26. d = [diff(slider) 0];
  27. base = repmat(m, size(slider));
  28. %pointer = min(saturate, max(find(slider==m)));
  29. pointer = saturate;
  30. base(1:pointer) = slider(1:pointer);
  31. while pointer < length(slider),
  32.    if d(pointer) <= 0,
  33. %      'dn'
  34.       click = min(find(d(pointer:end) >= 0))- 1;
  35.       base(pointer:pointer+click) = slider(pointer:pointer+click);
  36.    else
  37. %      'up'
  38.       click = min(find(slider(pointer:end) < base(pointer))) - 1;
  39.       base(pointer:end) = slider(pointer);
  40.    end
  41.    pointer = pointer+click;
  42. end
  43.