Figure 1:
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.2 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
df <- read.csv("emg_feature_subset-1.csv")
# Create a fake time variable (since not provided)
df <- df %>%
group_by(Subject) %>%
mutate(Time = seq(0, 4, length.out = n())) %>%
ungroup()
panel a: injured vs healthy
df_a <- df %>%
mutate(Group = ifelse(Label == 1, "injured", "healthy"))
ggplot(df_a, aes(x = Time, y = Sensor1_RMS, color = Group)) +
geom_line(stat = "smooth", se = FALSE) +
labs(
title = "Rectus Femoris EMG",
x = "Time (s)",
y = "EMG Signal (RMS)"
) +
theme_minimal()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
part 2: hamstring sensor
ggplot(df_a, aes(x = Time, y = Sensor2_RMS, color = Group)) +
geom_line(stat = "smooth", se = FALSE) +
labs(
title = "Hamstrings EMG",
x = "Time (s)",
y = "EMG Signal (RMS)"
) +
theme_minimal()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
panel b: movement conditions
df_b <- df %>%
mutate(Condition = factor(Label))
ggplot(df_b, aes(x = Time, y = Sensor1_RMS, color = Condition)) +
geom_line(stat = "smooth", se = FALSE) +
labs(
title = "Rectus Femoris EMG Across Conditions",
x = "Time (s)",
y = "EMG Signal"
) +
theme_minimal()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Panel c: muscle sensor3
ggplot(df_a, aes(x = Time, y = Sensor3_RMS, color = Group)) +
geom_line(stat = "smooth", se = FALSE) +
labs(
title = "Additional Muscle EMG",
x = "Time (s)",
y = "EMG Signal"
) +
theme_minimal()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Original figure 6 from the paper:
knitr::include_graphics("figure 6.html")
Figure 7 Recreation
library(tidyverse)
df <- read.csv("emg_feature_subset-1.csv")
# Convert Label to factor (activity)
df$Label <- as.factor(df$Label)
Panel a: Rectus Femoris + hamstring
ggplot(df, aes(x = Label, y = Sensor1_RMS, fill = Label)) +
geom_boxplot() +
labs(
title = "Rectus Femoris EMG (RMS)",
x = "Activity",
y = "EMG Signal (RMS)"
) +
theme_minimal()
# Hamstrings (Sensor2)
ggplot(df, aes(x = Label, y = Sensor2_RMS, fill = Label)) +
geom_boxplot() +
labs(
title = "Hamstrings EMG (RMS)",
x = "Activity",
y = "EMG Signal (RMS)"
) +
theme_minimal()
panel a: Multiple Muscles comparison
df_long_rms <- df %>%
pivot_longer(
cols = contains("_RMS"),
names_to = "Sensor",
values_to = "RMS"
)
ggplot(df_long_rms, aes(x = Sensor, y = RMS, fill = Label)) +
geom_boxplot() +
labs(
title = "EMG RMS Across Muscles",
x = "Muscle (Sensor)",
y = "RMS"
) +
theme_minimal()
Panel B: mean feature across muscles
df_long_mean <- df %>%
pivot_longer(
cols = contains("_Mean"),
names_to = "Sensor",
values_to = "Mean"
)
ggplot(df_long_mean, aes(x = Sensor, y = Mean, fill = Label)) +
geom_boxplot() +
labs(
title = "Mean EMG Across Muscles",
x = "Muscle",
y = "Mean Signal"
) +
theme_minimal()
panel c: standard deviation of tibialis
df_long_sd <- df %>%
pivot_longer(
cols = contains("_SD"),
names_to = "Sensor",
values_to = "SD"
)
ggplot(df_long_sd, aes(x = Label, y = SD, fill = Label)) +
geom_boxplot() +
labs(
title = "EMG Variability (SD) Across Activities",
x = "Activity",
y = "Standard Deviation"
) +
theme_minimal()
figure 7 original from paper:
knitr::include_graphics("figure 7.html")