Skip to contents

Estimates the noise level for each spectrum in a 1D NMR dataset by analyzing a signal-free region. Useful for quality control (QC) before or after spectral processing such as normalization or baseline correction.

Usage

noise.est(X, ppm, where = c(14.6, 14.7))

Arguments

X

Numeric matrix. NMR data with spectra represented in rows (samples x chemical shift bins).

ppm

Numeric vector. Chemical shift positions in ppm. Must match the number of columns in X.

where

Numeric vector of length 2. Specifies the ppm range to use for noise estimation. This range should be free of peaks (i.e., no expected metabolite signal). Default is c(14.6, 14.7).

Value

Numeric vector of noise levels, one value per spectrum (length equals nrow(X)).

Details

Noise is estimated after baseline correction using asymmetric least squares smoothing (via asysm). The output is based on the 95th percentile of the signal in the specified region and assumes a minimum of 50 points in that region. If fewer points are available, the function stops.

Note

Choose the where region carefully based on acquisition setup. Signal-free regions are typically at the high or low ppm ends (e.g., >10 ppm or <0 ppm).

Examples

data(covid_raw)
X <- covid_raw$X
ppm <- covid_raw$ppm
noise_vals <- noise.est(X, ppm, where = c(8.8, 8.9))
hist(noise_vals, main = "Estimated Noise", xlab = "Noise Level")