Skip to contents

For converting continuous time into discrete time series for functions that plot by sweeps or calculate events by stimuli within sweeps.

Usage

standardize_event_time(df, sweep_duration, time_ref = "rec_time_ms")

Arguments

df

Data Frame or Tibble with a sweep column

sweep_duration

Numeric, sweep/trial length in seconds.

time_ref

Character, event time reference point column name. Defaults to "rec_time_ms".

Value

Data Frame or Tibble with transformed time column, time_ms.

Examples

simple_df <- data.frame(
  rec_time_ms = c(400, 4400),
  sweep = ordered(c(1, 5), levels = c(1:5))
)

standardize_event_time(
  df = simple_df,
  sweep_duration = 1,
  time_ref = "rec_time_ms"
)
#>   rec_time_ms sweep time_ms
#> 1         400     1     400
#> 2        4400     5     400
if (FALSE) {
df <- standardize_event_time(
  df,
  matools_env$sweep_duration_sec,
  "rec_time_ms"
)
}