Baseline Fitting
hernants
I am writing an integration macro that will mimic the integration function of the GC used in our lab. I am also finished but all I need now is to write the code for a better baseline. Currently, I have it set to finding the minimal value between all of the peaks and just using that y minimal value as the straight line baseline. However, I wish to be more precise by making a baseline that will form straight lines between each local minimum between each peak. I have already written the code to find the local minimums between each peak. Now, I just wish to curve fit lines between each local minimum so that this can be used as a baseline (the baseline is essentially going to be a piecewise function where each section is simply a straight line from each local minimum). My idea right now currently is to break up the wave into sections based on the local minimums using the Duplicate/R=[startP, endP] function in a loop, then curve fitting each section using a line curvefit based on the 2 end points, and finally combining each linear section into the full "piecewise" baseline using the Concatenate function. I do not know how to write this code specifically so any help is greatly appreciated!
See your Igor Pro Folder/Technical Notes/Igor Tech Notes/TN020-B Peak Areas folder.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
April 22, 2015 at 07:59 pm - Permalink
It sounds like you want a baseline matching the scaling of the original data set, but with linear segments between the peaks in the original data. If that is the case, then take a look at using interpolate2 with linear interpolation on the set of minimum values between peaks.
April 23, 2015 at 05:27 am - Permalink
y = (x-x1)*(y2-y1)/(x2-x1)+x1
Variable x1 = ..., y1= ....
Variable x2 = ..., y2= ....
my_background(x1,x2) = (x-x1)*(y2-y1)/(x2-x1)+x1
endfor
April 27, 2015 at 11:56 pm - Permalink