Calculates the change in body angle between consecutive frames.
flyspin(trx, framelag = 1)
a track data frame (only requires CTrax output variables)
the number of frames to compare angles across; defaults to 1 (consecutive frames)
Uses the major axis angle of the ellipse fit by CTrax (
theta) as this
turns out to be much more reliable than the angular speed approach based on centroid
location, especially when there is little movement.
Assumes that flies don't turn more than 90 degrees, so 'flips' the fly if that results in a lower angle.
Note that this assumption is probably true on a frame-by-frame basis; therefore if
framelag is set
to a value >1, it is calculated as the sum of consecutive (small) spins.
It is currently run across the whole dataset without splitting it by
id, as the amount of artefacts should
be small, but ideally it would be best to run it with an
A numeric vector matching the structure of
trx containing the spin value for each object and timepoint, or
NAs when it can't be calculated.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.