Deriving biomechanical descriptors of movement using magnetometer data
In a recent study on behaviour recognition using accelerometers [10], posture, movement intensity, and periodicity were used as biomechanical descriptors of static and dynamic behaviours.
Behaviour separation using posture estimated from magnetometer data can be achieved when a given axis of the sensor aligns in two opposite directions along the vertical axis for the two static behaviours to be separated (Fig.1). [10] used the accelerometer’s surge axis, which corresponds to the same direction as that of the magnetometer’s roll axis in the present study, for quantifying posture since values along this axis were least susceptible to changes caused by possible rotations of the collar around the axis of the meerkat’s cylindrical neck. Let \( {\overrightarrow{B}}_E \) be the local magnetic field vector with dip angle δ at the sensor location. During meerkat vigilance (Fig. 1a), in an idealised case, the roll axis would point directly upwards, perpendicular to the horizontal plane (the latter shown as a salmon-pink disk), and the sensor’s roll axis would measure \( \left|{\overrightarrow{B}}_E\right| sin\delta \). During curled-up resting (Fig. 1b), on the other hand, the roll axis would point downwards, perpendicular to the horizontal plane, and the sensor’s roll axis would measure \( -\left|{\overrightarrow{B}}_E\right| sin\delta \). We hypothesised that this polarity (positive and negative value of \( \left|{\overrightarrow{B}}_E\right| sin\delta \)) would enable discrimination of the two static behaviours, vigilance and curled-up resting. When the roll axis lies in the horizontal plane (Fig. 1c), however, the measurement along the roll axis of the projection of \( {\overrightarrow{B}}_E \) onto the horizontal plane, \( \left|{\overrightarrow{B}}_E\right| cos\delta \), would be affected by the azimuthal orientation of the animal (angle α between the direction faced with respect to magnetic North in the horizontal plane), and the measured value would now be \( \left|{\overrightarrow{B}}_E\right| cos\delta cos\alpha \). Since values of α may vary arbitrarily between 0° and 360°, the roll axis would record measurements in the range of [\( -\left|{\overrightarrow{B}}_E\right| cos\delta \), \( \left|{\overrightarrow{B}}_E\right| cos\delta \)] when it lies in the horizontal plane. Thus, static behaviours such as belly-flat resting as well as dynamic behaviours such as foraging and running may be difficult to separate only on the basis of posture, since the sensor’s roll axis can be oriented arbitrarily with respect to the North direction.
In carrying out dynamic activities such as running, the collar sensor would follow in the wake of movements made by the torso and neck as the animal heaves and sways, and rotate around the animal’s neck. Thus, the magnetometer’s axes would continuously change orientation with respect to the local magnetic field lines. The more intense the bodily movement is, the faster the sensor would change orientation with respect to the local field lines. For instance, large oscillations in triaxial magnetometer signals recorded during cheetah (Acinonyx jubatus) running behaviour have previously been reported [2]. If this motion is periodic, the change in sensor orientation will also be periodic. Thus, the magnitude of change in recorded signal values could be used as an indicator for the intensity of movement, and help distinguish between static and dynamic behaviours. Further, the periodicity of the rate of change in recorded signal values could be used to distinguish between the dynamic behaviours: for meerkats, running has been shown to be highly periodic, and foraging to be relatively aperiodic [10]. Measures of both intensity and periodicity may be characterised either by computing the amount of variation in the recorded signal itself, through measures such as standard deviation, or by computing the amount of variation in the time-differentiated signal.
Data collection and groundtruthing
Data from eleven recording sessions of three hours each were collected on ten adult meerkats at the Kalahari Meerkat Project, as described in [10]; one of the individuals was recorded twice. The individuals bore collars equipped with an inertial measurement unit (IMU) (adapted version of Physilog IV, GaitUp SA, Switzerland) containing a triaxial accelerometer (recording at 100 Hz/axis) and triaxial magnetometer [23], the latter recording at a sampling frequency of 50 Hz/axis with a range of ±1000 μT and 16-bit resolution. The size of the collar case (IMU and battery) was 35 mm × 29 mm × 19 mm, and overall weight was < 25 g. The total geomagnetic field intensity at the study site was 27.3 μT, with a declination angle of 17.9° pointing westwards and a dip (or inclination) angle of 65° pointing upwards, according to the International Geomagnetic Reference Field ([24]; values calculated from https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml#igrfwmm). Collars were positioned on the animals so that the axes of the magnetometer were oriented as shown in Fig. 2. The magnetometer was calibrated prior to each recording session according to the method by [25]. The software used to read magnetometer data resampled the data to 100 Hz/axis using linear interpolation (with the 'interp1' function in MATLAB R2016b) to match the sampling frequency of the accelerometer also present on board the recording device.
After the captured animal was collared and released, it was filmed using a handheld video camera recording at 25 frames/second that was synchronised with the collar sensor (see Appendix S1, Additional file 1 for more details). All videos were annotated using Solomon Coder (version: beta 17.03.22). This video annotation served as the groundtruthing data for our behaviour recognition scheme. Archetypal behaviours observed across a wide range of species [10] – foraging, running, and resting – were considered for the ethogram. In addition, we also considered vigilance, a behaviour typical for meerkats, where the individual is stationary and lifts its head and torso to survey its surroundings. Biologically significant information may be derived from these four behaviours [10]: (1) general stress or alertness level through vigilance, (2) periods of inactivity, mainly due to fatigue or excessive heat, through resting (3) proxies for body condition through foraging, and (4) high energy expenditure and possible important events such as aggressive interactions with rival groups through running. Any behaviour dependent upon contextual information, such as territory marking or dyadic social interactions, was excluded from the ethogram.
Developing candidate features to quantify biomechanical descriptors of movement
Raw triaxial magnetic field intensity data were calibrated and summarised in the form of features quantifying posture, movement intensity, and periodicity. Feature development followed from previous work done with accelerometers [10]. We computed features on a sliding window w of size two seconds with an overlap of 50% between successive windows. Windows containing data from exactly one video-labelled behaviour were retained, and those containing transitions between different behaviours were excluded. For each biomechanical descriptor, the candidate features (Table 1) were computed on each two-second window w containing N = 200 calibrated triaxial magnetic field intensity values recorded along the roll (mroll), pitch (mpitch), and yaw (myaw) axes.
Table 1 Feature development. Candidate features developed to describe the three biomechanical descriptors used in this study: posture (#1), movement intensity (#2 to #5), and movement periodicity (#6 to #9) Posture
We obtained a measure of neck inclination with respect to the local magnetic field vector by computing the mean of calibrated magnetic field intensity data recorded in each window w along the roll axis (meanRoll, equation (1), Table 1).
Intensity
We developed four candidate features (#2 to #5, Table 1) to quantify movement intensity: one (stdRollw, equation (2), Table 1) was aimed at characterising the extent to which mroll varied in window w, whereas the three others aimed to quantify the rate of change of sensor orientation through metrics based on the time-differentiated signal (meanAbsDiffRollw, equation (3); axMaxMeanAbsDiffw, equation (4); avgMeanAbsDiffw, equation (5), Table 1). Since the differentiation operation results in amplification of sensor- and analog-to-digital signal quantization-generated noise at higher frequencies [26], the raw calibrated magnetometer signal was first low-pass filtered using a Butterworth filter of order 4 and cut-off frequency 10 Hz. MATLAB’s (version R2016b) 'diff' function was used to compute differences between successive signal samples, and each resulting difference was multiplied by the sampling frequency (since, in d/dt, dt = 1/sampling frequency for discrete signals) to complete the time differentiation operation. To quantify the amount of rate of change in features computed from the time-differentiated signal (features #3, #4, #5 in Table 1), we took the absolute values of each differentiated sample and then computed the mean.
Periodicity
We quantified movement periodicity through the use of the Fourier transform (FT). As done in [10], for each window w, before computation of the FT, each input signal was filtered with a Butterworth low-pass filter of order 4 and cut-off frequency 10 Hz, normalised, zero-padded to smooth the frequency spectrum [27] by adding 100 zeroes before and after each two-second input signal, and windowed using the Blackman-Harris windowing function. This processed signal was then transformed with a frequency resolution of U = 0.01 Hz (corresponding to FT computation at L = Fs/U = 10,000 frequencies), and the squared magnitude of each Fourier coefficient (\( {c}_{f_i}^2 \), i ∈ 1…L), corresponding to the power of the signal at frequency fi, was computed. Triaxial signals yielded three sets of coefficients, one for each axis: { \( {c}_{f_i, roll},{c}_{f_i, pitch},{c}_{f_i, yaw} \) } in the case of the raw calibrated triaxial signal, and { \( {\delta}_{f_i, roll},{\delta}_{f_i, pitch},{\delta}_{f_i, yaw} \) } in the case of the time-differentiated signal. For a triaxial signal, the resulting FT was averaged across the three axes. From the final FT, the maximum power obtained across all frequencies fi (i ∈ 1…L) was chosen as a measure of the signal periodicity. This FT-based operation was applied to four different input signals in order to develop four candidate features characterising movement periodicity: (1) roll component of the local magnetic field (rollFftPeakPower, equation 6, Table 1), (2) triaxial magnetometer signal (avgFftPeakPower, equation 7, Table 1), (3) time-differentiated roll signal (rollDiffFftPeakPower, equation 8, Table 1), and (4) time-differentiated triaxial signal (avgDiffFftPeakPower, equation 8, Table 1). All feature computation was done using MATLAB R2016b.
Feature selection
To enable direct comparison with the three-feature accelerometer-based model in [10], we selected one feature for each of the three biomechanical descriptors of posture, movement intensity, and periodicity. We tested features quantifying movement intensity (feature # 2 to #5, Table 1) for their efficacy in separating static and dynamic behaviours, and foraging and running. We tested features quantifying movement periodicity (feature #6 to #9, Table 1) for their efficacy in separating foraging and running. We tested five different feature selection methods based on the filter method (using the 'rankfeatures' function in MATLAB R2016b,© 2003–2016 The MathWorks, Inc. See Appendix S3, Additional file 1 for more details) to select one feature to quantify movement intensity, and one to quantify periodicity. meanRoll (feature #1, Table 1), being the only candidate developed to describe posture, was chosen by default.
Behaviour recognition scheme and cross-validation
The behaviour recognition scheme had the same hierarchical tree-like structure and hybrid form as the one found for meerkat behaviour recognition using accelerometers [10]. The scheme consisted of three nodes, each dividing a parent behavioural category (static or dynamic) into two daughter behavioural types (vigilance/resting or foraging/running, respectively). A Support Vector Machine (SVM) was used at each node to obtain optimal feature-value thresholds in a completely automated fashion. At the first node, features encoding information on posture and movement intensity were used to separate static and dynamic behaviours. At the second node, static behaviours were separated into vigilance and resting using postural information. At the third node, dynamic behaviours were separated into foraging and running using information on movement intensity and periodicity. The 'svm' learner in MATLAB R2016b’s 'fitclinear' function (© 2015–2016 The MathWorks, Inc.) was used to train the SVM at each node.
To validate the predictions of the SVM-SVM-SVM hybrid model with the chosen features against groundtruth video-annotated behaviours, two cross-validation methods were tested: (1) stratified ten-fold cross-validation (STRAT), which evaluates model performance when the frequency and duration of different behaviours may be skewed, and (2) leave-one-individual-out cross-validation (LOIO), which evaluates model performance when inter-individual variability is taken into account [10]. We used standard confusion matrix-based metrics to evaluate and compare model performance. These performance statistics included three behaviour-specific metrics (sensitivity, precision, and specificity), and overall model accuracy (see Appendix S2, Additional file 1 for mathematical definitions, computation and interpretation). Custom software was written in MATLAB R2016b to perform cross-validation.