Skip to contents

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

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.

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.

Author

Vikram B. Baliga

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)
#> autodetect is an experimental feature -- please report issues.

## 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)