Skip to content

feat: support whittaker, cubic, and bernstein baseline algorithms#4008

Draft
hamed-musallam wants to merge 3 commits intomainfrom
support-new-baseline-methods
Draft

feat: support whittaker, cubic, and bernstein baseline algorithms#4008
hamed-musallam wants to merge 3 commits intomainfrom
support-new-baseline-methods

Conversation

@hamed-musallam
Copy link
Member

  • whittaker options: lambda, scale, maxIterations
  • cubic: no options
  • bernstein options: maxIterations, tolerance, factorStd, learningRate, minWeight

close #3969

- whittaker options: lambda, scale, maxIterations
- cubic: no options
- bernstein options: maxIterations, tolerance, factorStd, learningRate, minWeight

close  #3969
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 25, 2026

Deploying nmrium with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2ae875b
Status: ✅  Deploy successful!
Preview URL: https://76eb700e.nmrium.pages.dev
Branch Preview URL: https://support-new-baseline-methods.nmrium.pages.dev

View logs

@hamed-musallam
Copy link
Member Author

@lpatiny @jobo322

The new baseline correction filter options do not have enough room in the NMRium header. Which options are important to stay there? , FYI, all options will exist in the processing panel as well.

image image

@jobo322
The 'bernstein' crashes when tested. Could you have a look?

image

@hamed-musallam
Copy link
Member Author

@jobo322

Are there any constraints on the min and max values for each option?

@targos
Copy link
Member

targos commented Feb 27, 2026

@hamed-musallam

The 'bernstein' crashes when tested. Could you have a look?

degree is a mandatory option in the Bernstein algorithm:
CleanShot 2026-02-27 at 10 20 27

@jobo322
Copy link
Member

jobo322 commented Mar 10, 2026

CubicSpline(data, options)
Robust iterative cubic spline baseline correction that uses anchor points and iterative clipping to avoid pulling the baseline up through peaks.

Options:
zones (array): Array of {from, to} ranges defining baseline regions to prioritize for anchor selection.

header options:
numAnchors (number, default: Math.ceil(signal.length / 500), clamped to [8, 512]): Number of uniformly-spaced anchor points to seed the algorithm.
maxIterations (number, default: 10): Maximum number of clipping iterations.
noiseThreshold (number, default: 1.0): Multiplier for noise level to determine clipping threshold. Smaller values are more aggressive.

Only right panel:
tolerance (number, default: 1e-6): Convergence tolerance as fraction of noise level.
noiseLevel (number, optional): Override automatic noise estimation with a fixed value.
noisePercentile (number, default: 10): Percentile used for automatic noise estimation from signal differences.

@jobo322
Copy link
Member

jobo322 commented Mar 10, 2026

Bernstein(data, degree, options)
Iterative baseline correction using Bernstein polynomials with adaptive weighting.

Options:

zones (array): Array of {from, to} ranges defining baseline regions.

header options:
degree (number, default: 3): max value should be 25 a min value is 3 I guess
factorStd (number, default: 3): Factor to scale residuals for weight calculation.
learningRate (number, default: 0.3): Learning rate for iterative weight updates.
maxIterations (number, default: 100): Maximum number of iterations.

Only right panel:
tolerance (number, default: 1e-6): Convergence tolerance for RMS change.
logger (Logger, optional): Logger instance for debug information.

@jobo322
Copy link
Member

jobo322 commented Mar 10, 2026

  • Whittaker(data, options)
    Baseline correction using Whittaker smoothing with iterative reweighting.

Options:

zones (array): Array of {from, to} ranges defining baseline regions.

header options:
learningRate (number, default: 0.2): Weight update factor relative to standard deviation.
lambda (number, default: 2000): Smoothing parameter for the Whittaker smoother.
maxIterations (number, default: 20): Maximum number of iterations.

Only right panel:
tolerance (number, default: 1e-3): Convergence tolerance for baseline change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add support for 3 new baseline methods available in baseline filter

3 participants