filter_data: Run a filter on the data to smooth it out.

View source: R/make_smoothed_data.R

filter_dataR Documentation

Run a filter on the data to smooth it out.

Description

filter_data allows three different options for filtering, a butterworth lowpass filter, a hanning filter, or a median filter. You can also set the degree of this filter; we recommend a default of 11. This filters on one pupil, it can be re-run on a second pupil if needed. Lowpass makes use of the butterworth filter and filtfilt from package signal, median makes use of runmed.

Usage

filter_data(
  data,
  pupil,
  filter = c("median", "hanning", "lowpass"),
  degree = 11
)

Arguments

data

a PupillometryR dataframe

pupil

column name for pupil data

filter

option for filtering the data

degree

filter degree

Value

filtered pupil data

Examples

Sdata <- make_pupillometryr_data(data = pupil_data,
subject = ID,
trial = Trial,
time = Time,
condition = Type)
mean_data <- calculate_mean_pupil_size(data = Sdata,
pupil1 = RPupil, pupil2 = LPupil)
filtered_data <- filter_data(data = mean_data,
pupil = mean_pupil,
filter = 'hanning',
degree = 11)

samhforbes/PupillometryR documentation built on Sept. 25, 2023, 10:19 a.m.