Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Asymmetric Least Squares (AsLS) Baseline Correction

Magnetic Resonance Spectroscopy (MRS) signals often ride on top of a broad, rolling baseline. This distortion is typically caused by macromolecules with extremely short T2T_2 relaxation times (creating very broad frequency-domain peaks), acoustic ringing, or incomplete water suppression.

To accurately quantify the sharp, narrow metabolite peaks, this baseline must be mathematically isolated and removed.

The Mathematics of AsLS

In xmris, we use the Asymmetric Least Squares (AsLS) algorithm introduced by Eilers & Boelens (2005). Unlike simple polynomial fitting, AsLS does not require the user to manually define “signal-free” noise regions. Instead, it balances two competing goals: minimizing the distance between the experimental data and the baseline, and maximizing the smoothness of the baseline itself.

It minimizes the following penalized least-squares objective function:

S=∑iwi(yi−zi)2+λ∑i(Δ2zi)2S = \sum_i w_i (y_i - z_i)^2 + \lambda \sum_i (\Delta^2 z_i)^2

Where:

The asymmetry is governed by a parameter pp (typically between 0.001 and 0.05). The algorithm iteratively updates the weights: if a data point is above the baseline (a peak), it is given a tiny weight (pp). If it is below the baseline, it is given a large weight (1−p1-p). This forces the curve to aggressively hug the bottom of the signal, naturally slipping under the narrow absorption peaks.

1. Generating Synthetic Data

Let’s simulate a complex FID with two sharp metabolite peaks and one massive, heavily damped macromolecular peak acting as our rolling baseline.

2. Applying AsLS via the xmris Accessor

Because xmris baseline correction strictly operates on frequency-domain absorption peaks, we must first Fourier transform the signal using the to_spectrum() accessor method. Once in the frequency domain, we can seamlessly chain our baseline correction.

Visualizing the Results

Let’s look at the original real spectrum, the isolated baseline, and the final corrected spectrum.

<Figure size 1000x500 with 1 Axes>
References
  1. Eilers, P. H., & Boelens, H. F. (2005). Baseline correction with asymmetric least squares smoothing (Report No. 1; Vol. 1, p. 5). Leiden University Medical Centre.