User Tools

Site Tools


visual3d:documentation:pipeline:event_commands:example_-_gait_events_using_kinematic_data

This is an old revision of the document!


Example: Gait Events using Kinematic Data

Gait events refer to meaningful moments during walking movement, particularly Heelstrike (HS)- when the foot makes contact with the ground, and Toe-off (TO)- when the foot lifts off the ground. These events are typically identified by applying thresholds on ground reaction force (GRF) signals. These signals are acquired from lab-based kinetic equipment such as force plates or instrumented treadmills that are not always available in labs.

To address this issue, several journal articles have been published which introduce different algorithms that make use of kinematic features to identify these gait events.

Overview

This example walks through the application of these kinematic event detection methods into the Visual3D pipeline, in order to produce heelstrike and toe-off events.

It must be noted that these methods vary in their effectiveness on correctly identifying these events.

A research study was conducted to assess the different methods' reliability in structuring gait cycles as compared to kinetic based cycles. A tutorial was developed based off of the study and is available here:

Supporting Tutorial: Assessing Kinematic Methods of Structuring Gait

Pipeline Scripts

The pipeline scripts can be downloaded here.

Methods Overview

The following methods are implemented using the Visual3D pipelines. Each has a slightly different biomechanical rationale for estimating gait events based on kinematic features.

The first paper, presented by Zeni et al. (2008), outlines 2 separate methods.

Method 1A: Foot Position Relative to Pelvis

Method 1B: Foot Velocity Relative to Pelvis

Method 2: Hip Kinematics

Method 3: Foot Acceleration

Method 4: Foot Centre Vertical Velocity and Heel Position

Method 1A: Foot Position Relative to Pelvis

The first method uses the position data of the left heel and left toe relative to the pelvis coordinate system to identify gait events.

Specifically, Heelstrike (HS) is determined by the maximum forward position of the heel and toe-off (TO) is identified by the minimum forward position of the toe.

This pipeline follows the algorithm described in the literature and includes the following key steps:

1. Compute position signals of left heel and toe relative to the pelvis

Use the Compute_Model_Based_Data command to create position signals which will be used to find events for this method.

! Compute Left Toe Position relative to Pelvis
!----------------------------------------------------------------------------
Compute_Model_Based_Data
/RESULT_NAME=LToe_Wrt_Pelvis
/FUNCTION=SEG_DISTAL_JOINT
/SEGMENT=LFT
/REFERENCE_SEGMENT=RPV
/RESOLUTION_COORDINATE_SYSTEM=RPV
! /USE_CARDAN_SEQUENCE=FALSE
! /NORMALIZATION=FALSE
! /NORMALIZATION_METHOD=
! /NORMALIZATION_METRIC=
! /NEGATEX=FALSE
! /NEGATEY=FALSE
! /NEGATEZ=FALSE
! /AXIS1=X
! /AXIS2=Y
! /AXIS3=Z
! /TREADMILL_DATA=FALSE
! /TREADMILL_DIRECTION=UNIT_VECTOR(0,1,0)
! /TREADMILL_SPEED=0.0
;

! Compute Left Heel Position relative to Pelvis 
!----------------------------------------------------------------------------
Compute_Model_Based_Data
/RESULT_NAME=LHeel_Wrt_Pelvis
/FUNCTION=SEG_PROXIMAL_JOINT
/SEGMENT=LFT
/REFERENCE_SEGMENT=RPV
/RESOLUTION_COORDINATE_SYSTEM=RPV
! /USE_CARDAN_SEQUENCE=FALSE
! /NORMALIZATION=FALSE
! /NORMALIZATION_METHOD=
! /NORMALIZATION_METRIC=
! /NEGATEX=FALSE
! /NEGATEY=FALSE
! /NEGATEZ=FALSE
! /AXIS1=X
! /AXIS2=Y
! /AXIS3=Z
! /TREADMILL_DATA=FALSE
! /TREADMILL_DIRECTION=UNIT_VECTOR(0,1,0)
! /TREADMILL_SPEED=0.0
;

2. Detect heelstrike events as local maxima in the x-component of the heel position using Event_Maximum

! HEELSTRIKE (LHS) Event at MAX of Heel Signal in X Component
!----------------------------------------------------------------------------
Event_Maximum
/RESULT_EVENT_NAME=LHS Foot Position
/SIGNAL_TYPES=LINK_MODEL_BASED
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=LHEEL_WRT_PELVIS
/SIGNAL_COMPONENTS=X
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
! /FRAME_WINDOW=8
! /THRESHOLD=

3. Detect toe-off events as local minima in the x-component of the toe position using Event_Minimum

! TOE-OFF (LTO) Event at MIN of Toe Signal in X Component
!----------------------------------------------------------------------------
Event_Minimum
/RESULT_EVENT_NAME=LTO Foot Position
/SIGNAL_TYPES=LINK_MODEL_BASED
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=LTOE_WRT_PELVIS
/SIGNAL_COMPONENTS=X
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
! /FRAME_WINDOW=8
! /THRESHOLD=
;

A snapshot of the full pipeline can be seen below in the Visual3D pipeline workshop dialog:

Method 1B: Foot Velocity Relative to Pelvis

This method builds on the previous one by using the velocity of the heel and toe relative to the pelvis coordinate system rather than position. It identifies heelstrike when the heel velocity signal crosses zero on the descent, and toe-off when the toe velocity crosses zero on the ascent.

Like Method 1A, the heel and toe positions relative to the pelvis are computed using Compute_Model_Based_Data

Then, the pipeline follows the algorithm described in the second method presented in the literature:

1. Derive the velocity signals for both heel and toe using First_Derivative

! ----------------------------------------------------------------------------
!  Take derivative of both heel and toe position signals in order to find Velocity 
! ----------------------------------------------------------------------------
First_Derivative
/SIGNAL_TYPES=LINK_MODEL_BASED
/SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=LHeel_Wrt_Pelvis+LToe_Wrt_Pelvis
/RESULT_TYPES=DERIVED
/RESULT_FOLDERS=VELOCITY
/RESULT_NAME=_Vel
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE

2. Define Heelstrike (LHS) event when velocity signal (x-component) of the heel crosses the zero-value on descent, and toe-off (LTO) event when signal crosses on ascent using Event_Threshold

Event_Threshold
/RESULT_EVENT_NAME=LHS Foot Velocity
/SIGNAL_TYPES=DERIVED
/SIGNAL_FOLDER=VELOCITY
/SIGNAL_NAMES=LHeel_Wrt_Pelvis_Vel
/SIGNAL_COMPONENTS=X
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/THRESHOLD=0
/ON_ASCENT=FALSE
/ON_DESCENT=TRUE
! /FRAME_WINDOW=8
/ENSURE_FRAMES_BEFORE=TRUE
/ENSURE_FRAMES_AFTER=TRUE
;

Event_Threshold
/RESULT_EVENT_NAME=LTO Foot Velocity
/SIGNAL_TYPES=DERIVED
/SIGNAL_FOLDER=VELOCITY
/SIGNAL_NAMES=LToe_Wrt_Pelvis_Vel
/SIGNAL_COMPONENTS=X
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/THRESHOLD=0
/ON_ASCENT=TRUE
/ON_DESCENT=FALSE
! /FRAME_WINDOW=8
/ENSURE_FRAMES_BEFORE=TRUE
/ENSURE_FRAMES_AFTER=TRUE
;

A snapshot of the full pipeline can be seen below in the Visual3D pipeline workshop dialog:

Method 2: Hip Kinematics

This method identifies only heelstrike (HS) events, based on the peak extension of the contralateral hip. When the right hip reaches minimum extension in the sagittal plan, a left-side HS event is detected.

This corresponds with the point in gait where the opposite foot (left) is most likely contacting the ground.

The pipeline uses the algorithm described in the literature and includes the following key steps:

1. Calculate the Right Hip Joint Angle to identify minimum extension moments in this signal.

Compute_Model_Based_Data
/RESULT_NAME=RHip_Angle
/FUNCTION=JOINT_ANGLE
/SEGMENT=RTH
/REFERENCE_SEGMENT=RPV
/RESOLUTION_COORDINATE_SYSTEM=
! /USE_CARDAN_SEQUENCE=FALSE
! /NORMALIZATION=FALSE
/NORMALIZATION_METHOD=TRUE
! /NORMALIZATION_METRIC=
! /NEGATEX=FALSE
! /NEGATEY=FALSE
! /NEGATEZ=FALSE
! /AXIS1=X
! /AXIS2=Y
! /AXIS3=Z
;

2. Use Event_Minimum to identify LHS from contralateral extension in sagittal plane.

Event_Minimum
/RESULT_EVENT_NAME=LHS Hip Extension
/SIGNAL_TYPES=LINK_MODEL_BASED
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=RHip_Angle
/SIGNAL_COMPONENTS=Y
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/FRAME_WINDOW=50
! /THRESHOLD=
;

A snapshot of the full pipeline can be seen below in the Visual3D pipeline workshop dialog:

Method 3: Foot Acceleration

This method is based on the premise that certain peaks in foot acceleration correspond reliably to heelstrike and toe-off moments.

Specifically, this method uses the vertical acceleration of the Left Heel and the forward acceleration of the Left Fifth metatarsal (MT5) to identify these events.

A snapshot of the full pipeline can be seen below in the Visual3D pipeline workshop dialog:

1. Before computing acceleration, the Lowpass_Filter command is used to filter the positional signals of the Left Heel and Left MT5 markers. This smoothing step reduces noise that would be amplified when differentiating.

Lowpass_Filter
/SIGNAL_TYPES=TARGET
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=L.Heel+L.MT5
/RESULT_FOLDER=PROCESSED
/RESULT_SUFFIX=_filt
! /FILTER_CLASS=BUTTERWORTH
! /FREQUENCY_CUTOFF=6.0
! /NUM_REFLECTED=6
! /NUM_EXTRAPOLATED=0
! /TOTAL_BUFFER_SIZE=6
! /NUM_BIDIRECTIONAL_PASSES=1
;

2. The Second_Derivative command outputs the acceleration signals. The outputs are saved in the DERIVED folder with the suffix _accel.

Second_Derivative
/SIGNAL_TYPES=TARGET
/SIGNAL_FOLDER=PROCESSED
/SIGNAL_NAMES=L.Heel_filt+L.MT5_filt
/RESULT_TYPES= DERIVED
/RESULT_FOLDERS=ACCELERATION
/RESULT_NAME=_accel
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
;

3. The heelstrike events are identified as local maxima in the y-component (vertical) of the Left Heel's acceleration signal. This peak corresponds to the abrupt deceleration of the heel when it makes contact with the ground.

Event_Maximum
/RESULT_EVENT_NAME=LHS Foot Acceleration
/SIGNAL_TYPES=DERIVED
/SIGNAL_FOLDER=ACCELERATION
/SIGNAL_NAMES=L.Heel_filt_accel
/SIGNAL_COMPONENTS=Y
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/FRAME_WINDOW=80
! /THRESHOLD=
;

4. The toe-off events are similarly identified as local maxima in the x-component of the Left MT5's acceleration signal. This reflects the propulsion phase, where the forefoot pushes of and leaves the ground.

Event_Maximum
/RESULT_EVENT_NAME=LTO Foot Acceleration
/SIGNAL_TYPES=DERIVED
/SIGNAL_FOLDER=ACCELERATION
/SIGNAL_NAMES=L.MT5_filt_accel
/SIGNAL_COMPONENTS=X
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/FRAME_WINDOW=80
! /THRESHOLD=
;

A snapshot of the full pipeline can be seen below in the Visual3D pipeline workshop dialog:

Method 4: Foot Centre Vertical Velocity

This method is adapted from the work of O'Connor et al. (2007) and uses a combination of the vertical velocity of the foot center and the vertical position of the heel marker to identify toe-off and heelstrike events, respectively. The following steps can be taken:

1. Add a Landmark at the Foot Center

To represent the foot center, a custom landmark is added. This is placed halfway between the heel and the mid-foot (MT1 and MT5) markers.

Add_Landmark
/LANDMARK_NAME=LF_MIDPT
! /CALIBRATION_FILE=
! /USER_GENERATED=TRUE
/USE_PERCENTAGE=TRUE
! /CALIBRATION_ONLY=FALSE
/USE_TARGETS=TRUE
! /SEGMENT_NAME=
/TARGET_TYPES=TARGET+TARGET+TARGET
/TARGET_NAMES=L.HEEL+L.MT1+L.MT5
! /MCS_ML=0.0
! /MCS_AP=0.0
/MCS_AXIAL=0.5
! /LANDMARK_LOCATION=
! /REFERENCE_LOCATION_TYPE=
! /REFERENCE_LOCATION_NAME=
! /USE_REFERENCE_LOCATION=FALSE
;

2. Recalculate the model to update landmark positions

Running the recalc command here ensures that the new foot center landmark is recognized and used in subsequent calculations.

Recalc

;

3. Filter the Foot Centre Landmark

To smooth the signal before differentiation, a low-pass Butterworth filter (cutoff 7 Hz) is applied to the new landmark.

Lowpass_Filter
/SIGNAL_TYPES=LANDMARK
/SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=LF_MIDPT
/RESULT_FOLDER=FILTERED
/RESULT_SUFFIX=_filtered
! /FILTER_CLASS=BUTTERWORTH
/FREQUENCY_CUTOFF=7.0
! /NUM_REFLECTED=6
! /NUM_EXTRAPOLATED=0
! /TOTAL_BUFFER_SIZE=6
/NUM_BIDIRECTIONAL_PASSES=2
;

4. Calculate Vertical Velocity of the Foot Centre

The velocity of the foot center is calculated by taking the first derivative of the filtered landmark signal.

First_Derivative
/SIGNAL_TYPES=LANDMARK
/SIGNAL_FOLDER=FILTERED
 /SIGNAL_NAMES=LF_MIDPT_filtered
/RESULT_TYPES=LINK_MODEL_BASED
! /RESULT_FOLDERS=PROCESSED
/RESULT_NAME=LF_MIDPT Velocity
! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=
;

5. Define a Frame Window Equivalent to 0.8 seconds.

This is used later to detect peak values in the velocity curve for toe-off.

Metric_Explicit
! /RESULT_METRIC_FOLDER=PROCESSED
/RESULT_METRIC_NAME=Time_Converted_Frames
/METRIC_VALUE=((0.8)*(PARAMETERS::ANALOG::RATE) + 1)
;

6. Identify Toe-off (LTO) Events from Foot Centre Velocity

Toe-off is determined by finding local peaks (maxima) in the vertical velocity of the foot center.

Event_Maximum
/RESULT_EVENT_NAME=LTO OC
/SIGNAL_TYPES= LINK_MODEL_BASED
/SIGNAL_FOLDER=PROCESSED
/SIGNAL_NAMES=LF_MIDPT Velocity
/SIGNAL_COMPONENTS=Y
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/FRAME_WINDOW=80
! /THRESHOLD=
;
<code>

7. Determine heel height threshold (35% of Peak Heel Height)

TO identify valid heelstrikes, we calculate the maximum vertical position of the heel marker across the trial.

<code>
Metric_Maximum
! /RESULT_METRIC_FOLDER=PROCESSED
/RESULT_METRIC_NAME=LHeel Max
! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
/SIGNAL_TYPES=TARGET
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=L.Heel
/COMPONENT_SEQUENCE=Y
/EVENT_SEQUENCE=
/EXCLUDE_EVENTS=
/SEQUENCE_PERCENT_START=
/SEQUENCE_PERCENT_END=
! /GENERATE_MEAN_AND_STDDEV=TRUE
! /GENERATE_MEAN_AND_STDDEV_ACROSS_SUBJECTS=FALSE
! /APPEND_TO_EXISTING_VALUES=FALSE
/CREATE_GLOBAL_MAXIMUM=TRUE
! /CREATE_TRIAL_MAXIMUM=FALSE
;

8. Define the Entry and Exit Bounds for Heelstrike Detection

We identify the bounds in which to search for heelstrike events. These are the points where the heel marker crosses below and above 2-% of the maximum heel height (as an approximation of 35% from the original paper)

Event_Threshold
/RESULT_EVENT_NAME=L_START_HS
/SIGNAL_TYPES=TARGET
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=L.Heel
/SIGNAL_COMPONENTS=Y
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/THRESHOLD=0.20 * (METRIC::PROCESSED::LHeel Max)
/ON_ASCENT=FALSE
/ON_DESCENT=TRUE
! /FRAME_WINDOW=8
! /ENSURE_FRAMES_BEFORE=FALSE
! /ENSURE_FRAMES_AFTER=FALSE
;

Event_Threshold
/RESULT_EVENT_NAME=L_END_HS
/SIGNAL_TYPES=TARGET
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=L.Heel
/SIGNAL_COMPONENTS=Y
! /FRAME_OFFSET=0
! /TIME_OFFSET=
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /EVENT_INSTANCE=0
/THRESHOLD=0.20 * (METRIC::PROCESSED::LHeel Max)
/ON_ASCENT=TRUE
/ON_DESCENT=FALSE
! /FRAME_WINDOW=8
! /ENSURE_FRAMES_BEFORE=FALSE
! /ENSURE_FRAMES_AFTER=FALSE
;

9. Identify heelstrike (LHS) from Vertical Velocity of Foot Centre

Within the entry and exit bounds, we find the trough (minimum) in the vertical velocity of the foot center, corresponding to the heelstrike event.

Event_Global_Minimum
/RESULT_EVENT_NAME=LHS OC
/SIGNAL_TYPES=LINK_MODEL_BASED
/SIGNAL_FOLDER=PROCESSED
/SIGNAL_NAMES=LF_MIDPT Velocity
/SIGNAL_COMPONENTS=Y
! /FRAME_OFFSET=0
! /TIME_OFFSET=
/EVENT_SEQUENCE=L_START_HS+L_END_HS
! /EXCLUDE_EVENTS=
! /EVENT_SEQUENCE_INSTANCE=0
! /EVENT_SUBSEQUENCE=
! /SUBSEQUENCE_EXCLUDE_EVENTS=
! /EVENT_SUBSEQUENCE_INSTANCE=0
! /THRESHOLD=
;

10. Define Event Sequences

Two event sequences are defined, one for heelstrike cycles and one for toe-off cycles.

Event_Define_Event_Sequence
/EVENT_SEQUENCE_NAME=LHS Cycle OC
/EVENT_SEQUENCE=LHS OC+LHS OC
! /EXCLUDE_EVENTS=
! /INSIDE_OF_SEQUENCE=
! /OFFSET_FROM_START=
! /OFFSET_FROM_END=
! /OFFSET_BY=PERCENT
/EVENT_SEQUENCE_INSTANCE=0
;

Event_Define_Event_Sequence
/EVENT_SEQUENCE_NAME=LTO Cycle OC
/EVENT_SEQUENCE=LTO OC+LTO OC
! /EXCLUDE_EVENTS=
! /INSIDE_OF_SEQUENCE=
! /OFFSET_FROM_START=
! /OFFSET_FROM_END=
! /OFFSET_BY=PERCENT
/EVENT_SEQUENCE_INSTANCE=0
;

A snapshot of the full pipeline can be seen below in the Visual3D pipeline workshop dialog:

visual3d/documentation/pipeline/event_commands/example_-_gait_events_using_kinematic_data.1752245692.txt.gz · Last modified: 2025/07/11 14:54 by wikisysop