OSCR

Bilingualism modulates functional connectivity induced by a domain-general artificial grammar learning task.

Code ↔ Paper

3 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 3 matches
  1. [1] § Method › Statistical analysis ↔ Analysis/EEG/BIFUNC Supplementary Model Comparisons.Rmd, lines 166–181 · score 0.96 · approximate Likelihood Ratio, Akaike Information Criterion, Chi Square, anova.gam, adding handedness, better fit
  2. [2] § Results › Post-task ↔ Analysis/EEG/BIFUNC Pre- & Post-task Statistical Analysis.Rmd, lines 478–496 · score 0.57 · medial frontal, medial occipital, right parietal, post task, pre task, smooths
  3. [3] § Results › Post-task ↔ Analysis/EEG/BIFUNC Pre- & Post-task Statistical Analysis.Rmd, lines 794–836 · score 0.53 · right parietal, LSBQ composite score, post task, pre task, smooth, connection

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R Markdown · 840 lines · 23 KB · no license · 2 matches

  1. ---
  2. title: "BIFUNC Pre- & Post-task Statistical Analysis"
  3. author: "Alex Sheehan"
  4. date: "2025-09-16"
  5. output:
  6. html_document:
  7. theme: flatly
  8. highlight: tango
  9. toc: TRUE
  10. toc_float:
  11. collapsed: false
  12. smooth_scroll: true
  13. toc_depth: 3
  14. ---
  15. # Set-up
  16. ```{r setup, include=FALSE}
  17. knitr::opts_chunk$set(echo = TRUE,
  18. message = FALSE,
  19. warning = FALSE,
  20. dev = 'png')
  21. options(scipen=999)
  22. ```
  23. ## Load packages
  24. ```{r message=FALSE, warning=FALSE}
  25. library(readxl)
  26. library(mgcv)
  27. library(ggplot2)
  28. library(reshape2)
  29. library(tidyverse)
  30. library(tidygam)
  31. library(gratia)
  32. library(dplyr)
  33. ```
  34. ## Load data
  35. After the first time you run this markdown, this chunk should then find 'Data/projectdata_long.RData' and pre-load it
  36. ```{r}
  37. if (file.exists("Data/projectdata_long.RData")) {
  38. load("Data/projectdata_long.RData")
  39. print("Loaded 'projectdata_long'. Skip straight to 'Functions' section.")
  40. } else {
  41. print("Could not find 'projectdata_long' RData file. Importing original data sheet for wrangling...")
  42. data <- read_excel("Data/BIFUNC_data_GC_matrices.xlsx")
  43. maindata <- data.frame(data)
  44. }
  45. ```
  46. ## Set up data
  47. ```{r message=FALSE}
  48. # "postfib" = Domain-general
  49. # "postflan" = Attentional domain
  50. # "postmulti" = Language domain
  51. if (exists("projectdata_long")) {
  52. print("'projectdata_long' already loaded. Skip straight to 'Functions' section")
  53. } else {
  54. # Check column names
  55. names(maindata)
  56. }
  57. ```
  58. ### Set variable types
  59. ```{r collapse=TRUE}
  60. if (exists("projectdata_long")) {
  61. print("'projectdata_long' already loaded. Skip straight to 'Functions' section")
  62. } else {
  63. # Gender - nominal factor - 2 levels
  64. maindata$gender_quant <- factor(maindata$gender_quant,
  65. levels = c("1", "2"),
  66. labels = c("Female", "Male"))
  67. contrasts(maindata$gender_quant) <- "contr.treatment"
  68. # Subject Education level - ordinal factor - 5 levels
  69. maindata$education_subj_quant <- factor(maindata$education_subj_quant,
  70. levels = c("3", "4", "5"),
  71. labels = c("A-Level",
  72. "Degree/Diploma",
  73. "Postgraduate"),
  74. ordered = TRUE)
  75. contrasts(maindata$education_subj_quant) <- "contr.sum"
  76. # Subjid - factor - random effect
  77. maindata$subjid <- as.factor(maindata$subjid)
  78. }
  79. ```
  80. ### Convert to long format
  81. ```{r}
  82. if (exists("projectdata_long")) {
  83. print("'projectdata_long' has already been made & saved. Skip straight to 'Functions' section")
  84. } else {
  85. projectdata_long <- maindata
  86. projectdata_long <- maindata %>%
  87. pivot_longer(
  88. cols = matches("^(pretask|postfib|postflan|postmulti)_"),
  89. names_to = c("condition", "region"),
  90. names_pattern = "([^_]+)_(.*)",
  91. values_to = "connectivity"
  92. )
  93. # Set region to factor
  94. projectdata_long$region <- as.factor(projectdata_long$region)
  95. # Remove LSBQ_comp outlier
  96. projectdata_long <- subset(projectdata_long, subjid != "30")
  97. # Save for quick loading in future
  98. save(projectdata_long, file = "Data/projectdata_long.RData")
  99. }
  100. ```
  101. ## Functions
  102. Make sure to run all 3 of these to avoid errors later in the markdown
  103. ### MC correction function
  104. ```{r}
  105. extract_pre_post_pvals <- function(model, model_id = "model1") {
  106. smry <- summary(model)
  107. if (!is.null(smry$s.table) && "p-value" %in% colnames(smry$s.table)) {
  108. df <- data.frame(
  109. model_id = model_id,
  110. term = rownames(smry$s.table),
  111. p_value = smry$s.table[, "p-value"]
  112. )
  113. rownames(df) <- NULL
  114. df <- df %>%
  115. filter(grepl("^s\\(lsbq_comp):region", term)) %>%
  116. mutate(
  117. region = sub("^s\\(lsbq_comp):region", "", term),
  118. p_adj_fdr = p.adjust(p_value, method = "fdr"),
  119. sig_raw = ifelse(p_value < 0.05, "SIG", "-"),
  120. sig_fdr = ifelse(p_adj_fdr < 0.05, "SIG", "-")
  121. )
  122. return(df)
  123. } else {
  124. return(data.frame(
  125. model_id = character(0),
  126. term = character(0),
  127. p_value = numeric(0),
  128. region = character(0),
  129. p_adj_fdr = numeric(0),
  130. sig_raw = character(0),
  131. sig_fdr = character(0)
  132. ))
  133. }
  134. }
  135. ```
  136. ### Pre-task plots function
  137. ```{r}
  138. generate_pretask_plots <- function(model, term_list, color = "green4") {
  139. plot_list <- list()
  140. for (term in term_list) {
  141. region_label <- gsub("s\\(lsbq_comp):region", "", term)
  142. title_text <- gsub("_", " ", region_label)
  143. title_text <- tools::toTitleCase(title_text)
  144. plot_obj <- draw(model, select = term) +
  145. labs(
  146. title = paste("Pre-task", title_text, "Connectivity"),
  147. y = "Connectivity",
  148. x = "LSBQ Composite Score"
  149. ) +
  150. geom_line(color = color)
  151. plot_obj$layers[[1]]$aes_params$fill <- color
  152. plot_list[[region_label]] <- plot_obj
  153. print(plot_obj)
  154. }
  155. return(plot_list)
  156. }
  157. ```
  158. ### Post-task plots function
  159. ```{r}
  160. generate_posttask_plots <- function(model, term_list, color = "orange2") {
  161. plot_list <- list()
  162. for (term in term_list) {
  163. region_label <- gsub("s\\(lsbq_comp):region", "", term)
  164. title_text <- gsub("_", " ", region_label)
  165. title_text <- tools::toTitleCase(title_text)
  166. plot_obj <- draw(model, select = term) +
  167. labs(
  168. title = paste("Post-task", title_text, "Connectivity"),
  169. y = "Connectivity",
  170. x = "LSBQ Composite Score"
  171. ) +
  172. geom_line(color = color)
  173. plot_obj$layers[[1]]$aes_params$fill <- color
  174. plot_list[[region_label]] <- plot_obj
  175. print(plot_obj)
  176. }
  177. return(plot_list)
  178. }
  179. ```
  180. ### Save GAM checks function
  181. ```{r}
  182. save_gam_check <- function(model, name) {
  183. subfolder <- if (grepl("pretask", name, ignore.case = TRUE)) {
  184. "Checks/gam.check/Pretask"
  185. } else {
  186. "Checks/gam.check/Posttask"
  187. }
  188. dir.create(subfolder, recursive = TRUE, showWarnings = FALSE)
  189. txt <- capture.output(gam.check(model, k.rep = 1000))
  190. writeLines(txt, file.path(subfolder, paste0(name, "_gam.check.txt")))
  191. pdf(file.path(subfolder, paste0(name, "_gam.check.pdf")),
  192. width = 8.27, height = 11.69)
  193. lines_per_page <- 70
  194. total_lines <- length(txt)
  195. pages <- ceiling(total_lines / lines_per_page)
  196. for (i in seq_len(pages)) {
  197. start_line <- (i - 1) * lines_per_page + 1
  198. end_line <- min(i * lines_per_page, total_lines)
  199. plot.new()
  200. text(0, 1, paste(txt[start_line:end_line], collapse = "\n"),
  201. adj = c(0, 1), family = "mono", cex = 0.6)
  202. }
  203. gam.check(model, k.rep = 1000)
  204. dev.off()
  205. }
  206. ```
  207. # Models
  208. ## Load Pre-fitted
  209. After running this markdown for the first time, the chunk below should then find the listed models & summaries
  210. This avoids having to re-fit everything each time the markdown is loaded
  211. ```{r}
  212. gam_files <- c(
  213. "Models/lsbq_pretask.RData",
  214. "Models/lsbq_posttask.RData",
  215. "Summaries/lsbq_pretask_summ.RData",
  216. "Summaries/lsbq_posttask_summ.RData"
  217. )
  218. for (f in gam_files) {
  219. if (file.exists(f)) {
  220. load(f)
  221. print(paste("Loaded:", f))
  222. } else {
  223. print(paste("No previously-fitted GAM or summary found at", f))
  224. }
  225. }
  226. # Clean up env
  227. rm(f)
  228. rm(gam_files)
  229. ```
  230. ## Fitting
  231. ### Pre-task
  232. #### Construct & FDR correct
  233. ```{r}
  234. if (!exists("lsbq_pretask")) {
  235. lsbq_pretask <- bam(connectivity ~
  236. s(lsbq_comp, by = region, k = 15, sp = 0.02) + # k = 15 means k-value (no. of basis functions) = 14
  237. region +
  238. s(taskorder, bs = "re") +
  239. s(subjid, bs = "re") +
  240. age + lang2_aoa + education_subj_quant + gender_quant,
  241. data = projectdata_long %>%
  242. filter(condition == "pretask"),
  243. method = "fREML", discrete = TRUE, nthreads = 21)
  244. save(lsbq_pretask, file = "Models/lsbq_pretask.RData")
  245. lsbq_pretask_summ <- summary(lsbq_pretask)
  246. save(lsbq_pretask_summ, file = "Summaries/lsbq_pretask_summ.RData")
  247. print(lsbq_pretask_summ)
  248. pretask_pvals <- extract_pre_post_pvals(lsbq_pretask, model_id = "lsbq_pretask")
  249. write.csv(
  250. pretask_pvals,
  251. file = "MC_corrections/lsbq_pretask_pvals_fdr.csv",
  252. row.names = FALSE
  253. )
  254. } else {
  255. print("lsbq_pretask model already exists in environment; skipping re-fit & printing summary...")
  256. if (exists("lsbq_pretask_summ")) {
  257. print(lsbq_pretask_summ)
  258. pretask_pvals <- extract_pre_post_pvals(lsbq_pretask, model_id = "lsbq_pretask")
  259. } else {
  260. print("lsbq_pretask_summ object not found, saving for later retrieval & printing summary...")
  261. lsbq_pretask_summ <- summary(lsbq_pretask)
  262. save(lsbq_pretask_summ, file = "Summaries/lsbq_pretask_summ.RData")
  263. print(lsbq_pretask_summ)
  264. pretask_pvals <- extract_pre_post_pvals(lsbq_pretask, model_id = "lsbq_pretask")
  265. if (file.exists("MC_corrections/lsbq_pretask_pvals_fdr.csv")) {
  266. print("Pre-task FDR-corrected CSV file already exists; skipping saving...")
  267. } else {
  268. write.csv(
  269. pretask_pvals,
  270. file = "MC_corrections/lsbq_pretask_pvals_fdr.csv",
  271. row.names = FALSE
  272. )
  273. }
  274. }
  275. }
  276. ```
  277. ##### Corrected p-values
  278. ```{r}
  279. print(pretask_pvals[, c("region", "p_adj_fdr", "sig_fdr")])
  280. ```
  281. #### Plot
  282. ```{r}
  283. # List significant terms post-FDR correction
  284. pretask_sig_mods <- list(
  285. "s(lsbq_comp):regionleft_central_right_central",
  286. "s(lsbq_comp):regionleft_central_right_parietal",
  287. "s(lsbq_comp):regionmedial_occipital_medial_frontal",
  288. "s(lsbq_comp):regionright_central_medial_occipital",
  289. "s(lsbq_comp):regionright_temporal_right_parietal"
  290. )
  291. # Plot preliminary visualisations
  292. pretask_plots <- generate_pretask_plots(lsbq_pretask, pretask_sig_mods)
  293. ```
  294. ### Post-task
  295. #### Construct & FDR correct
  296. ```{r}
  297. if (!exists("lsbq_posttask")) {
  298. lsbq_posttask <- bam(connectivity ~
  299. s(lsbq_comp, by = region, k = 15, sp = 0.02) + # k = 15 means k-value (no. of basis functions) = 14
  300. region +
  301. s(taskorder, bs = "re") +
  302. s(subjid, bs = "re") +
  303. age + lang2_aoa + education_subj_quant + gender_quant,
  304. data = projectdata_long %>%
  305. filter(condition == "postfib"),
  306. method = "fREML", discrete = TRUE, nthreads = 21)
  307. save(lsbq_posttask, file = "Models/lsbq_posttask.RData")
  308. lsbq_posttask_summ <- summary(lsbq_posttask)
  309. save(lsbq_posttask_summ, file = "Summaries/lsbq_posttask_summ.RData")
  310. print(lsbq_posttask_summ)
  311. posttask_pvals <- extract_pre_post_pvals(lsbq_posttask, model_id = "lsbq_posttask")
  312. write.csv(
  313. posttask_pvals,
  314. file = "MC_corrections/lsbq_posttask_pvals_fdr.csv",
  315. row.names = FALSE
  316. )
  317. } else {
  318. print("lsbq_posttask model already exists in environment; skipping re-fit & printing summary...")
  319. if (exists("lsbq_posttask_summ")) {
  320. print(lsbq_posttask_summ)
  321. posttask_pvals <- extract_pre_post_pvals(lsbq_posttask, model_id = "lsbq_posttask")
  322. } else {
  323. print("lsbq_posttask_summ object not found, saving for later retrieval & printing summary...")
  324. lsbq_posttask_summ <- summary(lsbq_posttask)
  325. save(lsbq_posttask_summ, file = "Summaries/lsbq_posttask_summ.RData")
  326. print(lsbq_posttask_summ)
  327. posttask_pvals <- extract_pre_post_pvals(lsbq_posttask, model_id = "lsbq_posttask")
  328. if (file.exists("MC_corrections/lsbq_posttask_pvals_fdr.csv")) {
  329. print("Post-task FDR-corrected CSV file already exists; skipping saving...")
  330. } else {
  331. write.csv(
  332. posttask_pvals,
  333. file = "MC_corrections/lsbq_posttask_pvals_fdr.csv",
  334. row.names = FALSE
  335. )
  336. }
  337. }
  338. }
  339. ```
  340. ##### Corrected p-values
  341. ```{r}
  342. print(posttask_pvals[, c("region", "p_adj_fdr", "sig_fdr")])
  343. ```
  344. #### Plot
  345. ```{r}
  346. # List significant terms post-FDR correction
  347. posttask_sig_mods <- list(
  348. "s(lsbq_comp):regionleft_central_left_temporal",
  349. "s(lsbq_comp):regionleft_central_medial_occipital",
  350. "s(lsbq_comp):regionleft_central_right_parietal",
  351. "s(lsbq_comp):regionleft_temporal_left_parietal",
  352. "s(lsbq_comp):regionmedial_frontal_left_central",
  353. "s(lsbq_comp):regionmedial_frontal_left_temporal",
  354. "s(lsbq_comp):regionmedial_frontal_medial_occipital"
  355. )
  356. # Plot preliminary visualisations
  357. posttask_plots <- generate_posttask_plots(lsbq_posttask, posttask_sig_mods)
  358. ```
  359. # Model Checks
  360. ## Pre-task
  361. ```{r}
  362. save_gam_check(lsbq_pretask, "lsbq_pretask")
  363. ```
  364. ## Post-task
  365. ```{r}
  366. save_gam_check(lsbq_posttask, "lsbq_posttask")
  367. ```
  368. # Individual plots
  369. Running the chunks below will overwrite any plots already generated & saved
  370. ## Pre-task
  371. ```{r}
  372. # Show index numbers of terms in model
  373. invisible(lapply(seq_along(lsbq_pretask$smooth), function(i) {
  374. cat(paste0("[", i, "] ", lsbq_pretask$smooth[[i]]$label, "\n"))
  375. }))
  376. # # Sig. terms & index numbers
  377. # s(lsbq_comp):regionleft_central_right_central - [5]
  378. # s(lsbq_comp):regionleft_central_right_parietal - [6]
  379. # s(lsbq_comp):regionmedial_occipital_medial_frontal - [32]
  380. # s(lsbq_comp):regionright_central_medial_occipital - [40]
  381. # s(lsbq_comp):regionright_temporal_right_parietal - [56]
  382. ```
  383. ### Left Central to Right Central
  384. ```{r}
  385. plt_lsbq_pretask_lefcen_rigcen <- draw(lsbq_pretask, select = 5) +
  386. labs(title = "Left Central to Right Central",
  387. subtitle = NULL) +
  388. ylab("Granger Causality") +
  389. xlab("LSBQ Composite Score") +
  390. geom_line(color = "green4")
  391. plt_lsbq_pretask_lefcen_rigcen$layers[[1]]$aes_params$fill <- "green4"
  392. print(plt_lsbq_pretask_lefcen_rigcen)
  393. ggsave(
  394. "Pre-task - Left Central to Right Central.svg",
  395. device = "svg",
  396. path = "Plots/SVG/Pretask")
  397. ggsave(
  398. "Pre-task - Left Central to Right Central.png",
  399. device = "png",
  400. path = "Plots/PNG/Pretask")
  401. ```
  402. ### Left Central to Right Parietal
  403. ```{r}
  404. plt_lsbq_pretask_lefcen_rigpar <- draw(lsbq_pretask, select = 6) +
  405. labs(title = "Left Central to Right Parietal",
  406. subtitle = NULL) +
  407. ylab("Granger Causality") +
  408. xlab("LSBQ Composite Score") +
  409. geom_line(color = "green4")
  410. plt_lsbq_pretask_lefcen_rigpar$layers[[1]]$aes_params$fill <- "green4"
  411. print(plt_lsbq_pretask_lefcen_rigpar)
  412. ggsave(
  413. "Pre-task - Left Central to Right Parietal.svg",
  414. device = "svg",
  415. path = "Plots/SVG/Pretask")
  416. ggsave(
  417. "Pre-task - Left Central to Right Parietal.png",
  418. device = "png",
  419. path = "Plots/PNG/Pretask")
  420. ```
  421. ### Medial Occipital to Medial Frontal
  422. ```{r}
  423. plt_lsbq_pretask_medocc_medfro <- draw(lsbq_pretask, select = 32) +
  424. labs(title = "Medial Occipital to Medial Frontal",
  425. subtitle = NULL) +
  426. ylab("Granger Causality") +
  427. xlab("LSBQ Composite Score") +
  428. geom_line(color = "green4")
  429. plt_lsbq_pretask_medocc_medfro$layers[[1]]$aes_params$fill <- "green4"
  430. print(plt_lsbq_pretask_medocc_medfro)
  431. ggsave(
  432. "Pre-task - Medial Occipital to Medial Frontal.svg",
  433. device = "svg",
  434. path = "Plots/SVG/Pretask")
  435. ggsave(
  436. "Pre-task - Medial Occipital to Medial Frontal.png",
  437. device = "png",
  438. path = "Plots/PNG/Pretask")
  439. ```
  440. ### Right Central to Medial Occipital
  441. ```{r}
  442. plt_lsbq_pretask_rigcen_medocc <- draw(lsbq_pretask, select = 40) +
  443. labs(title = "Right Central to Medial Occipital",
  444. subtitle = NULL) +
  445. ylab("Granger Causality") +
  446. xlab("LSBQ Composite Score") +
  447. geom_line(color = "green4")
  448. plt_lsbq_pretask_rigcen_medocc$layers[[1]]$aes_params$fill <- "green4"
  449. print(plt_lsbq_pretask_rigcen_medocc)
  450. ggsave(
  451. "Pre-task - Right Central to Medial Occipital.svg",
  452. device = "svg",
  453. path = "Plots/SVG/Pretask")
  454. ggsave(
  455. "Pre-task - Right Central to Medial Occipital.png",
  456. device = "png",
  457. path = "Plots/PNG/Pretask")
  458. ```
  459. ### Right Temporal to Right Parietal
  460. ```{r}
  461. plt_lsbq_pretask_rigtem_rigpar <- draw(lsbq_pretask, select = 56) +
  462. labs(title = "Right Temporal to Right Parietal",
  463. subtitle = NULL) +
  464. ylab("Granger Causality") +
  465. xlab("LSBQ Composite Score") +
  466. geom_line(color = "green4")
  467. plt_lsbq_pretask_rigtem_rigpar$layers[[1]]$aes_params$fill <- "green4"
  468. print(plt_lsbq_pretask_rigtem_rigpar)
  469. ggsave(
  470. "Pre-task - Right Temporal to Right Parietal.svg",
  471. device = "svg",
  472. path = "Plots/SVG/Pretask")
  473. ggsave(
  474. "Pre-task - Right Temporal to Right Parietal.png",
  475. device = "png",
  476. path = "Plots/PNG/Pretask")
  477. ```
  478. ## Post-task
  479. ```{r}
  480. # Show index numbers of terms in model
  481. invisible(lapply(seq_along(lsbq_posttask$smooth), function(i) {
  482. cat(paste0("[", i, "] ", lsbq_posttask$smooth[[i]]$label, "\n"))
  483. }))
  484. # s(lsbq_comp):regionleft_central_left_temporal - [2]
  485. # s(lsbq_comp):regionleft_central_medial_occipital - [4]
  486. # s(lsbq_comp):regionleft_central_right_parietal - [6]
  487. # s(lsbq_comp):regionleft_temporal_left_parietal - [16]
  488. # s(lsbq_comp):regionmedial_frontal_left_central - [22]
  489. # s(lsbq_comp):regionmedial_frontal_left_temporal - [24]
  490. # s(lsbq_comp):regionmedial_frontal_medial_occipital - [25]
  491. ```
  492. ### Left Central to Left Temporal
  493. ```{r}
  494. plt_lsbq_posttask_lefcen_leftem <- draw(lsbq_posttask, select = 2) +
  495. labs(title = "Left Central to Left Temporal",
  496. subtitle = NULL) +
  497. ylab("Granger Causality") +
  498. xlab("LSBQ Composite Score") +
  499. geom_line(color = "orange2")
  500. plt_lsbq_posttask_lefcen_leftem$layers[[1]]$aes_params$fill <- "orange2"
  501. print(plt_lsbq_posttask_lefcen_leftem)
  502. ggsave(
  503. "Post-task - Left Central to Left Temporal.svg",
  504. device = "svg",
  505. path = "Plots/SVG/Posttask")
  506. ggsave(
  507. "Post-task - Left Central to Left Temporal.png",
  508. device = "png",
  509. path = "Plots/PNG/Posttask")
  510. ```
  511. ### Left Central to Medial Occipital
  512. ```{r}
  513. plt_lsbq_posttask_lefcen_medocc <- draw(lsbq_posttask, select = 4) +
  514. labs(title = "Left Central to Medial Occipital",
  515. subtitle = NULL) +
  516. ylab("Granger Causality") +
  517. xlab("LSBQ Composite Score") +
  518. geom_line(color = "orange2")
  519. plt_lsbq_posttask_lefcen_medocc$layers[[1]]$aes_params$fill <- "orange2"
  520. print(plt_lsbq_posttask_lefcen_medocc)
  521. ggsave(
  522. "Post-task - Left Central to Medial Occipital.svg",
  523. device = "svg",
  524. path = "Plots/SVG/Posttask")
  525. ggsave(
  526. "Post-task - Left Central to Medial Occipital.png",
  527. device = "png",
  528. path = "Plots/PNG/Posttask")
  529. ```
  530. ### Left Central to Right Parietal
  531. ```{r}
  532. plt_lsbq_posttask_lefcen_rigpar <- draw(lsbq_posttask, select = 6) +
  533. labs(title = "Left Central to Right Parietal",
  534. subtitle = NULL) +
  535. ylab("Granger Causality") +
  536. xlab("LSBQ Composite Score") +
  537. geom_line(color = "orange2")
  538. plt_lsbq_posttask_lefcen_rigpar$layers[[1]]$aes_params$fill <- "orange2"
  539. print(plt_lsbq_posttask_lefcen_rigpar)
  540. ggsave(
  541. "Post-task - Left Central to Right Parietal.svg",
  542. device = "svg",
  543. path = "Plots/SVG/Posttask")
  544. ggsave(
  545. "Post-task - Left Central to Right Parietal.png",
  546. device = "png",
  547. path = "Plots/PNG/Posttask")
  548. ```
  549. ### Left Temporal to Left Parietal
  550. ```{r}
  551. plt_lsbq_posttask_leftem_lefpar <- draw(lsbq_posttask, select = 16) +
  552. labs(title = "Left Temporal to Left Parietal",
  553. subtitle = NULL) +
  554. ylab("Granger Causality") +
  555. xlab("LSBQ Composite Score") +
  556. geom_line(color = "orange2")
  557. plt_lsbq_posttask_leftem_lefpar$layers[[1]]$aes_params$fill <- "orange2"
  558. print(plt_lsbq_posttask_leftem_lefpar)
  559. ggsave(
  560. "Post-task - Left Temporal to Left Parietal.svg",
  561. device = "svg",
  562. path = "Plots/SVG/Posttask")
  563. ggsave(
  564. "Post-task - Left Temporal to Left Parietal.png",
  565. device = "png",
  566. path = "Plots/PNG/Posttask")
  567. ```
  568. ### Medial Frontal to Left Central
  569. ```{r}
  570. plt_lsbq_posttask_medfro_lefcen <- draw(lsbq_posttask, select = 22) +
  571. labs(title = "Medial Frontal to Left Central",
  572. subtitle = NULL) +
  573. ylab("Granger Causality") +
  574. xlab("LSBQ Composite Score") +
  575. geom_line(color = "orange2")
  576. plt_lsbq_posttask_medfro_lefcen$layers[[1]]$aes_params$fill <- "orange2"
  577. print(plt_lsbq_posttask_medfro_lefcen)
  578. ggsave(
  579. "Post-task - Medial Frontal to Left Central.svg",
  580. device = "svg",
  581. path = "Plots/SVG/Posttask")
  582. ggsave(
  583. "Post-task - Medial Frontal to Left Central.png",
  584. device = "png",
  585. path = "Plots/PNG/Posttask")
  586. ```
  587. ### Medial Frontal to Left Temporal
  588. ```{r}
  589. plt_lsbq_posttask_medfro_leftem <- draw(lsbq_posttask, select = 24) +
  590. labs(title = "Medial Frontal to Left Temporal",
  591. subtitle = NULL) +
  592. ylab("Granger Causality") +
  593. xlab("LSBQ Composite Score") +
  594. geom_line(color = "orange2")
  595. plt_lsbq_posttask_medfro_leftem$layers[[1]]$aes_params$fill <- "orange2"
  596. print(plt_lsbq_posttask_medfro_leftem)
  597. ggsave(
  598. "Post-task - Medial Frontal to Left Temporal.svg",
  599. device = "svg",
  600. path = "Plots/SVG/Posttask")
  601. ggsave(
  602. "Post-task - Medial Frontal to Left Temporal.png",
  603. device = "png",
  604. path = "Plots/PNG/Posttask")
  605. ```
  606. ### Medial Frontal to Medial Occipital
  607. ```{r}
  608. plt_lsbq_posttask_medfro_medocc <- draw(lsbq_posttask, select = 25) +
  609. labs(title = "Medial Frontal to Medial Occipital",
  610. subtitle = NULL) +
  611. ylab("Granger Causality") +
  612. xlab("LSBQ Composite Score") +
  613. geom_line(color = "orange2")
  614. plt_lsbq_posttask_medfro_medocc$layers[[1]]$aes_params$fill <- "orange2"
  615. print(plt_lsbq_posttask_medfro_medocc)
  616. ggsave(
  617. "Post-task - Medial Frontal to Medial Occipital.svg",
  618. device = "svg",
  619. path = "Plots/SVG/Posttask")
  620. ggsave(
  621. "Post-task - Medial Frontal to Medial Occipital.png",
  622. device = "png",
  623. path = "Plots/PNG/Posttask")
  624. ```
  625. # Common connections between conditions
  626. ## Left Central to Right Parietal
  627. ```{r}
  628. lsbq_prepost <- compare_smooths(
  629. lsbq_pretask, lsbq_posttask,
  630. select = "s(lsbq_comp):regionleft_central_right_parietal"
  631. )
  632. lsbq_prepost$.model <- factor(lsbq_prepost$.model,
  633. levels = c("lsbq_pretask", "lsbq_posttask"),
  634. labels = c("Pre-task", "Post-task"))
  635. plt_lsbq_prepost_lefcen_rigpar <- draw(lsbq_prepost) +
  636. labs(title = "Left Central to Right Parietal",
  637. subtitle = "Pre-task and Post-task Comparison",
  638. color = "Condition") +
  639. scale_color_manual(labels = c("Pre-task", "Post-task"),
  640. values = c("green4", "orange2")) +
  641. scale_fill_manual(values = c("green4", "orange2")) +
  642. ylab("Granger Causality") +
  643. xlab("LSBQ Composite Score") +
  644. guides(fill = "none") +
  645. geom_rug(data = subset(projectdata_long, condition == "pretask"),
  646. mapping = aes(x = lsbq_comp),
  647. color = scales::alpha("grey40", 0.5),
  648. linewidth = 0.25,
  649. inherit.aes = FALSE,
  650. show.legend = FALSE,
  651. sides = "b")
  652. print(plt_lsbq_prepost_lefcen_rigpar)
  653. ggsave(
  654. "Pre-post Comparison - Left Central to Right Parietal.svg",
  655. device = "svg",
  656. path = "Plots/SVG/Both")
  657. ggsave(
  658. "Pre-post Comparison - Left Central to Right Parietal.png",
  659. device = "png",
  660. path = "Plots/PNG/Both")
  661. ```

BIFUNC Pre- & Post-task Statistical Analysis.Rmd, no license · at the source

Overview

Authors: Alex Sheehan1, Doug Saddy1, Diego Krivochen2, Shruti Gupta1,3, Mickey Sibsey1, Christos Pliatsikas1,4
  1. School of Psychology and Clinical Language Sciences, University of Reading, Reading, UK
  2. School of Languages, Linguistics, Literatures and, Cultures, Faculty of Arts, University of Calgary, Calgary, AB Canada
  3. King’s College Hospital NHS Foundation Trust, London, UK
  4. Facultad de Lenguas y Educación, Centro de Ciencia Cognitiva, Universidad Antonio de Nebrija, Madrid, Spain
Institutions: University of Reading (United Kingdom); University of Calgary (Canada); King's College Hospital NHS Foundation Trust (United Kingdom); Universidad Nebrija (Spain)
Journal: Scientific reports, volume 16, issue 1, article 12756
Dates: received 16 July 2025; accepted 24 February 2026; published online 9 March 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1038/s41598-026-42094-x · PMID 41803385 · PMCID PMC13096162 · OpenAlex W7134265266
Open access: gold, a free copy (OpenAlex)
Preprint: osf.io/da746
Status: code verified
Categories: EEG (modality), human (organism), cognitive (subfield)
Methods: Connectivity, Statistics, Smoothing, state filtering, decompositions, Preprocessing, fMRI & imaging
Keywords: Neuroscience, Psychology
MeSH: Brain*, Learning*, Multilingualism*, Adult, Brain Mapping, Electroencephalography, Female, Humans, Male, Reaction Time, Young Adult (* major topic)
Topic: Neurobiology of Language and Bilingualism (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Economic and Social Research Council (2604285)
Citations: not cited yet (Europe PMC); 98 references in the paper

Abstract

Bilingualism is associated with distinct patterns of resting-state functional brain connectivity – a consequence of ongoing language control demands that do not apply to monolinguals. However, it is not well understood how these patterns affect, and are affected by, brain activation for domain-general cognitively demanding tasks. Here, we employ a novel task-driven resting-state electroencephalography design including an implicit Lindenmayer grammar learning task, which tracks aperiodic and hierarchical dependencies, to determine task-related functional connectivity changes in bilinguals. Quantified bilingual experience was used as a predictor of directional effects, using Generalised Additive Models to account for non-linear patterns. Our results revealed post-task alterations to connectivity involving increased involvement of occipital regions, reduced involvement of frontal and central regions, and faster reaction times to stimuli at higher levels of bilingual experience. Crucially, the regions implicated post-task appear to reflect task-relevant regions which are involved in the language and executive control networks, reflecting greater short-term task-driven flexibility. These findings have important implications for our understanding of how domain-general processing and connectivity are shaped by linguistic experience.

Supplementary Information: The online version contains supplementary material available at 10.1038/s41598-026-42094-x.

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.

OSF 4qkfd

License: none: the authors keep all their rights
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Languages: R (3)
Size: 11 files, 3 scripts
Software Heritage: not checked
Found in: “Data availability”
Holds: 3 notebooks
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: ggplot2 (3 files), mgcv (3 files), reshape2 (3 files), tidyverse (3 files), broom (1 file), lme4 (1 file), lmerTest (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
  • 30 September 2026: the link answers (HTTP 200)
3 files
At the source: osf.io/4qkfd/

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;
  • 3 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

The data sheets, code, and task used for this manuscript are available in an Open Science Framework repository at https://osf.io/4qkfd/.

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, 30 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 2 keywords, 11 MeSH terms, 1 funder, 66 references.

Cite

This paper

Sheehan, A., Saddy, D., Krivochen, D., Gupta, S., Sibsey, M., & Pliatsikas, C. (2026). Bilingualism modulates functional connectivity induced by a domain-general artificial grammar learning task. Scientific reports, 16(1), 12756. https://doi.org/10.1038/s41598-026-42094-x

BibTeX

@article{sheehan2026bilingualism,
author = {Sheehan, Alex and Saddy, Doug and Krivochen, Diego and Gupta, Shruti and Sibsey, Mickey and Pliatsikas, Christos},
title = {{Bilingualism modulates functional connectivity induced by a domain-general artificial grammar learning task}},
journal = {Scientific reports},
year = {2026},
month = mar,
volume = {16},
number = {1},
pages = {12756},
publisher = {Nature Publishing Group},
issn = {2045-2322},
doi = {10.1038/s41598-026-42094-x},
url = {https://doi.org/10.1038/s41598-026-42094-x},
pmid = {41803385},
pmcid = {PMC13096162}
}

RIS

TY - JOUR
AU - Sheehan, Alex
AU - Saddy, Doug
AU - Krivochen, Diego
AU - Gupta, Shruti
AU - Sibsey, Mickey
AU - Pliatsikas, Christos
TI - Bilingualism modulates functional connectivity induced by a domain-general artificial grammar learning task
T2 - Scientific reports
J2 - Sci Rep
PY - 2026
DA - 2026/03/09
VL - 16
IS - 1
SP - 12756
SN - 2045-2322
PB - Nature Publishing Group
DO - 10.1038/s41598-026-42094-x
UR - https://doi.org/10.1038/s41598-026-42094-x
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41598-026-42094-x",
"type": "article-journal",
"title": "Bilingualism modulates functional connectivity induced by a domain-general artificial grammar learning task",
"container-title": "Scientific reports",
"author": [
{
"family": "Sheehan",
"given": "Alex"
},
{
"family": "Saddy",
"given": "Doug"
},
{
"family": "Krivochen",
"given": "Diego"
},
{
"family": "Gupta",
"given": "Shruti"
},
{
"family": "Sibsey",
"given": "Mickey"
},
{
"family": "Pliatsikas",
"given": "Christos"
}
],
"container-title-short": "Sci Rep",
"volume": "16",
"issue": "1",
"page": "12756",
"DOI": "10.1038/s41598-026-42094-x",
"PMID": "41803385",
"PMCID": "PMC13096162",
"ISSN": "2045-2322",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41598-026-42094-x",
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
9
]
]
}
}

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.1038/s41467-026-71415-x [code]
Regional BOLD variability reflects microstructural maturation and neuronal ensheathment in the preterm infant cortex.
Journal: Nature communications
In common: mgcv, broom, lmerTest, 4 other tools
[2] doi:10.1016/j.celrep.2026.117505 [code]
Impaired spatial coding and neuronal hyperactivity in the medial entorhinal cortex of aged APP knock-in mice.
Journal: Cell reports
In common: mgcv, broom, lmerTest, 4 other tools
[3] doi:10.1111/psyp.70265 [code]
Neurocognitive Dynamics of Translating Information From a Spatial Map Into Action.
Journal: Psychophysiology
In common: mgcv, lmerTest, lme4, 2 other tools, EEG, cognitive, 1 reference
[4] doi:10.1038/s41593-026-02363-4 [code]
Cortical thickness changes precede high levels of amyloid by at least 7 years.
Journal: Nature neuroscience
In common: mgcv, broom, lmerTest, 3 other tools
[5] doi:10.1093/bioinformatics/btag592 [code]
Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.
Journal: Bioinformatics (Oxford, England)
In common: mgcv, broom, lme4, 3 other tools
[6] doi:10.1038/s41467-026-73072-6 [code]
Mapping the spatiotemporal continuum of structural connectivity development across the human connectome in youth.
Journal: Nature communications
In common: mgcv, lmerTest, lme4, 3 other tools
[7] doi:10.1162/opmi.a.372 [code]
Broadening the Agent Preference Hypothesis Through Experiencers: Eye-Tracking and EEG Evidence of Proto-Agents and Proto-Patients.
Journal: Open mind : discoveries in cognitive science
In common: mgcv, reshape2, ggplot2, 1 other tool, EEG, 2 references
[8] doi:10.1371/journal.pone.0353990 [code]
Positive mood enhances accessibility of unrelated concepts in the first language but not in the foreign language.
Journal: PloS one
In common: lmerTest, lme4, reshape2, 2 other tools, EEG, cognitive, 1 reference
[9] doi:10.1016/j.neuroimage.2026.122115 [code]
Midfrontal theta power relates to response speeding following frustrative nonreward.
Journal: NeuroImage
In common: lmerTest, lme4, reshape2, 2 other tools, EEG, cognitive, 1 reference
[10] doi:10.1523/eneuro.0316-25.2026 [code]
Neural Mechanisms of Self-Generated Action Sequences.
Journal: eNeuro
In common: lmerTest, lme4, reshape2, 2 other tools, EEG, cognitive, 1 reference

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.

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: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.