View source: R/pipeline-downsample.R
downsample | R Documentation |
This function downsamples pupillometry data by applying an anti-aliasing filter before decimation. Unlike binning, downsampling preserves the original temporal dynamics without averaging within bins.
downsample(
eyeris,
target_fs,
plot_freqz = FALSE,
rp = 1,
rs = 35,
call_info = NULL
)
eyeris |
An object of class |
target_fs |
The target sampling frequency in Hz after downsampling. |
plot_freqz |
Boolean flag for displaying filter frequency response (default FALSE). |
rp |
Passband ripple in dB (default 1). |
rs |
Stopband attenuation in dB (default 35). |
call_info |
A list of call information and parameters. If not provided, it will be generated from the function call. |
Downsampling reduces the sampling frequency by decimating data points.
The function automatically designs an anti-aliasing filter using the
lpfilt()
function with carefully chosen parameters:
ws
(stopband frequency) = Fs_new / 2 (Nyquist freq of new sampling rate)
wp
(passband frequency) = ws - max(5, Fs_nq * 0.2)
An error is raised if wp < 4
to prevent loss of pupillary responses
The resulting time points will be: 0, 1/X, 2/X, 3/X, ..., etc. where X is the new sampling frequency.
An eyeris
object with downsampled data and updated sampling rate.
This function is part of the glassbox()
preprocessing pipeline and is not
intended for direct use in most cases. Provide parameters via
downsample = list(...)
.
Advanced users may call it directly if needed.
glassbox()
for the recommended way to run this step as
part of the full eyeris glassbox preprocessing pipeline.
bin()
for binning functionality.
demo_data <- eyelink_asc_demo_dataset()
# downsample pupil data recorded at 1000 Hz to 100 Hz with the default params
demo_data |>
eyeris::glassbox(downsample = list(target_fs = 100)) |>
plot(seed = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.