Strong mnemonic prediction errors increase cognitive control, attention, and arousal.
The 3 matches
- [1] § Results › Effects of mnemonic prediction errors › Distinct pupil features reflect MPEs and attentional orienting ↔ scripts/pupil/pupil_temporal_pca.Rmd, lines 1339 to 1389 · score 0.64 · cognitive effort, temporal PCA, orienting responses, PC6, PC2, PC5 · Report a mismatch
- [2] § Methods › EEG and pupillometry analyses › Pupillary temporal PCA ↔ scripts/pupil/pupil_temporal_pca.Rmd, lines 161 to 281 · score 0.51 · Temporal PCA, matrix, rotation, varimax, RT, components · Report a mismatch
- [3] § Methods › EEG and pupillometry analyses › Pupillary temporal PCA ↔ scripts/pupil/pupil_temporal_pca_include_incorrect.Rmd, lines 186 to 309 · score 0.51 · Temporal PCA, matrix, rotation, varimax, RT, components · Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
R Markdown · 2,507 lines · 88 KB · GPL-3.0 · 2 matches
- ---
- title: "Temporal PCA on pupil data during associative retrieval"
- author: "Alice M. Xue ([email hidden])"
- date: "`r format(Sys.time(), '%B %d, %Y')`"
- params:
- exp_id: "MPE"
- run_models: yes
- output:
- html_document:
- toc: yes
- toc_depth: 3
- toc_float:
- collapsed: no
- self_contained: true
- pdf_document:
- toc: yes
- toc_depth: '3'
- ---
- ```{r setup, include=FALSE}
- library(plyr)
- library(Hmisc)
- library(ggplot2)
- library(knitr)
- library(kableExtra)
- library(data.table)
- library(psycho)
- library(lme4)
- library(sjPlot)
- library(afex)
- library(viridis)
- library(showtext)
- library(tidyverse)
- library(mgcv)
- library(itsadug)
- library(RColorBrewer)
- library(ggcorrplot)
- library(devtools)
- library(factoextra)
- library(tidyjson)
- library(purrr)
- library(broom)
- library(zoo)
- library(psych)
- library(patchwork)
- library(emmeans)
- library(ggpubr)
- library(stats)
- library(broom.mixed)
- library(pracma)
- library(afex)
- library(stringr)
- library(ggeffects)
- font_add(family = "Avenir Next",
- regular = "../utils/AvenirNext-Regular.ttf",
- bold = "../utils/AvenirNext-DemiBold.ttf",
- italic = "../utils/AvenirNext-Italic.ttf")
- showtext.auto()
- op <- showtext_opts()
- fontfamily <- "Avenir Next"
- set_theme(
- base=theme_classic(base_size = 12,
- base_family="Avenir Next")
- )
- options(dplyr.summarise.inform = FALSE)
- #knitr::opts_chunk$set(dev = 'pdf') # set output device to pdf
- knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message = FALSE)
- ```
- ```{r, echo=F}
- source("../utils/summary_se_utils.R")
- ```
- ```{r get_behavior, echo=F}
- set.seed(478)
- exp_id <- params$exp_id
- run_models <- params$run_models
- data_ret <- fread("../../data/behavior/MPE_asso_retrieval_behavior.csv") %>%
- mutate(key = match_response.keys,
- rt = match_response.rt * 1000)
- data_recog <- fread("../../data/behavior/MPE_mismatch_recog_behavior.csv") %>%
- mutate(rt = recognition_response.rt * 1000)
- recognition_behavior <- data_recog %>%
- mutate(trialN = trials.thisTrialN) %>%
- select(trialN,
- recognition_response.keys,
- recognition_response.rt,
- is_old,
- img,
- subjectId,
- expId) %>%
- mutate(hit = is_old & (recognition_response.keys==1)) %>%
- mutate(false_alarm = !is_old & (recognition_response.keys==1)) %>%
- mutate(miss = is_old & (recognition_response.keys==2)) %>%
- mutate(correct_rejection = !is_old & (recognition_response.keys==2)) %>%
- mutate(trial_outcome = case_when(hit ~ "Hit",
- false_alarm ~ "FA",
- miss ~ "Miss",
- correct_rejection ~ "CR")) %>%
- group_by(subjectId,
- trialN,
- trial_outcome,
- is_old,
- img,
- recognition_response.keys,
- expId) %>%
- summarize(recognition_response.rt = mean(recognition_response.rt)) %>%
- ungroup()
- ```
- ```{r load_models, echo=F, eval=!run_models}
- load("tpca_models_correct_only.RData")
- ```
- ```{r save_or_load_data, echo=F}
- retrieval_pupil <- fread("../../data/pupil/MPE_imm_retrieval_pupil.csv")
- retrieval_pupil.del <- fread("../../data/pupil/MPE_del_retrieval_pupil.csv")
- retrieval_pupil <- bind_rows(retrieval_pupil, retrieval_pupil.del) %>%
- mutate(expId = case_when(grepl("MPE1", subjectId) ~ "imm",
- grepl("MPE3", subjectId) ~ "del",
- grepl("MPE5", subjectId) ~ "del")) %>%
- mutate(across(expId,
- factor,
- levels=c("imm", "del"))) %>%
- mutate(room_setup = case_when(grepl("MPE1", subjectId) ~ "1", # eeg + pupil, shared-eeg lab
- grepl("MPE3", subjectId) ~ "2", # pupil only, shared-eeg lab
- grepl("MPE5", subjectId) ~ "3")) # pupil only, 4th floor lab
- ```
- ```{r labels, echo=F}
- palette <- c("#008080", "#9fdfbf")
- hit_miss_palette <- c("#6E9075", "#FC7753")
- ret_labels_strong <- tibble(event = c("cue", "delay", "probe", "ITI"),
- time = c(0, 1, 2, 2.75))
- ret_labels_weak <- tibble(event = c("cue", "delay", "probe", "ITI"),
- time = c(0, 1, 2, 2.75))
- ret_labels <- rbind(ret_labels_strong, ret_labels_weak)
- ret_labels$position <- 0.12
- ```
- ```{r tempPCA_trial, echo=F}
- subj_timeseries_trial <- retrieval_pupil %>%
- dplyr::filter(trial_outcome %in% c("Hit", "CR")) %>%
- mutate(pupil_diameter = pupil_diameter_z)
- subj_timeseries_trial %>%
- pivot_wider(id_cols = c("subjectId",
- "expId",
- "room_setup",
- "trial_outcome",
- "match_response.rt",
- "association_strength",
- "trialN",
- "img"),
- names_from = c("time"),
- values_from = c("pupil_diameter")) %>%
- mutate(across(trial_outcome,
- factor,
- levels=c("Hit", "CR", "Miss", "FA"))) %>%
- group_by(trial_outcome, association_strength) %>%
- summarize(count = n()) %>%
- ungroup() %>%
- mutate(total_ntrials = sum(count)) %>%
- mutate(percent_data = round(count / total_ntrials * 100, 2)) %>%
- kable() %>%
- kable_styling(bootstrap_options = "striped",
- full_width = F,
- position = "left")
- subj.data <- subj_timeseries_trial %>%
- pivot_wider(id_cols = c("trial_outcome",
- "association_strength",
- "subjectId",
- "expId",
- "room_setup",
- "trialN",
- "img",
- "trialN_block",
- "match_response.rt",
- "block"),
- names_from = c("time"),
- values_from = c("pupil_diameter"))
- pca_input <- subj.data %>%
- select(-trial_outcome,
- -association_strength,
- -subjectId,
- -expId,
- -room_setup,
- -match_response.rt,
- -trialN,
- -img,
- -trialN_block,
- -block)
- ncomp <- 6
- pc_names <- paste("PC", 1:ncomp, sep = "")
- data.pca <- prcomp(pca_input, center=T, scale=T)
- # scree plot
- plot(data.pca)
- # change the sign of PC4 columns to flip the sign of the loadings
- rot <- data.pca$rotation
- rot[, c(4)] <- rot[, c(4)] * -1
- data.pca$rotation <- rot
- raw.loadings <- data.pca$rotation[,1:ncomp] %*% diag(data.pca$sdev, ncomp, ncomp)
- rotated.loadings <- varimax(raw.loadings)$loadings
- inv.loadings <- t(pracma::pinv(rotated.loadings))
- loadings <- rotated.loadings
- scores <- scale(pca_input) %*% inv.loadings
- subj.pred <- as_tibble(scores) %>%
- rename_with(~ gsub("V", "PC", .))
- fviz_eig(data.pca, addlabels = TRUE)
- pca.loadings <- as_tibble(matrix(as.numeric(loadings),
- attributes(loadings)$dim,
- dimnames=attributes(loadings)$dimnames),
- rownames="time") %>%
- mutate(time = as.numeric(time))
- pca.loadings <- pca.loadings %>%
- rename_with(~ gsub("V", "PC", .))
- ss_loadings <- colSums(loadings^2)
- var_explained <- as_tibble(ss_loadings/nrow(loadings)) %>%
- mutate(percent_var_explained = value * 100) %>%
- add_column(component = pc_names)
- var_explained <- var_explained %>%
- arrange(desc(percent_var_explained)) %>%
- mutate(component_renamed = paste("PC", row_number(), sep=""))
- pca.loadings <- pca.loadings %>%
- pivot_longer(cols = pc_names,
- names_to = "component",
- values_to = "loading") %>%
- left_join(var_explained, by=c("component")) %>%
- rename(component_orig = component,
- component = component_renamed)
- # ordered by "peak time"
- ordered_pcs <- c("PC2",
- "PC5",
- "PC1",
- "PC6",
- "PC3",
- "PC4")
- component_order_with_var_explained <- c("PC2: 25.89%",
- "PC5: 5.66%",
- "PC1: 28.81%",
- "PC6: 1.83%",
- "PC3: 19.29%",
- "PC4: 14.68%")
- ```
- ```{r plot_pc_loadings, echo=F}
- rainbow <- c("#E82C42",
- "#F46D43",
- "#FFCC00",
- "#29A343",
- "#1E8DD2",
- "#59169C")
- pca.loadings %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- mutate(across(component,
- factor,
- levels=component_order_with_var_explained)) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(linewidth=1.2) +
- geom_text(aes(label = event,
- x = time,
- y = 0.9),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 6,
- colour = "gray37",
- family = fontfamily) +
- labs(x = "Time (s)",
- y = "PC loading",
- title = "Components extracted by temporal PCA") +
- scale_color_manual(values=rainbow, name="") +
- theme(text = element_text(size=15))
- pca.loadings %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- labs(x = "Time (s)",
- y = "PC loading",
- title = "Temporal PCA") +
- scale_color_brewer(palette="Set2") +
- theme(legend.position = "none")
- subj.data.scores <- subj.data %>%
- add_column(subj.pred) %>%
- pivot_longer(cols = pc_names,
- names_to = "component",
- values_to = "component_score") %>%
- left_join(var_explained, by=c("component")) %>%
- rename(component_orig = component,
- component = component_renamed)
- scores <- subj.data.scores %>%
- select(subjectId,
- trialN,
- img,
- trialN_block,
- block,
- trial_outcome,
- association_strength,
- component,
- component_score)
- save(loadings,
- inv.loadings,
- subj.data.scores,
- file="pupil_tPCA_correct_only.RData")
- write.csv(scores, "pupil_tPCA_scores_correct_trials_only.csv")
- write.csv(pca.loadings, "pupil_tPCA_loadings_correct_trials_only.csv")
- ```
- ```{r loadings_plts, echo=F}
- loadings.plt <- pca.loadings %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component, ncol=1) +
- labs(x = "Time (s)",
- y = "PC loading") +
- theme(legend.position = "none")
- loadings.vrt.plt <- pca.loadings %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- mutate(across(component,
- factor,
- levels=component_order_with_var_explained)) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component, ncol=1) +
- labs(x = "Time (s)",
- y = "PC loading") +
- theme(legend.position = "none")
- ```
- ## Memory outcome models
- Match v. mismatch, correct v. incorrect
- ```{r match_mismatch_acc_models, echo=F, eval=run_models, fig.width=6.5, fig.height=3, results="asis"}
- models <- c()
- models.compact.no.mismatch <- c()
- for (i in 1:ncomp) {
- mod.data <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", i, sep="")) %>%
- mutate(is_mismatch = if_else(trial_outcome %in% c("Hit", "Miss"),
- 0,
- 1)) %>%
- mutate(is_incorrect = if_else(trial_outcome %in% c("Hit", "CR"),
- 0,
- 1))
- mod <- mod.data %>%
- lmer(component_score ~ is_mismatch * association_strength +
- (is_mismatch * association_strength | subjectId) +
- (1 | expId),
- data = .)
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- lmer(component_score ~ is_mismatch * association_strength +
- (is_mismatch * association_strength | subjectId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- lmer(component_score ~ is_mismatch * association_strength +
- (is_mismatch + association_strength | subjectId) +
- (1 | expId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- lmer(component_score ~ is_mismatch * association_strength +
- (is_mismatch + association_strength | subjectId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- lmer(component_score ~ is_mismatch * association_strength +
- (1 | subjectId) +
- (1 | expId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- lmer(component_score ~ is_mismatch * association_strength +
- (1 | subjectId),
- data = .)
- }
- final.mod.formula <- formula(mod) [3]
- final.mod.formula <- paste("component_score ~", final.mod.formula)
- no.mismatch.formula <- gsub("is_mismatch \\* ", "", final.mod.formula)
- no.mismatch.formula <- gsub("is_mismatch \\+ ", "", no.mismatch.formula)
- mod.no.mismatch <- mod.data %>%
- lmer(as.formula(no.mismatch.formula),
- data = .)
- if (isSingular(mod.no.mismatch) | any(grepl("failed to converge", mod.no.mismatch@optinfo$conv$lme4$messages))) {
- mod.no.mismatch <- mod.data %>%
- lmer(component_score ~ association_strength +
- (association_strength | subjectId),
- data = .)
- }
- if (isSingular(mod.no.mismatch) | any(grepl("failed to converge", mod.no.mismatch@optinfo$conv$lme4$messages))) {
- mod.no.mismatch <- mod.data %>%
- lmer(component_score ~ association_strength +
- (1 | subjectId),
- data = .)
- }
- models <- c(models, mod)
- models.compact.no.mismatch <- c(models.compact.no.mismatch, mod.no.mismatch)
- }
- ```
- ```{r show_match_mismatch_acc_models, echo=F, eval=T, fig.width=6.5, fig.height=3, results="asis"}
- for (i in 1:ncomp) {
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", i, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- labs(x = "Time (s)",
- y = "PC loading") +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none")
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", i, sep="")) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- mutate(across(trial_outcome,
- factor,
- levels=c("Hit", "CR", "Miss", "FA"))) %>%
- ggplot(aes(x = association_strength,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_wrap(~component, scales = "free") +
- scale_color_manual(values=c("#1a75ff", "#ff751a", "#80b3ff", "#ffb380"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a", "#80b3ff", "#ffb380"), name="") +
- labs(x = "", y = "PC score")
- print(fig1 + fig2)
- mod <- models[[i]]
- mod.no.mismatch <- models.compact.no.mismatch[[i]]
- title <- formula(mod) [3]
- title <- gsub("is_mismatch", "Mismatch", title)
- title <- gsub("is_incorrect", "Accuracy", title)
- title <- gsub("association_strength", "Strength", title)
- title <- gsub(":", " x ", title)
- tidy(mod, effects = "fixed", conf.int = T, conf.level = 0.95) %>%
- mutate(CI = paste0("[",
- sprintf("%.03f", conf.low),
- ", ",
- sprintf("%.03f", conf.high),
- "]",
- sep="")) %>%
- select(term, estimate, CI, p.value, std.error, df) %>%
- rename("Estimate" = estimate,
- "p-value" = p.value,
- "SE" = std.error,
- "DF" = df
- ) %>%
- mutate(term = gsub("is_mismatch", "Mismatch", term),
- term = gsub("is_incorrect", "Accuracy", term),
- term = gsub("association_strengthWeak \\(1x\\)", "Strength", term),
- term = gsub(":", " x ", term)) %>%
- kable(caption=paste("PC", i, " score ~ ", title, sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- tidy(mod, effects = "ran_pars", scales = "vcov") %>%
- select(term, estimate) %>%
- mutate(term = gsub("var__", "Variance ", term),
- term = gsub("cov__", "Covariance ", term),
- term = gsub("\\(Intercept\\)", "intercept", term),
- term = gsub("is_mismatch", "Mismatch", term),
- term = gsub("is_incorrect", "Accuracy", term),
- term = gsub("association_strengthWeak \\(1x\\)", "Strength", term),
- term = gsub("\\.", ", ", term)) %>%
- kable(digits=3, caption="Random effects") %>%
- kable_styling() %>%
- cat()
- anova(mod.no.mismatch, mod, test="LRT") %>%
- tidy() %>%
- kable(caption=paste("mod.no.mismatch:",
- formula(mod.no.mismatch) [3])) %>%
- kable_styling() %>%
- cat()
- print(paste("No mismatch compact model failed to converge: ",
- isSingular(mod.no.mismatch) | any(grepl("failed to converge", mod.no.mismatch@optinfo$conv$lme4$messages))))
- emm <- emmeans(mod, ~ is_mismatch | association_strength, lmerTest.limit = 10346)
- print(emm)
- tidy(emm, effects = "fixed", conf.int = T, conf.level = 0.95) %>%
- kable(digits=3, caption=paste("PC", i, "; Emmeans", sep="")) %>%
- kable_styling() %>%
- cat()
- emm.pairs <- pairs(emm)
- print(emm.pairs)
- tidy(emm.pairs, effects = "fixed", conf.int = T, conf.level = 0.95) %>%
- kable(digits=3, caption=paste("PC", i, "; Pairwise comparisons", sep="")) %>%
- kable_styling() %>%
- cat()
- }
- ```
- ```{r full_model_all_pc, echo=F, eval=F}
- mod <- subj.data.scores %>%
- mutate(is_mismatch = if_else(trial_outcome %in% c("Hit", "Miss"),
- 0,
- 1)) %>%
- mutate(is_incorrect = if_else(trial_outcome %in% c("Hit", "CR"),
- 0,
- 1)) %>%
- lmer(component_score ~ component * is_mismatch * association_strength +
- (component + is_mismatch + association_strength | subjectId),
- data = .)
- mod %>%
- summary()
- tidy(mod, effects = "fixed", conf.int = T, conf.level = 0.95) %>%
- select(term, estimate, conf.low, conf.high, p.value, std.error, df) %>%
- kable(digits=3) %>%
- kable_styling()
- tidy(mod, effects = "ran_pars", scales = "vcov") %>%
- select(term, estimate) %>%
- kable(digits=3, caption="Random effects") %>%
- kable_styling()
- ```
- ## RT models
- ```{r get_rt_data_obj, echo=F}
- ### joint plot
- rt_data <- subj.data.scores %>%
- mutate_at(c('trial_outcome'), as.character) %>%
- mutate(trial_outcome=replace(trial_outcome, trial_outcome=="Hit", "Match")) %>%
- mutate(trial_outcome=replace(trial_outcome, trial_outcome=="CR", "Mismatch")) %>%
- dplyr::filter(trial_outcome %in% c("Match", "Mismatch"))
- ```
- ```{r match_mismatch_rt, echo=F, eval=run_models, fig.width=7, fig.height=10}
- models.rt <- c()
- for (pc in 1:ncomp) {
- mod <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(match_response.rt = log(match_response.rt)) %>%
- lmer(match_response.rt ~ component_score * association_strength * trial_outcome +
- (component_score * association_strength * trial_outcome | subjectId) +
- (1 | expId),
- data = .)
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(match_response.rt = log(match_response.rt)) %>%
- lmer(match_response.rt ~ component_score * association_strength * trial_outcome +
- (component_score * trial_outcome * association_strength | subjectId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(match_response.rt = log(match_response.rt)) %>%
- lmer(match_response.rt ~ component_score * association_strength * trial_outcome +
- (component_score + trial_outcome + association_strength | subjectId) +
- (1 | expId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(match_response.rt = log(match_response.rt)) %>%
- lmer(match_response.rt ~ component_score * association_strength * trial_outcome +
- (component_score + trial_outcome + association_strength | subjectId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(match_response.rt = log(match_response.rt)) %>%
- lmer(match_response.rt ~ component_score * association_strength * trial_outcome +
- (component_score | subjectId) +
- (1 | expId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(match_response.rt = log(match_response.rt)) %>%
- lmer(match_response.rt ~ component_score * association_strength * trial_outcome +
- (1 | subjectId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- print(paste("MODEL DID NOT CONVERGE FOR PC", pc))
- }
- models.rt <- c(models.rt, mod)
- }
- ```
- ```{r binned_rt, echo=F, fig.width=7, fig.height=10}
- nbins <- 4
- rt.binned.plt <- rt_data %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- mutate(trial_count = n()) %>%
- ungroup() %>%
- dplyr::filter(trial_count > nbins-1) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- mutate(component_score_bin = cut_interval(component_score,
- n = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, component_score_bin) %>%
- summarize(rt = median(match_response.rt)) %>%
- summarySEwithin(.,
- measurevar="rt",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "component_score_bin"),
- idvar="subjectId") %>%
- ggplot(aes(x = as.numeric(as.character(component_score_bin)),
- y = rt,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=rt-se, ymax=rt+se),
- width=0.2) +
- facet_grid(rows=vars(component),
- cols=vars(association_strength),
- axes="all_x",
- scales = "free") +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "PC score quartile", y = "RT (s)") +
- theme(strip.text.y = element_blank())
- loadings.plt + rt.binned.plt +
- plot_layout(widths=c(1,2))
- ```
- ```{r show_mismatch_rt_models, echo=F, fig.width=6.5, fig.height=3, results="asis"}
- for (pc in 1:ncomp) {
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- labs(x = "Time (s)",
- y = "PC loading") +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none")
- mod <- models.rt[[pc]]
- fig2 <- mod %>%
- plot_model(type="pred",
- terms=c("component_score[all]",
- "trial_outcome[all]",
- "association_strength[Strong (4x), Weak (1x)]")) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(y = "RT (s)") +
- theme(plot.title=element_blank(),
- axis.title.x=element_blank())
- print(fig1 + fig2)
- title <- formula(mod)[3]
- title <- gsub("trial_outcome", "Mismatch", title)
- title <- gsub("component_score",
- paste("PC", pc, " score", sep=""),
- title)
- title <- gsub("association_strength", "Strength", title)
- title <- gsub(":", " x ", title)
- tidy(mod, effects = "fixed", conf.int = T, conf.level = 0.95) %>%
- mutate(CI = paste0("[",
- sprintf("%.03f", conf.low),
- ", ",
- sprintf("%.03f", conf.high),
- "]",
- sep="")) %>%
- select(term, estimate, CI, p.value, std.error, df) %>%
- rename("Estimate" = estimate,
- "p-value" = p.value,
- "SE" = std.error,
- "DF" = df
- ) %>%
- mutate(term = gsub("trial_outcomeMismatch", "Mismatch", term),
- term = gsub("component_score",
- paste("PC", pc, " score", sep=""),
- term),
- term = gsub("association_strengthWeak \\(1x\\)", "Strength", term),
- term = gsub(":", " x ", term)) %>%
- kable(caption=paste("RT ~ ", title, sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- tidy(mod, effects = "ran_pars", scales = "vcov") %>%
- select(term, estimate) %>%
- mutate(term = gsub("var__", "Variance ", term),
- term = gsub("cov__", "Covariance ", term),
- term = gsub("\\(Intercept\\)", "intercept", term),
- term = gsub("is_mismatch", "Mismatch", term),
- term = gsub("is_incorrect", "Accuracy", term),
- term = gsub("association_strengthWeak \\(1x\\)", "Strength", term),
- term = gsub("\\.", ", ", term)) %>%
- kable(digits=3, caption="Random effects") %>%
- kable_styling() %>%
- cat()
- slopes <- emtrends(mod, pairwise ~ association_strength * trial_outcome, var = "component_score", lmerTest.limit = 10346)
- print(slopes)
- tidy(slopes$emtrends, conf.int = T, conf.level = 0.95) %>%
- kable(caption=paste("slopes: RT ~ ", title, sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- tidy(slopes$contrasts, conf.int = T, conf.level = 0.95) %>%
- select(contrast, estimate, std.error, df, conf.low, conf.high, statistic, adj.p.value) %>%
- kable(caption=paste("slope contrasts: RT ~ ", title, sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- }
- ```
- ## Individual PC plots
- ```{r indivi_pc_plots, fig.width=6, fig.height=2, echo=F}
- showtext_opts(dpi = 300)
- for (pc in 1:ncomp) {
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading") +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none")
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(trial_outcome = ifelse(as.character(trial_outcome) %in% c("Hit"),
- "Match", "Mismatch")) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "", y = "PC score") +
- theme(axis.title.x=element_blank(),
- axis.text.x=element_blank(),
- axis.ticks.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- # exclude any subjects with # trials < # bins
- mutate(trial_count = n()) %>%
- ungroup() %>%
- dplyr::filter(trial_count > nbins-1) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- mutate(component_score_bin = cut_interval(component_score,
- n = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, component_score_bin) %>%
- summarize(rt = median(match_response.rt)) %>%
- summarySEwithin(.,
- measurevar="rt",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "component_score_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = as.numeric(as.character(component_score_bin)),
- y = rt,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=rt-se, ymax=rt+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "PC score quartile", y = "RT (s)") +
- guides(color = "none")
- joint.fig <- (fig1 + fig2 + fig3) +
- plot_layout(widths=c(1,1,1),
- guides="collect", axis_titles = "collect") &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- )
- ggsave(paste("tPCA_figures_correct_only/PC", pc, "_scores_and_RT.pdf", sep=""),
- plot=joint.fig,
- width=22,
- height=7,
- dpi=300,
- create.dir=T,
- units="cm")
- }
- showtext_opts(op)
- ```
- ```{r other_version_of_pc_plots, fig.width=6, fig.height=2, echo=F}
- showtext_opts(dpi = 300)
- for (pc in 1:ncomp) {
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading") +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none",
- strip.text.x = element_text(size=12),
- strip.background = element_blank())
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(trial_outcome = ifelse(as.character(trial_outcome) %in% c("Hit"),
- "Match", "Mismatch")) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "", y = "PC score") +
- theme(axis.title.x=element_blank(),
- axis.text.x=element_blank(),
- axis.ticks.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- # exclude any subjects with # trials < # bins
- mutate(trial_count = n()) %>%
- ungroup() %>%
- dplyr::filter(trial_count > nbins-1) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- mutate(component_score_bin = cut_interval(component_score,
- n = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, component_score_bin) %>%
- summarize(rt = median(match_response.rt)) %>%
- summarySEwithin(.,
- measurevar="rt",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "component_score_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = as.numeric(as.character(component_score_bin)),
- y = rt,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=rt-se, ymax=rt+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "PC score quartile", y = "RT (s)") +
- guides(color = "none")
- joint.fig <- (fig1 + fig2 + fig3) +
- plot_layout(widths=c(1,1,1),
- guides="collect", axis_titles = "collect") &
- theme(strip.text.y = element_blank()
- )
- ggsave(paste("tPCA_figures_correct_only/PC", pc, "_scores_and_RT_framed.pdf", sep=""),
- plot=joint.fig,
- width=23,
- height=7,
- dpi=300,
- create.dir=T,
- units="cm")
- }
- showtext_opts(op)
- ```
- ```{r rainbow_indivi_pc_plots, fig.width=2, fig.height=6, echo=F}
- showtext_opts(dpi = 300)
- full.rainbow.fig <- list()
- for (pc in 1:ncomp) {
- ordered.rainbow <- c("#FFCC00", "#E82C42", "#59169C", "#1E8DD2", "#F46D43", "#29A343")
- pc.color <- ordered.rainbow[[pc]]
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color=pc.color, linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading") +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none")
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(trial_outcome = ifelse(trial_outcome %in% c("Hit"),
- "Match", "Mismatch")) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "Memory outcome", y = "PC score") +
- theme(axis.text.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(trial_outcome = ifelse(trial_outcome %in% c("Hit"),
- "Match", "Mismatch")) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- # exclude any subjects with # trials < # bins
- mutate(trial_count = n()) %>%
- ungroup() %>%
- dplyr::filter(trial_count > nbins-1) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- mutate(component_score_bin = cut_interval(component_score,
- n = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, component_score_bin) %>%
- summarize(rt = median(match_response.rt)) %>%
- summarySEwithin(.,
- measurevar="rt",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "component_score_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = as.numeric(as.character(component_score_bin)),
- y = rt,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=rt-se, ymax=rt+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "PC score quartile", y = "RT (s)") +
- guides(color = "none")
- full.rainbow.fig[[pc]] <- fig1 / fig2 / fig3
- }
- rainbow.fig <- (full.rainbow.fig[[2]] |
- full.rainbow.fig[[5]] |
- full.rainbow.fig[[1]] |
- full.rainbow.fig[[6]] |
- full.rainbow.fig[[4]] |
- full.rainbow.fig[[3]]) +
- plot_layout(
- guides = "collect", axes = "collect", axis_titles = "collect") &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- legend.position = "left"
- )
- ggsave(paste("tPCA_figures_correct_only/rainbow_all_PC_scores_and_RT.pdf", sep=""),
- plot=rainbow.fig,
- width=40,
- height=18,
- dpi=300,
- create.dir=T,
- units="cm")
- showtext_opts(op)
- ```
- ```{r rainbow_with_titles_indivi_pc_plots, fig.width=2, fig.height=6, echo=F}
- showtext_opts(dpi = 300)
- titles <- list("PC1"="'Memory reinstatement strength'",
- "PC2"="'Preparatory attention'",
- "PC3"="'Prediction error x strength'",
- "PC4"="'Orienting response to errors'",
- "PC5"="'Cognitive effort'",
- "PC6"="'Mismatch detection'")
- full.rainbow.fig <- list()
- for (pc in 1:ncomp) {
- ordered.rainbow <- c("#FFCC00", "#E82C42", "#59169C", "#1E8DD2", "#F46D43", "#29A343")
- pc.color <- ordered.rainbow[[pc]]
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color=pc.color, linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading",
- title = titles[[pc]]) +
- theme(legend.position = "none",
- plot.title=element_text(hjust=0),
- plot.subtitle=element_text(size=12))
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(across(trial_outcome,
- factor,
- levels=c("Hit", "Miss", "CR", "FA"))) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "Memory outcome", y = "PC score") +
- theme(axis.text.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- # exclude any subjects with # trials < # bins
- mutate(trial_count = n()) %>%
- ungroup() %>%
- dplyr::filter(trial_count > nbins-1) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- mutate(component_score_bin = cut_interval(component_score,
- n = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, component_score_bin) %>%
- summarize(rt = median(match_response.rt)) %>%
- summarySEwithin(.,
- measurevar="rt",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "component_score_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = as.numeric(as.character(component_score_bin)),
- y = rt,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=rt-se, ymax=rt+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "PC score quartile", y = "RT (s)") +
- guides(color = "none")
- full.rainbow.fig[[pc]] <- fig1 / fig2 / fig3
- }
- rainbow.fig <- (full.rainbow.fig[[2]] |
- full.rainbow.fig[[5]] |
- full.rainbow.fig[[1]] |
- full.rainbow.fig[[6]] |
- full.rainbow.fig[[3]] |
- full.rainbow.fig[[4]]) +
- plot_layout(guides="collect",
- tag_level = 'new') +
- plot_annotation(tag_levels = list(c("A", "", "",
- "B", "", "",
- "C", "", "",
- "D", "", "",
- "E", "", "",
- "F", "", ""))) &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- plot.margin = margin(0, 10, 0, 10),
- plot.title.position = "plot",
- plot.subtitle=element_text(hjust=0, margin=margin(t=5)),
- plot.tag = element_text(face="bold", margin=margin(t=5, b=5)),
- axis.title.y = element_text(margin = margin(r=0)),
- axis.text.y = element_text(margin = margin(l=3, r=3)))
- ggsave(paste("tPCA_figures_correct_only/rainbow_all_PC_scores_and_RT_titled.pdf", sep=""),
- plot=rainbow.fig,
- width=46,
- height=16,
- dpi=300,
- create.dir=T,
- units="cm")
- showtext_opts(op)
- ```
- ```{r custom_indivi_pc_plots, fig.width=6, fig.height=2, echo=F}
- indiv_pc_plots <- list()
- showtext_opts(dpi = 300)
- for (pc in 1:ncomp) {
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 4,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading",
- subtitle = titles[[paste("PC", pc, sep="")]]) +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none",
- plot.title=element_text(hjust=-0.1),
- plot.subtitle=element_text(size=12))
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(across(trial_outcome,
- factor,
- levels=c("Hit", "Miss", "CR", "FA"))) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "", y = "PC score") +
- theme(axis.title.x=element_blank(),
- axis.text.x=element_blank(),
- axis.ticks.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- # exclude any subjects with # trials < # bins
- mutate(trial_count = n()) %>%
- ungroup() %>%
- dplyr::filter(trial_count > nbins-1) %>%
- group_by(subjectId, component, association_strength, trial_outcome) %>%
- mutate(component_score_bin = cut_interval(component_score,
- n = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, component_score_bin) %>%
- summarize(rt = median(match_response.rt)) %>%
- summarySEwithin(.,
- measurevar="rt",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "component_score_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = as.numeric(as.character(component_score_bin)),
- y = rt,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=rt-se, ymax=rt+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "PC score quartile", y = "RT (s)") +
- guides(color = "none")
- joint.fig <- (fig1 + fig2 + fig3) +
- plot_layout(widths=c(1,1,1),
- guides="collect", axes = "collect", axis_titles = "collect") &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- plot.title=element_text(hjust=0.5)
- )
- indiv_pc_plots[[paste("PC", pc, sep="")]] <- fig1 + fig2 + fig3
- # ggsave(paste("tPCA_figures_correct_only/PC", pc, "_scores_and_RT.pdf", sep=""),
- # plot=joint.fig,
- # width=22,
- # height=7,
- # dpi=300,
- # units="cm")
- }
- plot.full <- (indiv_pc_plots[["PC2"]] /
- indiv_pc_plots[["PC5"]] /
- indiv_pc_plots[["PC1"]] /
- indiv_pc_plots[["PC6"]] /
- indiv_pc_plots[["PC3"]] /
- indiv_pc_plots[["PC4"]]) +
- plot_layout(guides="collect",
- tag_level = 'new') +
- plot_annotation(tag_levels = list(c("A", "", "",
- "B", "", "",
- "C", "", "",
- "D", "", "",
- "E", "", "",
- "F", "", ""))) &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- plot.margin = margin(0, 0, 0, 5),
- plot.title.position = "plot",
- plot.subtitle=element_text(hjust=0, margin=margin(t=5)),
- plot.tag = element_text(face="bold", margin=margin(t=0)),
- axis.title.y = element_text(margin = margin(r=0)),
- axis.text.y = element_text(margin = margin(l=3, r=3)))
- ggsave(paste("tPCA_figures_correct_only/full_PC_plot.pdf", sep=""),
- plot=plot.full,
- width=9,
- height=16,
- dpi=300,
- create.dir=T,
- units="in")
- showtext_opts(op)
- ```
- ## Individual PC plots: score by RT
- ```{r rainbow_indivi_pc_plots_yx, fig.width=2, fig.height=6, echo=F}
- showtext_opts(dpi = 300)
- full.rainbow.fig <- list()
- for (pc in 1:ncomp) {
- ordered.rainbow <- c("#FFCC00", "#E82C42", "#59169C", "#1E8DD2", "#F46D43", "#29A343")
- pc.color <- ordered.rainbow[[pc]]
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color=pc.color, linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading") +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none")
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(across(trial_outcome,
- factor,
- levels=c("Hit", "Miss", "CR", "FA"))) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "Memory outcome", y = "PC score") +
- theme(axis.text.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(rt = round(match_response.rt, 1)) %>%
- group_by(association_strength) %>%
- mutate(rt_bin = cut_interval(rt,
- n = nbins)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, rt_bin) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "rt_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = rt_bin,
- y = component_score,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(y = "PC score", x = "RT bin") +
- guides(color = "none") +
- theme(axis.text.x = element_text(angle = 45, hjust = 1))
- full.rainbow.fig[[pc]] <- fig1 / fig2 / fig3
- }
- rainbow.fig <- (full.rainbow.fig[[2]] |
- full.rainbow.fig[[5]] |
- full.rainbow.fig[[1]] |
- full.rainbow.fig[[6]] |
- full.rainbow.fig[[3]] |
- full.rainbow.fig[[4]]) +
- plot_layout(
- guides = "collect", axes = "collect", axis_titles = "collect") &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- legend.position = "left"
- )
- ggsave(paste("tPCA_figures_correct_only/rainbow_all_PC_scores_and_RT_yx.pdf", sep=""),
- plot=rainbow.fig,
- width=40,
- height=18,
- dpi=300,
- create.dir=T,
- units="cm")
- showtext_opts(op)
- ```
- ```{r rainbow_with_titles_indivi_pc_plots_yx, fig.width=2, fig.height=6, echo=F}
- showtext_opts(dpi = 300)
- titles <- list("PC1"="'Memory reinstatement strength'",
- "PC2"="'Preparatory attention'",
- "PC3"="'Prediction error x strength'",
- "PC4"="'Orienting response to errors'",
- "PC5"="'Cognitive effort'",
- "PC6"="'Mismatch detection'")
- full.rainbow.fig <- list()
- for (pc in 1:ncomp) {
- ordered.rainbow <- c("#FFCC00", "#E82C42", "#59169C", "#1E8DD2", "#F46D43", "#29A343")
- pc.color <- ordered.rainbow[[pc]]
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color=pc.color, linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 3,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading",
- title = titles[[pc]]) +
- theme(legend.position = "none",
- plot.title=element_text(hjust=0),
- plot.subtitle=element_text(size=12))
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(across(trial_outcome,
- factor,
- levels=c("Hit", "Miss", "CR", "FA"))) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "Memory outcome", y = "PC score") +
- theme(axis.text.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(rt = round(match_response.rt, 1)) %>%
- group_by(association_strength) %>%
- mutate(rt_bin = cut_interval(rt,
- n = nbins)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, rt_bin) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "rt_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = rt_bin,
- y = component_score,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(y = "PC score", x = "RT bin") +
- guides(color = "none") +
- theme(axis.text.x = element_text(angle = 45, hjust = 1))
- full.rainbow.fig[[pc]] <- fig1 / fig2 / fig3
- }
- rainbow.fig <- (full.rainbow.fig[[2]] |
- full.rainbow.fig[[5]] |
- full.rainbow.fig[[1]] |
- full.rainbow.fig[[6]] |
- full.rainbow.fig[[3]] |
- full.rainbow.fig[[4]]) +
- plot_layout(guides="collect",
- tag_level = 'new') +
- plot_annotation(tag_levels = list(c("A", "", "",
- "B", "", "",
- "C", "", "",
- "D", "", "",
- "E", "", "",
- "F", "", ""))) &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- plot.margin = margin(0, 10, 0, 10),
- plot.title.position = "plot",
- plot.subtitle=element_text(hjust=0, margin=margin(t=5)),
- plot.tag = element_text(face="bold", margin=margin(t=5, b=5)),
- axis.title.y = element_text(margin = margin(r=0)),
- axis.text.y = element_text(margin = margin(l=3, r=3)))
- ggsave(paste("tPCA_figures_correct_only/rainbow_all_PC_scores_and_RT_titled_yx.pdf", sep=""),
- plot=rainbow.fig,
- width=46,
- height=16,
- dpi=300,
- create.dir=T,
- units="cm")
- showtext_opts(op)
- ```
- ```{r custom_indivi_pc_plots_yx, fig.width=6, fig.height=2, echo=F}
- indiv_pc_plots <- list()
- showtext_opts(dpi = 300)
- for (pc in 1:ncomp) {
- fig1 <- pca.loadings %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(component = paste(component, ": ", round(percent_var_explained, 2),
- "%",
- sep = "")) %>%
- ggplot(aes(x = time,
- y = loading,
- color = component,
- fill = component)) +
- geom_vline(xintercept = c(0, 1, 2, 2.75),
- linetype = "dashed",
- color = "gray37") +
- geom_line(color="black", linewidth=1) +
- geom_text(aes(label = event,
- x = time,
- y = 0.75),
- data = ret_labels,
- inherit.aes = FALSE,
- angle = 90,
- hjust = 1,
- vjust = 1.2,
- size = 4,
- colour = "gray37",
- family = fontfamily) +
- facet_wrap(~component) +
- ylim(-0.25, 1) +
- labs(x = "Time (s)",
- y = "PC loading",
- subtitle = titles[[paste("PC", pc, sep="")]]) +
- scale_color_brewer(palette="Set2") +
- scale_fill_brewer(palette="Set2") +
- theme(legend.position = "none",
- plot.title=element_text(hjust=-0.1),
- plot.subtitle=element_text(size=12))
- fig2 <- subj.data.scores %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(across(trial_outcome,
- factor,
- levels=c("Hit", "Miss", "CR", "FA"))) %>%
- group_by(subjectId, association_strength, trial_outcome, component) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component"),
- idvar="subjectId") %>%
- ggplot(aes(x = exp_id,
- y = component_score,
- fill = trial_outcome)) +
- stat_summary(fun = "mean",
- geom = "bar",
- color = "black",
- position=position_dodge()) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- position=position_dodge(.9),
- width=.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(x = "", y = "PC score") +
- theme(axis.title.x=element_blank(),
- axis.text.x=element_blank(),
- axis.ticks.x=element_blank())
- fig3 <- rt_data %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(rt = round(match_response.rt, 1)) %>%
- group_by(association_strength) %>%
- mutate(rt_bin = cut_interval(rt,
- n = nbins)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, rt_bin) %>%
- summarize(component_score = mean(component_score)) %>%
- summarySEwithin(.,
- measurevar="component_score",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "rt_bin"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = rt_bin,
- y = component_score,
- color = trial_outcome,
- group = trial_outcome)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=component_score-se, ymax=component_score+se),
- width=0.2) +
- facet_grid(cols=vars(association_strength),
- rows=vars(component)) +
- scale_color_manual(values=c("#1a75ff", "#ff751a"), name="") +
- scale_fill_manual(values=c("#1a75ff", "#ff751a"), name="") +
- labs(y = "PC score", x = "RT bin") +
- guides(color = "none") +
- theme(axis.text.x = element_text(angle = 45, hjust = 1))
- joint.fig <- (fig1 + fig2 + fig3) +
- plot_layout(widths=c(1,1,1),
- guides="collect", axes = "collect", axis_titles = "collect") &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- plot.title=element_text(hjust=0.5)
- )
- indiv_pc_plots[[paste("PC", pc, sep="")]] <- fig1 + fig2 + fig3
- # ggsave(paste("tPCA_figures_correct_only/PC", pc, "_scores_and_RT.pdf", sep=""),
- # plot=joint.fig,
- # width=22,
- # height=7,
- # dpi=300,
- # units="cm")
- }
- plot.full <- (indiv_pc_plots[["PC2"]] /
- indiv_pc_plots[["PC5"]] /
- indiv_pc_plots[["PC1"]] /
- indiv_pc_plots[["PC6"]] /
- indiv_pc_plots[["PC3"]] /
- indiv_pc_plots[["PC4"]]) +
- plot_layout(guides="collect",
- tag_level = 'new') +
- plot_annotation(tag_levels = list(c("A", "", "",
- "B", "", "",
- "C", "", "",
- "D", "", "",
- "E", "", "",
- "F", "", ""))) &
- theme(strip.text.x = element_text(size=12),
- strip.text.y = element_blank(),
- strip.background = element_blank(),
- text = element_text(size = 10),
- plot.margin = margin(0, 0, 0, 5),
- plot.title.position = "plot",
- plot.subtitle=element_text(hjust=0, margin=margin(t=5)),
- plot.tag = element_text(face="bold", margin=margin(t=0)),
- axis.title.y = element_text(margin = margin(r=0)),
- axis.text.y = element_text(margin = margin(l=3, r=3)))
- ggsave(paste("tPCA_figures_correct_only/full_PC_plot_yx.pdf", sep=""),
- plot=plot.full,
- width=9,
- height=16,
- dpi=300,
- create.dir=T,
- units="in")
- showtext_opts(op)
- ```
- ## Subsequent memory - CR trials
- ```{r submem_hist, echo=F, eval=T}
- palette <- c("#59735e", "#b7c8ba")
- palette <- c("#008080", "#9fdfbf")
- subs.exclude <- c("MPE514", "MPE527") # insufficient number of trials
- subj.data.submem <- subj.data.scores %>%
- dplyr::filter(!subjectId %in% subs.exclude) %>%
- left_join(recognition_behavior,
- by = c("subjectId", "expId", "img"),
- suffix = c(".retrieval", ".recognition")) %>%
- dplyr::filter(!is.na(trial_outcome.recognition)) %>%
- dplyr::filter(trial_outcome.retrieval == "CR") %>%
- mutate(across(trial_outcome.recognition,
- factor,
- levels=c("Hit", "Miss"))) %>%
- mutate(trial_outcome.recognition = recode(trial_outcome.recognition,
- "Hit" = 1,
- "Miss" = 0)) %>%
- group_by(subjectId, component) %>%
- mutate(component_score = scale(component_score)) %>%
- ungroup() %>%
- mutate(expId = recode(expId,
- "imm" = "Experiment 1 (same day)",
- "del" = "Experiment 2 (48 hrs later)"))
- ```
- ### Models
- ```{r recog_models, echo=F, results="asis", eval=run_models}
- recog.glmer.models <- list()
- for (i in 1:ncomp) {
- mod.data <- subj.data.submem %>%
- dplyr::filter(component == paste("PC", i, sep=""))
- mod <- mod.data %>%
- glmer(trial_outcome.recognition ~ component_score * association_strength * expId +
- (component_score * association_strength | subjectId),
- data = .)
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- glmer(trial_outcome.recognition ~ component_score * association_strength * expId +
- (component_score + association_strength | subjectId),
- family = "binomial",
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- glmer(trial_outcome.recognition ~ component_score * association_strength * expId +
- (component_score | subjectId),
- family = "binomial",
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- mod.data %>%
- glmer(trial_outcome.recognition ~ component_score * association_strength * expId +
- (1 | subjectId),
- family = "binomial",
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- print("MODEL DID NOT CONVERGE")
- }
- recog.glmer.models[[i]] <- mod
- }
- ```
- ```{r show_recog_mods, echo=F, results="asis", fig.height=3, fig.width=6}
- for (i in 1:ncomp) {
- mod <- recog.glmer.models[[i]]
- tidy(mod, effects = "fixed", conf.int = T, conf.level = 0.95, exponentiate=T) %>%
- # select(term, estimate, conf.low, conf.high, p.value, std.error, df) %>%
- kable(caption=paste("PC", i, ": ", formula(mod)[3], sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- tidy(mod, effects = "ran_pars", scales = "vcov") %>%
- select(term, estimate) %>%
- kable(digits=3, caption="Random effects") %>%
- kable_styling() %>%
- cat()
- if (i == 1) {
- slopes <- emtrends(mod, pairwise ~ association_strength * expId, var = "component_score")
- print(slopes)
- title <- formula(mod)[3]
- tidy(slopes$emtrends, conf.int = T, conf.level = 0.95) %>%
- kable(caption=paste("slopes: remember ~ ", title, sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- tidy(slopes$contrasts, conf.int = T, conf.level = 0.95) %>%
- select(contrast, estimate, std.error, df, conf.low, conf.high, statistic, adj.p.value) %>%
- kable(caption=paste("slope contrasts: remember ~ ", title, sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- }
- plt <- mod %>%
- plot_model(type="pred",
- terms=c("component_score[all]",
- "association_strength[Strong (4x), Weak (1x)]",
- "expId"),
- show.data=F) +
- scale_color_manual(values=palette, name="") +
- scale_fill_manual(values=palette, name="") +
- scale_y_continuous(limits = c(0, 1)) +
- labs(y = "P(remember probe)",
- x = paste("PC", i, " score (z)", sep=""),
- title = paste("PC", i, sep="")) +
- theme(plot.subtitle = element_text(size = 12))
- print(plt)
- nbins <- 4
- submem.summary <- subj.data.submem %>%
- dplyr::filter(component == paste("PC", i, sep="")) %>%
- group_by(subjectId, association_strength, expId) %>%
- mutate(component_score_bin = cut(component_score,
- breaks = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, component_score_bin, association_strength, expId) %>%
- summarize(component_score = mean(component_score),
- prob.remember = mean(trial_outcome.recognition)) %>%
- ungroup() %>%
- group_by(component_score_bin, association_strength, expId) %>%
- mutate(component_score_mean = mean(component_score)) %>%
- ungroup() %>%
- mutate(component_score_mean = as.numeric(component_score_mean)) %>%
- summarySEwithin(.,
- measurevar="prob.remember",
- withinvars=c("association_strength",
- "component_score_mean"),
- betweenvars=c("expId"),
- idvar="subjectId") %>%
- mutate(component_score_mean = as.numeric(as.character(component_score_mean)))
- pred <- data.frame(ggpredict(mod, terms = c("component_score[all]",
- "association_strength[Strong (4x), Weak (1x)]",
- "expId"))) %>%
- rename(component_score_mean = x,
- association_strength = group,
- expId = facet)
- plt <- ggplot() +
- geom_ribbon(data = as.data.frame(pred),
- aes(x = component_score_mean,
- ymin = conf.low,
- ymax = conf.high,
- fill = association_strength),
- alpha = 0.2, color = NA) +
- geom_line(data = as.data.frame(pred),
- aes(x = component_score_mean,
- y = predicted,
- color = association_strength),
- linewidth = 1) +
- geom_point(data = submem.summary,
- aes(x = component_score_mean,
- y = prob.remember,
- color = association_strength),
- size = 1.5) +
- geom_errorbar(data = submem.summary,
- aes(x = component_score_mean,
- ymin = prob.remember - se,
- ymax = prob.remember + se,
- color = association_strength),
- width = 0.2) +
- facet_wrap(~ expId) +
- scale_color_manual(values = palette, name = "") +
- scale_fill_manual(values = palette, name = "") +
- scale_y_continuous(limits = c(0, 1)) +
- labs(y = "P(remember probe)",
- x = paste("PC", i, " score (z)", sep=""),
- title = paste("PC", i, sep = "")) +
- theme(strip.text.x = element_text(size=12))
- print(plt)
- showtext_opts(dpi = 300)
- ggsave(paste("submem_figures/submem_PC", i, ".pdf", sep=""),
- plot=plt,
- width=17,
- height=8,
- dpi=300,
- create.dir=T,
- units="cm")
- showtext_opts(op)
- # print(mod %>%
- # plot_model(type="pred",
- # pred.type = "re",
- # terms=c("component_score",
- # "subjectId",
- # "expId",
- # "association_strength"
- # ),
- # ci.lvl = NA,
- # show.data=F,
- # color = "gray",
- # line.size = 0.2) +
- # scale_y_continuous(limits = c(0, 1)) +
- # theme(legend.position = "none"))
- }
- ```
- ## Subsequent memory RT
- ```{r rt_data_submem, echo=F}
- ### joint plot
- rt_data.submem <- subj.data.submem %>%
- dplyr::filter(trial_outcome.recognition == 1) %>%
- mutate(across(association_strength,
- factor,
- levels=c("Strong (4x)", "Weak (1x)")))
- ```
- ```{r submem_rt_joint_plot, echo=F, fig.width=10, fig.height=8, results="asis", eval=run_models}
- models.recog.rt <- list()
- for (pc in 1:ncomp) {
- mod <- rt_data.submem %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(recognition_response.rt = log(recognition_response.rt)) %>%
- lmer(recognition_response.rt ~ component_score * association_strength * expId +
- (component_score * association_strength * expId | subjectId),
- data = .)
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data.submem %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(recognition_response.rt = log(recognition_response.rt)) %>%
- lmer(recognition_response.rt ~ component_score * association_strength * expId +
- (component_score + association_strength + expId | subjectId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data.submem %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(recognition_response.rt = log(recognition_response.rt)) %>%
- lmer(recognition_response.rt ~ component_score * association_strength * expId +
- (component_score | subjectId),
- data = .)
- }
- if (isSingular(mod) | any(grepl("failed to converge", mod@optinfo$conv$lme4$messages))) {
- mod <- rt_data.submem %>%
- dplyr::filter(component == paste("PC", pc, sep="")) %>%
- mutate(recognition_response.rt = log(recognition_response.rt)) %>%
- lmer(recognition_response.rt ~ component_score * association_strength * expId +
- (1 | subjectId),
- data = .)
- }
- models.recog.rt[[pc]] <- mod
- }
- ```
- ```{r submem.binned.rt, echo=F, fig.width=7, fig.height=10, eval=T}
- nbins <- 4
- rt.binned.plt <- rt_data.submem %>%
- mutate(trial_outcome = trial_outcome.recognition) %>%
- mutate(across(association_strength,
- factor,
- levels=c("Strong (4x)", "Weak (1x)"))) %>%
- group_by(subjectId, component, association_strength, trial_outcome, expId) %>%
- mutate(trial_count = n()) %>%
- ungroup() %>%
- dplyr::filter(trial_count > nbins-1) %>%
- group_by(subjectId, component, association_strength, trial_outcome, expId) %>%
- mutate(component_score_bin = cut_interval(component_score,
- n = nbins,
- labels = F)) %>%
- ungroup() %>%
- group_by(subjectId, trial_outcome, association_strength,
- component, component_score_bin, expId) %>%
- summarize(rt = median(recognition_response.rt)) %>%
- summarySEwithin(.,
- measurevar="rt",
- withinvars=c("association_strength",
- "trial_outcome",
- "component",
- "component_score_bin"),
- betweenvars=c("expId"),
- idvar="subjectId") %>%
- mutate(across(component,
- factor,
- levels=ordered_pcs)) %>%
- ggplot(aes(x = as.numeric(as.character(component_score_bin)),
- y = rt,
- color = association_strength,
- group = association_strength)) +
- geom_line(linewidth=0.8) +
- geom_point(size=1.5) +
- geom_errorbar(aes(ymin=rt-se, ymax=rt+se),
- width=0.2) +
- facet_grid(rows=vars(component),
- axes="all",
- scales = "free") +
- scale_color_manual(values=palette, name="") +
- scale_fill_manual(values=palette, name="") +
- labs(x = "PC score", y = "RT (s)") +
- theme(strip.text.y = element_blank()) +
- facet_grid(rows = vars(component),
- cols = vars(expId))
- loadings.vrt.plt + rt.binned.plt +
- plot_layout(widths=c(1,1.5))
- ```
- ### Models
- ```{r print_submem_rt_models, echo=F, results="asis", eval=T}
- for (pc in 1:ncomp) {
- tidy(models.recog.rt[[pc]], effects = "fixed", conf.int = T, conf.level = 0.95) %>%
- select(term, estimate, conf.low, conf.high, p.value, std.error, df) %>%
- kable(caption=paste("PC", pc, ": ", formula(mod)[3], sep=""),
- digits=3) %>%
- kable_styling() %>%
- cat()
- tidy(models.recog.rt[[pc]], effects = "ran_pars", scales = "vcov") %>%
- select(term, estimate) %>%
- kable(digits=3, caption="Random effects") %>%
- kable_styling() %>%
- cat()
- }
- ```
- ## Save
- ```{r save_models, echo=F, eval=run_models}
- save(models,
- models.compact.no.mismatch,
- models.rt,
- recog.glmer.models,
- models.recog.rt,
- file="tpca_models_correct_only.RData")
- ```
pupil_temporal_pca.Rmd at commit d144397, under GPL-3.0 · at the source
Overview
- Department of Psychology, Stanford University Stanford United States
- Wu Tsai Neurosciences Institute, Stanford University Stanford United States
Abstract
Ongoing experience is continuously processed in the context of past events. Divergence between current experience and memory-based predictions (i.e., a mnemonic prediction error; MPE) is theorized to be a signal that encoding, as opposed to retrieval, should be prioritized. We asked how MPEs place demands on control and attention-related processes, and whether these demands differ as a function of prediction strength. We investigated these questions across two experiments, wherein we recorded scalp electroencephalography and/
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 3 matches between paragraphs and lines of code.
alicexue/mpe-attention-cog-ctrl
d1443971f1b402b0abcfa740f67bedc99daf88db, 20 October 2026Availability: 1 check, the latest on 25 October 2026: the link answers
- 25 October 2026: the link answers
22 files
- scripts/
behavior/ , R, 864 linesbehavioral_analysis.Rmd - scripts/
eeg/ , R, 213 linescompile_eeg_and_pupil_be tas.R - scripts/
eeg/ , R, 75 linesgenerate_power_reports.R - scripts/
eeg/ , R, 597 linesmediation_models_brms.Rm d - scripts/
eeg/ , R, 991 linespower_and_pupil_cross_co rr.Rmd - scripts/
eeg/ , R, 3,646 linesspectral_analyses_and_pu pil.Rmd - scripts/
eeg/ , R, 1,236 linesspectral_analyses_and_su b_mem.Rmd - scripts/
eeg/ , R, 1,917 linesspectral_analyses_includ e_incorrect.Rmd - scripts/
eeg/ , R, 1,155 linesspectral_timeseries.Rmd - scripts/
eeg/ , R, 1,350 linestheta_alpha_corr.Rmd - scripts/
pupil/ , R, 148 linescompare_experiment_tPCA_ loadings.Rmd - scripts/
pupil/ , R, 45 linesgenerate_pupil_reports.R - scripts/
pupil/ , R, 2,008 linespupil_retrieval_timeseri es.Rmd - scripts/
pupil/ , R, 1,896 linespupil_retrieval_timeseri es_by_experiment.Rmd - scripts/
pupil/ , R, 1,190 linespupil_retrieval_timeseri es_include_incorrect.Rmd - scripts/
pupil/ , R, 2,507 lines, 2 matchespupil_temporal_pca.Rmd - scripts/
pupil/ , R, 1,115 linespupil_temporal_pca_boots trap.Rmd - scripts/
pupil/ , R, 2,370 lines, 1 matchpupil_temporal_pca_inclu de_incorrect.Rmd - scripts/
pupil/ , R, 612 linespupil_tpca_next_trial_ef fects.Rmd - scripts/
utils/ , R, 136 linessummary_se_utils.R - LICENSE, License, 674 lines
- README.md, Text, 3 lines
The paper's code and data availability statement is in the Data section.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 20 scripts, each with its path and the digest of its content;
- 3 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability
Data and code for this manuscript are accessible at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 25 October 2026: the first record
Recorded: type, language, journal, volume, pages, dates, 4 authors, 7 keywords, 12 MeSH terms, 3 funders, 94 references.
Cite
This paper
Xue, A. M., Jokhani, J., Norcia, A. M., & Wagner, A. D. (2026). Strong mnemonic prediction errors increase cognitive control, attention, and arousal. eLife, 15, RP109678. https://
BibTeX
@article{xue2026strong,
author = {Xue, Alice M and Jokhani, Jenna and Norcia, Anthony M and Wagner, Anthony D},
title = {{Strong mnemonic prediction errors increase cognitive control, attention, and arousal}},
journal = {eLife},
year = {2026},
month = oct,
volume = {15},
pages = {RP109678},
publisher = {eLife Sciences Publications, Ltd},
issn = {2050-084X},
doi = {10.7554/
url = {https://
pmid = {42905440},
pmcid = {PMC13686618}
}
RIS
TY - JOUR
AU - Xue, Alice M
AU - Jokhani, Jenna
AU - Norcia, Anthony M
AU - Wagner, Anthony D
TI - Strong mnemonic prediction errors increase cognitive control, attention, and arousal
T2 - eLife
J2 - eLife
PY - 2026
DA - 2026/
VL - 15
SP - RP109678
SN - 2050-084X
PB - eLife Sciences Publications, Ltd
DO - 10.7554/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.7554/
"type": "article-journal",
"title": "Strong mnemonic prediction errors increase cognitive control, attention, and arousal",
"container-title": "eLife",
"author": [
{
"family": "Xue",
"given": "Alice M"
},
{
"family": "Jokhani",
"given": "Jenna"
},
{
"family": "Norcia",
"given": "Anthony M"
},
{
"family": "Wagner",
"given": "Anthony D"
}
],
"container-title-short":
"volume": "15",
"page": "RP109678",
"DOI": "10.7554/
"PMID": "42905440",
"PMCID": "PMC13686618",
"ISSN": "2050-084X",
"publisher": "eLife Sciences Publications, Ltd",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
10,
21
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1186/s13229-025-00678-w [code]
- Locus coeruleus tonic upregulation increases selectivity to inconspicuous auditory information in autistic compared to non-autistic individuals: a combined pupillometry and electroencephalography study.Journal: Molecular autismIn common: brms, easystats, psych, 5 other tools, EEG, cognitive, 6 references
- [2] doi:10.1371/journal.pone.0355165 [code]
- Pupillary dynamics during hands-off L2 driving and transitions of control under high cognitive load.Journal: PloS oneIn common: brms, mgcv, easystats, 6 other tools, cognitive, 4 references
- [3] doi:10.1073/pnas.2503535122 [code]
- Hippocampal mismatch signals are based on episodic memories and not schematic knowledge.Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: cognitive, 11 references
- [4] doi:10.3758/s13423-022-02124-x [code]
- Explicitly predicting outcomes enhances learning of expectancy-violating information.Journal: Psychonomic bulletin & reviewIn common: afex, easystats, psych, 6 other tools, cognitive, 3 references
- [5] doi:10.1186/s11689-025-09651-3 [code]
- The association between infant EEG aperiodic exponent and the trajectory of restricted and repetitive behaviors for toddlers with and without autism.Journal: Journal of neurodevelopmental disordersIn common: brms, afex, mgcv, 8 other tools, EEG
- [6] doi:10.1162/imag_a_00312 [code]
- Alpha-band fluctuations represent behaviorally relevant excitability changes as a consequence of top-down guided spatial attention in a probabilistic spatial cueing design.Journal: Imaging neuroscience (Cambridge, Mass.)In common: brms, afex, broom, 6 other tools, EEG, cognitive, 2 references
- [7] doi:10.1038/s41593-024-01672-w [code]
- Cognitive control training with domain-general response inhibition does not change children's brains or behavior.Journal: Nature neuroscienceIn common: brms, afex, broom, 8 other tools, cognitive
- [8] doi:10.1038/s41398-026-03948-0 [code]
- Locus coeruleus modulation of neurophysiological sensory selectivity differs in autism and other mental health conditions.Journal: Translational psychiatryIn common: easystats, psych, emmeans, 5 other tools, EEG, 4 references
- [9] doi:10.1016/j.neuroimage.2026.122115 [code]
- Midfrontal theta power relates to response speeding following frustrative nonreward.Journal: NeuroImageIn common: easystats, psych, emmeans, 5 other tools, EEG, cognitive, 4 references
- [10] doi:10.1038/s41467-022-31040-w [code]
- Hippocampal representations switch from errors to predictions during acquisition of predictive associations.Journal: Nature communicationsIn common: cognitive, 10 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 20 scripts, and 3 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:208c65270f4a095b…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.7554/elife.109678)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.7554/elife.109678.svg
:target: https://openscicode.org/badge/doi/10.7554/elife.109678
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.7554/elife.109678"><img src="https://openscicode.org/badge/doi/10.7554/elife.109678.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
