Learn R Programming

specmine (version 4.0.0)

raman_find_peaks: Find peaks in Raman or SERS spectra

Description

Finds local maxima in one-dimensional spectra according to peak properties such as height, threshold, distance, prominence, width and plateau size.

Usage

raman_find_peaks(
  x,
  height = NULL,
  threshold = NULL,
  distance = NULL,
  prominence = NULL,
  width = NULL,
  plateau_size = NULL,
  wlen = NULL,
  rel_height = 0.5
)

Value

A list with two elements:

peaks

Integer vector of one-based indices of peaks in x satisfying the requested conditions.

properties

Data frame containing properties of the returned peaks, including peak_index and peak_height. Additional columns are included when the respective properties are calculated.

Arguments

x

Numeric vector containing the signal intensity values.

height

Numeric value or length-two numeric vector specifying the required height of peaks. A single value is interpreted as a minimum height. A vector c(min, max) defines a closed interval.

threshold

Numeric value or length-two numeric vector specifying the required vertical distance to neighbouring samples.

distance

Positive integer specifying the minimum horizontal distance, in samples, between neighbouring peaks.

prominence

Numeric value or length-two numeric vector specifying the required prominence of peaks.

width

Numeric value or length-two numeric vector specifying the required width of peaks, in samples.

plateau_size

Numeric value or length-two numeric vector specifying the required size of the flat top of peaks, in samples.

wlen

Optional positive integer. It defines the maximum number of samples inspected on each side of a peak when calculating prominence.

rel_height

Numeric value between zero and one used for peak-width calculations.

Details

The interface and peak-property terminology are inspired by scipy.signal.find_peaks(). Prominence and width calculations use an R implementation tailored to Raman/SERS spectra and are not intended to reproduce SciPy results exactly.

Examples

Run this code
x = c(0, 1, 0, 2, 1, 0, 3, 2, 0, 4, 1)

res = raman_find_peaks(
  x,
  height = 1,
  distance = 2
)

res$peaks
res$properties

Run the code above in your browser using DataLab