4.4.2 Use Script to Search for Baseline Anchor Points in Peak Analyzer


In OriginPro, the Peak Analyzer is capable of creating and subtracting baseline. You can create a baseline by finding baseline anchor points first and then connect those anchor points either by interpolation or by fitting. To search for those baseline anchor points, you can either use built-in methods or define the search method on your own using LabTalk scripts.

What you will learn

  • How to create baseline with user-defined scripts
  • How to integrate peaks from user-defined baseline


Create baseline with User-Defined Scripts

  1. Start a New Workbook and import the <Origin EXE Folder>\Samples\Spectroscopy\Chromatography\Liquid chromatogram.dat. Highlight the second column. In the main menu, select Analysis: Peaks and Baseline: Peak Analyzer to open the dialog of the Peak Analyzer.
  2. Make sure Goal is selected as Integrate Peaks and click Next button to go to Baseline Mode page.
  3. Select Baseline Mode as User Defined and continue to select Anchor Points Finding Method under Baseline Anchor Points node as Use Script to Search.
  4. Enter apt_x and apt_y in X= and Y= edit boxes, respectively. Then paste the scripts shown below into Before Formula Script box. Click Find button will run the scripts and the detected baseline anchor points will display on the preview window.
Dataset dspos;
pkfind iy:=(dsx, dsy) dir:=p npts:=5 value:=200 ocenter:=dspos; // Find major peak positions
int npk=dspos.GetSize(); // Get major peak numbers
 // Create datasets to store anchor points
int nn = dsx.GetSize(); // Get source X size
dataset apt_x, apt_y;// Create datasets to store anchor points
apt_x.SetSize(npk+1); // Set anchor points number
apt_x[1] = dsx[1]; // Set 1st data point as 1st anchor point
apt_y[1] = dsy[1]; 
apt_x[npk+1] = dsx[nn]; // Set last data point as last anchor point
apt_y[npk+1] = dsy[nn]; 
for (ii=1; ii<=npk; ii++) 
int istart = dspos[ii]; // Get row index of ii-th peak
int iend = dspos[ii+1]; // Get row index of the next peak
range rtemp = [??]!dsy[$(istart):$(iend)]; // Declare the range and point to the loose dataset
limit rtemp; // Get stats of the subrange
int ind = limit.imin; // Get min Y row index
apt_y[ii+1]=limit.ymin; // Get min Y between two peaks as anchor point

The script will firstly find all major peak positions and then treat the minimum between every two adjacent peaks as one baseline anchor point, then add the first and last data points as two baseline anchor points.

Note: You can still uncheck Enable Auto Find checkbox and then use Add or Modify/Del to add or remove baseline anchor points.

5. Click Next button to go to Create Baseline page, make sure Connect by is selected as Interpolation and the Interpolation Method is Line. Then click Finish to obtain integration areas for each peak.