Adjusts the positions of markers by moving them towards a specified center position within each timeframe by a specified distance. The center (centroid) can be determined by one of two methods:
data: A data frame where each row represents a marker at a specific timeframe, with columns 'Timeframe', 'Marker', 'X', 'Y', 'Z'.
distance: Numeric value indicating the distance to adjust markers towards the center (default is 1 cm).
centroid: A character string specifying the method to compute the centroid. Either "average" (default) or "convex hull".
Returns
A data frame of the same dimensions as data, containing the adjusted marker coordinates.
Details
"average" (default): The centroid is computed as the mean of all marker coordinates in each timeframe.
"convex hull" : The centroid is computed using a convex hull-based approach, representing a geometrically derived center.
When centroid = "average", the centroid is simply the mean of X, Y, and Z for all markers within each timeframe. When centroid = "convex hull", the centroid is computed using a convex hull-based method to identify a more geometrically relevant center.
Examples
data("sample_data")reformat_data <- reformat_marker_data(head(sample_data))# Using the average centroid (default)adjusted_data_avg <- adj_position(reformat_data, distance =1, centroid ="average")head(adjusted_data_avg)# Using the convex hull centroidadjusted_data_ch <- adj_position(reformat_data, distance =1, centroid ="convex hull")