This function adds a keep TRUE/FALSE column in the input dataframe based on
whether the average speed and polarization of the group is larger than the
input thresholds, reflecting whether a timestep is considered part of a
collective event or not.
the dataframe that was given as input with an extra keep
column. The function also prints the number and duration of the defined
events.
Arguments
df
A dataframe with a pol_av and speed_av columns for
polarization and speed, respectively (as calculated by the
group_metrics_per_set function).
sp_lim
The (lower) threshold of speed to use for defining which
timesteps are part of an events of collective motion. In other words, during
an event the group should have an average speed of at least sp_lim.
pol_lim
The (lower) threshold of polarization to use for defining
which timesteps are part of an events of collective motion. In other words,
during an event the group's polarization should be at least pol_lim.
step2time
Sampling frequency, i.e. the relation between time steps
(rows) in the input dataframe and real time (in seconds).
noise_thresh
The limit of time difference between consecutive events
to be considered the same event. The default value is 0 (no event merging).