Baseline Fitting

Baselines is a baseline fitting utility for spectroscopic data.

New for Version 4

  • Baselines now includes all of the baseline types from the ArcHull and BaselineSpline projects.
  • A lot of the code has been rewritten and the user interface updated.
  • Some code bottlenecks have been fixed. The result is that the baseline preview is updated more smoothly in response to changing settings, dragging nodes or moving cursors.
  • Preferences are now saved in a package preferences file and are easily editable.
  • Subrange fitting provides an easy way to adjust the output of the automatic baseline algorithms, and can used to treat different regions of interest separately. See usage notes for more details.
  • New "marquee buttons" for quick input, and SetVariable controls for precise adjustment of fitting range.
  • Improved algorithm for guessing node positions for spline type baselines. Hold down the shift key when clicking the reset button to snap-to-trace.
  • Node editing mode can be toggled using a new graph window button. The button is moveable in Igor 8+ and transparent in Igor 9.
  • A user-defined function can be used for both masked and automatic iterative fitting.
  • New manual baselines use cursors for input.
  • Wave assignments for large waves are multithreaded.
  • A help file is included in the package and can be opened via a control panel button.

How to use the Baseline Fitting package

When you select 'Baselines' from the analysis menu a baseline control panel is attached to the top graph. Traces in the graph will be recolored (unless the trace recoloring option is turned off in the settings panel) so that the selected trace, together with a preview of the baseline and baseline-subtracted waves, are the only non-grey traces. Traces are reset to their original colors when the panel is closed. Select spectrum and baseline type from popup menus in the control panel. The four tabs select between four 'families' of baseline algorithms: masked function fitting, manual function fitting, automatic baselines that process the input data to estimate a baseline, and spline baselines that are interpolated between node positions selected by the user. Baselines works with both waveform and x-y traces, but not with 2D waves. Close the panel to clean up after fitting.

Subrange Fitting

Enable subrange fitting by clicking the checkbox and select a subrange by adjusting the values in the setvariable controls or by dragging the vertical cursors. When a baseline is subtracted, points within the selected range of any existing output wave are overwritten. For baselines in the mask, manual and spline families this setting affects only the baseline subtraction process: the baseline calculation includes masked regions, cursors or nodes outside of the selected region. For algorithmic baselines (Auto tab), the data within the selected region are used to calculate the baseline, so adjusting the output range also changes the baseline. Spline nodes are not saved for subranges.

If a baseline has already been subtracted from the selected trace, points outside of the subrange will be filled with the existing values in both the baseline and baseline-subtracted output preview.

Subtracting Baselines

The subtract button will make copies of baseline and baseline-subtracted waves. The output waves can be saved in either the current data folder, or in the same location as the input data wave. The names of the output waves are formed from the input wavename, together with a suffix as defined in the settings panel. Use the subrange setting to subtract baselines in a piecemeal fashion.

All-at-once fitting cycles through all of the traces in the plot, fitting a baseline using the current settings. Baselines and baseline-subtracted waves are created for each trace. All-at-once spline fitting guesses a y-position for the nodes for each trace.

Note that output waves with the baseline and subtracted-wave suffixes defined in the settings cannot be chosen as data waves for baseline fitting. If you want to fit a sequence of baselines, edit the suffix to enable this (or use a batch renaming utility between fits).

Baseline fit parameters are saved in the wavenotes of output waves. When a baseline subrange is subtracted, the baseline parameters for the subrange are appended to the wavenotes of the output waves.

Masked Fitting

Setting mask regions: Use the graph marquee tool (click and drag) to select a region of the spectrum, then use the + and - buttons (buttons adjacent to the marquee or the ones in the control panel) to add or remove a fitting region. The baseline is determined by a leastsquares fit of the chosen function to data that fall within the selected regions.

The tangent baseline (mask tab) will attempt to find a common tangent to two cubic functions. You must have two regions selected for fitting. The fit will be successful only if the selected regions can each be fit nicely with a cubic function, and if the two cubics have a common tangent.

The gauss3 and lor3 baselines fit a Gaussian (Gauss1D) or Lorentzian (lor) function with the first coefficient set to the baseline reference value, meaning that these are peak functions with no vertical offset.

A user-defined fit function can be added by editing the last three functions in the procedure file. Your function will be available in the baseline type popups in the masked-region and auto tabs.

Manual Fitting

The manual baselines allow you to create a baseline by positioning the cursors. The step function is calculated as y = (y2+y1)/2 + (y2-y1)/2*tanh((x-(x1+x2)/2)*7/(x2-x1)), where (x1, y1) and (x2, y2) are the cursor positions.

Auto Fitting

The arc hull type baseline adds a circular arc with adjustable depth to the spectrum (ie., the spectrum is bent), and the lower portion of a convex hull is calculated for the resultant spectrum. The baseline consists of the sum of the arc and the convex hull. Adjust arc depth using the SetVariable control to find an optimal value. Arc depth increments by 10% of its value and has y-axis units. Setting arc depth to zero creates a convex hull (a.k.a. 'rubber band') type baseline. For X-Y data, the X wave needs to be monatonic for Arc Hull calculation. Note that baseline segments can be convex or concave depending on the sign of the depth variable. The ArcHull algorithm is not iterative.

Spline: baseline is a cubic spline using the convex hull as nodes. When arc depth is non-zero the nodes are more like a subset of alphashape vertices. Adjust Smooth and Depth parameters to produce an optimal number of nodes.

Iterative: the function selected in the Fit Func popup is fitted iteratively. Any fit point with a negative residual (positive if the negative peaks checkbox is selected) is replaced by the corresponding point from the input data after each iteration, thus eliminating points with a positive residual, so ultimately eliminating peaks from the fit. The fit output is used as the input for the next iteration. The algorithm is similar to that described by Lieber C.A. and Mahadevan-Jansen A. (2003) Applied Spectroscopy 57: 1363-1367. For the first 10 iterations only points with a residual above the 50th percentile are eliminated.

Pre-smoothing: the baseline is calculated for a smoothed copy of the spectrum, then subtracted from the original. With the right choice of smoothing factor, the baseline will pass through spectral noise rather than underlying the noise. Note that the baseline-subtracted output is not smoothed with respect to the original data, the smoothing is used only for calculating the baseline.

Negative Peaks: subtract the top part of the convex hull, or fit to the top of the spectrum. Useful for dealing with downward facing peaks, or for when you have a reverse-scaled vertical axis. The negative peaks setting is also adjustable in the settings panel, and affects the guesses for y positions of spline nodes.

Use Convex Hull at Start: In the first iteration, the baseline function is fit to the lower (upper for negative peaks) part of a convex hull of the input data. For some spectra this reduces the influence of peaks on the iterative baseline output.

Spline Baselines

When 'edit mode' is selected the nodes can be moved. The spline updates as the nodes are repositioned. In edit mode you can add a new node at any position on the graph by positioning the mouse cursor and clicking while holding down the control key. Nodes may be deleted by clicking them with the option key held down. Clicking the (moveable) button in the graph window will toggle between node editing mode and 'normal' mode where you can interact with the graph as usual. Cubic and smoothing splines are calculated using Igor's Interpolate2 operation. Cubic splines are calculated with 'natural' ends. When a spline type baseline is subtracted the node positions are saved in a 2D wave and can be later reloaded. Selecting a trace will reposition the nodes by adjusting their vertical positions. Clicking the node reset button resets horizontal and vertical node positions. The default algorithm guesses node positions by first fitting an auto-type baseline. Clicking the reset button with the shift key held down will position the nodes on the trace rather than guessing their positions. The horizontal positions are not changed unless there are insufficient nodes within the x-range of the new trace.

Installing this package

  • Consider using the IgorExchange Installer to install Baselines.ipf in the User Procedures folder.
  • The Procedure Loader can be used to load or unload files stored in the User Procedures folder.

Project Details

Current Project Release

Baselines IGOR.7.00.x-4.00

Release File: Baselines400.zip
Version: IGOR.7.00.x-4.00
Version Date: Sat, 07/03/2021 - 09:41 am
Version Major: 4
Version Patch Level: 0
OS Compatibility: Windows Mac-Intel
Release Notes:

Version 4 merges the former ArcHull and Baseline Spline Fit projects with this project.

View All Releases

If anyone is watching this space and would like to test a pre-release version of this project, let me know. It's a major rewrite, and there will likely be bugs. Once the worst of the bugs are shaken out I will release as version 4.

Forum

Support

Gallery

Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More