Reads and formats movement tracking data exported from TRex (Walter & Couzin, 2021). TRex is a software for tracking animal movement in videos, which exports coordinate data in CSV format. This function processes these files into a standardized movement data format.
Arguments
- path
Character string specifying the path to a TRex CSV file. The file should contain columns for:
time
x and y coordinates for tracked points (e.g., x_head, y_head)
x and y coordinates for centroid (x_number_wcentroid_cm, y_number_wcentroid_cm)
- video_height
Optional numeric height of the source video frame in the same spatial units as the tracking output (TRex defaults to centimetres). TRex's CSV export does not record this, so without it
max(y)is used as a fallback when reflecting tobottom_left.
Value
A data frame containing movement data with the following columns:
time: Time values from the trackingindividual: Factor (set to NA, as TRex tracks one individual)keypoint: Factor identifying tracked points (e.g., "head", "centroid")x: x-coordinates in centimetersy: y-coordinates in centimetersconfidence: Numeric confidence values (set to NA as TRex doesn't provide these)
Details
The function performs several processing steps:
Validates the input file format (must be CSV)
Reads the data using vroom for efficient processing
Cleans column names to a consistent format
Restructures the data from wide to long format
Initializes metadata fields required for movement data