Learn R Programming

specmine (version 4.0.0)

raman_despike: Remove spikes from Raman or SERS spectra

Description

Detects and replaces intensity spikes in Raman or surface-enhanced Raman spectroscopy (SERS) spectra using modified Z-scores based on the median absolute deviation (MAD).

Usage

raman_despike(dataset, ma = 10, threshold = 7)

Value

A dataset equivalent to dataset, with despiked spectra stored in dataset$data. Information about the operation is stored in

dataset$despike.

Arguments

dataset

A dataset list containing a numeric matrix in dataset$data, with wavenumbers in rows and samples in columns.

ma

Non-negative integer specifying the number of neighbouring points considered on each side of a detected spike.

threshold

Positive finite numeric value specifying the modified Z-score threshold used to identify spikes.

Details

The dataset must contain wavenumbers in rows and samples in columns. Each sample spectrum is processed independently. Detected spikes are replaced by the mean intensity of neighbouring non-spike points.

Examples

Run this code
dataset = list(
  data = matrix(
    c(
      1, 1.1, 1.2, 20, 1.1, 1.2,
      2, 2.1, 2.2, 30, 2.1, 2.2
    ),
    nrow = 6,
    ncol = 2,
    dimnames = list(
      paste0("wavenumber", 1:6),
      paste0("sample", 1:2)
    )
  )
)

despiked = raman_despike(
  dataset,
  ma = 1,
  threshold = 3
)

despiked$despike$n_spikes

Run the code above in your browser using DataLab