Rules-Based Real-Time Gait Event Detection Algorithm for Lower-Limb Prosthesis Users during Level-Ground and Ramp Walking

Real-time gait event detection (GED) using inertial sensors is important for applications such as remote gait assessments, intelligent assistive devices including microprocessor-based prostheses or exoskeletons, and gait training systems. GED algorithms using acceleration and/or angular velocity signals achieve reasonable performance; however, most are not suited for real-time applications involving clinical populations walking in free-living environments. The aim of this study was to develop and evaluate a real-time rules-based GED algorithm with low latency and high accuracy and sensitivity across different walking states and participant groups. The algorithm was evaluated using gait data collected from seven able-bodied (AB) and seven lower-limb prosthesis user (LLPU) participants for three walking states (level-ground walking (LGW), ramp ascent (RA), ramp descent (RD)). The performance (sensitivity and temporal error) was compared to a validated motion capture system. The overall sensitivity was 98.87% for AB and 97.05% and 93.51% for LLPU intact and prosthetic sides, respectively, across all walking states (LGW, RA, RD). The overall temporal error (in milliseconds) for both FS and FO was 10 (0, 20) for AB and 10 (0, 25) and 10 (0, 20) for the LLPU intact and prosthetic sides, respectively, across all walking states. Finally, the overall error (as a percentage of gait cycle) was 0.96 (0, 1.92) for AB and 0.83 (0, 2.08) and 0.83 (0, 1.66) for the LLPU intact and prosthetic sides, respectively, across all walking states. Compared to other studies and algorithms, the herein-developed algorithm concurrently achieves high sensitivity and low temporal error with near real-time detection of gait in both typical and clinical populations walking over a variety of terrains.


Overview
Gait event detection (GED), identification of key instances during a gait cycle such as foot-strike (FS) and foot-off (FO), is important for applications involving gait assessments, intelligent assistive devices such as microprocessor-based prostheses and exoskeletons, and gait training systems [1,2]. In free-living environments, GED is most commonly achieved using inertial measurement units (IMUs) which are robust, inexpensive, wearable, and compact and have minimal power requirements [3]. This makes these systems highly suitable for applications such as telerehabilitation and gait monitoring in free-living environments, to improve diagnosis, track rehabilitation progress, or assess treatment effectiveness [4][5][6]; it also makes it possible for advanced microprocessor-based assistive prosthetic and orthotic devices to function [7]. However, for accurate and reliable in-community GED, the systems must not only be capable of discerning the walking conditions (i.e., terrain, type of gait, activity), but also be robust when gait is atypical and gait deviations or anomalies are

Algorithm Design
The developed GED algorithm uses the y-axis (frontal-sagittal axis) raw angular velocity (gyroscope) signal from a triaxial IMU placed on the lower leg below the knee joint on each leg as in Figure 1. This location was selected as most previously reported GED algorithms used the same or similar location, due to the convenience of strapping the sensors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MVN Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings and min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 ms based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for local minima and maxima to be detected. Compared to a previous study [20] which used a 200 ms window, this reduces the processing time significantly. The zero-crossing (ZC) state of the signal at the ith sample is always determined for each sample. The ZC state is then stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first minimum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participant exhibited a MSW value much lower than −2 rad/s from the data collected. Additionally, based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. FS is determined as the first maximum after the first ascending ZC following MSW detection. FO is determined as the last maximum before descending ZC. Since multiple ZCs may occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detection. The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 s, respectively. Since the average stance time is 60% of the gait cycle (approximately 624 ms for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would miss an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxima are stored, and once the descending ZC occurs, the last stored value is then selected as FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter in which each output sample is computed as the median value of the input samples under the window. This avoids the use of other filters such as Butterworth filters that are commonly used in GED work but require a phase shift correction to allow for real-time detection [28]. Table 1. Summary of heuristic rules for GED algorithm.

Gait Event Conditions
Mid-swing (MSW) MSW is based on: on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28].

Gait Event Conditions
Mid-swing (MSW) MSW is based on:  Find descending (positive-to-negative signal) zero crossing.  Search for minimum value:  If minimum value is <−2 rad/s, then save current value (timeframe) as MSW.  Else continue minimum value search.

Foot Strike (FS)
FS is based on:  MSW detection:  If MSW for this cycle has been detected, then proceed.  Else return to MSW detection search.  Find ascending (negative-to-positive signal) zero crossing.  Search for maximum value:  If maximum value found, then save current value (timeframe) as FS. Trigger a 200 ms tim delay for FO detection.  Else return to MSW detection search.

Foot Off (FO)
FO is based on:  MSW and FS detection:  If MSW and FS for this cycle has been detected, then proceed.  Else return to MSW detection search.  Check 200 ms time delay is complete.  Search for and store all maximum values.  Find the next descending (positive-to-negative signal) zero crossing: Find descending (positive-to-negative signal) zero crossing.
Sensors 2022, 22, x FOR PEER REVIEW 3 of on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28]. on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28].  Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28]. on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28]. on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28]. on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28]. on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28]. on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28]. on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28]. on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28]. on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28]. on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28]. on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28]. on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28]. on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28]. on each leg as in Figure 1. This location was selected as most previously reported GE algorithms used the same or similar location, due to the convenience of strapping the se sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens MV Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section 2.2. The algorithm, presented in Table 1, is based on a sequence of zero-crossings an min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is 30 m based on a sampling frequency of 100 Hz, is used. A window size of 3 allows for loc minima and maxima to be detected. Compared to a previous study [20] which used a 20 ms window, this reduces the processing time significantly. The zero-crossing (ZC) sta of the signal at the i th sample is always determined for each sample. The ZC state is the stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the first min mum greater than abs(2) rad/s after descending ZC. This threshold was used for MSW since it can be easily translated between participants and populations, as every participa exhibited a MSW value much lower than -2 rad/s from the data collected. Additionall based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11,20]. F is determined as the first maximum after the first ascending ZC following MSW detectio FO is determined as the last maximum before descending ZC. Since multiple ZCs ma occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS detectio The average gait cycle from this study for AB and LLPU participants was 1.04 s and 1.2 respectively. Since the average stance time is 60% of the gait cycle (approximately 624 m for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that would mi an FO or FS gait event [27]. To ensure the correct maximum is selected, all local maxim are stored, and once the descending ZC occurs, the last stored value is then selected a FO. Signals are filtered using a third-order median filter, defined as a nonlinear filter which each output sample is computed as the median value of the input samples und the window. This avoids the use of other filters such as Butterworth filters that are com monly used in GED work but require a phase shift correction to allow for real-time dete tion [28].   Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28].

Gait Event Conditions
Mid-swing (MSW) MSW is based on:  Find descending (positive-to-negative signal) zero crossing.  Search for minimum value:  If minimum value is <−2 rad/s, then save current value (timeframe) as MSW.  Else continue minimum value search.

Foot Strike (FS)
FS is based on:  MSW detection:  If MSW for this cycle has been detected, then proceed.  Else return to MSW detection search.  Find ascending (negative-to-positive signal) zero crossing.  Search for maximum value:  If maximum value found, then save current value (timeframe) as FS. Trigger a 200 m delay for FO detection.  Else return to MSW detection search.
If count (maximum values found) > 1, then save the latest value as FO.
Sensors 2022, 22, x FOR PEER REVIEW on each leg as in Figure 1. This location was selected as most previously reporte algorithms used the same or similar location, due to the convenience of strapping t sors on the lower legs [12,20,25]. The IMU signals were acquired using the Xsens Awinda (Xsens North America Inc., El Segundo, CA, USA), as described in Section The algorithm, presented in Table 1, is based on a sequence of zero-crossin min/max conditions [20,26]. A window of 3 samples (i − 1, i, I + 1 samples), which is based on a sampling frequency of 100 Hz, is used. A window size of 3 allows fo minima and maxima to be detected. Compared to a previous study [20] which use ms window, this reduces the processing time significantly. The zero-crossing (ZC of the signal at the i th sample is always determined for each sample. The ZC state stored as a binary flag (i.e., 0, 1). The first mid-swing (MSW) is detected as the firs mum greater than abs(2) rad/s after descending ZC. This threshold was used for since it can be easily translated between participants and populations, as every part exhibited a MSW value much lower than -2 rad/s from the data collected. Additi based on previous literature, MSW always occurs beyond 2 rad/s (~115 deg/s) [11, is determined as the first maximum after the first ascending ZC following MSW det FO is determined as the last maximum before descending ZC. Since multiple ZC occur between FS and FO, a wait time of 20 samples (200 ms) is placed after FS det The average gait cycle from this study for AB and LLPU participants was 1.04 s an respectively. Since the average stance time is 60% of the gait cycle (approximately for AB, 720 ms for LLPU), a 200 ms delay would be well below the timing that wou an FO or FS gait event [27]. To ensure the correct maximum is selected, all local m are stored, and once the descending ZC occurs, the last stored value is then sele FO. Signals are filtered using a third-order median filter, defined as a nonlinear f which each output sample is computed as the median value of the input samples the window. This avoids the use of other filters such as Butterworth filters that ar monly used in GED work but require a phase shift correction to allow for real-time tion [28].

Gait Event Conditions
Mid-swing (MSW) MSW is based on:  Find descending (positive-to-negative signal) zero crossing.  Search for minimum value:  If minimum value is <−2 rad/s, then save current value (timeframe) as MSW.  Else continue minimum value search.

Foot Strike (FS)
FS is based on:  MSW detection:  If MSW for this cycle has been detected, then proceed.  Else return to MSW detection search.  Find ascending (negative-to-positive signal) zero crossing.  Search for maximum value:  If maximum value found, then save current value (timeframe) as FS. Trigger a 200 m delay for FO detection.
Else return to MSW detection search.

System Instrumentation
The performance of the developed algorithm was validated by comparing the gait events (FS, FO) detected by the developed algorithm and the results from a validated reference motion capture system, the Xsens MVN Awinda. Seven inertial sensors (Xsens North America Inc., CA, USA) were attached to the feet (x2), lower leg (x2), upper leg (x2), and pelvis (x1) (Figure 1). Foot contact events were processed and extracted using the MVN Analyze software (Xsens North America Inc., CA, USA), which uses all seven sensors to reliably and accurately measure the FS and FO gait events across a wide range of gait conditions [29][30][31]. However, it is noted here that our GED algorithm uses only the raw angular velocity (gyroscope) signals from two lower-leg inertial sensors. All sensor data were sampled at a frequency of 100 Hz.

System Instrumentation
The performance of the developed algorithm was validated by comparing the gait events (FS, FO) detected by the developed algorithm and the results from a validated reference motion capture system, the Xsens MVN Awinda. Seven inertial sensors (Xsens North America Inc., CA, USA) were attached to the feet (x2), lower leg (x2), upper leg (x2), and pelvis (x1) (Figure 1). Foot contact events were processed and extracted using the MVN Analyze software (Xsens North America Inc., CA, USA), which uses all seven sensors to reliably and accurately measure the FS and FO gait events across a wide range of gait conditions [29][30][31]. However, it is noted here that our GED algorithm uses only the raw angular velocity (gyroscope) signals from two lower-leg inertial sensors. All sensor data were sampled at a frequency of 100 Hz. Sensors were attached to the feet (middle of the bridge of foot), lower leg (flat on the shin bone, medial surface of the tibia, approximately 5 cm below the patella), upper leg (middle of the lateral thigh, above the knee), and pelvis (flat on the sacrum) [32]. Solid and dashed outlines represent visible and not visible sensors, respectively. Lower-leg sensors (highlighted by filled light blue boxes) were used for validating the proposed GED algorithm.

Participants
Participants were recruited if they were fourteen years or older and community ambulators able to walk on level ground and ramps without ambulatory aids (except for current prosthetic device for LLPU participants). LLPU participants with unilateral amputations at any level (Symes, below-knee, above-knee) were included. Bilateral lowerlimb amputations and/or participants using additional walking aids (i.e., crutches, canes, etc.) were excluded. All participants had no previously known neurological disorders.
All participants were recruited through Holland Bloorview Kids Rehabilitation Hospital. AB participants were recruited through posted recruitment bulletins, and potential  [32]. Solid and dashed outlines represent visible and not visible sensors, respectively. Lower-leg sensors (highlighted by filled light blue boxes) were used for validating the proposed GED algorithm.

Participants
Participants were recruited if they were fourteen years or older and community ambulators able to walk on level ground and ramps without ambulatory aids (except for current prosthetic device for LLPU participants). LLPU participants with unilateral amputations at any level (Symes, below-knee, above-knee) were included. Bilateral lowerlimb amputations and/or participants using additional walking aids (i.e., crutches, canes, etc.) were excluded. All participants had no previously known neurological disorders.
All participants were recruited through Holland Bloorview Kids Rehabilitation Hospital. AB participants were recruited through posted recruitment bulletins, and potential LLPU participants were referred to our research group through the Prosthetics and Orthotics department at the hospital, based on the aforementioned criteria.

Experimental Protocol
Participants were involved in a single 2 h data collection session. Participants were equipped with the Xsens wearable motion capture system as outlined in Figure 1. Then, an N-pose calibration was performed for the Xsens Awinda system to initialize the orientation of the inertial sensors [25]. During data collection, subjects walked in three different walking states: level-ground walking (LGW), ramp ascent (RA), and ramp descent (RD). As outlined in Figure 2, each participant completed six 20 m straight LGW and eight 15 m RD-turn-RA walk trials. Five-minute rest breaks were taken between LGW and RA/RD. After each walking pass, data collection was stopped before the participant turned around and then restarted after the turn was completed. This was done to ensure only straight walking was included in the analysis. The experimental protocol was approved (REB-0102) by the Research Ethics Board at Holland Bloorview Kids Rehabilitation Hospital, Canada. Informed written consent from each participant was obtained before the study was conducted.
thotics department at the hospital, based on the aforementioned criteria.

Experimental Protocol
Participants were involved in a single 2 h data collection session. Participants were equipped with the Xsens wearable motion capture system as outlined in Figure 1. Then, an N-pose calibration was performed for the Xsens Awinda system to initialize the orientation of the inertial sensors [25]. During data collection, subjects walked in three different walking states: level-ground walking (LGW), ramp ascent (RA), and ramp descent (RD). As outlined in Figure 2, each participant completed six 20 m straight LGW and eight 15 m RD-turn-RA walk trials. Five-minute rest breaks were taken between LGW and RA/RD. After each walking pass, data collection was stopped before the participant turned around and then restarted after the turn was completed. This was done to ensure only straight walking was included in the analysis. The experimental protocol was approved (REB-0102) by the Research Ethics Board at Holland Bloorview Kids Rehabilitation Hospital, Canada. Informed written consent from each participant was obtained before the study was conducted. LGW: level-ground walking, RA: ramp ascent, RD: ramp descent.

Data Analysis
The developed algorithm was implemented, tested, and analyzed using a custom Python script. The script ran through each gait trial and using the y-axis angular velocity signal of each limb, the GED algorithm yielded all MSW, FS, and FO events. Foot contact data from the validated algorithms within Xsens were processed and exported to XML format using Xsens MVN Analyze software (Xsens North America Inc., El Segundo, CA, USA). Data were then parsed using another custom python script, which extracted all the FS and FO events from each trial. In total, 1260 steps were detected and evaluated for each side (30 steps per activity per participant). Sensitivity (Equation (1)) and temporal error (Equations (2) and (4)) were evaluated by comparing the gait events detected by the Xsens MVN Analyze software and by the developed GED algorithm respectively [33][34][35].  LGW: level-ground walking, RA: ramp ascent, RD: ramp descent.

Data Analysis
The developed algorithm was implemented, tested, and analyzed using a custom Python script. The script ran through each gait trial and using the y-axis angular velocity signal of each limb, the GED algorithm yielded all MSW, FS, and FO events. Foot contact data from the validated algorithms within Xsens were processed and exported to XML format using Xsens MVN Analyze software (Xsens North America Inc., El Segundo, CA, USA). Data were then parsed using another custom python script, which extracted all the FS and FO events from each trial. In total, 1260 steps were detected and evaluated for each side (30 steps per activity per participant). Sensitivity (Equation (1)) and temporal error (Equations (2) and (4)) were evaluated by comparing the gait events detected by the Xsens MVN Analyze software and by the developed GED algorithm respectively [33][34][35].

Sensitivity =
True Positives True Positives + False Negatives (1) Error (ms) = Timestamp xsens − Timestamp algorithm (2) Gait Cycle Duration (ms) = FS i − FS i−1 Error(% of Gait Cycle) = Error Gait Cycle Duration × 100% (4) Significant differences in temporal error levels between groups (AB vs. LLPU) were statistically analyzed in JMP Pro 16 software (Statistical Discovery, SAS, Cary, NC, USA). To assess the normality of the data distribution, Shapiro-Wilk test was used (p < 0.05), which indicated all data to be non-normally distributed. Thus, a non-parametric two-tailed Wilcoxon signed-rank test was used to assess the difference in accuracy and sensitivity levels. Using a Bonferroni correction with an adjusted critical alpha value of 0.00417 (p = 0.05/12), statistical significance was adjusted to account for any potential type I errors.
Since the temporal error data were found to be non-normally distributed, median and interquartile ranges were reported [36]. Finally, to assess the agreement between the results from the developed GED algorithm and the Xsens MVN Analyze software, Kendall's W (coefficient of concordance) was calculated, since the data were found to be non-normally distributed [37].

Results
The overall sensitivity was 98.87% for AB and 97.05% and 93.51% for LLPU intact and prosthetic sides, respectively, across all walking states (LGW, RA, RD) ( Table 2). The overall temporal error (ms) between the proposed and referenced detection for both FS and FO was 10 (0, 20) ms for AB and 10 (0, 25) ms and 10 (0, 20) ms for the LLPU intact and prosthetic sides, respectively, across all walking states (Figure 3, Table 3). The overall temporal error, as a percentage of gait cycle, was 0.96 (0, 1.92)% for AB and 0.83 (0, 2.08)% and 0.83 (0, 1.66)% for the LLPU intact and prosthetic sides, respectively, across all walking states ( Table 4). The overall ICC was found to be 0.99 for both AB and LLPU groups. To assess the normality of the data distribution, Shapiro-Wilk test was used (p < 0.05), which indicated all data to be non-normally distributed. Thus, a non-parametric twotailed Wilcoxon signed-rank test was used to assess the difference in accuracy and sensitivity levels. Using a Bonferroni correction with an adjusted critical alpha value of 0.00417 (p = 0.05/12), statistical significance was adjusted to account for any potential type I errors.
Since the temporal error data were found to be non-normally distributed, median and interquartile ranges were reported [36]. Finally, to assess the agreement between the results from the developed GED algorithm and the Xsens MVN Analyze software, Kendall's W (coefficient of concordance) was calculated, since the data were found to be non-normally distributed [37].

Results
The overall sensitivity was 98.87% for AB and 97.05% and 93.51% for LLPU intact and prosthetic sides, respectively, across all walking states (LGW, RA, RD) ( Table 2). The overall temporal error (ms) between the proposed and referenced detection for both FS and FO was 10 (0, 20) ms for AB and 10 (0, 25) ms and 10 (0, 20) ms for the LLPU intact and prosthetic sides, respectively, across all walking states ( Figure 3, Table 3). The overall temporal error, as a percentage of gait cycle, was 0.96 (0, 1.92)% for AB and 0.83 (0, 2.08)% and 0.83 (0, 1.66)% for the LLPU intact and prosthetic sides, respectively, across all walking states ( Table 4). The overall ICC was found to be 0.99 for both AB and LLPU groups.
When evaluating the results separately across different walking states and groups, FS and FO detection of the AB group had the highest sensitivity during all walking states, whereas for the LLPU group, sensitivity was approximately 8% lower for RA and RD walking states. On the other hand, the accuracy of FS and FO had similar ranges between each of the groups. However, accuracy decreased during RA and RD for both AB and LLPU groups. The pairwise statistical comparison results, as highlighted in Table 3, indicate a significant difference between the LLPU and AB groups for all comparisons except for FS during RA of the intact side and FS and FO during LGW and RA of the prosthetic side.     When evaluating the results separately across different walking states and groups, FS and FO detection of the AB group had the highest sensitivity during all walking states, whereas for the LLPU group, sensitivity was approximately 8% lower for RA and RD walking states. On the other hand, the accuracy of FS and FO had similar ranges between each of the groups. However, accuracy decreased during RA and RD for both AB and LLPU groups. The pairwise statistical comparison results, as highlighted in Table 3, indicate a significant difference between the LLPU and AB groups for all comparisons except for FS during RA of the intact side and FS and FO during LGW and RA of the prosthetic side.

Discussion
The study presents a new rules-based algorithm that can be used in real time for FS and FO detection using a single gyroscope signal on each leg that achieved an overall mean sensitivity of >93% and a median error of <30 ms and <1% of a gait cycle for both AB and LLPU groups across three different walking states (LGW, RA, RD). Furthermore, a very high agreement (Kendall's W = 0.99) between the developed algorithm and the Xsens results was found for both groups.
Sensitivity and error were compared to previous studies (Table 5). However, few studies used the same methods (i.e., type of participant group, walking states, real-time application), and thus a direct comparison was not possible. Table 4 suggests that this study's algorithm performed comparably to or better than previous studies. Most of the mentioned studies did not report sensitivity results. However, Catalfamo et al. reported an overall 99.5% sensitivity for LGW, RA, and RD when tested with an AB group [20]. The sensitivity in our study was slightly lower in all groups (98.87%, 97.05%, and 93.51% for AB, LLPU intact, and LLPU prosthetic, respectively). However, this could be due to the larger sample size in our study resulting in a higher probability of detecting outliers resulting in false negatives, which might have been missed in smaller sample size studies. Table 5. Summary of results of previous studies with at least partially comparable results [11,12,19,20,24,26].

Study Participant Population Activity Detection Method FS Error (ms) FO Error (ms) Real-Time Analysis
Compared to the reported studies in Table 5, the accuracy of our algorithm achieved similar results. However, in some instances such as FO detection, the algorithm yields considerably higher accuracy results. For example, compared to the results of Maqbool et al. during RD walking, the temporal error is improved by approximately 100 ms for the LLPU group [11]. This highlights the improved accuracy exhibited by the proposed algorithm, as FO is typically more challenging to detect due to the increased variations of the gait signal prior to mid-swing [38]. The improved accuracy can be due to the proposed algorithm being independent of a constant threshold, which has been used in previous studies, when detecting FO. Therefore, any variability in the magnitude of the angular velocity Sensors 2022, 22, 8888 9 of 12 signal typically observed due to the walking state (i.e., ramp ascent or descent) [39] or prosthesis technology used (i.e., hydraulic, bionic prosthesis, etc.) would not affect the accuracy [40]. As aforementioned, the overall error as a percentage of the gait cycle was <1%, with the highest median error (percentage of gait cycle) being 2.8 (1.86, 3.73)% for FS detection of the AB group during RD (Table 4). For real-time gait analysis, such an accuracy level is acceptable since it is below the coefficient of variation of AB gait, as reported by Beauchet et al. to be 4% and 3% for swing and stance time, respectively [41].
Although the algorithm performed better for the AB relative to the LLPU group, based on the statistical pairwise comparison, the differences were small and the LLPU group results were still comparable to other studies that evaluated their GED algorithms with the LLPU population [12,19]. This reduced performance in the LLPU (compared to AB) could be due to the variety of gait styles exhibited by the LLPU participants based on the level of their amputation and/or the type of prosthetic device used. In addition, to account for such differences, future work should investigate adaptable delays. For example, the 200 ms delay applied after FS detection can be adjusted based on the individual's own stance time (i.e., faster/slower walking). This will ensure that in cases where an individual may be walking faster (stance time less than approximately 600 ms), the delay remains below the individual's average stance time.
Finally, one of the unique features of the proposed algorithm is the minimal window size required for accurate GED. The algorithm requires three samples or 30 ms of data at a time, whereas other studies have either used the overall signal to identify all the peaks at once [12,24] or used larger window sizes of 200 ms, which can be approximately 20% of an average gait cycle [20]; neither of these algorithms is suitable for real-time implementations such as biofeedback systems used for gait training and prosthetic control [19,42,43]. Such systems require a minimal delay to allow for the sensory feedback to activate. However, it is important to note that with a lower sampling frequency, the window size would increase, as it is based on the number of samples as opposed to the timing length of the window. Future work should evaluate the algorithm using different sampling rates, and with a faster sampling rate, it may be possible to reduce the latency further.
Some of the limitations of this study include the large error variability, which appears to be a consistent issue with many of the previously studied GED algorithms [11,12,19]. This could be addressed by first evaluating the GED algorithms with a significantly higher sampling rate and then identifying additional signal features that increase accuracy. Additionally, this study did not evaluate the differences between both sides of the AB group. Some studies have suggested that, although gait in healthy populations is often symmetrical with less variability, there are cases of gait asymmetry with higher variability that may occur due to factors such as fatigue or walking speed [39,44]. Thus, future studies should account for some of these factors to assess the difference in GED performance between both sides. Finally, future work should focus on improving and validating the proposed algorithm for other walking states (i.e., uneven terrain, running, stair walking) and with other patient populations (i.e., cerebral palsy, Parkinson's). Moreover, future studies should assess the algorithm performance over longer periods of time (i.e., multiple sessions for the same participant) to evaluate the test-retest reliability.

Conclusions
The results of this study support the use of angular velocity signals acquired from the lower legs for real-time GED in the AB and LLPU populations for gait on a variety of terrains, while avoiding the use of pre-set thresholds for FS and FO detection. The new algorithm achieved near real-time gait event detection, with error and sensitivity levels of <30 ms and >93%, respectively, using only a single sensor (signal) for each limb, which is comparable and in some cases an improvement compared to previous studies. The findings of the proposed algorithm support the translation of this work into clinical practice using low-cost gyroscopes for gait analysis, as it was tested with two distinct groups (AB and LLPU). Future work should focus on assessing the robustness of the GED algorithm for different walking states and clinical populations. Furthermore, to improve the variability of accuracy levels, future work should assess the performance for significantly higher sampling rates. Informed Consent Statement: Informed consent was obtained from all subjects involved in the study.