## 2 Data Acquisition
### Data Preparation  
The first step of dataset preparation is the ground-truth joint-angle computation. The MT Manager software exports the collected raw motion data from the seven sensors as a text file. However, only three quantities, a 3-axis accelerometer, a 3-axis gyroscope, and a quaternion orientation, were extracted. The MT Manager software calculates each sensor's orientation in both Euler angles and unit quaternions and outputs it with reference to a global coordinate system. After the raw data are exported and saved as a text file, the next step is to compute the leg-joint angles which will be used as target values during the supervised neural-network training. The joint-angle calculation, dataset preparation, training, and inferencing steps were computed and programmed on the PyCharm IDE using Python 3.7. Since each sensor is firmly attached to each bone segment of the body, it is assumed that the sensor's orientation corresponds to the orientation of the associated body segment. The orientation difference between the distal and proximal segments then defines the joint rotation angle that connects them. This is mathematically expressed in Equation (1). All attached sensors are aligned to face the same direction. In other words, if a subject stands upright, making his shank and thigh perpendicular to the flat ground, the extension/flexion angle of the knee and hip will be 0\({}^{\circ}\). \[\mathbf{q}^{\textit{dis\_prox}}=\mathbf{*q}^{\textit{dis}}\otimes\mathbf{q}^{\textit{prox}}. \tag{1}\]  
where \(\mathbf{q}^{\textit{dis\_prox}}\) denotes the distal and proximal bone segments orientation difference, \(\mathbf{q}^{\textit{dis}}\) is the distal bone segment orientation, and \(\mathbf{q}^{\textit{prox}}\) is the proximal bone segment orientation. Both the later quantities are measured in reference to the global frame. The '\(\otimes\)' symbol denotes quaternion multiplication while '\(\mathbf{*}\)' indicates quaternion complex conjugate. For instance, the rotation angle of the knee joint is computed from the orientations of the distal (thigh) and the proximal (shank) bone segments. This is illustrated in Figure 5. Subsequently, the quaternion result from Equation (1) was transformed to Euler angles format from which relevant Euler angles corresponding to the extension/flexion of hip and knee joints were taken as the ground-truth values. The size of the computed joint angles is the same in size as the original raw data collected. Figure 4: Experimental area (Google Maps). Two sets of target leg-joint angles were investigated. The first set is comprised of four joint angles, namely the extension/flexion joint angles of both the hip and knee of both legs. The second set contains the ankle dorsiflexion/plantarflexion and hip abduction and adduction joint angles of both legs in addition to the first leg-joint angle set. From the collected data, the rotation of hip, knee, and ankle joints ranges from \(-40^{\circ}\) (flexion) to \(20^{\circ}\) (extension) and \(0^{\circ}\) (extension) to \(80^{\circ}\) (flexion), and \(-18^{\circ}\) (dorsiflexion) to \(40^{\circ}\) (plantarflexion), respectively. Datasets preparation is the second step during the data preparation stage. Datasets are the input arrays for neural networks during deep learning. These are created by cutting the raw time-series data into smaller-sized data pieces. To prepare the datasets, a sampling window of 100 samples-wide (equivalent to 1 s) with an overlap of 80% was employed to cut the time-series raw data as shown in Figure 6. The resultant dataset becomes an array of size 100 \(\times\) 6 inertial data. This method was implemented on all the inertial data of the pelvis, thigh, shank, and foot. The target labels for the neural networks are the joint angles that correspond to the last frame of the shifting window. The target joint angles which correspond to the input inertial datasets are shown with the vertical lines in Figure 6. The target (label) joint-angle data were then organized into 4 \(\times\) 1 and 8 \(\times\) 1 arrays for both sets.