OSCR

Neural and Behavioral Tracking of Musical Phrases Occurs Without Temporal Regularity.

Code ↔ Paper

11 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 11 matches
  1. [1] § Methods › Neural Tracking of Phrase Structure ↔ eeg_analysis/7_TRF_power_random_phrase_boundary.m, lines 1–67 · score 0.79 · ft_freqanalysis, FieldTrip, phrase tracking, 2.48, wavelet, phrase boundaries
  2. [2] § Methods › Neural Tracking of Phrase Structure ↔ eeg_analysis/6_TRF_power_with_acoustic_predictors.m, lines 2–67 · score 0.79 · ft_freqanalysis, FieldTrip, 2.48, phrase tracking, wavelet, widths
  3. [3] § Results › Phrase Boundary Detection Relies on Structural Cues Rather Than Local Acoustic Changes ↔ behavioural_analysis/analysis_behavioural.Rmd, lines 583–641 · score 0.73 · linear model, boundary detection, acoustic features, frequency interval, fitted, phrase boundaries
  4. [4] § Methods › Stimuli ↔ behavioural_analysis/analysis_behavioural.Rmd, lines 396–463 · score 0.69 · frequency interval, acoustic features, lme4, binomial, glmer, model
  5. [5] § Results › Listeners Are Able to Detect Phrase Boundaries ↔ behavioural_analysis/analysis_behavioural.Rmd, lines 177–198 · score 0.67 · Tukey HSD, post hoc, Krippendorff, agreement, adj, ANOVA
  6. [6] § Methods › EEG Data Preprocessing ↔ eeg_analysis/2_MCCA.m, lines 51–101 · score 0.64 · pass filter, FieldTrip, Epochs, preprocessed, MATLAB, ICA
  7. [7] § Methods › EEG Data Preprocessing ↔ eeg_analysis/1_read_data.m, lines 9–95 · score 0.63 · FieldTrip toolbox, preprocessed, MATLAB, filter, offset, 35 Hz
  8. [8] § Results › Neural Tracking of Phrase Boundaries Is the Strongest for Regular Phrases ↔ eeg_analysis/7_TRF_power_random_phrase_boundary.m, lines 223–345 · score 0.60 · randomized boundary predictors, phrase boundary predictor, TRF models, band, positions, power
  9. [9] § Methods › Cerebral–Acoustic Coherence (Cacoh) ↔ eeg_analysis/3_Cacoh.m, lines 30–83 · score 0.60 · 0.1–20 Hz, Hanning, mscohere, coherence, Cacoh, 0.1 Hz
  10. [10] § Methods › Analysis of Behavioral Data ↔ behavioural_analysis/analysis_behavioural.Rmd, lines 583–641 · score 0.57 · Detection rate, frequency interval, fitted, model, phrase boundary, acoustic
  11. [11] § Methods › Temporal Response Function (TRF) Over Acoustic Envelope ↔ eeg_analysis/stimuli_envelope_trf.m, lines 1–84 · score 0.52 · 4000 Hz, filterbank, gammatone, bands, envelope, TRF

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 · 641 lines · 20 KB · no license · 4 matches

  1. # **ENVIRONMENT SET-UP**
  2. load required packages
  3. ```{r libraries}
  4. rm(list=ls())
  5. library(scales)
  6. library(readxl)
  7. library(tidyr)
  8. library(plyr)
  9. library(dplyr)
  10. library(ggplot2)
  11. library(Rmisc)
  12. library(tidyverse)
  13. #library(hrbrthemes)
  14. library(ggpubr)
  15. library(psych)
  16. library(slider)
  17. library(rstatix)
  18. library(lme4)
  19. library(irr)
  20. library(svglite)
  21. library(sjPlot)
  22. ```
  23. load data
  24. ```{r data, include=FALSE}
  25. setwd("~/Documents/Phrase_tracking/4_Analysis/1_behavioural/data")
  26. real_data <- read_csv('realness_rating.csv')
  27. df <- read_csv("df.csv")
  28. df_zeros <- read_csv("df_zeros.csv")
  29. beat_setup <- read_csv('beat_setup.csv')
  30. signal_theory <- read_csv('signal_theory.csv')
  31. signal_df <- read_csv('signal_df.csv')
  32. goldmsi <- read_csv('goldmsi.csv')
  33. stamps <- read_csv('stamps.csv')
  34. stamps$beat <- floor(stamps$beat)
  35. ```
  36. load variables
  37. ``` {r variables}
  38. palette = c("#D81B60", "#1E88E5", "#FFC107")
  39. conditions = c(
  40. "regular_maj_1_a", "regular_maj_2_a", "regular_min_1_a", "regular_min_2_a",
  41. "irregular_maj_1_a", "irregular_maj_2_a", "irregular_min_1_a", "irregular_min_2_a",
  42. "shuffled_maj_1_a", "shuffled_maj_2_a", "shuffled_min_1_a", "shuffled_min_2_a"
  43. )
  44. plot_DIR = "~/Documents/Phrase_tracking/4_Analysis/1_behavioural/plots"
  45. ```
  46. # **S1 - individual differences in behavioural task**
  47. ```{r}
  48. temp_cond = "regular_maj_1_a"
  49. df_plot <- df %>%
  50. filter(condition==temp_cond) ##SET THE STIMULUS NAME
  51. df_plot <- df_plot %>%
  52. group_by(number, sub_ID)
  53. intercept = stamps %>% filter(Stim==temp_cond)
  54. df_plot$sub_ID <- sub("^.{3}", "", df_plot$sub_ID)
  55. ind_plot = df_plot %>%
  56. ggplot(aes(x=number, y=N)) +
  57. geom_col(fill="#2E75B6", color="#2E75B6", alpha=0.6)+
  58. theme_minimal()+
  59. # ggtitle("Regular major - version 1") + ##CHANGE TITLE ACCORDING TO THE SIMULUS
  60. theme(plot.title = element_text(size=15),
  61. #axis.text.x =element_blank(),
  62. axis.text.y =element_blank(),
  63. strip.text.y = element_text(angle = 0),
  64. #axis.title.x = element_text(hjust=0.95),
  65. axis.title.y = element_text(hjust=0.95),
  66. text=element_text(size=11, family="Arial"),
  67. panel.border = element_blank(),
  68. #panel.grid.major = element_blank(),
  69. #panel.grid.minor = element_blank(),
  70. panel.background = element_blank())+
  71. #axis.line = element_line(colour = "black")
  72. scale_x_continuous(breaks = seq(0, 100, 5))+
  73. scale_y_continuous(breaks = seq(0, 2, 2))+
  74. ylab(" ")+
  75. xlab("Time (in beats of musical piece)")+
  76. theme(legend.position="none")+
  77. facet_grid(rows = vars(sub_ID))+
  78. geom_vline(xintercept = intercept$beat, alpha=0.6)
  79. ggsave(filename = file.path(plot_DIR, 'indiv_data.svg'), plot = ind_plot, width = 10, height = 7, units = "in")
  80. ```
  81. ```{r aggregated data from participants}
  82. df_plot <- df_plot %>%
  83. group_by(number) %>%
  84. summarise(total=sum(N))
  85. intercept = stamps %>% filter(Stim==temp_cond)
  86. agg_plot = df_plot %>%
  87. ggplot(aes(x=number, y=total)) +
  88. geom_col(fill="#2E75B6", color="#2E75B6", alpha=0.6)+
  89. theme_classic()+
  90. theme(plot.title = element_text(size=15),
  91. axis.text.x =element_blank(),
  92. # axis.text.y =element_blank(),
  93. strip.text.y = element_text(angle = 0),
  94. axis.title.y = element_text(hjust=0.95),
  95. text=element_text(size=11, family="Arial"),
  96. panel.border = element_blank(),
  97. panel.background = element_blank())+
  98. scale_x_continuous(breaks = seq(0, 100, 5))+
  99. scale_y_continuous(breaks = seq(0, 15, 3))+
  100. ylab(" ")+
  101. xlab(" ")+
  102. theme(legend.position="none")+
  103. geom_vline(xintercept = intercept$beat, alpha=0.6)
  104. ggsave(filename = file.path(plot_DIR, 'agg_data.svg'), plot = agg_plot, width = 14, height = 3, units = "in")
  105. ```
  106. # **REALNESS OF THE MELODY**
  107. ```{r plot}
  108. real_data %>%
  109. ggplot(aes(x=items, y=scores, fill=category)) +
  110. scale_fill_manual(values=palette)+
  111. geom_boxplot(varwidth = TRUE, alpha=0.3) +
  112. theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
  113. stat_summary(fun=mean, colour="black", geom="point",
  114. shape=20, size=2, show.legend=FALSE, alpha=0.5) #+
  115. geom_jitter(color="black", size=0.4, alpha=0.9) # add or remove jitter
  116. ```
  117. ```{r data prep}
  118. real_data_agr <- aggregate(scores ~ items+category+subject, data = real_data, FUN=mean)
  119. names(real_data_agr)[2] <- "condition"
  120. res.aov = aov(scores ~ condition, data = real_data_agr)
  121. summary(res.aov)
  122. ```
  123. ```{r models}
  124. real.model = lmer(scores ~ condition + (1|items) + (1|subject), data = real_data_agr, REML = F)
  125. summary(real.model)
  126. tab_model(real.model)
  127. null.model = lmer(scores ~ 1 + (1|items) + (1|subject), data = real_data_agr, REML =F )
  128. summary(null.model)
  129. anova(real.model, null.model)
  130. ```
  131. # **KRIPPENDORFF'S ALPHA**
  132. ```{r compute kripp's alpha}
  133. process_condition <- function(data, cond) {
  134. condition_data <- data %>%
  135. filter(condition == cond) %>%
  136. select(-(1:5)) %>%
  137. as.matrix()
  138. condition_data <- condition_data[rowSums(condition_data, na.rm = TRUE) > 1, ] #remove rows with 1 or less observations
  139. kripp.alpha(condition_data)[[5]]
  140. }
  141. agreement_scores <- matrix(nrow = length(conditions), ncol = 2)
  142. colnames(agreement_scores) <- c("condition", "alpha")
  143. agreement_scores[, 1] <- conditions
  144. for (i in seq_along(conditions)) {
  145. agreement_scores[i, 2] <- process_condition(df_zeros, conditions[i])
  146. }
  147. agreement_scores <- as.data.frame(agreement_scores)
  148. agreement_scores$alpha <- as.numeric(agreement_scores$alpha)
  149. agreement_scores <- agreement_scores %>%
  150. mutate(category = case_when(
  151. startsWith(condition, "ir") ~ "irregular",
  152. startsWith(condition, "re") ~ "regular",
  153. startsWith(condition, "sh") ~ "shuffled"
  154. ))
  155. ```
  156. ```{r plot}
  157. res.aov_kripp <- agreement_scores %>% anova_test(alpha ~ category)
  158. post_hoc <- agreement_scores %>%
  159. tukey_hsd(alpha ~ category)
  160. post_hoc <- post_hoc %>% add_xy_position(x = "category")
  161. agreement_scores$category <- factor(agreement_scores$category, levels = c("irregular", "regular", "shuffled"))
  162. plot = ggboxplot(agreement_scores, x = "category", y = "alpha", fill = "category", alpha=0.8) +
  163. stat_pvalue_manual(post_hoc, label = "p.adj.signif", tip.length = 0.005, step.increase = 0.01) +
  164. scale_fill_manual(values=palette) +
  165. ylab("Krippendorff's alpha") +
  166. xlab("") +
  167. theme_classic() +
  168. theme(
  169. legend.position = "none",
  170. axis.text = element_text(size = 14),
  171. axis.title = element_text(size = 18)
  172. )
  173. plot
  174. ggsave(filename = file.path(plot_DIR, 'kripp_alpha.svg'), plot = plot, width = 6, height = 6, units = "in")
  175. ```
  176. ```{r model}
  177. kripp.model = lm(alpha ~ category, data = agreement_scores)
  178. summary(kripp.model)
  179. ```
  180. # **F-SCORE**
  181. ```{r compute}
  182. signal_theory[is.na(signal_theory)] <- 0
  183. signal_theory <- add_column(signal_theory, precision = NA)
  184. signal_theory <- add_column(signal_theory, recall = NA)
  185. signal_theory <- add_column(signal_theory, ff1 = NA)
  186. for (i in 1:nrow(signal_theory)) {
  187. #precision
  188. signal_theory [[i, 7]] <- signal_theory[[i, 5]]/(signal_theory[[i, 5]]+signal_theory[[i, 4]])
  189. #recall
  190. signal_theory [[i, 8]] <- signal_theory[[i,5]]/(signal_theory[[i, 5]]+signal_theory[[i, 6]])
  191. #ff1
  192. signal_theory[[i,9]] <- 2/((1/signal_theory[[i, 8]])+(1/signal_theory[[i,7]]))
  193. }
  194. ```
  195. ``` {r}
  196. signal_theory<- add_column(signal_theory, category = NA)
  197. signal_theory <- signal_theory %>%
  198. mutate(category = case_when(
  199. startsWith(condition, "ir") ~ "irregular",
  200. startsWith(condition, "re") ~ "regular",
  201. startsWith(condition, "sh") ~ "shuffled"
  202. ))
  203. ```
  204. ```{r plot}
  205. signal_theory_agg <- signal_theory %>%
  206. group_by(sub_ID, category) %>%
  207. summarize(avg_ff1 = mean(ff1, na.rm = TRUE), .groups = 'drop')
  208. stat.test_ff1 <- signal_theory_agg %>%
  209. anova_test(dv = avg_ff1, wid = sub_ID, within = category) %>%
  210. add_significance()
  211. post_hoc <- signal_theory_agg %>%
  212. pairwise_t_test(avg_ff1 ~ category, paired = TRUE, p.adjust.method = "bonferroni")
  213. post_hoc <- post_hoc %>%
  214. add_xy_position(x = "category", step.increase = 0.22)
  215. plot_f <- ggplot(signal_theory_agg, aes(x = category, y = avg_ff1)) +
  216. #geom_boxjitter(aes(fill = category),jitter.shape = 21, jitter.color = NA, outlier.color = NA, errorbar.draw = TRUE) +
  217. geom_violin(aes(fill=category)) +
  218. geom_boxplot(width = 0.4, color = 'black', alpha = 0.4) +
  219. scale_fill_manual(values = palette) +
  220. stat_pvalue_manual(post_hoc, label = 'p.adj.signif', tip.length = 0.01) +
  221. #labs(subtitle = get_test_label(stat.test_ff1, detailed = TRUE)) +
  222. scale_y_continuous(breaks = c(0, 0.25, 0.5, 0.75, 1), limits = c(0, 1), labels = c(0, 0.25, 0.5, 0.75, 1)) +
  223. ylab('F-score')+
  224. xlab('')+
  225. theme_classic()+
  226. theme(legend.position = "none",
  227. axis.text=element_text(size=14),
  228. axis.title=element_text(size=18))
  229. plot_f
  230. ggsave(filename = file.path(plot_DIR, 'ff1.svg'), plot = plot_f, width = 6, height = 6, units = "in")
  231. ```
  232. ```{r model}
  233. accuracy.model = lmer(ff1~ category + (1|sub_ID) + (1|condition), data=signal_theory, REML=T)
  234. null.model = lmer(ff1 ~ 1 + (1|sub_ID) + (1|condition), data=signal_theory,REML=T)
  235. anova(null.model, accuracy.model)
  236. summary(accuracy.model)
  237. ```
  238. # **Gold-MSI**
  239. ```{r data preparation}
  240. gold_df <- signal_theory[,-c(3:8)]
  241. gold_df_agg <- gold_df %>%
  242. group_by(sub_ID, category) %>%
  243. summarize(avg_ff1 = mean(ff1, na.rm = TRUE), .groups = 'drop')
  244. regular_irregular_avg <- gold_df_agg %>%
  245. filter(category %in% c("regular", "irregular")) %>%
  246. group_by(sub_ID) %>%
  247. summarize(avg_ff1 = mean(avg_ff1, na.rm = TRUE), .groups = 'drop') %>%
  248. mutate(category = "avg")
  249. # Combine the new category with the original aggregated data
  250. gold_df_combined <- bind_rows(gold_df_agg, regular_irregular_avg)
  251. gold_df_agg <- pivot_wider(gold_df_combined, names_from = category, values_from = avg_ff1)
  252. gold_df_agg$MT <- goldmsi$MT
  253. gold_df_agg$GI <- goldmsi$GI
  254. gold_df_agg <- pivot_longer(gold_df_agg, cols = 2:5, names_to = "category", values_to = "avg_ff1")
  255. gold_df_agg <- pivot_longer(gold_df_agg, cols = 2:3, names_to = "scales", values_to = "goldmsi")
  256. ```
  257. ```{r correlation}
  258. MT <- gold_df_agg %>%
  259. filter(scales == "MT") %>%
  260. ggplot(aes(x = goldmsi, y = avg_ff1, color = category)) +
  261. geom_point(alpha = 0.4, size = 0.5, aes(color = category,)) +
  262. #geom_smooth(method = "lm", aes(group = 1), color = "black",
  263. # alpha = 0.2, se = TRUE, linetype = 1, size = 0.5) + # General fit
  264. geom_smooth(method = "lm", alpha = 0.2, se = TRUE, linetype = 1, size = 0.5) + # Condition fits
  265. ylim(0, 0.85) +
  266. scale_color_manual(values = c('#000000', palette)) +
  267. xlab("Musical Training") +
  268. ylab("F-score") +
  269. theme_classic()+
  270. theme(legend.position = "none",
  271. axis.text=element_text(size=14),
  272. axis.title=element_text(size=18))
  273. GI <- gold_df_agg %>%
  274. filter(scales == "GI") %>%
  275. ggplot(aes(x = goldmsi, y = avg_ff1, color = category)) +
  276. geom_point(alpha = 0.4, size = 0.5, aes(color = category,)) +
  277. #geom_smooth(method = "lm", aes(group = 1), color = "black",
  278. # alpha = 0.2, se = TRUE, linetype = 1, size = 0.5) + # General fit
  279. geom_smooth(method = "lm", alpha = 0.2, se = TRUE, linetype = 1, size = 0.5) + # Condition fits
  280. ylim(0, 0.85) +
  281. scale_color_manual(values = c('#000000', palette)) +
  282. xlab("General Index") +
  283. ylab("F-score") +
  284. theme_classic()+
  285. theme(legend.position = "none",axis.text=element_text(size=14),
  286. axis.title=element_text(size=18))
  287. plot_g <- ggarrange(MT,GI,
  288. ncol = 1, nrow = 2)
  289. ggsave(filename = file.path(plot_DIR, 'gold_corr.svg'), plot = plot_g, width = 4, height = 6, units = "in")
  290. ```
  291. ```{r}
  292. # General correlation for MT
  293. MT_data <- gold_df_agg %>%
  294. filter(scales == "MT") %>%
  295. filter(category == 'avg')
  296. general_corr_MT <- cor.test(MT_data$goldmsi, MT_data$avg_ff1)
  297. # Print general correlation results for MT
  298. print(paste("MT General Correlation: r = ", round(general_corr_MT$estimate, 3),
  299. ", p = ", round(general_corr_MT$p.value, 3)))
  300. # General correlation for GI
  301. GI_data <- gold_df_agg %>%
  302. filter(scales == "GI") %>%
  303. filter(category == 'avg')
  304. general_corr_GI <- cor.test(GI_data$goldmsi, GI_data$avg_ff1)
  305. # Print general correlation results for GI
  306. print(paste("GI General Correlation: r = ", round(general_corr_GI$estimate, 3),
  307. ", p = ", round(general_corr_GI$p.value, 3)))
  308. # Category-specific correlations for MT
  309. category_corr_MT <- gold_df_agg %>%
  310. filter(scales == "MT") %>%
  311. group_by(category) %>%
  312. summarize(
  313. correlation = map_dbl(list(cor.test(goldmsi, avg_ff1)), ~ .x$estimate), # Extract correlation coefficient (r)
  314. p_value = map_dbl(list(cor.test(goldmsi, avg_ff1)), ~ .x$p.value), # Extract p-value
  315. df = map_dbl(list(cor.test(goldmsi, avg_ff1)), ~ .x$parameter)
  316. )
  317. # Print category-specific correlations for MT
  318. print("MT Category-Specific Correlations:")
  319. print(category_corr_MT)
  320. # Category-specific correlations for GI
  321. category_corr_GI <- gold_df_agg %>%
  322. filter(scales == "GI") %>%
  323. group_by(category) %>%
  324. summarize(
  325. correlation = map_dbl(list(cor.test(goldmsi, avg_ff1)), ~ .x$estimate), # Extract correlation coefficient (r)
  326. p_value = map_dbl(list(cor.test(goldmsi, avg_ff1)), ~ .x$p.value), # Extract p-value
  327. df = map_dbl(list(cor.test(goldmsi, avg_ff1)), ~ .x$parameter)
  328. )
  329. # Print category-specific correlations for GI
  330. print("GI Category-Specific Correlations:")
  331. print(category_corr_GI)
  332. ```
  333. # ** ACOUSTIC PREDICTORS **
  334. ```{r}
  335. conditions <- c(
  336. "regular_maj_1_a", "regular_maj_2_a", "regular_min_1_a", "regular_min_2_a",
  337. "irregular_maj_1_a", "irregular_maj_2_a", "irregular_min_1_a", "irregular_min_2_a"
  338. )
  339. load_acoustic_features <- function(condition_name) {
  340. file_path <- paste0("~/Documents/Phrase_tracking/3_Experiment/6_stimuli/original/conditions/",
  341. condition_name, ".csv")
  342. df <- read_delim(file_path, delim = ";", col_names = TRUE, show_col_types = FALSE)
  343. df <- df %>%
  344. mutate(
  345. # Previous note duration (0 for first note)
  346. previous_duration = ifelse(row_number() == 1, 0, lag(duration)),
  347. # Frequency interval (0 for first note)
  348. prev_freq = lag(freq),
  349. freq_interval = ifelse(row_number() == 1, 0, abs(freq - prev_freq)),
  350. # Add stimulus name
  351. stimulus = condition_name,
  352. # Add melody identifier (each stimulus is a melody)
  353. melody = condition_name
  354. ) %>%
  355. select(melody, stimulus, onset_sec, boundary, duration, previous_duration,
  356. freq, freq_interval)
  357. return(df)
  358. }
  359. acoustic_data <- map_dfr(conditions, load_acoustic_features)
  360. acoustic_data <- acoustic_data %>%
  361. mutate(
  362. condition = case_when(
  363. startsWith(stimulus, "regular") ~ "regular",
  364. startsWith(stimulus, "irregular") ~ "irregular",
  365. TRUE ~ "other"
  366. ),
  367. condition_factor = factor(condition, levels = c("irregular", "regular"))
  368. )
  369. acoustic_data <- acoustic_data %>%
  370. mutate(
  371. previous_duration_z = scale(previous_duration)[,1],
  372. freq_interval_z = scale(freq_interval)[,1]
  373. )
  374. acoustic_data_clean <- acoustic_data %>%
  375. group_by(melody) %>%
  376. filter(row_number() > 1) %>%
  377. ungroup()
  378. boundary_model <- glmer(
  379. boundary ~ previous_duration_z * condition_factor +
  380. freq_interval_z * condition_factor +
  381. (1|melody),
  382. data = acoustic_data_clean,
  383. family = binomial(link = "logit"),
  384. control = glmerControl(optimizer = "bobyqa")
  385. )
  386. tab_model(boundary_model)
  387. summary(boundary_model)
  388. ```
  389. # *RT at boundary*
  390. ```{r}
  391. setwd("~/Documents/Phrase_tracking/4_Analysis/1_behavioural")
  392. data <- readxl::read_excel("excel_test.xlsx", sheet="processed")
  393. stamps <- readxl::read_excel("~/Documents/Phrase_tracking/3_Experiment/6_stimuli/stim - time stamps.xlsx")
  394. df <- read_csv("df.csv")
  395. df_zeros <- read_csv("df_zeros.csv")
  396. data <- data[ -c(2:6)]
  397. data$hit <- 0
  398. data <- data %>%
  399. mutate(category = case_when(
  400. startsWith(STIMULUS, "ir") ~ "irregular",
  401. startsWith(STIMULUS, "re") ~ "regular",
  402. startsWith(STIMULUS, "sh") ~ "shuffled"
  403. ))
  404. data$gt <- 0
  405. data <- data %>%
  406. filter(category != "shuffled")
  407. stamps <- stamps %>%
  408. filter(phrase_dur_s != "onset")
  409. for (j in 1:nrow(data)){
  410. value <- as.numeric(data[j, 4])
  411. cur_stim <- as.character(data[j, 2])
  412. temp_df <- stamps %>%
  413. filter(Stim ==cur_stim)
  414. for (i in 1:nrow(temp_df)) {
  415. bound <- as.numeric(temp_df[i, 4])
  416. bef <- bound - 1
  417. af <- bound + 1
  418. if (data[j, 5]==0){
  419. if(value >= bef & value <= af){
  420. data[j, 5] <- 1
  421. data[j, 7] <- bound
  422. } else {
  423. data[j, 5] <- 0
  424. }
  425. }
  426. }
  427. }
  428. hits <- data %>%
  429. filter(hit==1)
  430. hits$distance <- NA
  431. for (k in 1:nrow(hits)) {
  432. bound <- as.numeric(hits[k, 7])
  433. click <- as.numeric(hits[k, 4])
  434. dist <- as.numeric(click - bound)
  435. hits[k, 8] <- dist
  436. }
  437. cat("\nOverall statistics:\n")
  438. cat("Mean:", mean(hits$distance, na.rm = TRUE), "\n")
  439. cat("SD:", sd(hits$distance, na.rm = TRUE), "\n")
  440. distance_summary <- hits %>%
  441. group_by(category) %>%
  442. summarise(
  443. mean_distance = mean(distance, na.rm = TRUE),
  444. sd_distance = sd(distance, na.rm = TRUE),
  445. n = n(),
  446. se_distance = sd_distance / sqrt(n)
  447. )
  448. print(distance_summary)
  449. # T-test comparing regular vs irregular
  450. t_test_result <- t.test(distance ~ category, data = hits)
  451. print(t_test_result)
  452. # Create the plot
  453. colors <- c("regular" = "#1E88E5", "irregular" = "#D81B60")
  454. plot_distance <- ggplot(hits, aes(x = category, y = distance, fill = category)) +
  455. scale_fill_manual(values = colors) +
  456. geom_violin(width = 0.6) +
  457. geom_boxplot(alpha=0.4, width = 0.3)+
  458. labs(
  459. title = "Mean Distance from Phrase Boundary by Category",
  460. x = "Category",
  461. y = "Mean Distance (s)",
  462. fill = "Category"
  463. ) +
  464. theme_minimal() +
  465. theme(
  466. legend.position = "none",
  467. plot.title = element_text(hjust = 0.5, face = "bold"),
  468. axis.text = element_text(size = 12),
  469. axis.title = element_text(size = 13, face = "bold")
  470. )
  471. print(plot_distance)
  472. plot_distance <- ggplot(hits, aes(x = category, y = distance, fill = category)) +
  473. geom_violin(alpha = 1, width=0.3) +
  474. geom_boxplot(width = 0.2, color = 'black', alpha = 0.4) +
  475. scale_fill_manual(values = palette) +
  476. scale_y_continuous(lim = c(-2, 2))+
  477. #stat_pvalue_manual(stat_test, label = 'p.adj.signif', tip.length = 0.01) +
  478. ylab('Distance from boundary (s)') +
  479. xlab('') +
  480. theme_classic() +
  481. theme(
  482. legend.position = "none",
  483. axis.text = element_text(size = 14),
  484. axis.title = element_text(size = 18)
  485. )
  486. print(plot_distance)
  487. ggsave('time_difference.svg', plot = plot_distance)
  488. ```
  489. # *ACCURACY OF PHRASE BOUNDARY DETECTION AND ACOUSTIC PREDICTORS*
  490. ```{r}
  491. acoustics_boundary <- acoustic_data_clean %>%
  492. filter(boundary == 1)
  493. signal_df_boundary <- signal_df %>%
  494. mutate(
  495. is_boundary = ground_truth == 1 &
  496. lag(ground_truth, default = 0) == 1 &
  497. lead(ground_truth, default = 0) == 1
  498. ) %>%
  499. filter(is_boundary)
  500. signal_with_acoustics <- signal_df_boundary %>%
  501. group_by(sub_ID, condition) %>%
  502. mutate(boundary_number = row_number()) %>%
  503. ungroup() %>%
  504. left_join(
  505. acoustics_boundary %>%
  506. group_by(melody) %>%
  507. mutate(boundary_number = row_number()) %>%
  508. ungroup(),
  509. by = c("condition" = "melody", "boundary_number")
  510. )
  511. signal_with_acoustics <- signal_with_acoustics %>%
  512. mutate(hit = ifelse(detection == "hit", 1, 0))
  513. # Calculate detection rate for each boundary across participants
  514. boundary_detection_rate <- signal_df_boundary %>%
  515. group_by(condition, number) %>%
  516. summarise(
  517. detection_rate = mean(detection == "hit"),
  518. n_participants = n(),
  519. .groups = "drop"
  520. ) %>%
  521. # Add boundary number within each melody
  522. group_by(condition) %>%
  523. mutate(boundary_number = row_number()) %>%
  524. ungroup()
  525. # Join with acoustic features
  526. boundary_analysis <- boundary_detection_rate %>%
  527. left_join(
  528. acoustics_boundary %>%
  529. group_by(melody) %>%
  530. mutate(boundary_number = row_number()) %>%
  531. ungroup(),
  532. by = c("condition" = "melody", "boundary_number")
  533. )
  534. # Fit linear model
  535. model <- lmer(detection_rate ~ previous_duration_z * freq_interval_z + (1 | condition),
  536. data = boundary_analysis)
  537. summary(model)
  538. tab_model(model)
  539. ```

analysis_behavioural.Rmd, no license · at the source

Overview

Authors: Zofia Anna Hołubowska1,2,3,4, Xiangbin Teng5,6, Pauline Larrouy‐Maestri1
  1. Max‐Planck‐Institute for Empirical Aesthetics Frankfurt Germany
  2. Institute of Applied Psychology, Faculty of Management and Social Communication Jagiellonian University Kraków Poland
  3. Max‐Planck‐Institute for Human Cognitive and Brain Sciences Leipzig Germany
  4. Institute of Biology, Faculty of Life Sciences University of Leipzig Leipzig Germany
  5. Department of Psychology Chinese University of Hong Kong Shatin New Territories, Hong Kong SAR China
  6. Brain and Mind Institute The Chinese University of Hong Kong Shatin New Territories, Hong Kong SAR China
Journal: The European journal of neuroscience, volume 63, issue 7, article e70481
Dates: received 2 June 2025; accepted 9 March 2026; published online 12 April 2026; in print April 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1111/ejn.70481 · PMID 41968537 · PMCID PMC13071237 · OpenAlex W7154134826
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: EEG (modality), human (organism), cognitive (subfield)
Methods: Spectral & time-frequency, Connectivity, Statistics, Smoothing, state filtering, decompositions, Evoked potentials, Physiology & signal measures, Preprocessing
Keywords: EEG, music perception, music structure, neural tracking, phrase segmentation
MeSH: Auditory Perception*, Brain*, Music*, Acoustic Stimulation, Adult, Electroencephalography, Female, Humans, Male, Young Adult (* major topic)
Topic: Neuroscience and Music Perception (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Improvement on Competitiveness in Hiring New Faculties Funding Scheme, the Chinese University of Hong Kong (4937113)
Citations: cited by 1 paper (Europe PMC); 59 references in the paper

Abstract

When listening to music or speech, people naturally divide continuous sound streams into segments for easier and faster processing of information. The segmentation boundaries are not random. Listeners agree on the points of segmentation, which are consistent with arbitrary rules—for example, those established by music theory—and often occur at regular time intervals. It is thus unclear whether phrase tracking relies on understanding of musical structure or merely on temporal predictability. To address this, we examined how non‐musicians process both regular (temporally predictable) and irregular musical phrases derived from J.S. Bach's compositions. This approach preserved authentic musical structure while manipulating temporal predictability. We also included control stimuli matched in acoustic properties but lacking musical structure. Behavioral and EEG measures revealed that listeners could accurately detect phrase boundaries in both regular and irregular conditions. Neural activity, indexed by an increase in low‐frequency EEG power, reflected the tracking structural boundaries regardless of temporal regularity. These findings demonstrate that musical segmentation depends fundamentally on implicit understanding of musical structure, rather than on temporal predictability alone.

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 11 matches between paragraphs and lines of code.

OSF btmxa

License: none: the authors keep all their rights
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Languages: MATLAB (18), R (3)
Size: 88 files, 21 scripts
Software Heritage: not checked
Found in: “Data Availability Statement”
Holds: README, 2 notebooks
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Psychtoolbox (7 files), boundedline (5 files), FieldTrip (5 files), ggplot2 (3 files), tidyverse (3 files), ggpubr (2 files), lme4 (2 files), psych (2 files), rstatix (2 files), Image Processing Toolbox (1 file), Signal Processing Toolbox (1 file), patchwork (1 file), reticulate (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
  • 28 September 2026: the link answers (HTTP 200)
22 files
At the source: osf.io/btmxa

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;
  • 21 scripts, each with its path and the digest of its content;
  • 11 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 Statement

Behavioral data, as well as preprocessed EEG data, stimuli, and preprocessing and analysis scripts are available at https://osf.io/btmxa. Raw EEG data is available upon request to the corresponding author (Z.A.H.).

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 2, 28 September 2026

  • Publisher: n/a → Wiley

Version 1, 28 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 3 authors, 5 keywords, 10 MeSH terms, 1 funder, 51 references.

Cite

This paper

Hołubowska, Z. A., Teng, X., & Larrouy‐Maestri, P. (2026). Neural and Behavioral Tracking of Musical Phrases Occurs Without Temporal Regularity. The European journal of neuroscience, 63(7), e70481. https://doi.org/10.1111/ejn.70481

BibTeX

@article{houbowska2026neural,
author = {Hołubowska, Zofia Anna and Teng, Xiangbin and Larrouy‐Maestri, Pauline},
title = {{Neural and Behavioral Tracking of Musical Phrases Occurs Without Temporal Regularity}},
journal = {The European journal of neuroscience},
year = {2026},
month = apr,
volume = {63},
number = {7},
pages = {e70481},
publisher = {Wiley},
issn = {0953-816X},
doi = {10.1111/ejn.70481},
url = {https://doi.org/10.1111/ejn.70481},
pmid = {41968537},
pmcid = {PMC13071237}
}

RIS

TY - JOUR
AU - Hołubowska, Zofia Anna
AU - Teng, Xiangbin
AU - Larrouy‐Maestri, Pauline
TI - Neural and Behavioral Tracking of Musical Phrases Occurs Without Temporal Regularity
T2 - The European journal of neuroscience
J2 - Eur J Neurosci
PY - 2026
DA - 2026/04/01
VL - 63
IS - 7
SP - e70481
SN - 0953-816X
PB - Wiley
DO - 10.1111/ejn.70481
UR - https://doi.org/10.1111/ejn.70481
LA - en
ER -

CSL-JSON

{
"id": "10.1111/ejn.70481",
"type": "article-journal",
"title": "Neural and Behavioral Tracking of Musical Phrases Occurs Without Temporal Regularity",
"container-title": "The European journal of neuroscience",
"author": [
{
"family": "Hołubowska",
"given": "Zofia Anna"
},
{
"family": "Teng",
"given": "Xiangbin"
},
{
"family": "Larrouy‐Maestri",
"given": "Pauline"
}
],
"container-title-short": "Eur J Neurosci",
"volume": "63",
"issue": "7",
"page": "e70481",
"DOI": "10.1111/ejn.70481",
"PMID": "41968537",
"PMCID": "PMC13071237",
"ISSN": "0953-816X",
"publisher": "Wiley",
"URL": "https://doi.org/10.1111/ejn.70481",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
1
]
]
}
}

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.1162/nol.a.249 [code]
How Low-Frequency Neural Activity Structures Language in Time.
Journal: Neurobiology of language (Cambridge, Mass.)
In common: FieldTrip, lme4, ggpubr, 3 other tools, cognitive, 5 references
[2] doi:10.1016/j.neuroimage.2026.122115 [code]
Midfrontal theta power relates to response speeding following frustrative nonreward.
Journal: NeuroImage
In common: psych, rstatix, lme4, 5 other tools, EEG, cognitive, 1 reference
[3] doi:10.1038/s41593-026-02345-6 [code]
Human hippocampal ripples tune cortical responses based on predicted uncertainty.
Journal: Nature neuroscience
In common: boundedline, FieldTrip, lme4, 4 other tools, cognitive, 2 references
[4] doi:10.1371/journal.pbio.3003979 [code]
Impaired midfrontal‑motor theta phase synchronization characterizes maladaptive motivational behavior in people with obsessive‑compulsive disorder.
Journal: PLoS biology
In common: boundedline, psych, FieldTrip, 3 other tools, EEG, 3 references
[5] doi:10.1016/j.isci.2026.116458 [code]
Neural tracking of prosodic and statistical rhythms jointly supports artificial language learning.
Journal: iScience
In common: Psychtoolbox, FieldTrip, lme4, 2 other tools, cognitive, 4 references
[6] doi:10.1038/s41467-026-74565-0 [code]
The functional neurobiology of dispositions towards negative emotions.
Journal: Nature communications
In common: boundedline, psych, FieldTrip, 5 other tools, cognitive
[7] doi:10.64898/2026.05.08.26348885 [code]
Insights from nine nights of self-applied, low-density sleep EEG during sleep restriction therapy: a proof-of-concept evaluation
Journal: medRxiv (preprint)
In common: rstatix, FieldTrip, lme4, 5 other tools, EEG, 1 reference
[8] doi:10.1162/imag.a.1245 [code]
Towards precision EEG connectomics: Evaluating the benefits of dense sampling.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: psych, rstatix, FieldTrip, 5 other tools, EEG
[9] doi:10.1016/j.nicl.2026.104012 [code]
Structural-functional multilayer brain network properties and outcome of combined repetitive transcranial magnetic stimulation and psychotherapy for obsessive-compulsive disorder.
Journal: NeuroImage. Clinical
In common: psych, rstatix, lme4, 5 other tools
[10] doi:10.1038/s41467-026-74331-2 [code]
Trial-by-trial fMRI-neurofeedback dissociates fusiform and occipital contributions to face detection and recognition.
Journal: Nature communications
In common: Psychtoolbox, rstatix, lme4, 4 other tools, 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.