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 / massTrans.m < prev    next >
Text File  |  2007-12-04  |  1KB  |  44 lines

  1. function mx = massTrans(X, mass, resolution)
  2. %
  3. % MX = massTrans(X, MASS, RESOLUTION)
  4. % Transform an input vector or matrix X (thought of as one or more mass
  5. % spectra collected at equal time points) to an output vector MX equally
  6. % spaced on the mass scale. This uses the calibration vector MASS to give
  7. % the mapping from times to masses and the scalar RESOLUTION to determine
  8. % the spacing between mass measurements. The main application is to allow
  9. % the plotting of images or heat maps on the mass axis instead of the time
  10. % axis. For example,
  11. %    mx = massTrans(X, mass, 1);
  12. %    imagesc(mx)
  13.  
  14. % Copyright (c) 2003, 2004 UT M.D. Anderson Cancer Center. All rights reserved.
  15. % See the accompanying file "license.txt" for details.
  16.  
  17. cc = median(diff(diff(mass)))/2;
  18.  
  19. tt = 1:length(mass);
  20. ss = diff(mass) - 2*cc*tt(1:end-1) - cc;
  21. bb = median(ss);
  22.  
  23. rr = mass - cc*tt.^2 - bb.*tt;
  24. aa = median(rr);
  25.  
  26. start = floor(max(0, min(mass)));
  27. finish = ceil(max(mass));
  28. newmass = start:resolution:finish;
  29. timer = (-bb + sqrt(bb.^2 - 4*cc*(aa-newmass)))/(2*cc);
  30.  
  31. [nr nc] = size(X);
  32. s = find(1 <= timer & timer < nc);
  33. ti = floor(timer(s));
  34. tr = timer(s) - ti;
  35.  
  36. g = X(:, ti+1) - X(:, ti);
  37. echo on
  38. size(ti)
  39. size(g)
  40. size(tr)
  41. size(repmat(tr, [nr 1]))
  42. echo off
  43. mx = X(:, ti) + repmat(tr, [nr 1]) .* g;
  44.