rubitLinearInterpolate: Resamples and interpolates data to achieve regular time...

Description Usage Arguments Value Note See Also Examples

View source: R/linearInterpolate.R

Description

X,Y-positions are returned at a regular time interval using linear interpolation. Data can be trimmed to fit within desired start and end timepoints, or new positions inferred for additional timepoints (before or after object tracking).

Usage

1
2
rubitLinearInterpolate(m, hz = 30, start_at = NA, end_at = NA,
  adj_fps = NA, minRow = 11)

Arguments

m

a numerical matrix corresponding to an area.

hz

the desired resampling frequency, in Hz.

start_at, end_at

the starting / ending times to interpolate and/or cut data to, in minutes.

adj_fps

encodes a new framerate, in Hz.

minRow

an integer defining the minimal number of reads. If less than minRow reads are present in m, the function returns an empty matrix.

Value

A trimmed and resampled numerical matrix based upon the input data. The attributes of the input matrix are copied to the new matrix.

Note

X,Y-positions are defined as 'NA' between the start_at time and the point of first object tracking. For terminally interpolated timepoints (i.e. between last object detection and the end_at time), the last known X,Y-position is repeated. Re-encoding a new framerate with adj_fps can correct potential errors made during video recording and/or tracking analysis. Check that the value returned by calcFPS matches the calculated framerate of the original video (e.g. using the 'ffprobe' function in FFmpeg [https://ffmpeg.org/].

See Also

rubitMedianFilter to smooth data before interpolation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(weevils_raw)

### Interpolation before filtering
w1 <- lapply(weevils_raw, rubitLinearInterpolate, hz = 50)
plot(w1[['08']][,'X'] ~ w1[['08']][,'Y'], asp=1, type='l')

### Interpolation after filtering
w19 <- lapply(weevils_raw, rubitRemoveOutliers, p = 0.001)
w19 <- lapply(w19, rubitMedianFilter, k = 19)
w19 <- lapply(w19, rubitLinearInterpolate, hz = 50)
plot(w19[['08']][,'X'] ~ w15[['08']][,'Y'], asp=1, type='l')

JoGall/rubitrail documentation built on May 7, 2019, 10:53 a.m.