11.7 The Integrate GadgetGadgetIntegration
Overview
The Integrate Gadget tool (the addtool_curve_integ XFunction) allows you to select an arbitrary range of data on a graph intuitively, using the region of interest (ROI) object (yellow rectangle). Then the tool performs integration on the chosen section to calculate the area under the curve and display the results instantly on top of the ROI.
With this Gadget, you can:
 Specify the integration limits
 Specify baseline
 Display the difference curve and the integral curve inside the ROI
 Calculate quantities including: peak area, peak height, peak center and FWHM
To Open Integrate Gadget
To use this tool, select Gadgets: Integrate... from the Origin menu when a graph window is active. If the tool has already been activated, you can reopen the Integrate dialog by clicking on the arrow in the upperright corner of the ROI and choosing Preferences.
To Show or Hide Gadget Tool
To toggle the display of all gadget ROI boxes in a graph at the same time, click the H button in the top right corner of the graph, which enables users to export the graph with gadget results.
ROI Box tab
X Scale

Specify the X Data range for the ROI.
 From
 The beginning of X scale.
 To
 The ending of X scale.
 Fixed (Prevent moving by ROI)
 Fix the X scale to prevent from moving by ROI box.

Show Tool Name (toolname)

Specify whether to show the tool name at the top of the rectangle in the graph. The tool name can be specified in Preferences.

Fill Color (rectcolor)

Specify the color of the rectangle that attaches to the graph. See the list of colors.

Show Area/FWHM on CenterTop (showtop)

Specify whether to show the integrated area and FWHM of the selected section at the top of the rectangle in the graph.

Integration tab
Fit Limits To (fitlimit)

Specify the integration limits. You can get the limits through linear interpolation/extrapolation or use raw data points as integral limits.
 Interpolate to Rectangle Edge
 Specify whether to interpolate the two points at the rectangle edges according to the source data, and then use these two points as integration limits. Please note that if the rectangle edge exceeds the source data, it will not interpolate.
 Interpolate/Extrapolate to Rectangle Edge
 Specify whether to interpolate/extrapolate the two points at the rectangle edges according to the source data and then use these two points as integration limits.
 Data Points
 Do not interpolate and use the raw data points as integration limits.

Area Type (areatype)

Specify the integral area type.
 Mathematical Area
 The area is the algebraic sum of trapezoids.
 Absolute Area
 The area is the sum of absolute trapezoid values.

Show (showIntegrArea)

 Baseline Subtracted Curve
 Specify whether to show the baseline subtracted curve in the graph.
 Show Integrated Area
 Specify whether to show the integrated area in the graph.
 Keep the shading color after New Output
 Specify whether to keep the shadow of integrated area after selecting New Output options everytime.
 Note: For information on customizing the shaded (integrated) area and baseline, see this FAQ.
 Integral Curve
 None
 Do not show the integral curve in the graph.
 Restrict to Rectangle
 Show the integral curve inside the rectangle. If the integral values are much larger than the original curve, the integral curve will be rescaled to restrict inside the rectangle box. The integral curve does not show the true values in this case.
 True Value
 Show the actual integral values in the graph.

Baseline Tab
Method (method)

Specify a baseline mode.
 None (Y=0)
 Use Y=0 as baseline.
 Constant Y
 Use a horizontal line as the baseline.
 Straight Line
 Use a straight line, which can be tilted, as the baseline.
 Use Existing Dataset
 Use an existing data set as the baseline.
 2nd Derivative
 Use the 2nd Derivative method to create baseline.
 End Point Weighted
 Create a smoothed curve using data points from two ends

Y= (yvalue)

This is only available when Constant Y is selected for Method. You can use it to specify the Y value for the horizontal line to be used as the baseline.

Fix x to (fixxto)

This is only available when Straight Line is selected for Method. It works together with Y offset of left (yoffsetleft) and Y Offset of Right (yoffsetright). It is used to specify how to choose X values for the beginning and end of the baseline.
Now, suppose we define the value of Y offset of left (yoffsetleft) as b1 and Y offset of right (yoffsetright) as b2; the beginning Y value of the baseline as a1, and the ending Y value as a2. Then we always have a1b1=y1 and a2b2=y2, where y1 and y2 are the Y values at x1 and x2, respectively. For how to define x1 and x2, see below.
 Entire Data
 Fix x to the entire data set. When you select this, x1 is the X value of the beginning of the raw data and x2 is the X value of the end of the raw data.
 Rectangle
 Fix x to the rectangle. When you select this, x1 is the X value that corresponds to the left edge of the rectangle and x2 is the X value that corresponds to the right edge.
 Scale
 Fix x to the X scale. When you select this, x1 is the beginning of the scale and x2 is the end of it.

Y Offset of Left (yoffsetleft)

This is only available when Straight Line is selected for Method. It used to set the value of b1 mentioned above.

Y offset of Right (yoffsetright)

This is only available when Straight Line is selected for Method. It used to set the value of b2 mentioned above.

Baseline Dataset (xyrbase)

This is only available when Dataset is selected for Method. It is used to specify an existing data set to be used as the baseline.
Range 1 (Range1)
 X (X=)
 Specify the X range.
 Y (Y=)
 Specify the Y range.
 Rows
 Select this check box if you want to use only part of the data set as the baseline.
 From
 Specify the beginning row.
 To
 Specify the ending row.

Smoothing Method

Select a smoothing method to apply smoothing prior to creating the baseline. This option is only available when the Mode is set as 2nd Derivative. Options include:
 Window Size
 Specify the desired window size (a positive integer) in the moving window for the SavitzkyGolay or AdjacentAveraging smoothing.
 Threshold
 Specify threshold for the SavitzkyGolay or Adjacent_Averaging smoothing.
 Polynomial Order
 This parameter is available only when SavitzkyGolay is selected for Smoothing Method. It specifies the polynomial order (1 through 9).

Maximum Anchor Points

Specify the maximum of baseline anchor points. This option is only available when you set Mode to 2nd Derivative.

Connected Method

Specify connect method for the anchor points. This option is only available when you set Mode to 2nd Derivative.

End Points(%)

Specify the percentage of end points to create baseline. This option is only available when you set Mode as End Points Weighted.

Output tab
Output Quantities to
Customize the output results.
Script Window (script)

Specify whether to output the results to the Script window.

Results Log (reslog)

Specify whether to output the result to the Results Log.

Long Name in Results Log/Script Window (useLongName):

Specify whether to use the long names of the Quantities (quantities) or the variable names of them when Origin outputs the results to the Results Log or Script window.

Append to Worksheet (appendwks)

Specify whether to append the results to a worksheet.

Result Workbook Name (wbkName)

This is only available when Append to Worksheet (appendwks) is selected. It is used to specify the name of the worksheet.

Add Label to Graph (LabelToGraph)

It is used to specify whether output the label to the graph.

Significant Digits(signdigits)

It is used to specify the significant digits of output quantities. The default system follows the Digits settings on the Numeric Format tab of Preferences: Options dialog. It effects labels on the top of ROI box and the outputs to Script Window, Results Log and labels added to graph.

Quantities Branch
Specify the quantities to be outputted.
Dataset Identifier (name)

Specify a dataset identifier in the dropdown list.

Beginning Row Index (begin_row)

Specify whether to output the beginning row index.

Ending Row Index (end_row)

Specify whether to output the ending row index.

Beginning X (begin_x)

Specify whether to output the beginning X value.

Ending X (end_x)

Specify whether to output the ending X value.

Max Height (ph)

Specify whether to output the maximum height, as computed from the baseline.

X at YMax (pc)

Specify whether to output the X value at the maximum Y value.

Area (pa)

Specify whether to output the area, as computed from the baseline.

Area Above Baseline (paa)

Specify whether to output the area above the baseline.

Area Below Baseline (pab)

Specify whether to output the area below the baseline.

Centroid (pcd)

Specify whether to output the centroid.

FWHM (pfwhm)

Specify whether to output the FWHM (the full width at half the height of the source curve).

Left Half Width (plhw)

Specify whether to output the left half width.

Right Half Width (prhw)

Specify whether to output the right half width.

Y Max (pymax)

Specify whether to output the Y value on the input curve at the X position where the Y on subtracted curve has the maximum absolute value.

Index of X at YMax (pxofymax)

Specify whether to output the index of X for the Y Max value.

Baseline (base)

Specify whether to output the baseline information.

Notes: The name in the brackets is the tree node name, and the name outside is the tree node label. When an Xfunction executes by script, you have to assign values to tree nodes using their names. Special characters and spaces are not allowed in tree node names. However, you can use special characters and white space in the tree node label.

Baseline and Integrated Curve
Specify whether output the created baseline, integrated curve or/and subtracted curve of the selected range under the ROI box.
Baseline (base)

Specify whether to output the baseline information.

Integral Curve(Integrated)

Specify whether to output the Integral Curve.

Subtracted Curve(Subtracted)

Specify whether to output the Subtracted Curve(gotten by subtracting selected baseline from the source curve) if the Baseline Mode is not None.

Output To (Outputto)

Specify where to output the result .

The FlyOut Menu
Click the triangle button near the top right corner of the ROI to open a flyout menu that offers the following options:
New Output

Output the result.

New Output for All Curves (N)

Output the results for all curves in the current layer to the specified worksheet (if not empty, append the results).

New Output for All Layers (L)

Output the results for all curves in all layers within the current graph to the specified worksheet (if not empty, append the results).

Update Last Output

Update the last output. Only available when there is already an output.

Go to Result Worksheet

Go to the result worksheet once the result has been output to worksheet.

Go to Source Worksheet

Go to the source worksheet

Change Data

Change the input data.
By default, the Auto mode will be checked in the flyout menu, which means the target data/plot will follow the data plot selection/highlighting outside the ROI box on the graph. For the earlier versions than Origin 2019, Origin doesn't support this auto behavior; to change target plot/data, you can only select desired one from the flyout plot list.
In the flyout menu, it will show first 20 datasets/plots. If there are more than 20 plots in the graph, you can click More... at the bottom of the list to open the Select Plot dialog to select other plots.

Expand to Full Plot(s) Range

Expand the ROI box to the full Plots range.

Fix ROI Position

Fix the position of ROI box.

Save Theme

Save the settings in this dialog as a dialog theme.

Save as <default>

Save the setting in this dialog as <default> theme.

Load Theme

Load the dialog theme presaved.

Preferences

Open the Preferences dialog.

Example
To perform integration on an area of a graph with the baseline at y=2, do the following:
 Create a new worksheet.
 Import the Origin sample data fftfilter1.DAT which is located in <Origin Program Folder>\Samples\Signal Processing.
 Select Plot > 2D : Line: Spline from the Origin menu, to draw a graph.
 Select Gadgets: Integrate from the Origin menu when the graph window is active, to bring up the Integrate: addtool_curve_integ dialog box.
 Go to the Baseline tab. Choose Constant Y for the Method, and then enter 2 in the Y= edit box.
 Click the OK button. This will add a rectangle onto the plot. The integration area is shown at the top of the rectangle.
 Click the button and select New Output from the context menu. The results will be outputted to the Classic Script Window by default.
