Methods in Ecology and Evolution (Jun 2024)
Filtering heart rates using data densities: The boxfilter R package
Abstract
Abstract Over the past decades, there has been a growing interest in long‐term heart rate records, especially from free‐living animals. Largely, this increase is because most of the metabolic activity of tissues is based on oxygen delivery by the heart. Therefore, heart rate has served as a proxy for energy expenditure in animals. However, heart rates or other physiological variables recorded in humans and animals using loggers often contain noise. False measurements are sometimes eliminated by hand or by filters that reject variables based on the shape or frequency of the signal. Occasionally, outliers are rejected because they occur a long distance from genuine data. We introduce an R package, boxfilter, which enables users to eliminate noise based on counting the number of close neighbours inside a gliding window. Depending on the cut‐off value chosen, a focal point with a low proportion of neighbours will be rejected as noise. All three parameters, namely window width and height, as well as the cut‐off value, can be computed automatically. The choice of the clip‐off value beyond which data points are discarded is crucial. The package boxfilter cannot, of course, solve problems caused by completely erroneous measurements. Like the human eye, this filter prefers points that are part of a pattern, such as a dense band, and rejects isolated values. The boxfilter may also be applied to other measures than heart rate that do not change instantaneously, such as body temperature, blood pressure or sleep parameters.
Keywords