Polynomial baseline correction
This section describes various options for correcting a curved baseline.
Sometimes, only a linear correction is required – see options.
In addition to linear and polynomial corrections, backwards linear prediction, which corrects distortions of the first few points in an FID, can be used to flatten the baseline. The baseline can also be corrected from inside the integration routine, using the subcommand B. See tips for correcting really bad baselines.
This command enters a subroutine which fits the baseline with a 5th order polynomial. As a starting point, NUTS selects a set of baseline points as follows: The spectrum is divided into 64 regions and those regions which contain just noise are selected. The data points within each selected region are averaged to give one point for input into the polynomial fit. The 64 selected regions are displayed in inverse video, usually red. The decision as to what constitutes noise is based on the RM multiplier value (same parameter as is used for peak picking). If the user finds that the regions being selected as noise are not appropriate, the RM value may be changed. The user can also select or un-select individual regions using the mouse. Place the cursor on a region of the baseline to be selected and click once with the left mouse button. This is a toggle process, so clicking on a selected region will un-select it. The S subcommand selects all regions, and the user can then un-select regions containing peaks.
By default, the FB routine divides the spectrum (or expanded region) into 64 regions (or fewer, if very few data points are displayed). It is possible to override this, and specify the number of points in each region. This can be used to define narrower baseline regions, useful when the spectrum is very crowded, with only small segments of baseline between peaks. This is done in the non-2-letter command mode. The FB command will accept either one argument, or 2 arguments. The first argument specifies the number of data points in each region. If there is a second argument, it is a multiplier for the RM parameter, used in the automatic determination of which regions contain peaks, and which are baseline.
If an expanded region is displayed at the time the FB subroutine is entered, the fit will be confined to only that part of the spectrum. This allows a spectrum with very a distorted baseline to be corrected in sections. Be sure to execute a Ctrl-F first if the fit should be to the entire spectrum.
For historical reasons, 2 options are available for calculating the best fit polynomial: Simplex and Least Squares. Results from the 2 methods appear to be indistinguishable, and the least squares method is more than 10 times faster. However, sometimes the least squares method fails to converge, and simplex can be used instead.
To initiate the fitting process, type C for Simplex calculation or L for Least Squares, both of which are available from the Edit menu. (Note that if Enter is typed before initiating a fit, the routine is exited without altering the baseline.) The equation used is a 7th order polynomial whose coefficients are adjusted to fit the spectrum. As the Simplex optimization proceeds, the results of each cycle are displayed. The Error is the square of the difference between the calculated curve and the curve formed by the set of input points. This is displayed so that the user can monitor the process as the Error function converges to a minimum. The iteration can be stopped by typing Q. The coefficients of the calculated polynomial are printed on the screen at the end of the fitting operation.
The calculated polynomial can be displayed by selecting Draw Polynomial from the Display menu or by typing P. The region selection can be changed and the fit recalculated by repeating the fit (C or L command).
When satisfied with the calculated baseline, typing Enter will apply the correction and exit the FB subroutine. To abort the process and exit without altering the baseline, choose Quit from the file menu or type X.
If the correction is made on a part of the spectrum, rather than the entire spectrum, there arises the question of what should be done to the rest of the spectrum. If no adjustment is made to the data outside the displayed region, discontinuities may be introduced at the ends of the corrected region. A logical way to address this is to apply a DC correction to the adjacent regions to avoid discontinuities. However, that would result in changing the baseline, and therefore to the integrals, in parts of the spectrum other than the selected region. The best choice in this case depends on the characteristics of the spectrum and the information being extracted from it, so NUTS allows the user to choose how this situation should be handled.
The option to keep the baseline continuous, and avoid discontinuities, can be set in the nuts.ini file, with the following entry:
CONTINUOUS_BASELINE = TRUE
To prevent any changes to the spectrum outside of the displayed region, use the following entry in the nuts.ini file:
CONTINUOUS_BASELINE = FALSE
Changes to the nuts.ini file do not become effective until NUTS is restarted. To change this option while NUTS is running, the following non-2-letter commands can be used:
FB -c on
enables the DC adjustment of the baseline to eliminate discontinuities.
FB -c off
disables the DC adjustment of baseline, so that regions outside the current display region are unchanged.
These settings apply to both FB and FX.
It is possible to save a "mask" describing which regions of a spectrum should be used in calculating a polynomial baseline correction. This would be used for automated processing of very similar spectra. The user selects the regions in the usual manner, then saves those selections to a text file with the sub-command M or by selecting File/Save Mask on the menu while in the FB routine. The mask is then applied with the FX command.
If FB is used in a Link or macro, the automatically selected regions are used, the fit is calculated and the resulting correction applied, all without user interaction. Normally, the type of fit used in this automated mode is polynomial fit using least squares. However, the user has the option of changing this to either Simplex polynomial fit or Fudge mode (equivalent to F subcommand). This is set in the nuts.ini file.
To perform polynomial baseline corrections in arrayed mode, use the FX command. In arrayed mode, the FB command acts only on the displayed slice. This is useful for correcting baselines of selected slices.
FB also has the option of correcting the baseline by forcing each region to be flat by removing DC and tilt separately for each region. This is done with the subcommand F (stands for "fudge").
This is useful when the baseline distortions are of too high order to be corrected with a polynomial. See example.
Show me how to use FB.
- C Calculate Simplex fit to 5th order polynomial
L Perform Least squares fit to 5th order polynomial
F Fudge baseline by correcting DC and tilt for each region separately
3 Linear spline baseline correction
A Apply default correction and exit FB
M Save selected baseline regions as a "mask" to a text file
R Read a previously saved "mask" file
P Draw polynomial
Q Quit Simplex optimization
S Select all regions
U Un-select all regions
X Exit without applying correction
<ENTER> apply correction and exit
Polynomial baseline correction that works in arrayed mode.
For 1D spectra or when not in arrayed mode, FX is equivalent to QB. It applies a polynomial correction to the displayed slice using default parameters.
When applied to a 2D spectrum while in arrayed mode, FX will execute a polynomial correction independently for each slice.
When in the non-2-letter command mode, the FX command accepts an argument which is the file name of a "mask" file to use when calculating the polynomial fit. The mask must first have been created in the FB subroutine. The mask must be for the same 1D data size as the current data. If the mask was created while in a zoomed display mode, this command will use the same display region for the polynomial fit and NUTS will end up displaying that zoomed region when the command completes. The mask can be applied to 1D or 2D data.
Why use a mask? More reproducible baseline correction can be obtained, useful in defining a protocol for processing QC data, to insure that the same conditions are used each time. In the case of 2D data, the automatic selection of baseline regions can result in poor choice of baseline regions for some slices, causing serious baseline distortion. The recommended procedure is to examine slices using View (VW) to determine which regions represent "good" baseline throughout the dataset, and then use FB to select those regions and create a mask. The mask is then applied with
fx maskfile <ENTER>
where maskfile is the file name supplied when the mask was saved to disk.
By default, the "fx mask" command performs a polynomial fit. This can be invoked with any of the following 3 equivalent commands:
FX –p mask
FX –1 mask
Optionally, linear baseline “fudge” can be performed instead, identical to the FB routine’s F sub-command, with either of the following equivalent commands:
FX –f mask
FX –2 mask
A third option is linear spline correction, identical to the FB routine’s 3 sub-command, with either of the following equivalent commands:
FX –s mask
FX –3 mask
When executed as a 2-letter command, this performs a least squares polynomial baseline correction, just as would be done within the FB subroutine. There is no user interaction with this command.
In the non-2-letter command mode, QB can take optional parameters and performs a different kind of correction. If no parameters are given, then the routine automatically selects regions and corrects the baseline by a least squares fifth order polynomial. If other parameters are supplied, QB performs a different type of baseline correction, involving "deducing" a baseline much as the user might do "by eye", and then subtracting that baseline from the spectrum. To do this, the spectrum is divided into segments, and each segment is compared to the rms noise level to determine if it contains peaks.
Use of QB for this type of correction takes up to 3 parameters, as follows:
The first parameter specifies the number of data points for each segment into which the spectrum is divided. (In the default QB and FB corrections, the spectrum is divided into 64 segments). A multiple of rms noise used to distinguish peaks from noise; by default, this is the value of the RM parameter, set in the peak picking routines.
If a second argument is entered, it is used as the multiple of rms noise, instead of using RM, to distinguish peaks from noise.
The only valid value for a third argument is “show”, which displays the "deduced" baseline. This action replaces the current data set with the deduced baseline.
This correction is illustrated here.
Last updated: 1/26/05.