Split signals into consecutive, overlapping segments.

segmentation(
  signals,
  sRates,
  segments_size = 10,
  step = 1,
  padding = 0,
  resample = max(sRates),
  return_index = FALSE
)

Arguments

signals

A list of numeric vectors containing signals, or a single vector containing one signal.

sRates

A vector or list of integer values of the signals sample rates.

segments_size

The size of segments, in seconds.

step

The step between segments, in seconds.

padding

umber of previous and next epochs to pad the current epoch with. Defaults to 0.

resample

The sample rate to resample all signals. Defaults to to the max of the provided sample rates.

return_index

If TRUE, the index of segments is returned instead of the segments.

Value

A matrix of segments.

References

Choi SH, Yoon H, Kim HS, et al. Real-time apnea-hypopnea event detection during sleep by convolutional neural networks. Computers in Biology and Medicine. 2018;100:123-131.

Examples

computed_segments = segmentation(
  signals = list(c(sin(1:1000)),c(cos(1:1000))),
  sRates = c(1, 1),
  segments_size = 5,
  resample = 1)
dim(computed_segments)
#> [1] 995   5   2
plot(computed_segments[1,,1], type = "l")

plot(computed_segments[2,,1], type = "l")