mad-lab-fau / gaitmap

The Gait and Movement Analysis Package
https://gaitmap.readthedocs.io
Other
38 stars 2 forks source link

Stride definition for the `stride_list` argument of event detection #52

Closed rmndrs89 closed 11 months ago

rmndrs89 commented 11 months ago

Dear all,

if I remember correctly, then in the Hannink et al. (2018) paper different definitions for the strides were used (e.g., midstance-to-midstance versus initial contact-to-initial contact versus msDTW).

Now, when I want to detect specific gait events from my inertial sensor data, I need to supply the event detection algorithm, e.g., RamppEventDetection, with the stride_list. Does it matter which definition I use for the strides? Or is the only requirement that there are no gaps between subsequent strides? So could I theoretically also define my strides from midswing-to-midswing, for example?

Best regards, Robbin

AKuederle commented 11 months ago

Hi Robbin,

First some background for the decisions we made:

  1. We decided in general that calling midstance an event was "wrong" as biomechanically, it is a phase of the gait cycle not an individual event. Instead we started using the term "point of minimum velocity" (min-vel) to refer to the "event" that we use as the starting point for integration based methods.
  2. Given the first definition, using min-vel or midstance to define the start and the end of the stride (in particular if you want to compare between algorithms or systems) was kind of problematic, as there is no fixed definition or easy to obtain ground truth.
  3. Therefore, we followed the definition by Barth et al for our "segmented stride list", using the minima before the toe off/terminal contact (or the toe off, depending on which toe-off definition you use). This point in the signal is easy to define based on the IMU signal as it defines a clear minima in the gyro signal that is visible basically independent of the gait pattern. This allows to compare stride segmentation algorithms
  4. While this event is easy to find in IMU signal, there is no clear equivalent in any reference system. So for comparison with a reference system, we also combine gait segmentation and event detection to then use biomechanically well defined events (i.e. initial contact and terminal contact / heel strike and toe-off).

With that background, the RamppEventDetection expects the strides to be segmented from this pre-toe-off minima to the next pre-toe-off minima, as it divides each stride into several regions of interest to search the respective events. E.g. we expect the toe off to be the first zero-crossing of the gyr_ml signal and the initial contact to min-vel event to occur in the second half of the stride.

A couple of options how to solve your issue:

  1. Depending on what you are trying todo, you could combine the steps of StrideSegmentation and EventDetection (as often done in literature anyway). So don't compare event detection in isolation, but rather compare the "raw signals" -> "events per stride". Then you can use any of the segmentation methods in gaitmap to get a stride list that fits the definition for the Event Detection
  2. If you want to focus on just the event detection and you already have a ground truth for the StrideSegmentation, but this ground truth is from mid-swing to mid-swing (which I assume you defined as the maximum in the gyr_ml signal?), then you can try to convert the start and the end event, by shifting them to the minima before the swingphase. We did that for some comparisons in the past and it seems to work quite reliably to just define a realistic window size before your mid-swing event and then take the minima within this window on the gyr_ml axis. Potentially you could lowpass filter the signal beforehand to make that step even more robust.

In case you go with option 2, there is a function (which is not public API, but I think is fine to use for this), that can do that shift for you in one step: snap_to_min. Just supply an asymmetric window.

If you want to go a little more low-level, this function is based on gaitmap.utlis.array_handling.find_extrema_in_radius

rmndrs89 commented 11 months ago

Hi @AKuederle,

super, thanks for the elaborate clarification!

It makes a lot of sense to me to go with the local minima before toe-off, as this signal is --as you mention-- quite consistent across different gait patterns (speeds, neurological disorders).

Thanks, Robbin