Learning the Orientation of a Loosely-Fixed Wearable IMU Relative to the Body Improves the Recognition Rate of Human Postures and Activities

Features were developed which accounted for the changing orientation of the inertial measurement unit (IMU) relative to the body, and demonstrably improved the performance of models for human activity recognition (HAR). The method is proficient at separating periods of standing and sedentary activity (i.e., sitting and/or lying) using only one IMU, even if it is arbitrarily oriented or subsequently re-oriented relative to the body; since the body is upright during walking, learning the IMU orientation during walking provides a reference orientation against which sitting and/or lying can be inferred. Thus, the two activities can be identified (irrespective of the cohort) by analyzing the magnitude of the angle of shortest rotation which would be required to bring the upright direction into coincidence with the average orientation from the most recent 2.5 s of IMU data. Models for HAR were trained using data obtained from a cohort of 37 older adults (83.9 ± 3.4 years) or 20 younger adults (21.9 ± 1.7 years). Test data were generated from the training data by virtually re-orienting the IMU so that it is representative of carrying the phone in five different orientations (relative to the thigh). The overall performance of the model for HAR was consistent whether the model was trained with the data from the younger cohort, and tested with the data from the older cohort after it had been virtually re-oriented (Cohen’s Kappa 95% confidence interval [0.782, 0.793]; total class sensitivity 95% confidence interval [84.9%, 85.6%]), or the reciprocal scenario in which the model was trained with the data from the older cohort, and tested with the data from the younger cohort after it had been virtually re-oriented (Cohen’s Kappa 95% confidence interval [0.765, 0.784]; total class sensitivity 95% confidence interval [82.3%, 83.7%]).


Introduction
Wearable movement sensors, i.e., sensors that incorporate inertial measurement units (IMUs) and barometric altimeters, have been championed as tools that will positively impact health care [1]. These technologies have demonstrated their utility in the remote monitoring of patient rehabilitation [2], as well as the clinical analysis of gait [3], from which parameters can be extracted to predict falls in the elderly [4,5]. They have come to prominence in the management of Parkinson's disease [6], objectively quantifying patient tremor [7], and tracking the impact of the disease on their gait [8]. Moreover, wearables have been adopted for the longitudinal monitoring of physical activity, which can be used to identify those at risk of developing type-2 diabetes [9] and obesity [10].

Multiple Sensors or a Single Sensor?
The number of sensors that an individual needs to wear for adequate human activity recognition (HAR) is dependent on three factors: (i) the number of activities to be recognized, (ii) the location of the sensor(s) on the body, and (iii) the nature of the sensors (i.e., some arbitrary combination of accelerometers, gyroscopes, barometric pressure sensors, magnetometers, etc.). If the activities to be recognized involve the movement of each of the body's limbs (e.g., lunges, push ups, hand stands, etc.), multiple sensors may need to be worn on the body at specific locations to obtain measurements that allow the movement to be accurately identified. Wearing a single sensor on the body is sufficient if the model for HAR is only identifying gross body movements (e.g., standing, sitting, walking, running), placing the sensor near the body's center of mass is ideal (i.e., the thigh) [11].
In either case, wearing sensors at different locations on the body will increase the performance of a model for HAR [12], but at the expense of user compliance and burden [13], particularly if the sensor(s) must be placed somewhere uncomfortable or unsightly [14]. Consequently, wearable sensor systems for population-based studies are predominantly of the single-sensor variety [15,16], ideally integrating seamlessly into the daily lives of users (e.g., embedded within a watch, necklace, sock or belt) [17].

Smartphone-Based Human Activity Recognition
The dramatic recent increase in smartphone ownership [18,19] coupled with society's dependence on smartphones [20,21] has changed the paradigm. If individuals carry their device with them, the measurements from the smartphone's IMU and barometric altimeter can be analyzed to identify the users' gross body movements throughout the day. As a result, smartphones can be used as tools for the purposes of physical rehabilitation, weight loss, etc., in which the ability to recognize human activity is essential [22]. Finally, the greater penetration of smartphones amongst those of a lower socioeconomic status [23] would enable population-based interventions to be conducted at a reduced cost and with a wider reach. There are different models for HAR which can be adopted [24].

Fixed-to-the-Body
In this scenario, the IMUs embedded within smartphones are used in place of dedicated IMU devices to: (i) detect falls [25], (ii) monitor activities of daily living [26], (iii) monitor the performance of soccer and field hockey athletes [27], and (iv) swimmers [28]. These models assume that the smartphone will be worn at one location on the body and that the device's orientation relative to the body segment on which it is worn is known a priori and does not change during the monitoring period because it is held in place with a strap or similar apparatus.

Body-Position-Dependent
Conversely, models can be designed under the assumption that the smartphone is not strapped to the body and will be placed in either the user's pants/chest pocket [29], or hand or bag [30]. These models do not require the user's smartphone habits to change (as with those in Section 1.2.1) to accommodate the device being fixed to the body, however, this makes it challenging to infer the user's postural orientation due to the variability with which the sensor can be oriented in the pocket with respect to the body (i.e., the initial orientation of the device relative to the body segment on which it is worn cannot be controlled, and the orientation of the device can vary over time since it is not firmly fixed to the body).

Body-Position-Dependent
The final variant relaxes all constraints with respect to the smartphone's position and orientation on the body. Models are robust to device transitions from hand to pants/chest pocket [31], or bag, at any moment [32,33]. A trade-off for this robustness (compared to those discussed in Section 1.2.1 or 1.2.2) is that it can be difficult to determine body posture due to variability in both the device's location and its relative orientation to the body.

Extracting Information for Activity Recognition
There are two broad supervised learning approaches which have emerged to process sensor measurements for HAR: (i) feature engineering and classification, or (ii) deep learning.

Accounting for Variability in Device Orientation and Position
A number of pre-processing techniques have been proposed to reduce the variability in sensor measurements due to the inconsistency of the location and/or orientation with which the device is placed on the body. Khan et al. demonstrated that linear discriminant analysis (LDA) can be used to improve a classification algorithm's ability to distinguish between transitions from sitting to standing (and vice versa), and standing to lying (and vice versa) [34]. They also illustrated how kernel discriminant analysis (KDA) can estimate both the interclass and intraclass variance of features used to separate periods of walking, running, walking upstairs, and walking downstairs [35]. Henpraserttae et al. applied eigenvalue decomposition to tri-axial accelerometer measurements to infer the device's orientation with respect to the body by assuming that most of the acceleration due to body movement is in the forward direction, and that the vertical axis can be inferred from the low-pass filtered acceleration [36].
Yurtman and Barshan proposed another transformation based on singular value decomposition (SVD). They first pre-processed the data from a tri-axial accelerometer, tri-axial gyroscope, and tri-axial magnetometer so that it had unit variance, before SVD was applied to the entire time sequence to make the sensor measurements agnostic to the device's orientation [37]. Yurman et al. followed their seminal work with another method which combined the measurements from the accelerometer, gyroscope, and magnetometer, to estimate the sensor's orientation within the global frame of reference when it is firmly fixed to the body. The differential quaternions they generated, which estimated the relative change in the device's orientation between time intervals, enabled the raw sensor measurements to be expressed in a reference frame invariant to the sensor's orientation [38].

Feature Engineering and Classification
Feature engineering involves the application of domain knowledge to design hand-crafted features [39,40] which describe the changing characteristics of the data with respect to time. These features and labels (i.e., the human activities to be recognized which are temporally aligned with the feature values) are input to a classification algorithm (e.g., decision tree, support vector machine, Naïve Bayes, artificial neural networks, etc.) which tries to derive the best mathematical model that separates the labeled observations, based on the statistic distributions of those features.

Deep Learning/Deep Neural Networks
Alternatively, domain knowledge can be replaced with a standalone artificial intelligence solution that abstracts the entire feature extraction and classification process. Deep learning approaches are a natural extension to artificial neural networks, comprised of numerous neurons and layers, which attempt to learn both the Best Features and model for HAR by using the training labels to determine the value of the neurons' weights at each layer in the network [41]. The performance of these approaches are dependent on the network's architecture and the quality and quantity of the training data. While convolutional neural networks [42], short-time Fourier transforms combined with temporal convolution layers [43], long/short term memory (LSTM) networks [44], or a combination of convolution, recurrent, and LSTM network layers [45], have all been shown to perform exceptionally well, they incur a considerable energy cost when running on a smartphone due to the demands of real-time processing [46].

Contribution
This paper addresses the limitations associated with methods for inferring postural orientation that are dependent on the sensor's precise anatomical placement [47,48] by presenting a novel method (i.e., a hand-crafted feature) for identifying sedentary periods of activity that is robust to variability in the sensor's orientation. The sensor's orientation during walking periods is learned on-line and used as a reference for the upright body orientation (represented by the quaternion q upright ). Comparing the sensor's recent average orientation (over a sliding window) to q upright enables standing and sedentary periods to be distinguished, regardless of the IMU's orientation. It is important to distinguish between standing and sedentary activities due to their differing energy expenditure profiles [49,50]. Furthermore, there are definitive relationships between total sedentary time per day and: type-2 diabetes [51,52]; cardiovascular mortality; all-cause mortality [53,54]; and even cancer [55].

Materials
Wearable sensor data from our previous work [56], in which a cohort of twenty younger adults (15 male and five female) of ages 21.9 ± 1.7 years (Human Research Ethics Advisory, reference number 08/2012/48) and 37 older adults (25 male and 12 female) of age 83.9 ± 3.4 years (Human Research Ethics Committee, reference number HC12316) performed nine human activities whilst a smartphone was placed in their pants pocket, was used to evaluate the method proposed herein. The younger adults were able-bodied university students recruited from the University of New South Wales, Sydney, Australia. The older adults were recruited from a cohort of participants enrolled in an existing study on memory and aging at Neuroscience Research Australia (NeuRA), Sydney, Australia. These participants were community-dwelling and retirement village residents living in inner and eastern Sydney; aged 65+ years; English-speaking; with a mini-mental state examination (MMSE) score of 24 or above; no acute psychiatric condition with psychosis or unstable medical condition; not currently participating in a fall prevention trial.
Sensor data from the IMU and barometric altimeter were originally sampled at f I MU = 100 Hz and f bar = 16 Hz, respectively. The measurements from the IMU and altimeter were also re-sampled at 40 Hz and 20 Hz, respectively, to demonstrate the method's ability to be adapted for a reduced sampling rate, thereby reducing the prospective power consumption of the algorithm. This is important because the usability of wearable sensors increases if they can operate continuously throughout the waking day [24,57].
Periods of human activity, originally labeled as elevator up/down, were relabeled as standing to focus on the clinical relevance of the activity rather than the wider context of the person being in an elevator; this naturally increased the classification performance by reducing the range of activities being classified. Additionally, sitting and lying were collectively re-labeled as sedentary. Consequently, the nine activities described in [56] were reduced to six: sedentary, standing, walking, walking upstairs (WU), walking downstairs (WD) and postural transitions (PT).

Methods
Note in the sections that follow, (i) quaternion multiplication (⊗) and conjugation ( * ) are defined in [58]; (ii) vectors are bold-faced (i.e., b); (iii) quaternions are bold-faced, italicized and normalized unless explicitly stated (i.e., q = q /||q||); (iv) vectors expressed in the sensor frame, or estimated in the global frame of reference, will be denoted with the superscripts s b, and g b, respectively; (v) a function will be denoted as f (. . . ) with arguments inside the brackets.

Generating Data Representative of Different Orientations
Each quaternion in Figures 1a-f was used to transform the accelerometer and gyroscope data (r acc and r gyr , respectively) collected in our previous work [56], into new accelerometer and gyroscope data (v acc and v gyr , respectively) that would have been obtained if the smartphone were re-oriented in the pants pocket (Equation (1)). Note: (i) {r acc , r gyr , v acc , v gyr } ∈ R 3 ; (ii) data from the barometric altimeter were not transformed as these scalar measurements are orientation invariant.
0 v x v y v z = q ⊗ 0 r x r y r z ⊗ q * .
(1) lines labeled x, y, and z denote the original device reference frame, 1 q, whilst the orthogonal basis defined by the vectors, e 1 , e 2 , and e 3 illustrate the device orientation generated. In panels (a-d) the IMU is located on the anterior surface of the thigh (i.e., a pocket on the front of the pants), whilst in panels (e,f) the IMU is located on the lateral surface of the thigh (i.e., a pocket on the outer side of the pants).

Estimating the Orientation of the IMU
The data generated in Section 3.1 were fused using the adaptive error-state Kalman filter (AESKF) for orientation estimation, developed in our previous work [59], to estimate the device's orientation. The tuning parameters of the AESKF algorithm are listed in Table 1. Note, whilst there are many algorithms that can be used to estimate the IMU's orientation, the AESKF was chosen for its computational efficiency relative to other algorithms [59].

Removing the Heading from the Estimated Orientation
The estimated orientation, q AESKF,k , had an arbitrary heading that did not contain any information about the orientation of the IMU on the individual's body, since the person can face in any direction and perform the same activity. Consequently, this was removed by aligning the orientation, q AESKF,k , with the north-facing component of the standard basis, e x = [ 1 0 0 ]. First, the x basis vector of the quaternion, q AESKF,k , was identified and projected to the xy-plane (Equation (2)). Once x xy,k is determined, the quaternion, q north,k , that rotates the device orientation, q AESKF,k , northward can be calculated (Equations (4)-(6)). The resultant quaternion, q k , had a fixed heading, i.e., the yaw angle, ψ = 0 (see Figure 2b), which ensured that the shortest rotation between two quaternions (Section 4.2.2), did not contain any information about changes in the device's heading which normally occur due to turning the body.

Smoothing the Estimated Orientation
The effects of the IMU shifting/re-orienting within the individual's pants pocket as they move through the world were minimized by time-averaging the quaternion, q k , using a computationally-efficient one-pass method [60], to create a moving average (window size N) of the device orientation (Equation (7)) from the last 2.5 s worth of data,q k .

Feature Extraction
The features in Table 2 were aggregated (using a sliding window with 50% overlap) using sensor data from the most recent 2.5 s. Features (1)-(4) were obtained by processing the sensor measurements with finite impulse response (FIR) linear phase filters, as described in our previous work [56]. Whilst novel features (5)-(8) are described in Sections 4.1-4.3. Table 2. Features extracted from the accelerometer, gyroscope, and barometric altimeter.

Squared Magnitude of Pitch/Roll Angular Velocity
In our previous work [56], the three orthogonal gyroscope measurements were each band-pass filtered (between 1 and 20 Hz) to isolate the frequency components predominantly due to walking [61]. The squared magnitude of these three band-pass filtered signals at each time sample, ω 2 bpf,k , was used to distinguish between active/inactive periods of activity. Alternatively, the measurements can be expressed in the estimated global frame of reference (GFR) using the device orientation, q k . The squared magnitude of the pitch/roll rotation, g ω 2 xy,k , can be isolated using Equations (8) and (9) since rotations about the vertical axis are primarily due to turning.

Detecting Sedentary Periods
The tilt angle, Θ tilt,k , was previously used [56] to identify the postural orientation of the body relative to the global frame of reference (GFR) [47,48]. In this previous formulation, the magnitude of Θ tilt,k is dependent on one of the axes of the IMU (the y-axis in Figure 3a) remaining in coincidence with the long axis of the thigh. This constraint is apparent when the IMU is oriented such that another axis is aligned with the long axis of the thigh (Figure 3b), but is also a problem if the orientation of the IMU shifts in the pocket. A new approach is proposed in Section 4.2.2 which compares the average recent orientation with the average orientation during walking periods (i.e., the sensor's orientation during walking periods is continuously learned and used to define the 'upright' orientation, against which all other orientations are compared).

Estimate the Upright Orientation using the Orientation during Walking Periods
Walking periods were identified using the method proposed by Jiménez et al. [62] which analyzed the squared magnitude of the raw tri-axial gyroscope signal, s ω 2 k (see Equation (10)), and the magnitude of the unbiased sample variance, ς 2 acc,k (see Equation (12)), of the squared magnitude of the raw tri-axial accelerometer signal, s a 2 k (see Equation (11)). When both signals are greater than pre-determined thresholds, the individual carrying the IMU was presumed to be walking (see Equation (13)). Note, j = k − N + 1 in Equation (12), and ς 2 acc,k was calculated using a computationally-efficient method [60] with a sliding window of 0.25 s; i.e., N = 0.25 × f IMU .
The scalar and vector components of each orientation, q k , which correspond to these walking periods are stored and used to calculate the 'upright' orientation, q upright,k (see Equation (14) and Appendix A). Note: denotes the set of N indices corresponding to the most recent 2.5 s of data for which b walk,k = 1, and need not be a contiguous set of sample indices.
The approach presented herein improves upon the method proposed by Elvira et al. because: (i) an orientation algorithm is utilized [63] whose estimated inclination angle is immune to magnetic interference [64,65]; (ii) an adaptive error-state Kalman filter (AESKF) is used which enables the estimated orientation to be quickly corrected during 'quasi-static' periods [59]; (iii) the estimated heading (i.e., the yaw component, ψ°) is removed from the orientation estimated (the importance of which is demonstrated in Section 3.2.1); (iv) most importantly this method is believed to be the first to demonstrate the utility of the shortest rotation between two quaternions as a feature for HAR.

Calculate the Shortest Rotation between the Upright Orientation and the Average Recent Orientation
Once the average recent orientation,q k , and the upright orientation, q upright,k , are known, the magnitude of the shortest rotation between them (see Equation (15)) can be calculated (see derivation in Appendix B) and used to distinguish standing and sedentary (seated/lying) periods, regardless of the IMU's orientation relative to the thigh.

Estimating Velocity in the Vertical Direction of the GFR
The inertial acceleration in the sensor frame was obtained by measuring the magnitude of the Earth's gravitational acceleration, ||y a,0 ||, (i.e., the accelerometer measurement during a quasi-static period, where the accelerometer is not moving) and expressing this measurement in the sensor frame of reference as s z k using the accelerometer-corrected attitude, q k (see Equations (16) and (17)). The acceleration due to gravity, as measured in the sensor frame of reference, s g ref,k , can then be subtracted from the raw accelerometer measurement, s y a,k (Equation (18)), to obtain the inertial acceleration in the sensor frame, s d a,k .
This acceleration can be expressed in the estimated GFR, g d a,k = g d a,x g d a,y g d a,z k , using Equation (19). At this point, the sensor's velocity in the vertical direction of the GFR can be estimated by fusing the vertical component of the acceleration, g d a,z,k , with the barometric pressure sensor measurements, p k , using a complementary filter [66] or Kalman filter [67]. Assuming the external acceleration,z k = g d a,z,k , remains constant over the sampling interval, T = 1 f IMU , and the bandwidth ofz k is less than f IMU 2 , the time-propagation of the altitude, z and velocity,ż, can be modeled [68] according to Equation (20):

Process Model
Imperfections in Equation (20), i.e., acceleration not being constant during the sampling interval, and noise in the acceleration input to the system, u k , prevent the system's true state, x, from being observed. Consequently, the system's state can only be estimated asx k , by combining the process model with measurements obtained directly from the system. The 'prediction step' (i.e., Equations (22) and (23)) produces an a priori estimate of the system's state,x − k , and covariance, P − k . Note: (i) Q k is the process noise covariance matrix, (ii) a m 2 ≤ σ acc ≤ a m , where a m is the magnitude of the maximum acceleration the system will experience [68].

Observation Model
The observation model (Equation (24)) transforms the state estimate,x k , to the domain of the barometric pressure sensor p k (i.e., it converts altitude (in m) to air pressure (hPa) [69]), and enables the measurement residual,ỹ k , to be calculated (Equation (26)). The measurement residual has a covariance S k that combines the covariance of the a priori state estimate, P − k , and variance in the measurement from the barometric pressure sensor, R k = σ 2 bar (Equation (27)); i.e., the variance in the barometric pressure when the device remains stationary. The gain in the filter, K k , can be determined by consolidating the covariances of the a priori state estimate and measurement residual (Equation (28)), thereby enabling the a posteriori state estimate,x + k , and covariance, P + k , to be determined as described in Equations (29) and (30). Note: (i) H k is the Jacobian of h(x k ), that is, derivatives with respect to the elements of the state vector x k , evaluated at the estimate x k =x k ; (ii) I 2 a 2 × 2 identity matrix.
It is hoped that the Kalman-filtered velocity estimate,ż k , was able to distinguish between walking periods, upstairs (ż k >> 0), downstairs (ż k << 0), and on a level surface (ż k ≈ 0). This would extend the utility of the Kalman-filtered velocity estimate, beyond applications in fall detection [70], for example.

Hierarchical Description of Human Activity
Rather than use one supervised machine learning algorithm to perform HAR, a hierarchical model of human activity (HMHA) [71,72] was devised and translated into a feature-based model (see Figure 4). A decision tree based on the classification and regression tree (CART) algorithm developed by Brieman [73] was trained for each node of the model and pruned so that there is only one leaf node for each activity class (see an example in Figure 5b). This approach minimized over-fitting [74], ensured that the model was easily interpreted, and makes the process of HAR tractable in the event of misclassification [75]. In addition, the weights of each class were balanced when the decision tree was trained to ensure that the thresholds selected accounted for any class imbalances [76].   6)) in Table 2. Each blue rectangle represents a classification and regression tree (CART) [73] implemented in MATLAB 2013b with 'ClassificationTree.fit'. The CART algorithm used 'uniform' prior class probabilities to ensure that the thresholds selected accounted for any class imbalances.
Decision Tree Algorithm

Performance at a High Sampling Rate
A number of models were developed in which a model for recognizing human activity was trained using all of the sensor data collected from the younger and/or older cohorts using either: (i) the Original Features, i.e., features (1)-(4) in Table 2; (ii) the New Features (i.e., features (5)-(8) in Table 2), and; (iii) four pairs of features (i.e., features 1 and 5; features 2 and 6; features 3 and 7; features 4 and 8 from Table 2) were provided to four separate instances of the CART algorithm to select the four Best Features to separate the human activities into distinct classes according to the structure of the HMHA described in Figure 4a; these pairings represent features which are similar in terms of the information they captures, e.g., features 1 and 5 capture angular velocity information in subtly different ways.
The robustness of each model for HAR was evaluated by virtually re-orienting the device (as described in Section 3.1) to obtain data from the younger and/or older cohorts that are representative of five different device orientations (see Figure 1b-f). Each model's performance was evaluated by training the model with either of the younger and/or older cohorts data and testing the model with either of the younger and/or older cohorts data after it had been virtually re-oriented, using 10-fold cross-validation. Ninety-five percent confidence intervals (95%CIs) were calculated for the: Cohen's kappa (κ) and total classification sensitivity (%), as well as the sensitivity (%) and specificity (%) of each activity class. This process is repeated for the 'Best Features' (determined in the above search procedure).

Translating Performance to Different Sampling Rates
Finally, the HMHA are evaluated by training the model with data from the younger and/or older cohort at either (i) the original sampling rate (i.e.,the IMU sampled at 100 Hz, and the barometric altimeter data sampled at 16 Hz), or (ii) a reduced sampling rate (i.e., the IMU resampled at 40 Hz, and the barometric altimeter data resampled at 20 Hz), and testing the model with the virtually rotated data from the younger and/or older cohort at the reciprocal sampling rate to determine if the performance and thresholds of the model are consistent. The metrics reported in Section 6.1 were also used to evaluate the model's performance.

Comparing Features Using Shannon Entropy
When the Shannon entropy [77] of the training datasets (i.e., Figure 6a,c) or testing datasets (i.e., Figure 6b,d) were compared for the features gω2 xy,k andω 2 bpf,k , two things become evident. Firstly, both features appear to be orientation invariant because the Shannon entropy is constant whether or not it is calculated from the training data or test data (i.e., here the test data was the virtually re-oriented training data). Secondly, the Shannon entropy was reduced by 0.085 bits when the quaternion-derived feature was used in place of the original feature proposed in our previous work, showing an improvement in the separation of the class distributions [56].  Figure 6. The normalized histograms of the active (i.e., the walking, walking upstairs, walking downstairs, and postural transition classes pooled together) and inactive (i.e., the standing and sedentary classes pooled together) classes for the featuresω 2 bpf,k and gω2 xy,k . Panels (a,c) are generated from the training data (i.e., the pooled data from the younger and older cohorts, respectively). Panels (b,d) are generated from the test data (i.e., the pooled data from the younger and older cohort after they have been virtually re-oriented using the quaternions in Figure 1b-f). The bar charts in all panels are 'stacked'. Note that the Shannon entropy for the quaternion-derived feature is both smaller and consistent, irrespective of the data it is calculated from, which suggests that it will be better at distinguishing the activity classes and is orientation invariant.
The featuresΘ tilt,k andθ tilt,k can be used to further separate the inactive class into standing and sedentary (i.e., sitting or lying) classes. When the Shannon entropy was calculated for both tilt angle features using the training data (see Figure 7a,c, respectively) the Shannon entropy [77] dropped by 0.142 bits whenθ tilt,k was used in place ofΘ tilt,k . A more pronounced difference of 0.669 bits was observed betweenΘ tilt,k andθ tilt,k when the Shannon entropy was calculated using the test data (see Figure 7b,d, respectively). Whilst the Shannon entropy ofθ tilt,k increases by 0.291 bits when the test data are used in place of the training data, the shape of the normalized frequency distribution is more consistent for all device re-orientations when compared withΘ tilt,k which increased by 0.818 bits for the re-oriented (test) data. This suggests that the quaternion-derived feature,θ tilt,k is more robust to how a smartphone is initially placed in the pocket.  Figure 7. The normalized histograms of the sedentary and standing classes (illustrated in Figure 4) for the featuresΘ tilt,k andθ tilt,k . Panels (a,c) are the histograms obtained when the training data are used (i.e., the pooled data from the younger and older cohorts, respectively). Panels (b,d) are the histograms obtained when the test data are used (i.e., the pooled data from the younger and older cohort after it had been virtually re-oriented using each of the quaternions in Figure 1b-f). The bar charts in all panels are 'stacked'. Note that the entropy for the quaternion-derived feature is consistently smaller, which suggests that it will be better at distinguishing between activity classes.
Whilst the new feature,θ tilt,k , appears to improve the recognition rate of both standing and sedentary periods of activity, using the change in the shortest rotation between the upward and average orientations, ∆θ tilt,k to distinguish between postural transitions and periods of walking (i.e., walking upstairs, walking downstairs, or walking on a level surface) does not. This is evident by the increase in Shannon entropy (whenθ tilt,k is compared to ∆θ tilt,k ) whether or not the feature values are generated from the training or testing data, i.e., from 0.463 bits to 0.866 bits, or from 0.463 bits to 1.049 bits, respectively (see Figure 8). Additionally, since the Shannon entropy ofā 2 lpfdif,k remains constant at 0.463 bits irrespective of the dataset used, it confirms that the feature previously described [56] is orientation invariant, as expected.
Conversely, both the average differential pressure, ∆P k , and the velocity in the vertical direction of the estimated GFR,v z,k , are orientation invariant as evident by the Shannon entropy which remains constant whether or not the training or testing data are used, for both the original feature (Figure 9a,b) and the quaternion-derived feature (Figure 9c,d). The Shannon entropy of ∆P k (1.795 bits) is substantially smaller thanv z,k (4.070 bits) which suggests that the estimated velocity in the vertical direction (obtained by fusing vertical acceleration and barometric pressure using an extended Kalman filter) of the estimated GFR is not as useful in distinguishing between walking on flat or inclined surfaces when compared to using the rate of change of pressure measured by the barometric altimeter alone.  Figure 8. The normalized histograms of the walking (including walking up or down) and postural transition classes (illustrated in Figure 4) for the featuresā 2 lpfdif,k and ∆θ tilt,k . Panels (a,c) are the histograms obtained when the training data are used (i.e., the data from the younger and older cohorts, respectively). Panels (b,d) are the histograms obtained when the test data are used (i.e., the data from the younger and older cohort after it had been re-oriented with each of the quaternions in Figure 1b-f). The bar charts in all panels are 'stacked'. Note that the Shannon entropy for the original feature is consistently lower than the quaternion-derived feature which suggests that it will be better at distinguishing the activity classes.   Figure 9. The normalized histograms of the walk, walking upstairs, and walking downstairs classes for the features ∆P k andv z,k . Panels (a,c) are the histograms obtained when the training data are used (i.e., the data from the younger and older cohorts, respectively). Panels (b,d) are the histograms obtained when the test data are used (i.e., the data from the younger and older cohort after it had been re-oriented with each of the quaternions in Figure 1b-f). The bar charts in all panels are 'stacked'. Note how the Shannon entropy of each feature remains constant whether it is computed from the training or test data (which, remember, is the training data re-oriented), confirming that both features are invariant to the initial orientation, as expected.
Although speculative, it is likely that large amplitude accelerations measured by the IMU in the pants pocket during walking is masking the subtle pattern changes in vertical acceleration associated with ascending/descending stairs. It is plausible that if the accelerometer had been placed in a chest pocket, an improved estimate of vertical acceleration may have been obtained by the Kalman filter.

Comparing the Overall Performance of Models for HAR
When the HMHA is trained and tested with data from the cohort of younger adults (at the original sampling rate: f IMU = 100 Hz; f BAR = 16 Hz), or trained with the older cohort, and tested on the data from the younger cohort after it has been re-oriented, the performance improvement of the models (i.e., the 95% confidence interval of the Cohen's kappa, κ CI95 , and total class sensitivity, CI95 ) are negligible. For two out of the three remaining scenarios, there are substantial improvements in the model's performance when the quaternion-derived features developed herein (i.e., gω2 xy,k andθ tilt,k ) are incorporated into the process of human activity recognition. This can be observed in Table 3 when the model is trained with data from the older cohort and tested with the data from the older cohort after it has been re-oriented (i.e., κ CI95   Test data were obtained by re-orienting the data from the younger (Y) and/or older (O) cohort (see Section 3.1); † IMU data were re-sampled at 40 Hz, barometer data were re-sampled at 20 Hz.
It is particularly noteworthy that the performance of the model trained with the 'Best Features' using the data collected from the younger cohort and tested with the 'best beatures' using the data collected from the older adults after it has been re-oriented (i.e., κ CI95 = [0.782, 0.793]; CI95 = [84.9%, 85.6%]) is comparable to the performance of the model trained with the data collected from the older cohort and tested with the data from the younger cohort (i.e., κ CI95 = [0.765, 0.784]; CI95 = [82.3%, 83.7%]). This contradicts the finding of our previous work [56] in which the performance of a model for HAR trained on younger cohorts degraded substantially when tested on older cohorts (due to the use of the tilt angle feature,Θ tilt,k , which was not orientation invariant (see Table 3, the column labeled 'Original Features')), compared to the opposite scenario in which the model is trained with the older cohort's data and tested with the data from the younger cohort, which gives the better performance.
The improvements in total classification sensitivity and Cohen's kappa gained by incorporating the quaternion-derived features (see Table 3 column labeled 'Best Features') persist when the data from the IMU are re-sampled at a reduced rate (see the column labeled 'Best Features † ' in Table 3). This demonstrates the robustness of both the features and the HMHA to a decrease in the sample rate, which is an important design consideration given the limited battery life of wearable sensors (i.e., smartphones, smartwatches, etc.). Interestingly, there are marginal improvements in Cohen's kappa (i.e., from κ = [0.732, 0.742] when f IMU = 100 Hz to κ = [0.778, 0.787] when f IMU = 40 Hz) and total class sensitivity (i.e., from CI95 = [80.3%, 81.1%] when f IMU = 100 Hz to CI95 = [84.1%, 84.8%] when f IMU = 40 Hz) when the model is trained with the data from the younger and older cohorts and tested with the data from the younger and older cohorts after it has been re-oriented. Upon analyzing the class sensitivity of these two hierarchical models of human activity, it is evident that this is primarily due to an increase in the sensitivity of detecting the walking class, from ∼72% to ∼82% (see Figure 10xv,xx). This improvement can be attributed to the use of the quaternion derived feature, gω2 xy,k which measures the amount of pitch/roll rotation in the estimated GFR, a more consistent frame of reference than the local sensor frame.  Figure 10. The column titled: 'Original Features' (i.e., panels (i-v)) correspond to hierarchical models of human activity that were trained and tested with the features developed in our previous work [56] using the hierarchical model of human activity (HMHA) illustrated in Figure 4b; 'New Features' (i.e., panels (vi-x)) correspond to hierarchical models of human activity that were trained and tested with the features developed herein using the HMHA illustrated in Figure 4c; 'Best Features' (i.e., panels (xi-xv)) correspond to hierarchical models of human activity that were trained and tested with a combination of the original and New Features using the HMHA illustrated in Figure 4d; 'Best Features † ' (i.e., panels (xvi-xx)) equivalent to 'Best Features' with the IMU data re-sampled to 40 Hz, the barometer data to 20 Hz.

Identifying Which Features Drive Model Performance
When Figures 10i,xi are compared (i.e., a HMHA trained with the Original Features extracted from the younger cohort and a HMHA trained with the Best Features extracted from the younger cohort), the differences in the model's performance become apparent. Most notably, the sensitivity for the postural transition class increased from 70.05% to 86.64%. This improved performance is a by-product of modest increases in the model's ability to identify standing (i.e., the standing class sensitivity increased from 88.29% to 89.98%) and sedentary periods of activity (i.e., the class sensitivity increased from 93.67% to 94.42%). These pieces of evidence support the argument that the quaternion-derived feature, gω2 xy,k , is better at distinguishing periods of activity (i.e., walking, or postural transitions) from periods of inactivity (i.e., standing or sedentary), a trend which is consistent across each of the five training and testing scenarios proposed in Section 6. However, it is likely that gω2 xy,k would not be as effective in this task if the smartphone is placed in the user's chest pocket, which pitches and rolls less when compared to the thigh (i.e., it rotates less about the x and y axis of the estimated GFR) during walking.
The underlying causes for the improvement in the HMHA become clear after analyzing the sensitivity of the activity classes listed in Figure 10. When the columns corresponding to the HMHAs built using the Original Features and New Features (e.g., when Figure 10i is compared to Figure 10vi, Figure 10ii to Figure 10vii, and so on) were compared, it is evident that the model's sensitivity to periods of walking upstairs decreased dramatically (e.g., in the case of (i) and (v), from 84.21% to 58.16%) when the differential pressure, ∆P k , was replaced with the moving average velocity in the vertical direction of the estimated GFR,v z,k . This persisted whether the data from the younger or older cohort was used (i.e., when the columns entitled 'Original Features' and 'New Features' of Figure 10 are compared, the model's sensitivity to periods of walking either upstairs or downstairs is reduced). ∆P k is superior tov z,k in estimating vertical velocity and hence walking on stairs.
On the other hand, whenΘ tilt,k was substituted withθ tilt,k , the sensitivity of the model to standing classes increases (from 60-70% to >80%) when the HMHA was trained with: (a) the older cohort's data and tested with the older cohort's data after it had been re-oriented (the second row in Figure 10); (b) the younger cohort's data and tested with the older cohort's data after it had been re-oriented (the fourth row in Figure 10); (c) the data from both cohorts and tested with the data from both cohorts after it had been re-oriented. This improvement underscores the utility of learning the orientation of the device when the body is definitely upright (i.e., when walking), demonstrating how this method can intuitively account for the variability in sensor measurements which may arise due to inconsistent device orientation when the IMU is placed on the body.
In addition, the rate of misclassification of sedentary and stationary periods of activity as postural transitions decreases markedly. This phenomena is consistent across the five scenarios evaluated (recall Section 6). When the columns labeled 'Original Features' and 'Best Features' are compared row by row, periods of standing that were originally classified as postural transitions are all but eliminated (e.g., compare Figure 10i and Figure 10xi), whilst the misclassification rate of sedentary activity as postural transitions decreased from ∼16% to ∼9% (compare Figure 10i and Figure 10xi); ∼32% to ∼5% (compare Figure 10ii and Figure 10xii); ∼9% to ∼5% (compare Figure 10iii and Figure 10xiii); ∼33% to ∼10% (compare Figure 10iv and Figure 10xiv); ∼29% to ∼7% (compare Figure 10v and Figure 10xv).

Comparing Model Performance at Different Sampling Rates
Due to the limited battery life of smartphones, it is becoming increasingly important that algorithms for human activity recognition are able to operate at a reduced sampling rate without suffering a degradation in classification accuracy. Consequently, the robustness of the model's developed with the 'Best Features' were evaluated by training the model with the data collected from the younger and/or older cohort at 100 Hz, and testing the model's performance with data from the younger and/or older cohort at 40 Hz after it had been virtually re-oriented (and vice versa). From Table 4 it is evident that both the Cohen's kappa, and total class sensitivity of the HMHA proposed in Figure 4d remain consistent (i.e., the 95% confidence intervals overlap for almost all of the training and testing combinations evaluated) whether or not the HMHA is trained with the data at 100 Hz (i.e., the higher sampling rate) and tested with the re-oriented data at 40 Hz (i.e., the reduced sampling rate), or the reciprocal scenario in which the HMHA is trained with the data at 40 Hz and tested with the re-oriented data at 100 Hz. Test data were obtained by re-orienting the data from the younger (Y) and/or older (O) cohort (see Section 3.1); † IMU data were re-sampled at 40 Hz, barometer data were re-sampled at 20 Hz.
The sole exception to this trend is the scenario in which the data re-sampled at 40 Hz from both the younger and older cohorts are used to train the HMHA, whilst the data sampled at 100 Hz from the younger and older cohorts after it has been re-oriented are used to test the HMHA. In this particular scenario, the ninety-five percent confidence interval of the Cohen's kappa, κ, increased by ∼0.04 from κ CI95 = [0.732, 0.742] to κ CI95 = [0.776, 0.786]. Similarly, the ninety-five percent confidence interval of the total class sensitivity increased by ∼3% from CI95 = [80.3%, 81.1%] to CI95 = [84.0%, 84.7%] (see the bottom row of Table 4).
After analyzing Figure 11 it is evident that the model's sensitivity to each activity remains relatively consistent as long as only one of the cohort's data is used to train the model, and the other cohort's data is used to test the model, irrespective of the sampling rate (i.e., when Figure 11iii,viii,xiii are compared; Figure 11iv,ix,xiv are compared, and so on). When both cohort's data are used (i.e., when Figure 11v,x,xv are compared), the sensitivity of the model to the sedentary, standing, and postural transition classes is remarkably consistent whilst the sensitivity of the model to the three different walking, classes varies (whether or not the HMHA is trained with the data re-sampled at 40 Hz or the data sampled at 100 Hz). From Table 5 it is easy to see that this robustness in performance can be attributed to the relatively constant threshold values of gω2 xy,k , andθ tilt,k which change by <0.1 (rad 2 ·s −2 and radians, respectively), suggesting that these features are robust to both the variation in sampling rate and the cohort from which the threshold is extracted (i.e., the threshold changes little whether trained on the younger and/or older cohort's data).
Interestingly, the recognition rate of the postural transition class also remains fairly consistent (i.e., between ∼89-91%), irrespective of the data which are used to train and test the HMHA. This suggests thatā 2 lpfdif,k is also robust to variations in the sampling rate of the IMU and the cohort from which the threshold are determined (see Table 5).
In the case of the walking, walking upstairs, and walking downstairs classes, the differences were negligible when the HMHA was trained with the data sampled at 100 Hz and tested with the same data after it had been re-oriented; or trained with the data at 100 Hz and tested with the data re-sampled at 40 Hz after it had been re-oriented. However, when the model was trained with the data re-sampled at 40 Hz and tested with the data at 100 Hz there were slight changes in the class sensitivity when compared to either of the two previously mentioned scenarios. Figure 11. Class Sensitivity for a Hierarchical Model of Human Activity Recognition using the Best Features: (i-v) trained with the IMU data at 100 Hz and tested with the IMU data at 100 Hz after it has been re-oriented; (vi-x) trained with the IMU data at 100 Hz and tested with the IMU data at 40 Hz after it has been re-oriented; (xi-xv) trained with the IMU data at 40 Hz and tested with the IMU data at 100 Hz after it has been re-oriented.
In particular, the model's sensitivity to the walking class increased from ∼71-72% to ∼82% (trained with data at 40 Hz, tested with data at 100 Hz) due to marked reductions in periods of walking upstairs and walking downstairs being incorrectly identified as walking on a level surface (i.e., from 7.95% to 4.5% and 15.32% to 7.82%, respectively). Similarly, the sensitivity of the walking upstairs class decreased from ∼76% to ∼68% (see Appendix C, the row labeled 'Train Y&O Test (Y&O) * ' in Table A2) due to the increased misclassification of periods of walking upstairs as periods of walking on a level surface (i.e., from 4-5% to ∼10%; see Figure 11 and compare panels (x) and (xv)). This suggests that the smaller threshold of ∆P k = 0.092 hPa·s −1 (see Table 5) is better (when compared to ∆P k = 0.119 hPa·s −1 ) at distinguishing between periods of walking on a level surface versus walking upstairs.
This trend was mirrored in the reduction of the hierarchical model's sensitivity to the walking downstairs class; i.e., decreasing from ∼91-92% to ∼87% (see Appendix C, the row labeled 'Train Y&O Test (Y&O) * ' in Table A2) due to the increased misclassification of periods of walking downstairs as periods of walking on a level surface (i.e., from 3-4% to ∼8%; see Figure 11 and compare panels (x) and (xv)). Again, this suggests that the threshold of ∆P k = −0.062 hPa·s −1 (see Table 5) is better than the threshold of ∆P k = −0.094 hPa·s −1 (a change of ∼51% in the threshold value) at distinguishing between periods of walking on a level surface versus walking downstairs.

Comparison to the State-of-the-Art
In order to draw a fair comparison with other published work that is representative of state-of-the-art methods, the scope of these comparisons is limited to reports which only utilized the smartphone's internal sensing components to classify human activity. With this in mind, the state-of-the-art deep learning methods (recall Section 1.3.3) proposed by Ordoñez et al. [45] and Li et al. [78] are excluded because they utilize measurements from multiple IMUs that are placed at different anatomical locations on the body, whilst the works of Ravi et al. [43] and Ronao and Cho et al. [42] are included. Similarly, the 'feature engineering and classification'-based approaches (recall Section 1.3.2) developed by Bao and Intille et al. [79] are omitted, whilst the works of Anguita et al. [80] and Shoaib et al. [29] are included.
Anguita et al. developed a hardware-friendly multi-class support vector machine which processed the accelerometer and gyroscope data (at 50 Hz) from a waist-worn smartphone (i.e., attached to a belt worn about their waist) to identify activities of daily living in a cohort of thirty participants aged between nineteen and 48 years. From these six channels, they extracted 561 spatial or spectral features (every 1.25 seconds using 50% overlapping windows) to identify six activities with a sensitivity between 72% and 96%: walking (95.6%), walking upstairs (72.1%), walking downstairs (79.7%), standing (92.2%), sitting (96.4%), and lying (100%) [80].
Shoaib et al. evaluated the utility of a smartphone's internal sensors for the purposes of human activity recognition. They studied ten male participants, aged between 25 and 30 years, whilst a smartphone was firmly fixed to their body with a strap at one of five positions on their body (right and left front jeans pocket, on a belt near the right hip, right wrist, right upper arm). A smartphone application recorded the accelerometer, gyroscope, and magnetometer data at 50 Hz whilst each participant performed six activities of daily living (walking, jogging, sitting, standing, biking, walking upstairs, and walking downstairs) [29]. When features were extracted every two seconds (with 50% overlapping windows), the gyroscope-based features proved most effective in identifying periods of walking upstairs and walking downstairs (particularly when the sensor was placed in the jeans pocket or on the belt), whilst features from the magnetometer should only be used if they are independent of heading. Moreover, they advocate against 'blindly combining different sensors', suggesting a more manual approach to system and feature design.
Deep learning approaches attempt to tease out more subtle differences, imperceptible by human observation, in wearable sensor data which can be used for the purposes of HAR. Ronao and Cho, recruited 30 participants (age range not disclosed) to evaluate the performance of a model for HAR, based on deep convolutional neural networks (convnet). The smartphone was placed in a pocket of the participants' clothing (location on body not disclosed), whilst data from the accelerometer and gyroscope were recorded at 50 Hz [42]. When the data were segmented in 2.5 second intervals with 50% overlap, the convnet could identify six activities: walking (98.99%), walking upstairs (100.00%), walking downstairs (100.00%), standing (93.23%), sitting (88.88%), lying (87.71%); with an overall sensitivity of 94.79%. Before the accelerometer and gyroscope data could be processed, each channel (of six) needed to be normalized by subtracting the mean of each signal, and dividing each channel by the channel's standard deviation. At this point, 2.5 second data segments are input to a five-layer convnet comprised of three convolutional/pooling layers (with 96, 192, 192 neurons in each layer, respectively), a fully connected layer comprised of 1000 neurons, and a softmax classification layer with six neurons.
Ravi et al. combined features extracted from the spectrogram (i.e., the short-time Fourier transform coefficients) of accelerometer and gyroscope signals (both of which sampled at either 50 Hz or 200 Hz, respectively) with a three layered network comprised of a temporal convolution layer (15 filters, 80 nodes), fully-connected layer, and soft-max classification layer for the purposes of HAR. Data was obtained from ten subjects (using five different smartphones) who were allowed to place the phone anywhere on their body (or in their hand/bag) whilst they performed six activities of daily living. The total class sensitivity of their model for HAR was 95.7% with class sensitivities of ∼95% (running), ∼95% (walking), ∼96% (cycling), ∼96% (casual movement), ∼96% (public transport), ∼98% (idle), and ∼74% (standing). Whilst the features derived from the six channel spectrogram enabled highly-variable activities to be distinguished from repetitive activities, the absence of time-domain-based features limited the model's ability to infer the user's postural orientation, which was further limited by the fact that the phone could be placed at various parts of the body, in the hand, or in a bag [43].
The model for HAR constructed by Gu et al. [81] implemented denoising autoencoders (two layers, 1000 neurons per layer) combined with a softmax classification layer to automate the HAR process. Features were extracted from two-second intervals of data from the smartphone's accelerometer, gyroscope, magnetometer, and barometer (all of which were sampled at 64 Hz, except for the barometer which was sampled at 32 Hz). Twelve participants (six male, six female) aged between twenty-five and thirty-five years were recruited to train the model to recognize eight activities of daily living. When the data from all four sensors were used by the denoising autoencoders (corrupting noise level = 0.5, learning rate = 1 × 10 −3 , weight of sparsity penalty term = 1), the F-measure is 94.04% and the class sensitivity for the eight activities are: stationary (∼98%), walking (∼92%), stationary but using the phone (∼96%), running (∼97%), walking upstairs (∼94%), walking downstairs (∼93%), elevator up (∼84%), elevator down (∼87%).
A general pitfall of all of the above deep learning approaches is that this approach does not inherently allow the training of the neural network to be constrained by the domain knowledge that the smartphone could be placed anywhere on the body and with any orientation. For deep learning approaches, some safeguards against obtaining a classifier model which is not robust to such variability in smartphone placement and orientation involves collecting large datasets which capture this variability, or to perform preprocessing of the smartphone signals to generate features which are tolerant to such variability; the latter somewhat goes against the spirit of the deep learning approach.

Limitations
There are limitations with the study presented herein which need to be acknowledged. The model for HAR developed is dependent on the wearable sensor (i.e., device containing an IMU and barometer, such as a smartphone) remaining in the pants pocket throughout the day, which is not a realistic expectation since the individual's lower body garments may not always have a suitable pocket, or a pocket large enough to place the wearable sensor. If the wearable sensor is strapped to the thigh, the quaternion-derived feature,θ tilt,k , should always be able to separate standing and sedentary periods. If the device is sporadically removed from the pants pocket whilst the person is moving, it is conceivable that the walking detector (Equation (13)) could 'learn' an incorrect upright orientation, q upright,k , thereby reducing the accuracy of the model for HAR until it relearns the correct upright orientation from the next 2.5 s of true walking data; robustness to this scenario will be evaluated in future work.

Conclusions and Future Work
This paper developed a model for HAR capable of recognizing six human activities (standing, sedentary, walk, walk upstairs, walk downstairs, as well as postural transitions between the standing and sedentary classes), regardless of the smartphone's orientation in the pants pocket by using a quaternion-based complementary filter [63] to estimate the device's orientation, thereby enabling sensor measurements to be expressed in a consistent frame of reference (the world/global frame). Four New Features were developed, and two were shown to be useful in the classification of human activities, namely gω2 xy,k , which utilized an estimate of the IMU's orientation to determine the magnitude of the pitch/roll angular velocity, andθ tilt,k , which measured the angle between the recent average orientation and the estimated upright orientation; upright orientation was estimated as the average orientation of the IMU when walking was detected. The success of these quaternion-derived features suggest that existing methods for recognizing human activities would benefit from converting all measurements to the global frame of reference where the feature values would be more consistent, especially if the orientation of the IMU with respect to the body is not fixed.

Acknowledgments:
We gratefully acknowledge our colleagues at UNSW, Jingjing Wang and Kejia Wang, and at Neuroscience Research Australia, Stephen Lord, Kim Delbaere, and Matthew Brodie, for their assistance in collecting data for the older cohort.

Conflicts of Interest:
The authors declare no conflict of interest.

Appendix B. Shortest Rotation Between Two Quaternions
The rotation that brings two quaternions, q A and q B , into coincidence is q AB = q A ⊗ (q B ) * , i.e., q B ⊗ q AB = q A . The shortest angle between these quaternions, 0 ≤ ϑ ≤ π is given by q AB,0 , the scalar component of q AB , Equation (A2).
Appendix C. Ninety-five Percent Confidence Intervals for the Class Sensitivity and Class Specificity of the Hierarchical Models of Human Activity * The test data was obtained by virtually re-orienting the data from the younger (Y) and older (O) cohort as described in Section 3.1. Test data were obtained by re-orienting the data from the younger (Y) and/or older (O) cohort (see Section 3.1); † IMU data were re-sampled at 40 Hz, barometer data were re-sampled at 20 Hz.