Given the path of a table file (e.g., .txt or .csv, see read.table
) or an already imported dataframe or matrix containing the location of
one or several ROI, this function returns the coordinates of the ROI edges according to the condition specified by the edgeCrit
argument.
Arguments
- ROImat
The full path of matrix (e.g., a distance matrix to the ROI edge) containing the location (x and y coordinates as row and columns respectively) of the ROI (e.g., .txt or .csv, see
read.table
) or an already imported dataframe or matrix.- edgeCrit
A vector containing at least 1 numeric value or character string indicating the criterion used to retrieve ROI edges.
- xy
A numeric value, either 1 or 2 indicating whether the matrix have x values on columns and y on rows (1) or x values on rows and y on columns (2) (default = 1).
- sep
The field separator character. Values on each line of the file are separated by this character (default = tabs - only useful if ROImat is a path).
- dec
The character used in the file for decimal points (default = "." - only useful if ROImat is a path).
- order
A logical value (i.e., TRUE or FALSE) indicating whether the coordinates of the ROI edges (i.e., vertices) should be reordered (clockwise) according to the centroid of the ROI and angle of each vertex.
Value
This function returns a list containing the coordinates of the ROI edges. Each element of the list correspond to a dataframe containing the coordinates of the edges of one ROI. In case there is only one ROI to retrieve (i.e., edgeCrit argument is a vector of length 1), the function returns a dataframe containing the coordinates of the ROI edges.
Examples
if (FALSE) {
# Download the first dataset from the sample data repository
Path2Data <- MoveR::DLsampleData(dataSet = 1, tracker = "TRex")
Path2Data
# Example 1:
## For this exemple, we are importing the distance matrix from the edge of the arena (a distance matrix generated using color tresholding in imageJ)
## here, the edge of the ROI (i.e., the arena) correspond to the lower value of the distrance matrix plus 1 pixel (i.e., 1)
ArenaEdge <- MoveR::locROI(Path2Data[[2]], edgeCrit = 1)
## plot the arena edges
plot(ArenaEdge)
# Example 2:
## From the same distance matrix we can also retrieve the center of the arena which correspond to the maximum value of the distance matrix minus 1 pixel (i.e., 254)
ROIEdges <- MoveR::locROI(Path2Data[[2]], edgeCrit = c(1, 254))
## plot the arena edges and the edge of the center
plot(NULL,
xlim = c(0, max(do.call("rbind",ROIEdges)[1])),
ylim = c(0, max(do.call("rbind",ROIEdges)[2])))
lapply(ROIEdges, function(x)
points(x))
}