Skip to contents

step_measure_baseline_morph() creates a specification of a recipe step that applies iterative morphological baseline correction using erosion and dilation operations.

Usage

step_measure_baseline_morph(
  recipe,
  measures = NULL,
  half_window = 50L,
  iterations = 10L,
  role = NA,
  trained = FALSE,
  skip = FALSE,
  id = recipes::rand_id("measure_baseline_morph")
)

Arguments

recipe

A recipe object.

measures

An optional character vector of measure column names.

half_window

Half-window size for the structuring element. Default is 50.

iterations

Number of erosion-dilation iterations. Default is 10.

role

Not used.

trained

Logical indicating if the step has been trained.

skip

Logical. Should the step be skipped when baking?

id

Unique step identifier.

Value

An updated recipe with the new step added.

Details

This method applies iterative morphological operations (erosion followed by dilation) to estimate the baseline. Multiple iterations can help refine the baseline estimate for complex signals.

Examples

library(recipes)

rec <- recipe(water + fat + protein ~ ., data = meats_long) |>
  update_role(id, new_role = "id") |>
  step_measure_input_long(transmittance, location = vars(channel)) |>
  step_measure_baseline_morph(half_window = 30, iterations = 5) |>
  prep()