Given an object of class "tracklets" containing a list of tracklets and the result of a specified condition' test as returned by filterFunc this function remove the values that do not meet the condition of the test and split the tracklets accordingly. Also by specifying an additional "minDur" argument, filtered tracklets that have a low number of records can be removed. The function hence returns two sublist, the first containing a summary of the information about the tracklets before and after filtering and the second containing a tracklets object with the filtered tracklets according to the condition test and "minDur" argument.
Arguments
- trackDat
An object of class "tracklets" containing a list of tracklets and their characteristics classically used for further computations (at least x.pos, y.pos, frame).
- filter
A list of vector as returned by filterFunc and containing the result of a condition test.
- splitCond
The result of the condition test for which values have to be removed and tracklets have to be splitted (Default: TRUE).
- minDur
The minimum duration (i.e., number of records) to consider a tracklet valid after the filtering (default = 1).
- progess
A logical value (i.e., TRUE or FALSE) indicating whether a progress bar should be displayed to inform process progression (default = TRUE).
Value
This function returns a list containing two sublists:
"SummaryFiltering": a list containing a summary of the informations about the tracklets before and after filtering:
"Tracknb_before_filter": the initial number of tracklets.
"Tracknb_after_filter": the number of remaining tracklet after filtering, according to the "filter" argument.
"Tracknb_after_minDur": the number of remaining tracklet after filtering that have a number of records above "minDur" argument.
"TotTrackDuration_before_filter": the sum of the records belonging to each tracklet before the filtering.
"TotTrackDuration_after_filter": the sum of the records belonging to each tracklet after the filtering.
"TotTrackDuration_after_minDur": the sum of the records belonging to each tracklet that have a number of records above "minDur" argument after the filtering.
"%Data_kept_after_filter": the percent of records remaining afer the filtering.
"%Data_kept_after_minDur": the percent of records remaining afer the filtering for the tracklets that have a number of records above "minDur" argument only.
"CleanedTracklets": An object of class "tracklets" containing the filtered tracklets according to the condition test specified by filterFunc and "minDur" argument.
Examples
if (FALSE) {
# Download the first dataset from the sample data repository
Path2Data <- MoveR::DLsampleData(dataSet = 1, tracker = "TRex")
Path2Data
# Import the data as an object of class "tracklets"
trackDat <- MoveR::readTrex(Path2Data[[1]])
# example 1:
## test for the presence of infinite value in x.pos, if infinite values are detected, the result is TRUE
FiltInf <- MoveR::filterFunc(trackDat, toFilter = "x.pos", customFunc = function(x) is.infinite(x))
## Then remove infinite values and split the tracklets when an infinite value is found
## here we keep every remaining tracklet, whatever its duration (the number of record within each tracklet)
trackDatNoInf <- MoveR::filterTracklets(trackDat, filter = FiltInf, splitCond = TRUE, minDur = 1)
## Check the summary of the filtering
str(trackDatNoInf$SummaryFiltering)
## take a look at the first filtered tracklet
str(trackDatNoInf$CleanedTracklets[[1]])
## alternatively, we can only keep the tracklets with a duration above 10 (the number of record within each tracklet)
## by modifying the minDur argument
trackDatNoInfDur10 <- MoveR::filterTracklets(trackDat, filter = FiltInf, splitCond = TRUE, minDur = 10)
## Check the summary of the filtering
str(trackDatNoInfDur10$SummaryFiltering)
## take a look at the first filtered tracklet
str(trackDatNoInfDur10$CleanedTracklets[[1]])
# example 2: test for the length of the particles:
## keep only particles with a size included between 1 and 20 pixels
## if particles' size is ranging between 1 and 20 pixels, the result is TRUE.
FiltSize <- MoveR::filterFunc(trackDat, toFilter = "maj.ax", customFunc = function(x) x >= 1 & x <= 20)
## Then remove values that are not included within the [1:20] interval and split the tracklets accordingly
## here we keep every remaining tracklet, whatever its duration (the number of record within each tracklet)
trackDatSize20 <- MoveR::filterTracklets(trackDat, filter = FiltSize, splitCond = TRUE, minDur = 1)
## Check the summary of the filtering
str(trackDatSize20$SummaryFiltering)
## take a look at the first filtered tracklet
str(trackDatSize20$CleanedTracklets[[1]])
## alternatively, we can only keep the tracklets with a duration above 10 (the number of record within each tracklet) by modifying the minDur argument
trackDatSize20Dur10 <- MoveR::filterTracklets(trackDat, filter = FiltSize, splitCond = TRUE, minDur = 10)
## Check the summary of the filtering
str(trackDatSize20Dur10$SummaryFiltering)
## take a look at the first filtered tracklet
str(trackDatSize20Dur10$CleanedTracklets[[1]])
}