Anotate Movement

Anotate dataframes by adding movement related data/computations as columns

add_angular_diff()

Add angular difference wrt reference direction to movement or eye tracker data frame

add_fixation2target()

Add target fixations to eyetracker data

add_gaze_elevation()

Add gaze elevation to (head) movement or eye tracker data frame

add_in_view()

Add column indicating if a stationary or moving target is in foveal view

add_orientation2target()

Add direction of the orientation of a reference object relative to a stationary target (in 2D, XZ).

add_orientation2target2()

Add direction of the orientation of a reference object relative to a target movement (in 2D, XZ).

add_rot()

Add rotation matrix to movement or eye tracker data frame

add_rot_eye()

Helper function that takes an eye tracker data frame and adds a new column `R` with the rotation matrices.

add_rot_move()

Helper function that takes a movement data frame and adds a new column `R` with the rotation matrices.

add_speed()

Add movement speed to movement data frame

add_vector2target()

Add vector of a reference object relative to a stationary target

add_vector2target2()

Add gaze vector of a reference object relative to a target movement

Extract Movement

Extract common computations from data

extract_fixation()

Extract ratio of target fixation between a `min_time` and `max_time`. You can supply timestamps to `min_time` and `max_time` (e.g timestamp of begin escape) to average over only a period, or use the entire duration of the provided data frame.

extract_fruit_task()

Extract fruit picking between a `min_time` and `max_time`. You can supply timestamps to `min_time` and `max_time` (e.g timestamp of begin escape) to average over only a period. In this case, you can also retrieve the collection rate by setting `rate` to 1.

extract_gaze_elevation()

Extract gaze elevation between a `min_time` and `max_time`.

extract_movement_dist()

Extract (min, max or mean) 2D distance between movement trajectory and reference position.

extract_movement2_dist()

Extract (min, max or) 2D distance between two movement trajectories.

extract_orientation()

Extract direction of the orientation of a reference object relative to a stationary target (in 2D, XZ) between a `min_time` and `max_time`.

extract_orientation2()

Extract direction of the orientation of a reference object relative to a target movement (in 2D, XZ) between a `min_time` and `max_time`.

extract_path_length()

Extract 2D Path Length from Movement Data

extract_recording_duration()

Extract recording duration of a movement tibble

extract_speed()

Extract speed (peak or average speed) between a `min_time` and `max_time`.

extract_speed_angular()

Extract angular speed (peak or average speed) for a direction vector between a `min_time` and `max_time`.

extract_timestamp_duplicates()

Extract duplicated time stamps.

Movement Processing

Guess times; validate, prepare, resample or summarise movement data

average_timeseries()

Average a list of resampled time series (movement, fruit collection or eyetracking) data frames

check_valid_movement()

Check whether movement data frame contains valid tracker information

combine_movement()

Combine and resample two movement data frames

get_first_fruit_collection()

Get time of first fruit collection

get_fruit_time()

Get fruit appearance or collect time for the n-th fruit This function returns the exact time stamp of this fruit.

guess_first_view()

Guess first time an object is in foveal view

guess_escape_begin_time()

Guess start of escape

guess_escape_end_time()

Guess end of escape time

guess_escape_abortion()

Guess escape abortion position and time

guess_move_from_pos()

Guess First Move From Position

guess_move_at_pos()

Guess First Move From or To Position

guess_pos_at_time()

Guess/interpolate position at a point in time

guess_threat_speed()

Estimate actual threat speed from movement data

guess_time_at_dist2()

Guess time at a distance between two movement data frames

prepare_gaze_data()

Prepare gaze data for further processing

reorient_movement_to_start()

Reorient movement data frame such that initial values match start position and orientation

resample_eyetracker()

Resample an eyetracker data frame to new time index.

resample_filter_pos()

Resample and median-filter position and rotation columns in a movement data frame

resample_fruit_task()

Resample a fruit collection frame to new time index.

resample_movement()

Resample a movement data frame to new time index.

summarise_movement()

Summarise movement data frame for each unique time stamp

translate_movement_to_ref()

Translate positions in movement data frame to reference position.

Trial Processing

Manage trial data at a high level

apply_replacements()

Apply replacements using replacement data frame.

average_timeseries_cols()

Average time series data columns within group

check_tracker_cols()

Check movement data columns

create_threat_name()

Create threat name column from episode name

fix_old_names()

Fixes names in older versions of the output. Specifically, deletes the occurance of `"vrthreat_"` in any column names.

remove_tutorials()

Remove tutorial trials - i.e. episode either containing "Tutorial" or "Practice"

reorient_movement_cols_to_start()

Reorient movement columns to starting position.

resample_eyetracker_cols()

Resample eyetracker data columns

resample_fruit_task_cols()

Resample fruit task data columns

resample_movement_cols()

Resample movement data columns

summarise_movement_cols()

Summarise movement data columns to ensure unique time stamps

process_trial_results()

Proprocess a trial results tibble

Scenario Processing

Extract scenario related data from .json files

find_fruit_position()

Find fruit position

find_initial_threat_position()

Find initial threat position from programmatic scenario planner

find_safe_position()

Find safe position

find_start_position()

Find Start marker position and rotation

find_unity_threat_name()

Find Unity's internal threat name

get_time_of_first_event()

Get Time Of First Sequence Event

get_time_of_first_event_multi()

Get Time Of First Sequence Event across multiple sequence columns

Questionnaire

Manage quest data

read_quest_data()

Read and score questionnaire data

read_quest_raw()

Read raw (csv) questionnaire data

replace_redcapid_ppid()

Replace Redcap id in questionnaires by VR ppid

sub_sum_quest()

Get sum of a questionnaire subscale

sum_mssq()

Get MSSQ subscale score (Motion Sickness; Golding, 2006)

sum_quest()

Get sum of a questionnaire if questionnaire exists

Audio Processing

Help play and annotate sounds

detect_sound()

Automatically detect sounds in audio recording using a volume/duration threshold

get_audio_section()

Get audio section

play_audio_from_threat()

Play audio recording from threat appearance to the end

play_audio_section()

Play audio section

sound_classification_manual()

Manually classify sounds

sound_detection_manual()

Manually detect sounds

write_audio_section()

Write audio section

IO functions

Save figures and read data from Unity, Json, CSV into R.

clean_scenario_data()

Clean Scenario Data Column

create_out_folders()

Create output folders under an experiment name

load_trial_results()

Load and Optionally Clean Trial Results

join_data()

Join CSV Files to Trial Results

read_csv_files()

Read CSV Files

read_json_files()

Read JSON Files

read_log_messages()

Read log messages

read_log_messages_weapons()

Read and Join Weapon Log Messages

read_participant_details()

Read participant details from files

read_study_data()

Read complete study data

read_trial_results()

Read Trial Results

remove_tld()

Remove top-level directory in a full file path.

save_fig()

Wrapper around `ggsave` to save figures.

split_path()

Split a path name into into its components

standardise_path()

Standardise file path

update_file_pointers()

Update file pointers

Data Interfacing

Interface with STAN

array2STAN()

Convert 1-3 dimensional array to STAN format

Maths

Mathematical helper functions

angle_between()

This uses R base functions to calculate the angle between two vectors in degrees, accounting for rounding errors to avoid NaNs.

angle_diff_deg()

Calculate angle difference in degrees, respecting angles <0 or >360.

calculate_2d_angle_deg()

Calculate 2D angle between positive z-axis and a line from reference to target position in degrees

calculate_2d_dist()

Calculate 2D Euclidean distance between two positions

cart2sph()

Transform cartesian to spherical coordinates

create_resampling_index()

Create resampling index at desired sample rate

cummean_na()

Calculate cummean with previous neighbour interpolation

eulunity2rot()

Convert rotation in Unity Euler angles (in degrees) into 3D rotation matrix

find_argmax()

Find index of maximum, avoiding warnings and errors

find_argmin()

Find index of minimum, avoiding warnings and errors

find_max()

Find maximum, avoiding warnings

find_min()

Find minimum, avoiding warnings

orthdist()

Perpendicular distance of p3 from p1 along p1p2

proj_vec2vec()

Project vector x onto vector y

proj_vec2plane()

Project 3D-vector x into the plane spanned by y and z

rot2centralangle()

Compute central angle between two rotation matrices, for a direction vector

timeseries_mean()

Compute the mean across a vector `x` respecting time `t`, using trapezium rule.

vec2rot()

Find a rotation matrix that maps one vector onto the other

Statistical Modelling

Fit statistical models to data

fit_mdl()

Fit (generalised) linear model, checking for convergence, and obtain marginal means

fit_mdl_robust()

Fit (generalised) linear random effects model robustly, checking for convergence

fit_lmer_model()

Safely fit a linear mixed-effects model using lme4::lmer

Plotting functions

Scale, theme and plot 3D movement

plot_3D_movement()

Plot 3D movements for one trial

scale_pastel()

Pastel colored ggplot scale

scale_vrthreat_endstate()

VR Threat End State ggplot scale

scale_vrthreat_planningtime()

VR Threat Planning Time ggplot scale

scale_vrthreat_scenariotype()

VR Threat Scenario Type ggplot scale

theme_vrthreat()

VR Threat ggplot theme #'

Utility

Deal with unity file management

compare_colnames()

Compare Column Names Between Two Data Frames

create_file_paths()

Create Directory Paths Recursively

create_weapon_details()

Extract and annotate weapon-related details from raw event messages

find_hierarchy_object()

Find Hierarchy Object

find_hierarchy_object_any()

Find Hierarchy Object Matching Any Name

find_log_message()

Find messages in a session log and assign to trials

identify_na_columns()

Identify Columns with Missing Values

remove_missing_columns()

Remove Columns with All Missing Values

test_source_fun_run_tests_rep_coverage()

Source Functions, Run Tests, and Report Coverage

Constants

Constants

fruit_gameobject_names

Common fruit object names used in VRthreat Unity