Results 1 to 2 of 2

Thread: Getting height of peaks from a graph

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Getting height of peaks from a graph

    Hi,

    I have a serious question, related to both math and programming (I think).

    I am measuring a whole bunch of data from a mass spectrometer (thingy that measures the mass of molecules going through, doesn't matter). The material we're measuring comes through in cycles (described below) and there are generally about 20/30 steps of 10 cycles, separated by a short time of nothing ("pause").

    Each cycle consists of two materials flowing through, resulting in two peaks. One peak is very high and always the same height, and the other peak is much smaller and gradually becomes invisible in the noise levels.

    Example graph:


    You can see 3 sets of 10 cycles with a short pause in between (where it's labeled "Noise"). Each cycle starts with small*, rapidly decreasing peaks, and ends with a high relatively constant peak.

    *The first peak is actually higher than the constant peaks but that's only the very first measurement.



    Now, what I need is to extract the height of these small, decreasing peaks. I don't care about the high peaks, I only need the small peaks. What I need in the end is a graph showing the height of these peaks against time, so we can quantify the amount and speed at which they decrease.

    I can do it manually, I can click in the graph to find out the value of each peak, but I hope you can understand that's not an option when I have dozens of these graphs. I need it to be done automatically.


    What can I do to achieve this? I have a few mathematical applications at my disposal but I'm not good enough with them to figure out how this could be done...:
    - Origin (graphing application but also allows for advanced stuff like fitting, integrating, differentation, etc)
    - Maple (not really useful I think)
    - Matlab (not too good in using that)

    I was thinking of using a simple VB/C# script that reads the raw data of these graphs and extracts the peaks. I just don't really know how I could implement that. I could loop through the data in a fixed range of steps and store the highest point found, but I can see many problems there... For example, I will be counting noise levels too.

    The most difficult problem I think is that these small peaks are actually really small. It's hard to see in the graph because it's in logarithmic scale, but in linear scale they're all 'just about zero', similar to the noise levels...


    Does anyone have any advice for me? Thanks!

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Getting height of peaks from a graph

    I'm sure this could be done in Matlab. I haven't used Maple or Origin myself so I couldn't comment there. A scripting language seems like all you really need, which VB/C#/Matlab all provide. Since you want graphs at the end, I might lean towards Matlab, but I suppose it depends on how used to the language you are vs. how complicated your solution is. You might be able to find useful libraries for one of the above; an incredibly short search yielded this peak finding module.

    You definitely want to feed in log-scaled data to whatever routine you use. If you can find a peak finding routine (seems like a common enough problem that it wouldn't be hard to do so, and the above looked decent) you could pretty easily sort through the list of peaks to find your decreasing values, so long as you can safely discard anything near the "noise" level which, from the graph you've shown, looks very reasonable. More explicitly, given a list of peaks, collapse all contiguous blocks in the "noise" range down to a single peak. For each "noise" peak, iterate from that peak to the next "noise" peak. The first peak encountered is one you want. The 2nd, 3rd, and 4th are garbage, but the 5th is good. You could do some sanity checking by making sure the 3rd is in the "relatively constant" range. In general, the 4n+1'th peak is one you want, and the 4n+3'rd peak is "relatively constant". You might need an extra preprocessing phase to collapse down blocks of peaks very near each other, depending on the quality of the peak finding routine used.

    Hope that helps somewhat. While I'm sure numerous people have run into similar problems (considering how common mass spec machines are nowadays) I'm no chemist/physicist/etc. and have barely used them.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width