Skip to content

Commit 7fbfb1f

Browse files
committed
Updated section data acquisition and data sets
1 parent 87ee093 commit 7fbfb1f

File tree

2 files changed

+67
-15
lines changed

2 files changed

+67
-15
lines changed

_02_Material.qmd

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,19 @@ We used an IMU sensor to record the hip orientation over time. The IMU was compo
4848
4949
![Sensor positionned on the right hip.](images/sensor-position.png){#fig-sensor-position width=150}
5050
51-
We asked the participants to walk on the GAITRite® mat, a gold standard in gait analysis [@Menz2004] while wearing the IMU sensor on their right hip. This choice, required to have a labeling of gait events from the walkway, constrained the path followed by the participants to a straight line of approximately nine meters. The GAITRite® device gives various information thanks to pressure sensors contained in the mat such as the time points where the subject feet touch and leave the ground at each step, which are exactly the gait events of interest to train our segmentation models for the IMU sensor. To use the two devices simultaneously, they were started at the same time by the same person with their two index fingers, allowing a good synchronization between devices [@de1992stability].
51+
We asked the participants to walk on the GAITRite® mat, a gold standard in gait analysis [@Menz2004] while wearing the IMU sensor on their right hip. This choice, required to have a labeling of gait events from the walkway, constrained the path followed by the participants to a straight line of approximately nine meters. The GAITRite® device gives various information thanks to pressure sensors contained in the mat such as the time points where the subject feet touch and leave the ground at each step, which are exactly the gait events of interest to train our segmentation models for the IMU sensor. To use the two devices simultaneously, they were started at the same time by the same person with their two index fingers, allowing a good synchronization between devices [@de1992stability]. Also, we asked the participants to wait for three seconds before starting to walk on the mat to ensure that the sensor was properly calibrated and stable before walking.
5252
53-
We included six subjects in this study (three men and three women) of different ages and walking at different speeds to have a variety of gait data. @tbl-subjects summarized the demographic characteristics of the participants. We recorded a total of 174 walking sessions between June and September 2024.
53+
We included six subjects in this study (three men and three women) of different ages and walking at different speeds to have a variety of gait data. @tbl-subjects summarized the demographic characteristics of the participants. We recorded a total of 174 walking sessions between June and September 2024. The data is publicly available [^bhg-dataset]. We can therefore download it and store it in an R object for use in the rest of this document.
54+
55+
[^bhg-dataset]: <https://zenodo.org/records/18222246>.
5456
5557
::: {#tbl-subjects tbl-pos="H"}
5658
5759
```{r}
60+
bhg <- readRDS(url(
61+
"https://zenodo.org/records/18222246/files/bellier_healthy_gait.rds?download=1"
62+
))
63+
5864
bhg |>
5965
dplyr::group_by(subject, gender, age, condition) |>
6066
dplyr::summarise(speed = round(mean(speed), digits = 0), .groups = "drop") |>
@@ -102,27 +108,36 @@ Summary of subjects and walking speeds used to train the model.
102108
103109
Raw data
104110
105-
: As mentioned before, the IMU sensor records unit QTS representing the orientation of the hip over time, allowing the visualization of each coordinate time series (see @fig-timeserie) at each recorded time point. The four coordinates match the definition of a quaternion provided in @eq-quaternions. It is important to observe that @fig-timeserie displays the gait of a healthy individuals with nicely depicted gait cycles that are consistent over time. Impaired gait will not necessarily exhibit the same regularity.
111+
: As mentioned before, the IMU sensor records the orientation of the device over time in the form of a unit QTS every 10 milliseconds. The four coordinates match the definition of a quaternion provided in @eq-quaternions. This data is stored in the list-column `bhg$egait`.
112+
113+
::: {.callout-tip title="The [{squat}](https://lmjl-alea.github.io/squat/) package"}
114+
We developed a dedicated R package coined [{squat}](https://lmjl-alea.github.io/squat/) for **S**tatistics for **QUA**ternion **T**emporal Data which defines a specific data structure of class `qts` to store and manipulate unit QTS data. In particular, `bhg$egait` is a list of objects of class `qts` which stores the IMU sensor data that we collected. An object of class `qts` is a [tibble](https://tibble.tidyverse.org/) with five columns: a *time* column and four columns for the quaternion coordinates named *w*, *x*, *y* and *z*.
115+
:::
116+
117+
We first need to filter out the initial three seconds of data where the subject is standing still before walking on the mat. This can be achieved using the `dplyr::filter()` function. We implemented both a `graphics::plot()` and `ggplot2::autoplot()` S3 specializations for objects of class `qts` in [{squat}](https://cran.r-project.org/package=squat). Many other S3 specializations and methods for objects of class `qts` are available as explained in the dedicated website[^squat-website]. Below, we use the `autoplot` S3 specialization to produce @fig-raw-qts which shows an example of QTS from the data set `bhg`.
118+
119+
[^squat-website]: <https://lmjl-alea.github.io/squat/>.
106120
107-
::: {#fig-timeserie fig-pos="H"}
121+
::: {#fig-raw-qts fig-pos="H"}
108122
109123
```{r}
124+
bhg$egait <- lapply(
125+
bhg$egait,
126+
\(qts) {
127+
dplyr::filter(qts, time > 3)
128+
}
129+
)
110130
bhg$egait[[33]] |>
111-
dplyr::filter(time >= 3) |>
112131
autoplot() +
113132
theme_bw() +
114133
labs(title = "", x = "Time (seconds)")
115134
```
116135
117-
Data recorded by the IMU sensor as a four-coordinate unit quaternion time series.
136+
Raw data recorded by the IMU sensor as a 4-coordinate unit QTS.
118137
119138
:::
120139
121-
::: {.callout-tip title="The [{squat}](https://cran.r-project.org/package=squat) package"}
122-
We developed a dedicated R package coined [{squat}](https://cran.r-project.org/package=squat) for **S**tatistics for **QUA**ternion **T**emporal Data which defines a specific data structure of class `qts` to store and manipulate unit QTS data. In particular, `bhg$egait` is a list of objects of class `qts` which stores the IMU sensor data that we collected. We implemented both a `graphics::plot()` and `ggplot2::autoplot()` S3 specializations for objects of class `qts` in [{squat}](https://cran.r-project.org/package=squat). We implemented many other S3 specializations for QTS as explained in the dedicated website[^squat-website].
123-
124-
[^squat-website]: <https://lmjl-alea.github.io/squat/>.
125-
:::
140+
It is important to observe that @fig-raw-qts displays the gait of a healthy person with nicely depicted gait cycles that are consistent over time. Impaired gait will not necessarily exhibit the same regularity.
126141
127142
Centered data
128143
@@ -138,9 +153,49 @@ $$
138153
\mathbf{q}_{ij}^{(c)} = \mathbf{Q}_i^{(c)} (t_j) = \left( \mathbf{q}_j^{(m)} \right)^{-1} \mathbf{q}_{ij}, \hspace{5mm} j \in [\![ 1, p ]\!],\hspace{2mm} i \in [\![ 1, n ]\!].
139154
$$ {#eq-centring-qts}
140155
156+
From a practical perspective, the centring step can be performed by applying the `squat::centring()` function to each element of the list-column `bhg$egait`:
157+
158+
::: {#fig-raw-qts fig-pos="H"}
159+
160+
```{r}
161+
bhg$egait <- lapply(
162+
bhg$egait,
163+
\(qts) {
164+
squat::centring(qts)
165+
}
166+
)
167+
bhg$egait[[33]] |>
168+
autoplot() +
169+
theme_bw() +
170+
labs(title = "", x = "Time (seconds)")
171+
```
172+
173+
Raw data recorded by the IMU sensor after application of the centering step.
174+
175+
:::
176+
141177
B-spline representation
142178
143-
: The raw QTS data recorded by the sensor can be noisy due to small movements of the sensor during walking or electronic noise. To reduce this noise, we applied a smoothing step on the centered QTS using cubic splines. This step requires to choose a smoothness parameter that controls the amount of smoothing applied to the original data. A higher value of this parameter results in a smoother QTS but may also remove relevant information. In details, we fit a smoothing cubic spline representation separately to each component of the logarithm of the centered QTS using the `smooth.spline()` from the R {stats} package. The functional representation of the QTS itself is then obtained by exponentiating the smoothed logarithm back to the unit quaternion space. We used the default settings of the `stats::smooth.spline()` function except for the *spar* parameter which we tuned as a hyper-parameter (see @sec-feature-space).
179+
: The raw QTS data recorded by the sensor can be noisy due to small movements of the sensor during walking or electronic noise. To reduce this noise, we applied a smoothing step on the centered QTS using cubic splines. This step requires to choose a smoothness parameter that controls the amount of smoothing applied to the original data. A higher value of this parameter results in a smoother QTS but may also remove relevant information. In details, we fit a smoothing cubic spline representation separately to each component of the logarithm of the centered QTS using the `smooth.spline()` from the R {stats} package. The functional representation of the QTS itself is then obtained by exponentiating the smoothed logarithm back to the unit quaternion space. We used the default settings of the `stats::smooth.spline()` function except for the *spar* parameter which we tuned as a hyper-parameter (see @sec-feature-space). The code below shows the steps required to perform the smoothing step for a given value of the *spar* parameter:
180+
181+
```{r}
182+
spar <- 0.3 # example value for the spar parameter
183+
log_qts <- log(bhg$egait[[33]])
184+
smoothed_log_qts <- as_qts(dplyr::tibble(
185+
time = log_qts$time,
186+
w = 0,
187+
x = stats::smooth.spline(log_qts$time, log_qts$x, spar = spar)$y,
188+
y = stats::smooth.spline(log_qts$time, log_qts$y, spar = spar)$y,
189+
z = stats::smooth.spline(log_qts$time, log_qts$z, spar = spar)$y
190+
))
191+
smoothed_qts <- exp(smoothed_log_qts)
192+
smoothed_qts |>
193+
autoplot() +
194+
theme_bw() +
195+
labs(title = "", x = "Time (seconds)")
196+
```
197+
198+
The code above illustrates some other nice S3 specializations implemented in the [{squat}](https://cran.r-project.org/package=squat/) package such as the `log()` and `exp()` functions to compute the logarithm and exponential of a unit QTS respectively. As mentioned in @sec-quaternions, the logarithm of a unit quaternion has a null scalar part, which is why we set the *w* coordinate to zero in the code above and only smooth the three other coordinates.
144199
145200
### Pressure mat data
146201

template-computo-R.qmd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#| include: false
55
library(ggplot2)
66
library(squat)
7-
bhg <- readRDS(url(
8-
"https://zenodo.org/records/18222246/files/bellier_healthy_gait.rds?download=1"
9-
))
107
```
118

129
{{< include _01_Introduction.qmd >}}

0 commit comments

Comments
 (0)