Skip to contents

Bins the per-spectrum signal vector left-to-right into chunks of maxCombine chemical-shift columns and returns the per-bin sums as a feature matrix. Columns whose chemical-shift falls inside any igrs interval are removed before binning.

Accepts three input types:

  • spectra: uses x[[i]]$si directly.

  • decons2: uses x[[i]]$sit$sup (smoothed reconstruction).

  • aligns: builds a sparse vector from lcpar$pcial / lcpar$A * pi, then bins.

Suitable as the feat_fun argument of fit_mdm() for binning baselines.

Usage

bin(x, maxCombine = 128, igrs = list(), peakPos = NULL, ...)

Arguments

x

A spectra, decons2 or aligns object.

maxCombine

Bin width in chemical-shift columns.

igrs

List of two-element ppm intervals to ignore.

peakPos

Optional integer column indices for predict mode; when NULL the non-zero bins are kept and attached as attr(., "peakPos").

...

Ignored (protocol compatibility with peak_mat).

Value

A numeric matrix with one row per spectrum and one column per bin.

Examples

decons <- deconvolute(sim[1:3], sfr=c(3.55, 3.35), verbose=FALSE)
X <- bin(decons, maxCombine=50)