Skip to contents

Estimates the center of a midline based on mass distribution, volume distribution, or body width.

Usage

get_midline_center_df(
  .data,
  arclen,
  x,
  y,
  mass,
  width,
  height,
  .out = NULL,
  .frame = frame,
  .point = point,
  method = "mutate",
  overwrite = TRUE
)

Arguments

.data

Data frame containing the midlines.

arclen

The column containing the arc length. See arclength()

x, y

Columns containing the x and y coordinates of the midline. There should be N points.

mass

(optional) Column containing the mass of each segment, with N-1 segments.

width

(optional) Column containing the horizontal plane width of the body at each midline point (N points)

height

(optional) Column containing the dorso-ventral height of the body at each midline point (N points)

.out

Names of the output columns. Needs to have two elements specifying the names for the x and y coordinates of center position. Or it can be a named list containing at least some of the elements xctr and yctr. If the return elements aren't in the named list, the defaults are 'xcom' and 'ycom')

.frame, .point

Columns identifying frames and points (defaults are frame and point)

method

'mutate' or 'summarize'. If summarize, returns one center position for each frame. If mutate, returns a same center position repeated for each point in a frame.

overwrite

TRUE or FALSE to overwrite existing columns, if present.

cutoff

(optional) If this parameter is included, smooth the swimming axis data with a low-pass filter with a cutoff at this frequency.

Value

A data frame containing the original variables along with xcom, ycom (or names as specified in .out). The center of each midline in each frame.

Details

Given a mass distribution, it produces an estimates of the true center of mass. If given the body width and height, it assumes that the body has an oval cross section with varying width and height, and it estimates the volume distribution. This method will give a good estimate of the center of mass if the body has close to uniform density. If given just the width, it uses the width to estimate a weight average centroid position.

Examples

lampreydata |>
  group_by(frame) |>
  mutate(arclen = arclength(mxmm, mymm),
         width = interpolate_width(fishwidth$s, fishwidth$ammowidth, arclen)) |>
  get_midline_center_df(arclen, mxmm,mymm, width=width)
#> Error in mutate(group_by(lampreydata, frame), arclen = arclength(mxmm,     mymm), width = interpolate_width(fishwidth$s, fishwidth$ammowidth,     arclen)): could not find function "mutate"