compare_traces_em6

Load data

# load libs
library(readr)
Warning: package 'readr' was built under R version 4.2.3
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(tidyr)
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.2.3
# load data
#processed_data <- read_csv("scripts_and_data/processed_data/SG_ET_step2_March24.csv", show_col_types = F)
setwd("D:/Canna_d/EM6_stuff/May6")
processed_data <- read_csv("SG_ET_step2_May8_ALL_BATCHES.csv", show_col_types = F)

Raw traces each trial

Trace_data_trial1trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial1trip1, aes(x = milliseconds, y = mean_pupil, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Raw pupil - Trial 1 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
Warning: Removed 407 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial2trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 2 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial2trip1, aes(x = milliseconds, y = mean_pupil, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Raw pupil - Trial 2 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 325 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial3trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 3 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial3trip1, aes(x = milliseconds, y = mean_pupil, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Raw pupil - Trial 3 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 416 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial4trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 4 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial4trip1, aes(x = milliseconds, y = mean_pupil, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Raw pupil - Trial 4 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 278 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial5trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delayClosing" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial5trip1, aes(x = milliseconds, y = mean_pupil, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Raw pupil - Trial 5 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 549 rows containing missing values or values outside the scale range
(`geom_line()`).

Hann smoothed + interpolated traces each trial

Trace_data_trial1trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial1trip1, aes(x = milliseconds, y = smoothed_pupil3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Hann smoothed pupil - Trial 1 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 822 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial2trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 2 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial2trip1, aes(x = milliseconds, y = smoothed_pupil3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Hann smoothed pupil - Trial 2 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 545 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial3trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 3 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial3trip1, aes(x = milliseconds, y = smoothed_pupil3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Hann smoothed pupil - Trial 3 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 632 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial4trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 4 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial4trip1, aes(x = milliseconds, y = smoothed_pupil3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Hann smoothed pupil - Trial 4 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 570 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial5trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delayClosing" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial5trip1, aes(x = milliseconds, y = smoothed_pupil3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Hann smoothed pupil - Trial 5 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 988 rows containing missing values or values outside the scale range
(`geom_line()`).

Median smoothed + interpolated traces each trial

Trace_data_trial1trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial1trip1, aes(x = milliseconds, y = med_smoother3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Median smoothed pupil - Trial 1 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 546 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial2trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 2 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial2trip1, aes(x = milliseconds, y = med_smoother3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Median smoothed pupil - Trial 2 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 344 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial3trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 3 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial3trip1, aes(x = milliseconds, y = med_smoother3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Median smoothed pupil - Trial 3 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 410 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial4trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 4 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial4trip1, aes(x = milliseconds, y = med_smoother3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Median smoothed pupil - Trial 4 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 469 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial5trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delayClosing" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial5trip1, aes(x = milliseconds, y = med_smoother3, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Median smoothed pupil - Trial 5 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 841 rows containing missing values or values outside the scale range
(`geom_line()`).

Baseline corrected traces each trial

(Hann smoother w/ 500ms of list as the baseline)

Trace_data_trial1trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial1trip1, aes(x = milliseconds, y = change_from_baseline, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Baseline corrected pupil - Trial 1 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 822 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial2trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 2 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial2trip1, aes(x = milliseconds, y = change_from_baseline, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Baseline corrected pupil - Trial 2 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 545 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial3trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 3 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial3trip1, aes(x = milliseconds, y = change_from_baseline, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Baseline corrected pupil - Trial 3 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 632 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial4trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delay" &
           stage.x == "shelfBack" &
           trial == 4 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial4trip1, aes(x = milliseconds, y = change_from_baseline, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Baseline corrected pupil - Trial 4 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 570 rows containing missing values or values outside the scale range
(`geom_line()`).

Trace_data_trial5trip1 <- processed_data %>%
  filter(condsFile == "maintenance_delayClosing" &
           stage.x == "shelfBack" &
           trial == 1 &
           adjustTrip == 1 & !is.na(d_time))

ggplot(Trace_data_trial5trip1, aes(x = milliseconds, y = change_from_baseline, group = participant, color = participant)) +
  geom_line(size = 1) +  # Line plot for each participant's trace
  facet_wrap(~ participant, scales = "free_y") +  # Facet by participant, with independent y-axis
  labs(title = "Baseline corrected pupil - Trial 5 Trip 1 (All Participants)",
       x = "Frame",
       y = "Pupil (mm)") +
  theme_minimal() +
  theme(legend.position = "none")
Warning: Removed 988 rows containing missing values or values outside the scale range
(`geom_line()`).