msc: Multiplicative Signal Correction

View source: R/msc.R

mscR Documentation

Multiplicative Signal Correction

Description

This function performs multiplicative scatter/signal correction (MSC) on an input data of spectra. It corrects for multiplicative and additive effects in the spectral data by regressing against a reference spectrum.

Usage

msc(
  x,
  xref = NULL,
  drop_offset = TRUE,
  robust = TRUE,
  window = NULL,
  drop_na = TRUE,
  drop.offset = deprecated(),
  drop.na = deprecated()
)

Arguments

x

A numeric matrix or data frame containing the input spectra. Each row represents a sample, and each column represents a spectral variable.

xref

An optional numeric vector representing the reference spectrum. If NULL (default), the mean or median of x is used as the reference.

drop_offset

A logical value indicating whether the additive offset a_i should be removed from the spectra (default is TRUE). If FALSE, only the multiplicative effect is corrected: \textbf{x}_i / b_i.

robust

A logical value indicating whether the median (TRUE, default) or the mean (FALSE) of x is used as xref.

window

An optional list of numeric vectors specifying the column indices of spectral windows. If provided, MSC is performed separately for each window.

drop_na

A logical value indicating whether to remove spectra (rows) containing missing values. If TRUE (the default), such rows are removed.

drop.offset, drop.na

[Deprecated] Use drop_offset and drop_na.

Details

Each spectrum \textbf{x}_i is regressed against the reference spectrum, \textbf{x}_i = a_i + b_i \textbf{x}_{ref} + \textbf{e}_i, and corrected as (\textbf{x}_i - a_i) / b_i. When window is given, the regression and correction are carried out separately in each spectral window (piecewise MSC); variables outside all windows are left unchanged.

To correct new spectra consistently, pass the returned reference as xref.

Value

A list with the following components:

correction

The corrected spectra.

offset

The intercepts/offsets a_i (a matrix with one column per window when window is given).

slope

The multiplicative scatter factors/slopes b_i (a matrix with one column per window when window is given).

reference

The reference spectrum used.

Author(s)

Christian L. Goueguel

Examples

data(forageLIBS)
spectra <- forageLIBS[-(1:14)]  # the spectral channels
res <- msc(spectra)
res$correction[1:3, 1:4]

specProc documentation built on Nov. 20, 2026, 5:11 p.m.