Introduction and background

Studies on the dynamics of a moving animal are classically performed by digitizing video and tracking multiple body parts through time [1, 2]. However, these studies usually examine a narrow range of locomotor behaviors in laboratory settings, and expanding estimates beyond a single individual, into three dimensions, or over longer time frames of hours to days is challenging. Researchers can also place sensors at specific locations on an animal, allowing for precise estimates of some characteristic of that location on the body. For example, the use of electromyography electrodes allow estimation of muscle activation during movement [3,4,5]. Traditionally, these sensors are tethered to an external data recorder, which provides power, data storage and enables multiple sensors to be time-synced. However, this design requires the animal to be physically connected to an external device which generally restricts such studies to laboratory settings.

To move beyond these limitations, researchers have increasingly employed animal-born biologging devices [6, 7]. These devices have an internal battery and log data from a sensor to internal memory, and they “cut the cord” and eliminate the need for an individual to be tethered, allowing for in situ measurements of behavior in the field. Biologgers using a combination of accelerometers, gyroscopes, and magnetometers (collectively inertial measurement unit; IMU) have been increasingly adopted to study a diversity of questions focusing on the movement, behavior, physiology, and ecology of animals [8,9,10,11], and provide a rich data set well beyond what can be achieved in the laboratory.

Animals are dynamic, and recording information from only one sensor at a single location presents ambiguity in determining an animal’s actions, an incomplete picture of body dynamics, and is of limited utility in studying the complex three-dimensional kinematics of most animals. Limited attempts have been made to have a single datalogger record from multiple distributed sensors, but this approach is constrained by the requirement of having the sensors tethered across the animals body and by the recording bandwidth of the logger [12]. Furthermore, the majority of these attempts have been focused on categorizing human movements and behaviors [12,13,14,15].

Placing multiple IMU dataloggers distributed across the body would resolve these issues and allow both high temporal and spatial resolution of animal body dynamics as natural behaviors are executed in the field. However, minor differences in recording frequencies between loggers can accumulate, causing sensors to drift in time from each other [16]. This drift over time obfuscates temporal patterns and thus prevents synchronous comparisons of movement across the body.

To illustrate this problem, imagine an IMU on each foot of a person walking. The IMUs will begin by recording alternating steps: one foot moves forward, while the other is stationary. As small discrepancies in their recording rates accumulate, the datasets will drift apart, and unrealistic behavior such as both feet moving forward at the same time will be recorded, changing the interpretation of the locomotor mode used. Depending on the temporal precision that is required, the accuracy of each loggers clock, and the amount of time these loggers are deployed, this temporal drift can represent a significant and unknown source of error in analysis.

In this paper we demonstrate that temporal drift exists among multiple IMU data streams derived from the same controlled movement, and then (1) quantify the extent of this drift among commonly used commercially available data loggers, (2) measure the variation in drift across multiple datasets, and finally (3) illustrate a methodological approach to temporally synchronize separate IMU data loggers placed at various locations on a single individual. Demonstrating how to correct for IMU drift establishes the foundation for using multiple IMU loggers to reconstruct the three-dimensional body dynamics of animal movement in the field.

Methods

Two types of experiments were conducted: (1) robotic experiments where the movements of the tags were known, and (2) experiments on three species of live fishes in which the movement of tags was unknown. In all experiments dataloggers were manufactured by Technosmart Inc (Rome, Italy). Models used varied across the experiments and involved the AGM model, the Axy-4 model, and the Axy-5 model. The AGM model lacks a real time clock and records from an MPU-9250 (TDK InvenSense Inc.), which has a has a 3-axis accelerometer, 3-axis magnetometer, and 3-axis gyroscope. The Axy-4 and Axy-5 record 3-axis acceleration from an LIS2DH12TR (STMicroelectronics Inc.) and LSM303AGR (STMicroelectronics Inc.) respectively. In all experiments the tags were programmed to record at 100 Hz. AGM models were purchased at three different times with 6 tags having a larger 400 mAh battery and 6 tags having a 100 mAh battery, while the Axy4 and Axy-5 models each had a 100 mAh battery.

Robotic experiments

Experiments were conducted using an automated robotic flapping mechanism that has been extensively used to study dynamics of fish movement in the past [17,18,19] The robotic flapping system has two degrees of freedom and can alter the heading (yaw, or pitch) as well as induce lateral translative movements (sway, or heave), with the user programming the frequency and amplitude of these movements. Multiple dataloggers were rigidly affixed to the flapping mechanism so that all tags experienced the same movement simultaneously (Fig. 1A). The flapping mechanism was turned on for 1 min in duration and the tags were then oscillated laterally back and forth at 0.75 Hz and experienced a programmed 3 cm lateral amplitude and a 25 degree heading oscillation. Flapping was repeatedly conducted over a ~ 24 h period or until the tag batteries were drained. This entire procedure was repeated so that each tag’s drift rate could be estimated at least 3 times.

Fig. 1
figure 1

Pictures of multiple tags during each experimental set up. During robotic experiments (A) multiple tags were affixed to a rigid metal rod and simultaneously moved sinusoidally in heave and pitch to provide known a input movement pattern to all tags using a robotic flapping mechanism. Multiple tags were additionally attached along the body onto live animals including a smooth dogfish (B), white sucker (C) and sea lamprey (D)

After an experiment, tag data was downloaded, and the data were imported into R for analysis. In this experiment we had no “true” time, and thus Tag 1 was used as the baseline and all other tags were compared to this tag. The starting and stopping point of each flapping period was identified and a buffer of 60 s was added before and after the flapping period. Temporal lag between each tag and Tag 1 was estimated using a cross correlation function of the two tags Z-axis gyroscope data (change in heading). The lag that maximized the correlation between the two datasets was identified as the temporal lag during each flapping period. The lag for each tag was regressed against time in to estimate the drift rate and converted to seconds per hour. Linear mixed effects models were used to estimate the variance in drift rate within and between tags using the lme4 package in R [20]. Tag ID was identified as a random effect and was used to estimate variance between tags, while residual variance was used to estimate the within tag variation. After observing large discrepancies between groups of tags, a “fast-slow” recording group was also incorporated as a fixed effect.

Animal based experiments

While estimating drift under controlled laboratory conditions is beneficial and provides an accurate estimate of among-tag drift, ideally we want to directly estimate the drift rates of tags in the field during an actual deployment. To determine if this was possible, we placed multiple tags on three species of fishes (Fig. 1B–D) and allowed them to volitionally swim. Data loggers were fixed to the animal’s body using two sutures, one at the anterior side of the tag and a second at the posterior side of the tag. A smooth dogfish (Mustelus canis, TL = 99 cm, Fig. 1B) was tagged at three locations (anterior-above gills, mid:below first dorsal fin, and posterior: at caudal peduncle) using AGM tags. The shark was then placed into a small tank (2.5 m diameter) and allowed to swim freely for 26 h. White sucker (Catostomus commersonii, TL = 50 cm, Fig. 1C) were tagged with an AGM tag placed close to their center of mass with a second Axy-5 tag placed at the caudal peduncle. Finally, lamprey (Petromyzon marinus, TL = 65 cm, Fig. 1D) were tagged at three locations (anterior, mid body, and peduncle) with a combination of AGM, Axy-5, and Axy-4 tags. Lamprey and white sucker were released into a large holding tank (8 × 7 m) that was connected to a flume (36 m long and 0.635 m wide) inducing flow that has been used to investigate volitional bursting behavior in migrating fish [21, 22].

Data processing

Acceleration or angular velocity data from the latitudinal direction was used to estimate the drift in tag sensor data from live fishes as these animals primarily locomote using lateral body oscillation. Data from the two sensors was sequentially cross-correlated with each other using sliding and overlapping windows. Window size was 10 min and windows overlapped by 50 percent. The lag that represented the maximum cross correlation was selected as the lag for each analysis window. Windows that represented low cross correlation scores (ACF < 0.4) were excluded from further analysis. The lag for each window was regressed against time and any outlier with a Cooks distance of greater than 3 was excluded. To examine the sensitivity of drift estimate to window size, the analysis was rerun using window sizes that varied from 1 to 40 min (Additional file 1: Figs. S2–S4).

Results

Robotic experiments

Data from each tag were manually shifted to correct for initial starting time so that the tags produced similar and overlapping data during the first flapping time period (Fig. 2A). However, 24 h after the experiment started, there were noticeable temporal shifts in the flapping patterns in tag data (Fig. 2B), indicating that the data streams from the different tags had drifted with respect to each other. Tags that were purchased at the same time as Tag1 (Tags 1–4) experienced temporal drift between + 0.2 and − 0.5 s over a 24-h period (Fig. 3A), an average a drift rate of − 0.011 ± 0.015 s·h−1 across all trials. Tags 5–12 had a significantly greater drift rates than tags 2–4 (t = − 55.5, p < 0.001) and drifted from Tag1 by 4.0–5.3 s over a 9-h duration (Fig. 2B), with an average drift rate of 0.545 ± 0.014 s·h−1. Once this large difference in drift rate between tags 1–4 and tags 5–12 was accounted for, the variance between tags in each group was not significantly different (Tags 1–4: σ = 0.015 s·h−1, Tags 5–12: σ = 0.014 s·h−1). In addition, variance within a tag was an order of magnitude smaller (σ = 0.001 s h−1) than the variance across tags, representing only 0.5% of the total variance in drift estimates. This suggests that each tag was highly consistent in drift rate across all flapping trials, even as the average temperature between trials ranged from 21.1 to 27.0 C.

Fig. 2
figure 2

Raw angular velocity data from 4 AGM tags that were simultaneously moved over a 24 h period using a robotic flapping mechanism. Immediately after the tags were corrected for their initial temporal offset, all 4 tags show identical and overlapping gyroscope data (A). However, after 24 h, small differences in the clock frequency among tags led to considerable drift among the loggers (B)

Fig. 3
figure 3

The absolute amount of drift in seconds among Tags 1–4 over a 25 h period (A), and among tags 7–12 (B) over a 9 h period during one trial run. Each point represents an individual flapping trial, with the lines showing a linear model and the slope being the estimated drift rate. Tag 7 in B experienced a large instantaneous jump in the drift at ~ 3 h as noticed by the light blue points. All drift rate estimates for each tag, with each datapoint representing drift estimates from each trial (C). There was a large discrepancy in drift rate between the two sets of tags and thus the y axis is broken, but the original axis can be seen in the inset

Within an experiment, tags recorded low variation in temperature (< 1C) and drift rates were highly linear and remained constant over time (r2 > 0.99, Fig. 3). However, during trials we observed three noticeable exceptions (e.g. Tag 7, Fig. 3B) during which a tag experienced an unrecorded error that introduced an instantaneous 1 s shift. On one of these occasions, 100 datapoints were missing from the dataset. On the other two occasions, 100 extra datapoints were added into the dataset. As these errors were significantly greater than the drift rate, we were able to isolate when these shifts occurred and estimate the drift rate excluding this large error (Additional file 1: Fig. S1).

Animal experiments

The sliding window cross correlation during natural behavior was able to identify clear trends in temporal drift across both the shark (Fig. 4), the lamprey (Fig. 5) and the white sucker (Fig. 6) data sets. The shark and lamprey were tagged with the same AGM tags that were used in the robotic based experiments and allow us to directly compare drift estimates. Drift estimates from animal borne deployments were in the same direction and differed by less than 0.02 s·h−1, close to the drift rate we observed when all tags were moved with the same motion during the robotic flapping experiments in the laboratory. However, due to variation in behavior and subsequent temporal shifts in movement among the different tags, there was significantly more variation in animal datasets than in controlled simultaneous flapping. Furthermore, distance between the tags significantly impacted the mean cross correlation value between signals for the shark (ANOVA F1,728 = 35.8, p < 0.001) and for the lamprey (ANOVA F1,248 = 466, p < 0.001). In both cases the anterior and mid position of the body had a higher mean cross correlation than between the head and the posterior tag. Drift estimates were moderately sensitive to the window size used for the cross correlation; however, a window size of approximately 10 min was adequate across all three species (Additional file 1: Figs. S2–S4).

Fig. 4
figure 4

Estimation of the time lag between Tag 2 (A) and Tag 3 (B) compared to Tag 1, when deployed on a captive shark over a 30 h period. Solid lines represent the drift rate estimation calculated while deployed on the animal, while the dashed lines represent the estimate from the robotic flapping in the laboratory

Fig. 5
figure 5

Estimation of the time lag between the anterior (Tag 8) and middle (Tag 7) tags while deployed on a lamprey (A). The solid line represents the drift rate based on the wild deployment and the dashed line in A represents the estimate from robotic flapping in the laboratory. We are also able to estimate the drift between a previously untested Axy-4 tag deployed on the posterior tail of the lamprey and Tag 7 (B)

Fig. 6
figure 6

Estimation of the time lag between a mid-body tag (Tag 8) and an untested Axy-4 tag deployed on the posterior tail of a white sucker

Discussion

The attachment of multiple data loggers along the body of individual animals permits a detailed analysis of body dynamics during field-based locomotion going beyond what is possible to observe in the laboratory. In addition, data streams from IMU loggers provide an extremely rich source of information on animal movement that does not require the digitization and analysis of video recordings. Here we document the temporal drift in the data stream between multiple dataloggers, that if uncorrected, would result in erroneous analyses of animal body movement patterns. We document a methodology to measure temporal drift among independent dataloggers that are deployed on animals when it is not possible to externally validate their temporal offsets. We also demonstrate that different tags log time at different intervals from each either, and we show that the drift rate between two tags varies little over short periods of time (< 1 month). The standard deviation in drift rates between the tags used in these experiments was 0.015 s·h−1. While this deviation is small, when the error is extrapolated over a 24-h period, 33% of tag pairs will drift by more than 0.5 s from each other. While seemingly a minor quantity for the reconstruction of broader ecological movement patterns, for analyses of the movement of different parts of the body and studies of locomotor biomechanics in the field, a 0.5 s shift is substantial. For example, with a fish beating its tail at 1 Hz, this offset represents 50% of the total duration of the behavior of interest, and > 50% of the phase differences between parts of the body. If tags are applied to both a fish’s head and tail, the tail tag will gradually drift out of sync with the head, leading to a misalignment of behaviors and erroneous reconstruction of the phase relationships between head and tail movement, a key variable of interest in studying the biomechanics of fish locomotion.

While we found a drift estimate of 0.5 s per day to be common, it is not the maximal drift variation measured between tags. In our study, two groups of tag drift behaviors emerged: a “low-drift” group, with an average drift rate of − 0.011 ± 0.015 s·h−1, and a “high-drift” group, with an average drift rate of 0.545 ± 0.014 s·h−1. When comparing these two groups, the drift is large, with tags in group 1 drifting over 10 s from tags in group 2 over a 24-h period. This drift is an order of magnitude more than the difference in phase shift along a body, with the different tags representing entirely different tailbeats at the same point in time, solely as a result of drift. Lastly, we observed large instantaneous errors that offset datasets from each other by one second, again causing datasets to shift from each other by an entire tailbeat.

The AGM tags used in this study lack a real time clock, and thus the tags temporal accuracy is dependent on a temperature compensated oscillator stabilized by external capacitors. After discussions with the tag manufacturer, it was suggested variation in the batch of capacitors, quality of capacitors, or model of capacitor of the oscillator might account for the large discrepancy between the “fast” and “slow” groups drift rates. Furthermore, the instantaneous jumps were identified as an issue with the tags firmware, which has since been updated. These findings highlight the importance of testing and measuring clock drift when using multiple data loggers. In addition to multiple IMU tags deployed on a focal animal, biologging data streams are frequently referenced against additional datasets, such as additional tags on the same animal collecting different data using separate internal clocks (e.g. video loggers, swim speed sensors, muscle temperature loggers), or loggers simultaneously deployed on separate animals. Biologging datasets are also often compared to external environmental datasets (e.g. weather stations). As each of these datasets are independently collected, knowing the extent of drift among data streams becomes a key factor in data analysis and interpretation.

In addition to the precision of the components, tag recording frequencies are known to vary with device age, manufacturing tolerances, supplied voltage, and temperature [13, 23]. Temperature is known to be one of the biggest drivers of variation in clock frequency in electronics and usually has a nonlinear impact. As our study is aimed at deploying multiple tags on one animal, all tags are in roughly the same temperature environment and thus simultaneously experience temperature changes. However, as temperature deviates from the electronics designed operating temperatures differences in frequency between tags are expected to increase. We observed linear relationships in drift rate during this experiment, but field and lab experiments were also held at near constant temperatures. As the variation in temperature increases, such as animals moving through thermally stratified environments, variation in drift rates might also be expected to increase, potentially introducing non-linear impacts that are more difficult to correct. Future work should investigate and quantify the potential for temperature-based influences on tag drift rates.

We also chose to focus on the drift rate of tags with respect to each other, and not between tags and the “true” time. Compared to a highly accurate clock, all our tags could have drifted a substantial amount. Thus, the drift values within this paper should not be taken to represent the clocks’ absolute error. As many data products are indexed to “true”, global standardized times, additional experiments are needed to compare how biologgers drift from these time standards. Increasing clock accuracy will likewise decrease the drift rates between tags [13]. For tags purpose-built for simultaneous measurement, developers could incorporate temperature compensating internal crystals of higher accuracy (< < 10 ppm, ~ 0.86 s·h−1) to limit the degree of temporal drift. Throughout our robotic experiments, there was little variation in drift estimates within a tag. However, the stability of these estimates through time is unknown, future work is needed to understand the stability of the characteristic drift rate between tags over time.

We show that animal borne estimates of drift are comparable to controlled simultaneous estimates of drift. However, for animals displaying volitional behavior in the field, care should be employed before uncritically estimating the drift rates. After release, animals are known to exhibit shifts in behavior over time, such as large changes in tail beat frequency immediately post release [24, 25]. This change in behavior could make it difficult to separate the change in timing due to the tag’s temporal drift and the variation due to the animals’ movement. In these cases, alternative algorithms could be employed that would focus on similar or high intensity behaviors only that would be less susceptible variations due to animal behavior [13].

Standardizing time between multiple devices is a commonly encountered problem in electronics [26]. For circuits that are hard wired, time can easily be transferred in real time, or use an external synchronization signal to mark the temporal difference between recording units. Systems have been developed to have multiple data loggers synchronized using an external wire that sends pulses that can be simultaneously received by all loggers [15]. Alternatively, the data recording function can be centralized and where all sensors send information to a single device [12]. However, the size of the central recording station can be large and quite power intensive to have the bandwidth needed to record at a high frequency simultaneously from multiple dataloggers. In these situations, the devices used need to be custom designed and still require physical connections between the loggers, which can be difficult to manage while an animal is performing behaviors involving substantial body deformation. Furthermore, these connections risk altering the movement of each tag due to motion of the connecting wire. Increasingly, communication between tags is becoming wireless. Frameworks have been developed that allow for multiple independent sensors to wirelessly stream to a central data recorder/ processor, which could alleviate the problem of the tags being physically connected [26] or allow tags to periodically synchronize their times during deployments [27]. However, radio frequencies are rapidly attenuated in marine and aquatic environments, limiting wireless communication to acoustic transmission, which lacks the bandwidth to transfer data at a sufficiently high rate needed for recording higher-frequency animal body movements.

Once the drift between two tags is known, there are multiple computational methods that researchers can employ so that the datasets are temporally synchronized. For analytical methods that do not require simultaneous measurements, one of the tags timestamp can simply be recalculated. However, when simultaneous measurements are required for temporal comparison, a commonly employed method is that one, or both, of the datasets can be resampled with interpolated datapoints [28, 29]. However, when data are interpolated, the resulting values are ones that were never actually recorded by the tag. Depending on the method of interpolation, an increase or systematic decrease in the amplitude of recorded signals can be observed. Often, it is preferable to limit data manipulation to retain as much of the original data quality as possible. A simple method that limits data manipulation is to periodically delete or duplicate a single datapoint in one of the tag data streams so that the data are temporally synchronized. This method limits tag data manipulation to single localized time points, with the rest of the data stream being the true recorded values and temporal error between two tags is maximally half the recording frequency.

For future studies that employ multiple independent dataloggers on the same focal individual as shown in Fig. 1, we suggest that prior to field deployments, the tags be tested under controlled conditions of simultaneous movement to calculate drift estimates. In this study we employed a robotic flapping machine with repeated periodic flapping, although simpler methods would likely suffice. Attaching multiple tags to a rigid object, and then shaking the object at the beginning and then several hours later, would provide two estimates of lag. By regressing these two estimates of lag across time a simple estimate of drift can be calculated. Repeating this procedure would provide confidence that the drift estimates are repeatable and provide a baseline estimate of drift. However, we recommend that when deployed on an animal, researchers should still calculate the lag using moving window cross correlation to account for minor variation due to time or temperature. Laboratory based estimates can act as a prior and give confidence to understand the expected magnitude and direction of drift observed in the field among tags.

The use of multiple data loggers on one animal provides researchers with a key method to wholistically capture the movement of animals and significantly expand the ability of natural movement data to inform biomechanical studies. The use of multiple data loggers to capture the kinematics of animals is a rapidly advancing field and has been used to classify gait in horses [29]. However, deploying multiple motion sensing dataloggers has utility beyond biomechanics, as motion sensing data loggers are commonly used to estimate discrete animal behaviors and generate ethograms using both supervised and unsupervised classification [30, 31]. However, classifying all behaviors from a single point on the body can be difficult, especially for behaviors that are similar (e.g. prey capture attempt vs predator avoidance) [30]. Incorporating additional sensors (e.g. gyroscopes and magnetometers) into a single datalogger has improved accuracy of behavioral classification [32]. But by placing multiple sensors across an animal’s body, researchers will be able to add additional features to these datasets further increasing the ability to accurately identify discrete behaviors [33]. For example, placing a datalogger on an animal’s jaw in addition to the body midpoint would aid in the ability to separate prey capture attempts from escape behaviors not involving rapid jaw movements [34, 35].

Conclusions

We demonstrate the magnitude of temporal drift between multiple commercially available tags while deployed on free swimming animals. The methodology we present here allows researchers to use generic, commercially available tags to monitor multiple locations on an animal simultaneously. By employing multiple dataloggers, we can begin to understand movements at separate locations on the body simultaneously to better analyze and discretize specific behaviors. Studies on the complex three-dimensional kinematics of animals can now progress from the laboratory into the wild by capturing volitional behavior with ecologically relevant stimuli [36], and move toward analyzing thousands of locomotor behaviors (i.e. tailbeats and body kinematics) over long time periods to better understand the variability and dynamics of animal biomechanics and behavior.