get_full_trajectories: Retain trajectories that span a selected region of interest

View source: R/utility_functions.R

get_full_trajectoriesR Documentation

Retain trajectories that span a selected region of interest

Description

Specify a minimum span of the selected region of interest and then keep trajectories that are wider than that span and go from one end to the other of the region.

Usage

get_full_trajectories(obj_name, span = 0.8, ...)

Arguments

obj_name

The input viewr object; a tibble or data.frame with attribute pathviewr_steps that includes "viewr"

span

Span to use; must be numeric and between 0 and 1

...

Additional arguments passed to/from other pathviewr functions

Details

Because trajectories may not have observations exactly at the beginning or the end of the region of interest, it may be necessary to allow trajectories to be slightly shorter than the range of the selected region of interest. The span parameter of this function handles this. By supplying a numeric proportion from 0 to 1, a user may allow trajectories to span that proportion of the selected region. For example, setting span = 0.95 will keep all trajectories that span 95% of the length of the selected region of interest. Setting span = 1 (not recommended) will strictly keep trajectories that start and end at the exact cut-offs of the selected region of interest. For these reasons, spans of 0.99 to 0.95 are generally recommended.

Value

A viewr object (tibble or data.frame with attribute pathviewr_steps that includes "viewr") in which only trajectories that span the region of interest are retained. Data are labeled by direction (either "leftwards" or "rightwards") with respect to their starting and ending position_length values in the direction column.

Author(s)

Vikram B. Baliga

See Also

Other data cleaning functions: gather_tunnel_data(), quick_separate_trajectories(), redefine_tunnel_center(), relabel_viewr_axes(), rename_viewr_characters(), rotate_tunnel(), select_x_percent(), separate_trajectories(), standardize_tunnel(), trim_tunnel_outliers(), visualize_frame_gap_choice()

Other functions that define or clean trajectories: quick_separate_trajectories(), separate_trajectories(), visualize_frame_gap_choice()

Examples

motive_data <-
  read_motive_csv(system.file("extdata", "pathviewr_motive_example_data.csv",
                              package = 'pathviewr'))

## Clean the file. It is generally recommended to clean up to the
## "separate" step before running select_x_percent().
motive_separated <-
  motive_data %>%
  relabel_viewr_axes() %>%
  gather_tunnel_data() %>%
  trim_tunnel_outliers() %>%
  rotate_tunnel() %>%
  select_x_percent(desired_percent = 50) %>%
  separate_trajectories(max_frame_gap = "autodetect",
                        frame_rate_proportion = 0.1)

## Now retain only the "full" trajectories that span
## across 0.95 of the range of position_length
motive_full <-
  motive_separated %>%
  get_full_trajectories(span = 0.95)

pathviewr documentation built on March 31, 2023, 5:47 p.m.