Fitting a Gaussian to one peak in a mass spectrum and calculating area
Sat, 11/11/2023 - 02:42 pm
Need advice on a situation. I have mass spectra with many peaks. I am writing a code that has to do the following:
Step 1: Create a graph zoomed onto an individual peak that is centered at a specified x-axis value (mz value). Zoomed meaning that the x-axis of the graph is limited to showing the full peak centered at the specified mz.
Step 2: Fit a Gaussian curve specifically to this peak. In other words, fitting a Gaussian to only what is shown in this x-axis window ignoring the rest of the spectrum.
Step 3: Calculate the area under the Gaussian curve.
I can do step 2 and step 3 by manually adding cursors on both sides of the peak and then fitting a Gaussian curve but I need to automate this via code and hence I am struggling a little bit with step 1. I would be grateful for some advice on how to do Step 1.
Thanks a lot,