trackParticles: Track particles

trackParticlesR Documentation

Track particles

Description

trackParticles reconstructs trajectories by linking particles.

Usage

trackParticles(
  particles,
  L = 50,
  R = 2,
  weight = c(1, 1, 1),
  costconstant = FALSE,
  logsizes = FALSE
)

Arguments

particles

Object of class 'particles', obtained using identifyParticles.

L

Numeric. Maximum cost for linking a particle to another particle. When the cost is larger, particles will be not be linked (resulting in the begin or end of a segment). Default set at 50.

R

Integer. Link to how many subsequent frames? Default set at 2.

weight

Vector containing 3 weights to calculate costs. Depending on the study system, users may want to value certain elements over others. For instance, when individuals can vary in size over frames (which happens when objects move away or towards a camera) the "size" weight may be decreased. Weights are ordered as follows; first number gives the weight for differences in x and y coordinates; second number gives the weight for particle size differences; third number gives the difference between the predicted location and the observed location. The latter is calculated using the location of the identified particle in the previous frame.

costconstant

Logical. Default is FALSE. This increases the maximum cost L proportional to the number of images in between two frames (when R > 1). Set to TRUE keeps maximum cost L constant for all 1:R frames.

logsizes

Logical. Default is FALSE. Set to TRUE to take the natural logarithm of body sizes, when calculating the cost of linking two particles.

Value

A list of class 'TrDm' and 'records'. Use 'summary' and 'plot'.

Author(s)

Marjolein Bruijning, Caspar A. Hallmann & Marco D. Visser

Examples

## Not run: 
dir.create("images")
## Create image sequence
traj <- simulTrajec(path="images",
                    nframes=30,nIndividuals=20,domain="square",
                    h=0.01,rho=0.9,
                    sizes=runif(20,0.004,0.006))
## Load images
dir <- "images"
allFullImages <- loadImages (dirPictures=dir,nImages=1:30)
stillBack <- createBackground(allFullImages,method="mean")
allImages <- subtractBackground(stillBack)
partIden <- identifyParticles(allImages,threshold=-0.1,
                                   pixelRange=c(3,400))
records <- trackParticles(particles,L=40,R=2)
summary(records)
plot(records,type="trajectories")

## End(Not run)

trackdem documentation built on May 29, 2024, 7:43 a.m.