EMSC corrects multiplicative scatter effects and additive baseline variations in spectral data. For each row, the spectrum is modeled as a scaled reference spectrum combined with a polynomial baseline. The fitted baseline is subtracted, and the result is divided by the fitted reference coefficient.
The EMSC app lets users apply the method and choose the reference and polynomial order, inspect the correction, apply it to all rows, and export the result.
addpath('path/to/EMSC')
EMSC_test
app = EMSC(spectra);The constructor also accepts a struct:
input.data = spectra;
input.wavelength = wavelength;
input.reference = reference; % optional custom reference
app = EMSC(input);The empty constructor opens the data selector. If no x-axis is supplied, channel numbers are used.
| Purpose | Accepted values |
|---|---|
| Spectra | Numeric matrix, or data/spectra in a struct |
| X-axis | wavelength/wavelengths, optional |
| Custom reference | reference/customReference, optional |
Values must be real and finite. The x-axis must have one value per channel and must increase or decrease without repeats. A reference must have one value per channel. Without a custom reference, the app uses the mean or median spectrum.
For each spectrum y, the app compares it with a reference spectrum r and
fits:
y = b*r + c0 + c1*x + ... + cp*x^p + residual
The additive and polynomial terms describe the baseline and the coefficient
b describes the overall scale of the sample. The corrected result is:
(y - (c0 + c1*x + ... + cp*x^p)) / b
The x-axis is scaled before the polynomial is fitted. The calculation uses a stable matrix solve and rejects designs that do not contain enough independent information, or have a zero or very small multiplicative coefficient.
| Parameter | Values | Default |
|---|---|---|
| Polynomial order | 0 to 6 | 2 |
| Reference | Mean, median, or custom | Mean |
After Apply, app.getData() returns:
dataandspectra: corrected matrixwavelengthandwavelengths: x-axis valuesreference: reference used for the correctionmultiplicativeCoefficientsandnuisanceCoefficientsmetadata: method, parameters, source, rank, and condition estimate
The preview shows one selected sample, and the sample selector can be used to inspect other rows. Result plotting can still show the mean or multiple corrected spectra. This does not change the full exported matrix. Export checks MATLAB variable names and asks before overwriting an existing variable.
EMSC_test.m creates spectra, wavelength, and reference with known
scatter and polynomial baseline effects:
EMSC_test
app = EMSC(spectra);Run Code Analyzer from this folder:
checkcode('EMSC.m', '-id')
checkcode('business_logic/@EMSCCorrector/EMSCCorrector.m', '-id')
checkcode('business_logic/@EMSCDataValidator/EMSCDataValidator.m', '-id')MATLAB R2022a or later is required. No additional toolbox is needed.
Martens, H. and Stark, E. (1991). Extended multiplicative signal correction and spectral interference subtraction. Journal of Pharmaceutical and Biomedical Analysis, 9(8), 625-635.
License: MIT