CorrectBaseLine

Declaration: CorrectBaseLine (CorrectionType: TBLCorrType; SpecGroup, TimeSlot: integer; Pivots: TDoubleArray; Neighborhood, POrder, Iterations, Smoothing: integer; Stiffness, Asymmetry: double; NegPeaks, OmitCO2Pks, Feedback: boolean): integer;
Corrects the baseline of all pixels at the time specified by the parameter TimeSlot. The parameter CorrectionType determines the type of the baseline correction (valid values: bcPolynomial, bcPenSplines, bcLieber, bcEilers), the SpecGroup parameter specifies the spectrum to be corrected (valid values: 1..4, see spectral groups).

Depending on the CorrectionType various additional parameters are required, all unneeded parameters are ignored:

type of correction parameters
bcPolynomial
  • The dynamic array Pivots specifies the wavelengths of the pivot points to be used for the correction.
  • The parameter Neighborhood defines the number of data points around the pivot points to be averaged for determining the intensity of the pivots.
  • The POrder parameter controls the order of the polynomial used as a baseline.
bcPenSplines
  • The dynamic array Pivots specifies the wavelengths of the pivot points to be used for the correction.
  • The parameter Neighborhood defines the number of data points around the pivot points to be averaged for determining the intensity of the pivots.
  • The Stiffness parameter controls the stiffness of the spline.
bcLieber
  • The Iterations parameter specifies the number of iterations used by the Lieber algorithm. Typically the Iterations parameter should be set to values between 10 und 30.
  • The POrder parameter controls the order of the polynomial used as a baseline.
  • The parameter OmitCO2Pks controls whether the CO2 region in infrared spectra is included or omitted from the baseline correction.
bcEilers
  • The Iterations parameter specifies the number of iterations used by the Eilers algorithm. Please note that the number of iterations should not exceed a value of 8 (higher values slow down the calculations without improving the results).
  • The Smoothness parameter determines the flexibility of the calculated baseline. The lower the Smoothness parameter the more the baseline adapts to the data. The optimum value of this parameter depends on the data, typical value vary between 100 and 100000.
  • The Asymmetry parameter determines the weighting of the low and the high data values. The lower the Asymmetry value the more the baseline is shifted towards the lowest intensities.
  • Set the NegPeaks parameter to true if the peaks of the spectrum are negative.
  • The parameter OmitCO2Pks controls whether the CO2 region in infrared spectra is included or omitted from the baseline correction.
Finally the Feedback parameter determines whether a progress bar indicates the progress of the calculations. Please note that unless the script progress bar is already visible you have to make it visible before calling CorrectBaseLine, otherwise the feedback will not be displayed. You can activate the script progress bar by calling the function ScriptBar(0).

The function returns the following error codes:

 0 ... everything is OK
-1 ... invalid group index
-2 ... no. of pivots is too low for the selected polynomial order
-3 ... pivots are not within group range
-4 ... TimeSlot is out of range
-5 ... invalid range of layers (not within specified group)
-6 ... selected range of layers is too small (spectrum must contain at least 5 data points)
-7 ... calculation aborted by the user