On-Line Algorithms of Stride-Parameter Estimation for in-Shoe Motion-Sensor System

We propose two on-line algorithms for stride parameter estimation for an in-shoe motion-sensor system (IMS) system: one for on-line stride segmentation based on stable foot-flat detection using foot-sole angle and the other for a three-dimensional zero-velocity-update for accurate stride parameterization. We developed a small and lightweight IMS device, which consists of an inertial measurement unit, micro control unit, and peripheral electrical components, integrated with an insole so that it can be placed inside a shoe at the arch of the foot. Stride parameters, i.e., stride length, walking speed, foot height, circumduction, peak foot sole angle in the dorsiflexion and plantarflexion directions, and toe-in<inline-formula> <tex-math notation="LaTeX">$/$ </tex-math></inline-formula>out angle, that characterize a user’s foot motion are estimated. We recruited 30 healthy participants and evaluated the precision of our IMS system by comparing the stride parameters calculated with this system with those acquired from a motion-capture system. The results indicate the precision of the system in terms of the root mean square error for stride length of 0.069 m, walking speed of 0.094 <inline-formula> <tex-math notation="LaTeX">$\text{m}/\text{s}$ </tex-math></inline-formula>, foot height of 1.5 cm, circumduction of 1.0 cm, peak foot-sole angle in the dorsiflexion of 3.3 deg. and in the plantarflexion directions of 5.9 deg., and toe-in<inline-formula> <tex-math notation="LaTeX">$/$ </tex-math></inline-formula>out angle of 2.5 deg. Our IMS system has good precision regarding all parameters and high reliability and promises to contribute to personal health and wellness services and solutions by serving as a powerful and practical tool for objective gait assessment in real-world contexts.


I. INTRODUCTION
W EARABLE systems for measuring natural gait during daily activities have been receiving increasing attention regarding the development of personal health services to manage an individual's physical condition [1]- [8]. An optical motion-tracking system is the de facto standard for gait measurement, but such a system is not only expensive and complex but also limited to laboratory environments. It has been pointed out that human gait in controlled environments such as laboratories differs from natural gait during daily activities [9].
Hence, an in-shoe motion sensor (IMS) is of significant interest both in research and commercially thanks to its usability [10]. An IMS uses a single inertial measurement unit (IMU) to acquire foot motion by measuring the acceleration and angular velocity of a foot. By embedding an IMS device, which consists of an IMU, micro control unit (MCU), and peripheral electrical components, into an insole or shoe, users do not need to make extra effort when putting on shoes. Although only foot motion can be detected with an IMS device due to its minimal composition, various biomechanical and clinical studies identified effective parameters derived from foot motion for gait analysis [11]- [17].
However, to the best of our knowledge, no previous works have suggested a system that quantifies a user's foot motions having a user just walk with insole sensors on. Table I summarizes the features of existing studies and ours. The distinguising feature of the proposed method is on-line implementation inside an IMS device, which we identified as the major technical challenge in developing wearable computing systems for providing users with automated and timely feedback in a real-world context. Additionally, despite the fact that placing sensors at the foot arch should improve usability, sensors positioned at foot arch have not been so thoroughly explored. Regarding the evaluation dataset, we focused on healthy subjects and the walking condition of natural speed to  show the baseline of the proposed method, while some studies cover patients or multiple levels of walking speed with larger number of total strides in their dataset than ours.
The aim of this study is to develop an IMS system such that the whole process related to calculating stride parameters is completed on-line inside the IMS device; thus, no postprocessing at external devices is required. Our contributions include: • An on-line stride segmentation algorithm based on stable foot-flat detection using foot-sole angle. • Three-dimensional zero-velocity-update (3D ZUPT) algorithm for accurate stride parameterization. Our on-line stride segmentation exploits the foot-sole angle that can be directly measured by an IMU located at the arch of the foot. Unlike existing methods, the 3D ZUPT is designed to run on an MCU inside the IMS device with only 64 KB RAM.
The rest of this article is as follows. In Sec.II, we highlight the differences between this study and previous studies. Sec.III introduces our IMS system architecture. Sec.IV presents our proposed algorithms. The experimental results of the precision evaluation are shown in Sec.V. We discuss the results and benchmark by comparing them to existing works in Sec.VI, where the evaluation of processing time and power consumption is also provided. Finally, we conclude this article in Sec.VII.

II. RELATED WORK
Gait analysis for IMS systems can be divided into three main processing steps, and on-line processing is required for each step.

A. Walking-Bout Detection
This is the step for mining continuous walking motion to be analyzed out of a stream of sensor signals throughout the day. However, methods in the literature have been intended for off-line post-processing of continuously acquired motion signals [32].

B. Stride Segmentation
This step splits the detected walking signals stride by stride. Two major approaches have been proposed: accelerometerbased and gyroscope-based. Accelerometer-based methods utilize the variance or magnitude of acceleration signals to detect zero velocity as a stationary event of foot motion to segment strides. Skog et al. [33] revealed that a gyroscope-based method outperforms accelerometer-based one. Consequently, most recent works use gyroscope-based methods for stride segmentation [18]- [24], [26], [29], [30], where angular velocity peaks or zero-crossing that cyclically arise at foot motion of plantarflexion are detected. Arens et al. [29] proposed a robust method for hemiparetic gait utilizing signals from an IMU of contralateral foot. However, the IMU sensor position significantly affects the inertial signals [34], which makes it difficult to apply existing methods to our IMS system where an IMU is placed at the arch of the foot.

C. Stride-Parameter Calculation
Finally, stride-parameters are derived from the foot trajectory of each stride to characterize a user's foot motion. Existing methods are classified into two categories: double integration and learning-based regression.
1) Double Integration: The foot trajectory can be estimated by double integrating acceleration signals. Such calculation is challenging due to the existence of bias and noise in the signals, which results in large errors after integration. ZUPT is a technique for reducing accumulated error by resetting the velocity to zero at each timing of foot-flat (FF), assuming the foot is stationary. Variations include smootherbased [23] and Kalman-filter-based [26] ZUPT. They, however,  require external computers or smart phones to calculate stride paramters. While Mao et al. [30] proposed another approach for correcting double integration error utilizing an inverted pendulum model instead of ZUPT, their premise of locating an IMU at the shank makes their approach not applicable to our system.
2) Learning-Based Regression: The learning-based regression models proposed by Hannink et al. [27], [28] demonstrated the promising performance against conventional double-integration methods. Their models, based on convolutional neural networks, directly map IMU signals into stride parameters, thus the results are not inherently affected by double integration error. Zhang et al. [31] combined the doubleintegration method with support vector regression models to compensate for residual error. However, the availability of large dataset of IMU signals for foot motion during walking is limited in contrast to the research fields like computer vision and natural language processing. In particular, the lack of IMU dataset for foot arch and the difficulty of collecting substantial labeled data posed obstacles to applying their approach to our system. Fig. 1 shows an overview of the proposed IMS system. The type of architecture of the system is edge-computing; thus, no post-processing at external devices is required. The smartphone is only for showing and storing the parameters received via BLE.

B. IMS Device Hardware
The IMS device of our system is illustrated in Fig. 2(Left). The components of the IMS device include an MCU of ARM Cortex-M4F (nRF52832, CPU: 64 MHz, RAM: 64 KB, ROM: 512KB, Nordic Semiconductor, Norway), an IMU (BMI160, Bosch, Germany), an EEPROM (S-24C32C, 32K-bit, ABLIC, Japan), a real-time clock (RX8130CE, EPSON, Japan), and a 3-volt lithium-coin battery (CR2430, 300 mAh). The MCU includes a Bluetooth Low Energy (BLE) module. The IMU includes a three-axis accelerometer and a three-axis gyroscope. The external flash memory temporally stores calculated stride parameters before wireless data transmission to a smart phone if necessary, e.g., if wireless connection cannot be established.
The device is lightweight (10 g, including the coin battery) and small (29 × 40 × 7 mm) enough to be placed at the arch of the foot. We also designed a dedicated insole that has a space to place the IMS device ( Fig. 2(Right)). When the IMS device is placed in the insole, the X-, Y-, and Z-axes of the IMU are set along the medial-lateral, anterior-posterior, and vertical directions, respectively.

C. Implementation
We first implemented the on-line stride-segmentation and 3D ZUPT algorithms on a desktop computer using MATLAB (The MathWorks, Inc., USA). For this developmental environment, we developed pilot firmware for the IMS device to simply transmit raw data of sensor signals, i.e., acceleration and angular velocity. Using this setup, we evaluated the precision of our IMS system by comparing the stride parameters calculated with this system with those acquired from a motioncapture system, whose data were considered as a reference standard. Next, we re-implemented the algorithms to run on an MCU. For this operation environment, the firmware executes on-line calculation of stride parameters inside the MCU and transmits them instead of the raw data. We also propose walking-bout detection that simultaneously achieves on-line and low-power operation by waking up the MCU only when a user is walking, using the high-g detection that is a built-in function of an IMU. We then evaluated the processing time and the power consumption, to show that the proposed algorithms can be executed on-line.

IV. ALGORITHMS A. Foot-Sole-Angle-Based Stride-Segmentation Algorithm
In a typical healthy gait, the stance phase starts from foot contact (FC) to toe-off (TO), which is 0-60% of the gait cycle (GC). Foot-flat starts at 7% of the GC and ends at 40% of the GC at heel off. This means zero-velocity occurs during 7-40% of the GC because the foot sole fully comes into contact with the ground. By assuming the peak footsole angles in the dorsiflexion (DF) and plantarflexion (PF) directions correspond approximately to FC and TO, we defined the delimiter of a stride as the middle of these peaks (approx. 30% of the GC), which is expected to be zero-velocity.

1) Foot-Sole-Angle
Calculation: Foot-sole angles are calculated using the Madgwick filter [35] from IMU signals composed of a I MU where t = kT s is the sampling time; k ∈ Z is the discrete sampling index and T s is the sampling interval. We selected the Madgwick filter because it is one of the most common techniques for IMU orientation estimation [36]. The notations a I MU x , a I MU y , anda I MU z are the observed accelerations andθ pitch ,θ roll ,θ yaw are the observed angular velocities, which correspond to the rotation on the coronal, sagittal, and transverse planes, respectively. The IMU signals are sampled at the rate of f s = 100 Hz; thus, T s was 10 msec (= 1/ f s ) in our implementation.
The Madgwick filter outputs the quaternions q = [q 0 , q 1 , q 2 , q 3 ] for each sampling index k that expresses the orientation angles of IMU, which we call foot-sole angle because our IMS device is located at the sole of the foot. We define the foot-sole angle as the equivalent Euler angle θ pitch , θ roll , θ yaw , which can be calculated as 2) Gait-Phase-Transition Model: Typical waveform of θ roll is shown in Fig. 3(Top). The θ roll takes periodic negative and positive peaks, which correspond to the DF at FC and PF at TO. We define the time interval starting from a negative peak to the next positive peak as the stance phase and that starting from a positive peak to the next negative peak as the swing phase ( Fig. 3(Bottom)). It should be noted that these definitions are not consistent with the common definitions used in biomechanical research, where those phases separated by FC and TO are usually detected using the ground-reaction force. However, there is no force sensor in our IMS device; therefore, a model that requires only inertial information is required.
We now describe the on-line gait-phase-transition model based on the calculated foot-sole angle. Suppose the temporal window = [t − t : t], where t is the latest sample time and t is the window interval (in our implementation, t = 60 msec).
In the transition from the stance phase to swing phase, it is assumed that the positive peak of θ roll occurs. At this time, the shape of the signal within is convex upward (Fig. 4(Left)). This should satisfy that the maximum θ roll is larger than the oldest and latest θ roll within . In addition, two conditions  TABLE II  STATE-TRANSITION TABLE FOR GAIT-PHASE MODEL are empirically introduced to suppress peak artifacts caused by subtle motion. First, the amplitude of θ roll within should be larger than a certain thresholdh (in our implementation, 3 deg.). Second, the angular velocity in the DF direction is larger than a certain thresholdω 1 , which is −50 deg/s in our implementation. Note that the sign in the DF direction is negative. These conditions are formulated as Likewise, in the transition from the swing phase to stance phase, it is assumed that the negative peak of θ roll occurs. At this time, the shape of the signal within is convex downward (Fig. 4(Right)). This should satisfy that the minimum θ roll is less than the oldest and latest θ roll within . In addition, two conditions are empirically introduced to suppress peak artifacts caused by subtle motion. First, the amplitude of θ roll within should be larger than a certain thresholdh. Second, the angular velocity in the PF direction is larger than a certain thresholdω 2 , which was +30 deg/s in our implementation. Note that the sign in the PF direction is positive. These conditions are formulated as According to the above Boolean expressions 1 and 2 , we define the state-transition model shown in Table II to determine in which gait phase (stance or swing) the current state is. We defined λ[k] as the state of the model at the sampling index k. Since 1 and 2 can be evaluated using the latest sample and finite number of the past samples, this transition model is operable on-line.
Note that an initial state is 'Undetermined' because no clue for gait phase is provided at the beginning right after the MCU wakes up. Once a negative peak is detected (i.e., 2 occurs), the model changes its state to 'Stance' and keeps its state until a positive peak is detected (i.e., 1 occurs), which triggers the state transition to 'Swing'. Afterward, the states 'Stance' and 'Swing' toggle in the same manner.
3) Zero-Velocity Determination and Stride Segmentation: We defined the sampling index of the middle of the stance phase as the timing of zero-velocity, which we also used as a delimiter of a stride.
where k stance n denotes the sampling index at the n-th state transition to 'Stance', and k swing n denotes the sampling index at the n-th state transition to 'Swing'.
Finally, the n-th stride was defined by the time interval between two consecutive zero-velocity. Let us suppose n is the group of sample indices of the n-th stride.
We also defined | n | as the number of samples included in n . The stream of IMU signals (i.e., acceleration and angular velocity signals) were then partitioned into each stride as a single analysis unit.
B. Stride-Parameter Calculation 1) 3D ZUPT Algorithm for Trajectory Estimation: For each stride n , trajectory estimation based on strap-down integration was carried out, where acceleration signals were first transformed to the fixed frame coordination then integrated double-time. We applied ZUPT drift reduction by extending the previous method for the 1D signal shown in [19] to 3D signals.
First, acceleration signals were aligned in the fixed frame using the rotation matrix R derived from the quaternions q.
The low-pass finite impulse response (FIR) filter with the cut-off frequency of 20 Hz was then applied to the acceleration signal. At the same time, offset of gravity (g ≈ 9.8 m/s 2 ) was subtracted from the vertical component. ⎡ The drift components observed in the resultant velocity were then canceled on the assumption of linearity.
Fig. 5 shows an example of velocity waveforms. Since the staring and end points of a stride is foot-flat, it should be assumed that the velocity is zero at the starting (k = k F F n ) and end points (k = k F F n+1 − 1). However, Fig. 5(Left) does not satisfy this assumption since the XYZ components of the velocity at the end point is not zero. This can be attributed to noise, offset, temperature drift, etc. which are known as undesirable characteristics of the IMU. Equation 15 compensates for this error (Fig. 5(Right)). The

trajectories x[k], y[k], and z[k]
were then calculated: We applied two rotations, which are expressed as rotation matrices R 1 and R 2 , to the resultant trajectory to produce the final results.
The first rotation, R 1 , was carried out on the XY plane (i.e. ground plane) through an angle θ with respect to the Z-axis. The second rotation, R 2 , was carried out on the YZ plane through an angle φ with respect to the X-axis. The θ denotes the angle between the Y-axis and position vector denotes the angle between the XY plane and position vec- Each rotation is expressed as The R 1 rotates the trajectory so that the X component of its end point is aligned on the Y-axis (i.e., x[k F F n+1 − 1] = 0) to prepare for the successive parameter calculations. The R 2 rotates the trajectory so that the Z component of its end point is aligned on the XY plane (z[k F F n+1 −1] = 0) to cancel the drift components observed in z[k] on the assumption of level walking. Mariani et al. [19] conducted drift-cancelling where only the Z component was updated since their purpose was to analyze foot height, which is a 1D feature. However, their operation deforms the trajectory shape; thus, drift-cancelling by rotation is better suited to stride-parameter calculation in our system because it updates the XYZ component and preserves the trajectory shape, which we use in the next section.
2) Calculating Stride Parameters From Estimated Foot Trajectory: Fig. 6 shows an example of the foot trajectory on the XYZ space for one stride. Although our 3D ZUPT algorithm calculates the whole trajectory, it is more practical to parameterize its feature to characterize the user's gait. We chose the following parameters, which are also illustrated in Fig.7. a) Stride length: L is the Euclidean distance from the starting point to end point of the foot trajectory for the n-th stride.
b) Walking speed: v is calculated using the number of samples for the n-th stride | n |.
d) Circumduction: C is referred to as the displacement in the medial-lateral direction during the swing phase. We define C as the maximum absolute X (medial-lateral) component of the foot trajectory.  e) Peak foot-sole angles: θ D F and θ P F are defined as the angular displacement of θ roll at the negative (DF) and positive (PF) peaks with reference to the angle at foot-flat It should be noted that the observed θ roll is not zero at footflat (k = k F F n ) as it is affected by the height of the shoe heel. Thus, θ roll [k F F n ] is biased in the above expressions. f) Toe-in/out angle: ψ is referred to as the angle of foot adduction/abduction in this paper. In anatomical definition, it is the rotation on the transverse plane, and zero-point is set when the toe faces the frontal direction. However, inertial signals observed at the local foot coordination do not provide direct information of the frontal direction. To address this difficulty, we introduced a method for ψ calculation using the velocity during the swing phase. Fig. 8 shows the foot trajectory (blue), velocity vector (red), and IMU orientation θ yaw (yellow). We hypothesized that the velocity vector can approximately match the frontal direction. Based on this hypothesis, we define ψ as the angle between the velocity vector and θ yaw on the XY (i.e., floor) plane.
With our definition, ψ should be calculated only during the swing phase since the velocity takes nearly zero during the stance phase, resulting in instability due to the zero-division problem. Finally, the representative is calculated as the mean of ψ.
V. EVALUATION In this section, we discuss the validity of the stride parameters calculated from the foot trajectories and measured footsole angles, and the foot trajectories in one stride.

A. Participants
30 participants, twenty-four males and six females, participated in the experiment. The participants' data, including sex, age, height, weight, and shoes size were collected. The average age was 40.6 ± 9.5 years, average height was 169.6 ± 7.4 cm, average weight was 66.8 ± 10.9 kg, and average shoes size was 26.3 ± 1.1 cm. All participants could walk independently without any assistive devices, e.g., canes, crutches or orthotic devices. They had normal or corrected-to-normal vision, had no history of neuromuscular disease, and had no obstacles in communication. Those who had any orthopedic diseases were excluded. The study was approved by the Ethics Committee of NEC Corporation, and all participants provided informed consent before this experiment. Fig. 9 shows the type of shoe used in the experiment. To ensure every participant was able to walk naturally, sports shoes of various sizes were chosen. The shoes fit the participants tightly so that the motion of the shoe would be almost equivalent to the foot motion. The IMS device was only worn on the right foot. To evaluate the accuracy of the IMS system in calculating stride parameters from the estimated foot trajectories, the motion-capture system Track 3 (Vicon Motion Systems, UK) was applied as a reference and the parameters were compared for each stride. To synchronize the signals between the IMS and motion-capture systems, all IMU signals sampled at the rate of 100 Hz were wirelessly transferred to a smartphone via BLE. The parameters were calculated using algorithms described in Sec.IV that are implemented on MATLAB (Mathworks, USA) instead of the IMS device. This is because we need to rigorously synchronize the timestamp of signals from our IMS system with those from motion-capture system for the evaluation purpose. Calculation on MATLAB is off-line; however, we confirmed that the same algoritms were operatable on-line inside the MCU, as mentioned in Sec.VI-C. Fig. 10 shows the motion-capture system used in this experiment. The motion-analysis space was partitioned using ten motion capture cameras (Bonita B10 Vicon Motion Systems, UK), which were fixed 2 m above the ground. The cameras were set on the two sides of a straight walking path. Five cameras were placed on each side, the vertical distance from the mediate line to each side was 3 m, and the distance between the cameras on each side was 2 m. The markers for motion capture were attached to the surface of shoe, as shown in Fig. 9, and all the markers were used for composing a rigid body. Considering that there is only little transformation of  the shoe from mid-foot to hind-foot during walking, this part of shoe can be treated as a rigid body. Hence, we used these markers concentrated on this part of shoe to compose a rigid body in the motion-capture system. The center of gravity of the composed rigid body was set as the same position of the IMU in the IMS device. Therefore, the motion of the rigid body measured using the motion-capture system can be considered equivalent to the measured data from the IMS device.

B. Experimental Protocol
The participants walked in a straight line for 8 m in a width range of about 0.8 m at their own preferred speed. Every participant walked for four trials, only the data of one-way walking were captured with the motion-capture system (from left to right in Fig. 10). The IMS system also recorded the motion data. However, due to the independence between the two systems, measurements could not begin simultaneously; hence, the signals of both systems needed to be synchronized offline.
We found that the waveforms of foot-sole angles at the beginning of a walking trial (shown in Fig.11(a) with red dashed circles) were different from white noise/random motion and walking at a uniform velocity. Thus, this part of the waveforms could be used for synchronizing the two signals acquired from the different systems. First, a window was set on this particular part of the IMS waveform. It was then shifted on the temporal axis until it was completely superposed on the same part of the motion-capture waveform. The superposing position was determined on the basis of the appearance of the maximum Pearson product-moment correlation coefficient between the two waveforms. After synchronization (see Fig.11(b)), the data streams were split stride-by-stride from the middle stance phase to the next one. To ensure the waveforms of the IMS and motion-capture systems were synchronized in each stride, after splitting the data stream, the waveforms of each stride of the IMS and motion-capture systems were synchronized again by making their peaks and valleys in the θ roll waveform uniform. All these processes were executed on MATLAB.
Mean values and standard deviations (SD) were calculated for all participants. Levels of agreement between the motioncapture-system and IMS-system data were expressed as intraclass correlation coefficients (ICCs) of type (2, 1). The Pearson product-moment (r) was also calculated to measure the linear correlation between motion-capture-system and IMS-system data. Two-side independent t-tests were used to examine the difference between the stride parameters calculated from the motion-capture-system and IMS-system data. Analysis statistical significance was set at p < 0.05. Predefined acceptance rating similar to previous recommendations for ICCs were set at excellent (>0.9000), good (0.750 − 0.899), fair (0.500 − 0.749), and poor (<0.500) [37]. The calculated seven stride parameters of the same stride or same group (average every three continuous effective strides; average every five continuous effective strides) of strides between the motioncapture and IMS systems were compared. Precision was evaluated from the root mean square error (RMSE) in the stride parameters, trajectories, and foot-sole angles. In the evaluation of the foot trajectories and foot-sole angles, the waveforms of both were compared at a resolution of 1% in terms of the normalized time starting from the middle stance phase to the next one. Fig. 12 shows the validation results from the motion-capture and IMS systems of all 30 participants and a total 355 effective strides. In each trial, the first and last strides were discarded, only those strides at an average walking velocity were selected. The strides that contained outliers and missing frames from the motion-capture system were excluded from the data. Comparison of the measurement results from the motion-capture and IMS systems are listed in Table III, and the RMSEs  are summarized in Table IV, where the precision of averaged parameters for three or five strides are also shown.

C. Results
For all parameters, most of the data points fell around the equivalent line y = x, which is considered a promising result.
1) Stride Length: Combining the results of the RMSEs and mean values in Tables III and IV, the deviation of measured L was only 4.9% for every stride and only 2.3% for averaging every five strides. The ICC indicates that the L measured with the IMS system was good.
2) Walking Speed: A significant difference was observed between the measured data from the IMS and motion-capture systems. Fig. 12(b) shows that some points concentrated at the top of the equivalent line, which means v in some strides was overestimated. Nevertheless, Table III shows that both ICC and r of v were good.
3) Foot Height: According to the ICC, the measured H from the IMS system was "fair". Nevertheless, the deviation in the measurement was only about 1.46 cm in one stride and only  1.03 cm for averaging every five strides. The H was nearly correctly evaluated with the IMS system.

4) Circumduction:
The ICC revealed that the IMS system provided good C; below 1 cm, which is adequate for correctly evaluating users' foot fluctuation in the medial-lateral direction.
5) Peak Foot Sole Angle in DF and PF Directions: The IMS system was good and nearly good for evaluating θ D F and θ P F ; 11.6 and 7.7%, respectively. 6) Toe-in/Out Angle: The ICC suggested that the IMS system was good for rating . Fig. 13 shows the measured trajectory comparison between the motion-capture and IMS systems, which included the average waveforms of all 30 participants, total 355 effective strides, and RMSEs in one stride. The average trajectories were almost similar from the start to end, and the deviation of two trajectories seemed stable, where the RMSE was around 1.5 cm in lateral-medial direction and around 2.5 cm in the anterior-posterior direction. The results indicate that not only C or maximum H , but also the fluctuation in the lateral-medial direction and minimum foot clearance, etc. can be effectively evaluated with our IMS system. Fig. 14 shows the comparison of the measured three-axis foot-sole angles between the motion-capture and IMS systems. In all waveforms, the RMSEs in the swing phase were larger than in the stance phase. In particular, the maximum RMSEs appeared near the peaks of the waveforms. The θ roll and θ yaw waveforms looked almost similar with RMSEs below 5 deg. in the entire gait cycle, which indicates that the angular change on the sagittal and transverse planes were effectively measured with our IMS system, whereas θ pitch waveforms seemed to deviate from each other for some unclear reason.

VI. DISCUSSION A. Precisions of IMS System
In Fig. 14(b), θ pitch waveforms seem to deviate from each other. It is difficult to consider that only the angular information on the coronal plane is not effectively evaluated whereas the measurement precisions are effectively evaluated on the other two axes. We observed that the RMSE increased quickly after 20% of the normalized time, which is the start of the preswing phase, and reached the top at 30% of the normalized time, which is the timing of TO. Forefoot rocker motion was observed in the pre-swing phase. Due to this motion, the midfoot and hind-foot bent while the toe touched the ground, and the power moved from mid-foot to the big toe [38], [39]. As a result, the shoes and insole inside significantly distorted on the coronal plane. However, we set the mid-foot and hindfoot as a rigid body in the motion-capture system; thus, this system did not correctly evaluate the motion in the pre-swing phase with shoe distortion, which should be the reason of the deviation of the two θ pitch waveforms. If the markers of the motion-capture system are all selected on hind-foot, the two waveforms should be similar.
It should be highlighted that our method is comparable to existing methods (Table IV). Although Hao et al. [23], Benoussaad et al. [24] and Hannink et al. [27] reported better performance than ours for the case of 1 stride, they did not show on-line implementations. Ferrari et al. [26] demonstrated an on-line implementation and evaluation where sensor signals were processed on a smart phone. However, this system needs continuous transmission of raw signals from an IMS device, which results in large battery consumption. We will discuss battery lifetime with our IMS system in Sec.VI-C.
The precision of our IMS system make it possible for the system to be used in various applications according to previously reported cases, as shown below.

1) Stride Length and Walking Speed:
Our measurement results of L and v agree well with the report by Godfrey et al. [40], who recruited 80 participants with a wide range of ages. Grabiner et al. [11] reported a significant difference in L (about 0.3 m on average) at different v between young and elderly people. Shkuratova et al. [12] also reported the difference at the same level and demonstrated the relationship with balance-control ability at different ages. These previous results suggest that our system is suitable for measuring the gait of people of different ages and for applications such as evaluating balance-control ability.
2) Peak-Foot-Sole Angles θ DF and θ PF : Deschamps et al. [13] and Canseco et al. [14] demonstrated an approximately 5 deg. difference on PF features between healthy participants and those with hallux valgus. From Table IV, our system can  be used to address this difference if we average more than three strides in one measurement.
3) Circumduction: Itoh et al. [15] revealed the relationship between C and hemiplegic status with at least 2 cm difference between them. Hemiplegic patients have large C, which means our system can be used for rating such abnormality. Processing stages for walking-bout detection and power management. Stage 1: MCU is suspended until walking starts. Only IMU operates at low-frequency sampling mode (3.125 Hz). Stage 2: MCU turns in place for processing, and IMU starts sampling at full rate (100 Hz). IMS device checks if the motion is not one-shot but repetitive walking. If not, then it goes back to stage 1. Stage 3: Certain number N of strides are analyzed to calculate stride parameters, then IMS device goes back to stage 1. [16] investigated the correlation between fall risk and toe clearance under different flooring conditions with an average toe clearance of approximately 2 cm. The precision of our system is adequate for this purpose.

4) Foot Height: Kim and Lockhart
5) Toe-in/Out Angle: Due to arthrodesis, the movable range of the ankle decreases, i.e., an approximately 5 deg. alternation in the abduction-adduction directions after in the report by Wu et al. [17]. Our system can enable a more detail analysis for this application.
In a summary, our IMS system can be useful in the applications mentioned above and for users of different ages. It also has the possibility of contributing to evaluating balancecontrol ability, detecting hallux valgus and other abnormalities, rehabilitation applications, and risk prediction.

B. Walking-Bout Detection and Power Management of IMS Device
The IMS device of our system must satisfy contradictory demands regarding size and battery life. It should be small enough to be set into the space of the foot arch; thus, a large battery cannot be used. However, changing or charging the battery placed in an insole frequently loses usability. Therefore, long battery life is important.
Human activities involve, possibly for most of the day, no foot motion and non-walking motion. By suspending the MCU during such periods and waking up the MCU only when a user is walking, power consumption can be significantly suppressed. Current walking-bout-detection methods, however, are not suitable for this purpose since they are designed as offline post-processing methods and require continuous signal acquisition.
We carry out on-line walking-bout detection by using the high-g detection that is a built-in function of an IMU. There are three processing stages for our walking-bout detection and power management (Fig. 15).
Stage 1 involves waiting until the motion likely to be walking is detected. The criterion in our implementation is when the absolute value of the vertical component of acceleration exceeds the threshold of 2.25 G, which is empirically determined so that it discriminates walking motion from other subtle motion. At this stage, the MCU is set to sleep mode to save power, and only the IMU is working and monitoring the acceleration signal at the sampling rate of 3.125 Hz, which is as low as possible. Using an built-in function of the IMU (BMI160, Bosch) called 'high-g detection', the IMU generates a wake-up signal to the MCU when the aforementioned criterion is satisfied.
Stage 2 involves determining if the detected motion is walking. In typical human walking, the acceleration in the posterior direction sharply increases at foot contact because the forward foot motion during the swing phase stops suddenly. We used this feature as the signature of walking bouts. After receiving the wake-up signal, the MCU wakes up by a hardware-interrupt function. Once the MCU wakes up, it sets the sampling rate of the IMU to 100 Hz to acquire the acceleration signal. The MCU then counts the number of rising edges of the acceleration in the posterior direction that exceeds 3.5 G to check if the motion is not one-shot but repetitive, which is more likely to be a walking bout. If the count reaches a certain threshold (in our implementation, three), Stage 3 is executed. On the other hand, if the count does not reach the threshold within 5 sec, the IMS goes back to stage 1.
Stage 3 involves stride-parameter calculation. To save power, the IMS device of our system measures a limited number of strides, which we consider a single bout. The stride parameters for each stride are then averaged for the final output values (see Sec.V for the relation between the number of strides and the precision of averaged parameters). Once strideparameter calculation and transmission via BLE are done, the IMS goes back to stage 1 to wait for the next walking bout.
These stages are carried out on-line, simultaneously reducing power consumption by combinatorial operation of IMU and software processing in the MCU.

C. Processing Time and Power Consumption
We implemented the proposed algorithms on an MCU of ARM Cortex-M4F by manually porting the MATLAB code to the C language code.
We evaluated the processing time on MCU to check if the algorithms can be executed on-line. For a single stride during walking, the results varied 7 − 13 ms for 3D ZUPT, and 3 − 6 ms for Madgwick's filter, depending on the stride time. Stride-segmentation completed in less than 1 ms. Since typical stride time is around 1 sec., the processing achieved real-time performance and operated with no delay.
We also measured the average of current cunsumption: 0.012 mA for Stage 1, 8 mA for Stages 2 and 3, and 2 mA for Bluetooth data transmission. Considering the usage scenario of long-term gait observation in daily life, rather than whole strides, collecting several sets of stride parameters per day could be enough because gait alteration progresses gradually over days or months. Suppose three sets of parameters are collected per day, and five strides are averaged for each set (i.e., N = 5 in Fig.15). Stage 1 occupies most of a day, accumulating 0.288 mAh (0.012mA × 24hours). Stages 2 and 3 take at most 15 seconds per operation altogether, resulting in 0.1 mAh (= 8mA × 3times × 15 3600 hours). Bluetooth data transmission takes around 3 seconds including advertising, establishment of a connection, and disconnection. Thus, it consumes 0.005 mAh (= 2mA × 3times × 3 3600 hours). In total, the daily power consumption is estimated at 0.4mAh. With a battery capacity of 300 mAh, the theoretical lifetime is calculated as 750 days (= 300mAh/0.4mAh). The power consumption could increase if Stage 2 is activated more than three times as a result of non-walking motion. However, even if this situation is taken into account, we estimates that our IMS device has a one-year battery life at worst.

D. Limitations and Future Work
To broaden the applicability of our IMS system, further investigation from different perspectives is necessary. The first perspective is from individual differences. The stridesegmentation algorithm of our system depends on the typical waveform of the foot-sole angle of healthy participants; thus, detection may fail when applied to the elderly or patients with hemiplegia, osteoarthritis, Parkinson's disease, and so on. The second perspective is from environmental differences. With our foot-trajectory estimation, straight and level walking is assumed. However, human activities include various foot motions such as changing speed or direction, stairs/slope ascent or descent, running, and stepping over obstacles. Our system should be evaluated in such various environments, and we believe it is valuable to develop general and robust estimation models against environments. The third perspective is considering our IMS system as a tool for biomechanical research or clinical use since walking events are important for gait analysis. In our system, only foot contact and toeoff are detected. However, walking events are segmented into more categories. As mentioned earlier, our definitions of these events are not consistent with those in the literature.

VII. CONCLUSION
We proposed an IMS system that quantifies a user's foot motions. On-line stride segmentation based on foot-sole angle exploits stable features to detect zero-velocity of the foot motion during walking, and 3D ZUPT algorithm enables accurate stride-parameter calculation. These algorithms of our system are fully automatic; thus, no post-processing at external devices is required.
We evaluated the precision of our IMS system regarding stride length, walking velocity, foot height, circumduction, foot-sole angles and toe-in/out angle during walking by comparing them with those measured using a motion-capture system. These parameters were calculated on a PC by inputting Bluetooth-transferred raw data from the IMS device of our system. The results indicate that our IMS system has good precision regarding all parameters and high reliability, especially regarding stride length, walking speed, circumduction and toe-in/out angle. This indicates that our system is able to provide high-precision gait analysis and be used in various applications.
We also discussed walking-bout detection by using the high-g detection that is a built-in function of an IMU to automatically identify activities of interest from a stream of sensor signals throughout the day and simultaneously reduce power consumption by putting the MCU into sleep mode when a user is not walking. Finally, we evaluated the processing time and the power consumption of our IMS system to confirm the algorithms could be executed on-line.
Health-feedback systems based on biological information is the next scope of our research. The relation between gait and health have been revealed, but conventional gait-measurement systems (e.g., optical motion capture) are limited to laboratory environments. We believe that our IMS system will expand the potential of gait analysis and provide new opportunities for personal-health and wellness services and solutions.