Skip to contents

Like clean_viewr_batch(), but with import as the first step too

Usage

import_and_clean_batch(
  file_path_list,
  import_method = c("flydra", "motive"),
  file_id = NA,
  subject_name = NULL,
  frame_rate = NULL,
  simplify_marker_naming = TRUE,
  import_messaging = FALSE,
  ...
)

Arguments

file_path_list

A list of file paths leading to files to be imported.

import_method

Either "flydra" or "motive"

file_id

(Optional) identifier for this file. If not supplied, this defaults to basename(file_name).

subject_name

For Flydra, the subject name applied to all files

frame_rate

For Flydra, the frame rate applied to all files

simplify_marker_naming

For Motive, if Markers are encountered, should they be renamed from "Subject:marker" to "marker"? Defaults to TRUE

import_messaging

Should this function report each time a file has been processed?

...

Additional arguments to specify how data should be cleaned.

Value

A list of viewr objects (tibble or data.frame with attribute pathviewr_steps that includes "viewr") that have been passed through the corresponding cleaning functions.

Details

viewr objects should be in a list, e.g. the object generated by import_batch().

See clean_viewr() for details of how cleaning steps are handled and/or refer to the corresponding cleaning functions themselves.

See also

Other data import functions: as_viewr(), import_batch(), read_flydra_mat(), read_motive_csv()

Other batch functions: bind_viewr_objects(), clean_viewr_batch(), import_batch()

Author

Vikram B. Baliga

Examples

## Since we only have one example file of each type provided
## in pathviewr, we will simply import the same example multiple
## times to simulate batch importing. Replace the contents of
## the following list with your own list of files to be imported.

## Make a list of the same example file 3x
import_list <-
  c(rep(
    system.file("extdata", "pathviewr_motive_example_data.csv",
                package = 'pathviewr'),
    3
  ))

## Batch import
motive_batch_imports <-
  import_batch(import_list,
               import_method = "motive",
               import_messaging = TRUE)
#> File 1 imported.
#> File 2 imported.
#> File 3 imported.

## Batch cleaning of these imported files
## via clean_viewr_batch()
motive_batch_cleaned <-
  clean_viewr_batch(
    file_announce = TRUE,
    motive_batch_imports,
    desired_percent = 50,
    max_frame_gap = "autodetect",
    span = 0.95
  )
#> autodetect is an experimental feature -- please report issues.
#> File 1 has been cleaned successfully.
#> autodetect is an experimental feature -- please report issues.
#> File 2 has been cleaned successfully.
#> autodetect is an experimental feature -- please report issues.
#> File 3 has been cleaned successfully.

## Alternatively, use import_and_clean_batch() to
## combine import with cleaning on a batch of files
motive_batch_import_and_clean <-
  import_and_clean_batch(
    import_list,
    import_method = "motive",
    import_messaging = TRUE,
    motive_batch_imports,
    desired_percent = 50,
    max_frame_gap = "autodetect",
    span = 0.95
  )
#> File 1 imported.
#> File 2 imported.
#> File 3 imported.
#> autodetect is an experimental feature -- please report issues.
#> autodetect is an experimental feature -- please report issues.
#> autodetect is an experimental feature -- please report issues.

## Each of these lists of objects can be bound into
## one viewr object (i.e. one tibble) via
## bind_viewr_objects()
motive_bound_one <-
  bind_viewr_objects(motive_batch_cleaned)

motive_bound_two <-
  bind_viewr_objects(motive_batch_import_and_clean)

## Either route results in the same object ultimately:
identical(motive_bound_one, motive_bound_two)
#> [1] TRUE