BEADS baseline correction algorithm for (chemical) chromatograms - C++ implementation derived from X. Ning and L. Duval
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Baseline correction algorithm for correcting (chemical) chromatograms. This is a C++ implementation of the BEADS algorithm, the original paper and Matlab implementation are from from X. Ning, I. Selesnick and L. Duval This implementation uses the EIGEN library for linear algebra. This implementation uses sparse matrices to reduce the computational complexity of BEADS.

Code Example

A minimum working example is provided in Beadstest.cpp:
// y: Noisy observation
// d: Filter order (d = 1 or 2)
// fc: Filter cut-off frequency (cycles/sample) (0 < fc < 0.5)
// r: Asymmetry ratio
// lam0, lam1, lam2: Regularization parameters
std::vector<std::vector> AB = myBaseline.beads(y, d, fc, r, lam0, lam1, lam2);

where is the baseline corrected chromatogram is the baseline.


Hardly any C++ baseline correction implementation exists in the public domain. Hopefully this will bring some change to that.


  1. Download EIGEN from
  2. Extract the zip file
  3. Copy the eigen-eigen-xxx/Eigen folder to your project working directory
  4. Download the files from this github page through git clone or http download
  5. Past project content in working directory
  6. Modify SparseQR.h of EIGEN line 314: OUTCOMMENT "ord(matCpy, m_perm_c);" (This is a bug in EIGEN, assert is triggered without this modification)
  7. Compile should work now

API Reference

There is no API at the moment, this is just a bare-metal implementation. Don't expect great code performance from this.
A chromatogram with 4000 data points takes roughly 2.5s to complete baseline correction on a intel i7-2630HQ.


Compile Beadstest.cpp using VS 2017 64 bit release. A small section outcommented code containing ofstream statements can write the corrected chromatogram to a text file.


Created by T. Vijverberg - 01-01-2018 @Radboud University
Contact me at tgmvijverberg at online dot nl


BEADS baseline correction is developed by X. Ning, I. Selesnick and L. Duval. This C++ implementation is based on their MATLAB code at
Ownership of the original BEADS function resides with the authors mentioned, this implementation will be removed at their request.