OSCR

Hybrid spatial organization and evidence for magnitude-independent neural coding of linguistic information during sentence production.

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] § MATERIALS AND METHODS › Temporal warping ↔ code.zip/code/temporal warping/1 - simple linear stretch to median RT.R, lines 188–238 · score 0.64 · Temporal warping, speech onset, stimulus onset, median, outlier, epochs
  2. [2] § MATERIALS AND METHODS › Data collection and preprocessing ↔ code.zip/code/preprocessing/6_7_reference_hilbert_epoch.m, lines 237–255 · score 0.61 · spaced frequency bands, Hilbert, high gamma, 70 Hz, amplitude, 150 Hz
  3. [3] § MATERIALS AND METHODS › Temporal warping ↔ code.zip/code/temporal warping/1 - simple linear stretch to median RT.R, lines 188–238 · score 0.61 · median RT, speech onset, stimulus onset, epochs, temporally, warping

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 · 510 lines · 23 KB · CC-BY-4.0 · 2 matches

  1. ### Linearly interpolate the middle section (150ms post stim to 150ms pre speech) of all trials to have the same RT (i.e., median task RT)
  2. ### May 2023
  3. ### [email hidden]
  4. ###
  5. ### Readme
  6. ###
  7. ###
  8. ### Setup
  9. ###
  10. ### Packages
  11. library('dplyr') # for data organization, including bind_rows()
  12. # Clean up
  13. rm(list=ls())
  14. cat("\014")
  15. message("Begin stretching trials. ",Sys.time())
  16. ### Set path
  17. if(Sys.info()['sysname'] == 'Darwin'){ # Mac
  18. path = '/Users/adam/Dropbox/Research/ChickenSyntax/'
  19. n.cores.to.use = 4
  20. if(Sys.info()['nodename'] == 'FLINKERLABMBP06'){
  21. path = '/Users/am4611/Dropbox/Research/ChickenSyntax/'
  22. n.cores.to.use = 5
  23. }
  24. if(Sys.info()['nodename'] == 'FLINKERLABMS01'){
  25. path = '/Users/am4611/Dropbox/Research/ChickenSyntax/'
  26. n.cores.to.use = 15
  27. }
  28. }
  29. if(Sys.info()['sysname'] == 'Linux'){ # Ubuntu
  30. path = '/home/adam/Dropbox/Research/ChickenSyntax/'
  31. n.cores.to.use = 40
  32. }
  33. ### Lemmas
  34. # Function to convert between samples, sample labels, and times
  35. source(paste0(path,'/analysis/R/functions/time_convert.R'))
  36. # Function for rolling average smoothing
  37. source(paste0(path,'/analysis/R/functions/smoothing.R'))
  38. # Close any old parallel backends
  39. source(paste0(path,'/analysis/R/functions/unregister_dopar.R'))
  40. # Subset to just good picture naming trials
  41. source(paste0(path,'/analysis/R/functions/just_good_trial_functions.R'))
  42. # Plot time series
  43. source(paste0(path,'/analysis/R/functions/plot_time_series.R'))
  44. # Add colored text to plots
  45. source(paste0(path,'/analysis/R/functions/add_text_line_multiple_colors.R'))
  46. set.seed(seed = 404)
  47. # Data type:
  48. for(freq.band.loop in c('high_gamma','beta')){
  49. # freq.band.loop = c('high_gamma','beta')[1]
  50. freq.band.read.path <- list('high_gamma' = 'z_scored', 'beta' = 'z_scored_beta')[[freq.band.loop]]
  51. # Type of hilbert transform
  52. hilbert.type <- 'multiband'
  53. ## Metadata
  54. patients = c('Patient001',
  55. 'Patient002',
  56. 'Patient003', # slow PN RTs; check closely
  57. 'Patient004',
  58. 'Patient005',
  59. 'Patient006', # slow PN RTs; check closely
  60. 'Patient007',
  61. 'Patient008', # slow PN RTs and generally weird
  62. 'Patient009',
  63. 'Patient010')
  64. ## Tasks
  65. tasks <- c('pn','sp','lp')
  66. ## Plot stuff:
  67. load(paste0(path,'analysis/R/color palettes/output/all palettes.RData'))
  68. text.size.big = 1.6
  69. text.size.med = 1.4
  70. text.size.small = 1.2
  71. zoom = 2
  72. # Elec MNI coords, etc.
  73. elec.info <-
  74. read.csv(paste0(path,
  75. '/analysis/R/brain plots/ecog/output/data/elec info/patients - combined/row_labels_and_localizations.csv'))
  76. elec.info$use.these.elecs <-
  77. as.numeric((! elec.info$region_clinical %in% c('Unknown',
  78. '',
  79. 'NaN',
  80. 'Left-Cerebral-White-Matter',
  81. 'Left-Inf-Lat-Vent',
  82. 'Right-Cerebral-White-Matter')) &
  83. (elec.info$bad_elec == 0) &
  84. (elec.info$visual_elec == 0) &
  85. (elec.info$active == 1))
  86. rownames(elec.info) <- elec.info$patient_elec
  87. use.these.elecs <- elec.info[elec.info$use.these.elecs == 1,]$patient_elec
  88. ## Get all trial info across patients in one dataframe to analyze RTs:
  89. # Define range of RTs per patient to use
  90. rt.quantile.range <- c(.025, .95) # .025 just to get rid of weird fast trials (e.g., second of two 'nurse' trials in a row?) and .8 because long tail, probably reflecing lots of different things, so get rid of a bunch. shouldn't matter long-run, still a decent amount of data for NMF clustering
  91. ### Load trial labels
  92. # Initialize storage
  93. trial.info <- list()
  94. for(task.loop in c(tasks,'all')){
  95. trial.info[[task.loop]] <- list()
  96. }; rm(task.loop)
  97. # Loop thru patients and load data
  98. for(patient in rev(patients)){
  99. # patient = patients[1]
  100. print(patient)
  101. # Load data
  102. trial.info[['all']][[patient]] <- read.csv(paste0(path,
  103. 'data/',patient,'/data/epoched/',patient,'_trial_labels_without_bad_trials.csv'))
  104. trial.info[['all']][[patient]]$patient <- patient
  105. trial.info[['all']][[patient]]$rt <- time.convert(trial.info[['all']][[patient]]$production_latency,
  106. "samples", "times")
  107. # Separate by task
  108. trial.info[['pn']][[patient]] <-
  109. just.good.pic.naming(trial.info[['all']][[patient]],
  110. .remove.outliers = TRUE,
  111. .rt.quantile.range = rt.quantile.range)
  112. trial.info[['sp']][[patient]] <-
  113. just.first.word.sentence.data(trial.info[['all']][[patient]],
  114. .remove.outliers = TRUE,
  115. .rt.quantile.range = rt.quantile.range)
  116. trial.info[['lp']][[patient]] <-
  117. just.first.word.list.data(trial.info[['all']][[patient]],
  118. .remove.outliers = TRUE,
  119. .rt.quantile.range = rt.quantile.range)
  120. }; rm(patient)
  121. # Clean up
  122. trial.info$all <- NULL
  123. trial.info[['pn']] <- data.frame(bind_rows(trial.info[['pn']]))
  124. trial.info[['sp']] <- data.frame(bind_rows(trial.info[['sp']]))
  125. trial.info[['lp']] <- data.frame(bind_rows(trial.info[['lp']][patients[patients != 'Patient006']]))
  126. ## Get median RT by tasks -- i.e., target RT for all adjusted trials
  127. half.median.rt.samples <- round(sapply(trial.info, function(x){median(x$production_latency)}) / 2)
  128. median.rt.samples <- 2 * half.median.rt.samples # double rounded halves so always even
  129. # Windows of data keep (i.e., not stretch) pre-stim and post-speech
  130. stimulus.samples.range <- c(time.convert(-500, "times", "samples"), time.convert(150, "times", "samples"))
  131. production.samples.range <- c(time.convert(-150, "times", "samples"), time.convert(1200, "times", "samples"))
  132. stimulus.samples <- stimulus.samples.range[1]:stimulus.samples.range[2]
  133. production.samples <- production.samples.range[1]:production.samples.range[2]
  134. stimulus.sample.labels <- time.convert(
  135. stimulus.samples,
  136. "samples", "sample.labels")
  137. production.sample.labels <- time.convert(
  138. production.samples,
  139. "samples", "sample.labels")
  140. ### Read in data from both time-locks
  141. stretch.data <- list()
  142. patient.trial.info <- list()
  143. elec.means.pre.post <- list()
  144. elec.mean.maxes.pre.post <- list()
  145. for(patient in rev(patients)){
  146. # patient = patients[1]
  147. # Initialize storage
  148. data <- list()
  149. keep.data.stimulus <- list()
  150. keep.data.production <- list()
  151. for(lock.loop in c('locked_to_stimulus_onset','locked_to_production_onset')){
  152. #lock.loop <- c('locked_to_production_onset','locked_to_stimulus_onset')[2]
  153. # Storage
  154. data[[lock.loop]] <- list()
  155. # Progress update
  156. message(patient,": Loading ",lock.loop," data. ",Sys.time())
  157. # Number of linguistic columns
  158. n.lx.cols = read.table(paste0(path,'data/',patient,'/data/epoched/',patient,'_n_linguistic_columns.txt'))[1,1]
  159. # Where data?
  160. data.dir <- paste0(path,'data/',
  161. patient,
  162. '/data/epoched/elec_data_without_bad_trials/',hilbert.type,'/',
  163. lock.loop,'/', # always train on data locked to stimulus onset since we care about early stages!
  164. freq.band.read.path,'/')
  165. # Read in data
  166. message('Attach...')
  167. attach(paste0(data.dir, patient,' elec data.RData')) # reads in list "all.data"
  168. data[[lock.loop]][['all']] <- all.data
  169. detach()
  170. message('...detach!')
  171. ## Limit trials to inner range of RTs
  172. data[[lock.loop]][['pn']] <- lapply(data[[lock.loop]][['all']], function(x){
  173. just.good.pic.naming(x, .remove.outliers = TRUE, .rt.quantile.range = rt.quantile.range)})
  174. data[[lock.loop]][['sp']] <- lapply(data[[lock.loop]][['all']], function(x){
  175. just.first.word.sentence.data(x, .remove.outliers = TRUE, .rt.quantile.range = rt.quantile.range)})
  176. data[[lock.loop]][['lp']] <- lapply(data[[lock.loop]][['all']], function(x){
  177. just.first.word.list.data(x, .remove.outliers = TRUE, .rt.quantile.range = rt.quantile.range)})
  178. # Clean up
  179. data[[lock.loop]][['all']] <- NULL
  180. }; rm(lock.loop)
  181. ## Set aside the "keep" data -- pre-stim and post-speech onsets (with a little extra from the middle)
  182. patient.trial.info[[patient]] <- list()
  183. for(task.loop in tasks){
  184. # task.loop = tasks[1]
  185. # Store the trial info (linguistic columns) for this patient
  186. patient.trial.info[[patient]][[task.loop]] <-
  187. data[['locked_to_production_onset']][[task.loop]][[1]][,1:n.lx.cols]
  188. # Get the "keep" data
  189. keep.data.stimulus[[task.loop]] <-
  190. lapply(data[['locked_to_stimulus_onset']][[task.loop]], function(x){
  191. x <- x[,stimulus.sample.labels]
  192. colnames(x) <- paste0('stim.',colnames(x)) # make unique column names to avoid duplicates
  193. return(x)
  194. })
  195. keep.data.production[[task.loop]] <-
  196. lapply(data[['locked_to_production_onset']][[task.loop]], function(x){
  197. x <- x[,production.sample.labels]
  198. colnames(x) <- paste0('prod.',colnames(x)) # make unique column names to avoid duplicates
  199. return(x)
  200. })
  201. # Remove the linguistic trial data from the data to be stretched
  202. for(lock.loop in c('locked_to_stimulus_onset','locked_to_production_onset')){
  203. data[[lock.loop]][[task.loop]] <-
  204. lapply(data[[lock.loop]][[task.loop]], function(x){
  205. x[,-c(1:n.lx.cols)]
  206. })
  207. }; rm(lock.loop)
  208. # Remove the "keep" data (and any even earlier/later than stimulus/production) from the data to be stretched
  209. data[['locked_to_stimulus_onset']][[task.loop]] <-
  210. lapply(data[['locked_to_stimulus_onset']][[task.loop]], function(x){
  211. x[,-which(time.convert(colnames(x), "sample.labels", "samples") <= max(stimulus.samples))]
  212. })
  213. data[['locked_to_production_onset']][[task.loop]] <-
  214. lapply(data[['locked_to_production_onset']][[task.loop]], function(x){
  215. x[,-which(time.convert(colnames(x), "sample.labels", "samples") >= min(production.samples))]
  216. })
  217. }; rm(task.loop)
  218. ### Set up metadata for stretching data
  219. # Electrodes
  220. elecs <- names(data$locked_to_stimulus_onset$pn)
  221. # Target number of samples
  222. stim.n.samples.out <- half.median.rt.samples - stimulus.samples.range[2]
  223. prod.n.samples.out <- half.median.rt.samples - (-production.samples.range[1])
  224. # Save names for the final, stretched sample labels
  225. stretch.sample.labels <- list()
  226. for(task.loop in tasks){ # task.loop = tasks[1]
  227. stretch.sample.labels[[task.loop]] <- list()
  228. # Get samples
  229. stretch.sample.labels[[task.loop]][['locked_to_stimulus_onset']] <- c(
  230. stimulus.samples.range[1]:(median.rt.samples[[task.loop]] + production.samples.range[2] + 1)
  231. )
  232. stretch.sample.labels[[task.loop]][['locked_to_production_onset']] <- c(
  233. stretch.sample.labels[[task.loop]][['locked_to_stimulus_onset']] - median.rt.samples[[task.loop]]
  234. )
  235. # Convert to sample labels
  236. stretch.sample.labels[[task.loop]][['locked_to_stimulus_onset']] <-
  237. time.convert(stretch.sample.labels[[task.loop]][['locked_to_stimulus_onset']],
  238. "samples", "sample.labels")
  239. stretch.sample.labels[[task.loop]][['locked_to_production_onset']] <-
  240. time.convert(stretch.sample.labels[[task.loop]][['locked_to_production_onset']],
  241. "samples", "sample.labels")
  242. }; rm(task.loop)
  243. ### For each trial, get the "stretch" data as a single list entry -- but *just* the data from 150ms post-stim to 150ms pre-production
  244. # Take the first half from the stim-locked data and second half from the prod-locked data to cover cases where the RT is longer than the epoch
  245. stretch.data[[patient]] <- list()
  246. for(task.loop in tasks){
  247. # task.loop = tasks[3]
  248. message(patient,': Beginning stretching of ',task.loop,' data. ',Sys.time())
  249. # Loop thru elecs
  250. stretch.data[[patient]][[task.loop]] <- list()
  251. for(elec.loop in elecs){
  252. # elec.loop = elecs[1]
  253. .n.trials <- nrow(patient.trial.info[[patient]][[task.loop]])
  254. if(.n.trials == 0){
  255. stretch.data[[patient]][[task.loop]][[elec.loop]]
  256. }else{
  257. # Loop thru trials and interpolate
  258. stretch.data[[patient]][[task.loop]][[elec.loop]] <- list()
  259. for(trial.loop in 1:nrow(patient.trial.info[[patient]][[task.loop]])){
  260. # trial.loop = 1
  261. # Get all the samples from 1 to production onset
  262. .rt.samples <- patient.trial.info[[patient]][[task.loop]]$production_latency[trial.loop]
  263. .all.rt.samples <- (stimulus.samples.range[2] + 1) : (.rt.samples + production.samples.range[1] - 1)
  264. .stim.locked.samples <-
  265. time.convert(.all.rt.samples[c(1:floor(length(.all.rt.samples) / 2))],
  266. "samples", "sample.labels")
  267. .prod.locked.samples <-
  268. time.convert(.all.rt.samples[-c(1:floor(length(.all.rt.samples) / 2))] - .rt.samples,
  269. "samples", "sample.labels")
  270. # Verify that the value at t=0 prod-locked is the same as the value at the RT stim-locked
  271. if(! all(round(data[['locked_to_stimulus_onset']][[task.loop]][[elec.loop]][
  272. trial.loop, c(.stim.locked.samples[length(.stim.locked.samples)],
  273. time.convert(time.convert(.stim.locked.samples[length(.stim.locked.samples)],
  274. "sample.labels", "samples") + 1,
  275. "samples", "sample.labels"))], 6) ==
  276. round(data[['locked_to_production_onset']][[task.loop]][[elec.loop]][
  277. trial.loop, c(time.convert(time.convert(.prod.locked.samples[1],
  278. "sample.labels", "samples") - 1,
  279. "samples", "sample.labels"),
  280. .prod.locked.samples[1])], 6))){
  281. message('WARNING!!! Stim- and prod-locked data not the same!')
  282. }
  283. # Interpolate
  284. .stim.locked.interpolated.data <-
  285. approx(x = time.convert(.stim.locked.samples, "sample.labels", "samples"),
  286. y = unlist(data[['locked_to_stimulus_onset']][[task.loop]][[elec.loop]][trial.loop, .stim.locked.samples]),
  287. n = stim.n.samples.out[[task.loop]])$y
  288. .prod.locked.interpolated.data <-
  289. approx(x = time.convert(.prod.locked.samples, "sample.labels", "samples"),
  290. y = unlist(data[['locked_to_production_onset']][[task.loop]][[elec.loop]][trial.loop, .prod.locked.samples]),
  291. n = prod.n.samples.out[[task.loop]])$y
  292. # Turn into a dataframe
  293. .stim.locked.interpolated.data <- data.frame(matrix(.stim.locked.interpolated.data, nrow = 1))
  294. .prod.locked.interpolated.data <- data.frame(matrix(.prod.locked.interpolated.data, nrow = 1))
  295. colnames(.stim.locked.interpolated.data) <- paste0('stim.', 1:stim.n.samples.out[[task.loop]])
  296. colnames(.prod.locked.interpolated.data) <- paste0('prod.', 1:prod.n.samples.out[[task.loop]])
  297. stretch.data[[patient]][[task.loop]][[elec.loop]][[trial.loop]] <-
  298. cbind(.stim.locked.interpolated.data, .prod.locked.interpolated.data)
  299. rm(.stim.locked.interpolated.data, .prod.locked.interpolated.data, .rt.samples, .all.rt.samples, .stim.locked.samples, .prod.locked.samples)
  300. }; rm(trial.loop)
  301. # Recombine trials into dataframe
  302. stretch.data[[patient]][[task.loop]][[elec.loop]] <- bind_rows(stretch.data[[patient]][[task.loop]][[elec.loop]])
  303. # Add stim-locked prod-locked data back in
  304. stretch.data[[patient]][[task.loop]][[elec.loop]] <- cbind(
  305. keep.data.stimulus[[task.loop]][[elec.loop]],
  306. stretch.data[[patient]][[task.loop]][[elec.loop]],
  307. keep.data.production[[task.loop]][[elec.loop]]
  308. )
  309. colnames(stretch.data[[patient]][[task.loop]][[elec.loop]]) <- stretch.sample.labels[[task.loop]][['locked_to_production_onset']]
  310. } # if(.n.trials > 0){
  311. }; rm(elec.loop)
  312. }; rm(task.loop)
  313. ### Visual check
  314. ## Plot random trials
  315. save.fig.path <- paste0(path,
  316. 'analysis/R/warp time series to standard RT/simple linear stretch to median RT/output - ',
  317. freq.band.loop,
  318. '/figures/',patient,'/')
  319. save.fig.path.trial <- paste0(save.fig.path, 'randomly sampled trials/')
  320. save.fig.path.mean <- paste0(save.fig.path, 'elec means/')
  321. dir.create(save.fig.path.trial, showWarnings = FALSE, recursive = TRUE)
  322. dir.create(save.fig.path.mean, showWarnings = FALSE, recursive = TRUE)
  323. elec.means.pre.post[[patient]] <- list()
  324. elec.mean.maxes.pre.post[[patient]] <- list()
  325. for(task.loop in tasks){
  326. # task.loop = tasks[1]
  327. elec.means.pre.post[[patient]][[task.loop]] <- list()
  328. elec.mean.maxes.pre.post[[patient]][[task.loop]] <- list()
  329. for(elec.loop in elecs){
  330. # elec.loop = elecs[3]
  331. ## Compare difference between [mean unstretched signal] & [mean stretched signal] as a function of signal:
  332. # low signal (noise) the should get lower (noise reduction)
  333. # high signal should get higher if this stretching approach isn't muddying things
  334. .n.trials <- nrow(patient.trial.info[[patient]][[task.loop]])
  335. if(.n.trials > 0){ # if they completed any trials this task (Patient006 didn't do listing block)
  336. # Samples to compare
  337. samples.to.compare <-
  338. time.convert((-(median.rt.samples[task.loop] - stimulus.samples.range[2] - 1)):
  339. (production.samples.range[1]),
  340. "samples", "sample.labels")
  341. # Stretched data
  342. .stretch.mean <- colMeans(stretch.data[[patient]][[task.loop]][[elec.loop]])
  343. .stretch.peak.time <-
  344. time.convert(names(which.max(abs(.stretch.mean))),
  345. "sample.labels", "times")
  346. # Means
  347. elec.means.pre.post[[patient]][[task.loop]][[elec.loop]] <-
  348. data.frame('sample.label' = samples.to.compare,
  349. 'elec' = elec.loop,
  350. 'task' = task.loop,
  351. 'localization' = elec.info[elec.loop, 'region_clinical'],
  352. 'stretch.mean' = abs(.stretch.mean[samples.to.compare]),
  353. row.names = NULL)
  354. # Maxes
  355. elec.mean.maxes.pre.post[[patient]][[task.loop]][[elec.loop]] <-
  356. data.frame('patient' = patient,
  357. 'elec' = elec.loop,
  358. 'task' = task.loop,
  359. 'localization' = elec.info[elec.loop, 'region_clinical'],
  360. 'stretch.max' = max(abs(.stretch.mean[samples.to.compare]), na.rm = TRUE),
  361. 'stretch.peak.time' = .stretch.peak.time,
  362. row.names = NULL)
  363. for(lock.loop in c('locked_to_production_onset','locked_to_stimulus_onset')){
  364. # lock.loop in c('locked_to_production_onset','locked_to_stimulus_onset')[1]
  365. # Redefine samples to compare if stim-locked
  366. if(lock.loop == 'locked_to_stimulus_onset'){
  367. samples.to.compare <-
  368. time.convert((stimulus.samples.range[2]):
  369. (median.rt.samples[task.loop] + production.samples.range[1] - 1),
  370. "samples", "sample.labels")
  371. } # if(lock.loop == 'locked_to_stimulus_onset'){
  372. # Get mean of OG data locked to lock.loop
  373. .original.mean <- colMeans(data[[lock.loop]][[task.loop]][[elec.loop]])
  374. .original.peak.time <-
  375. time.convert(names(which.max(abs(.original.mean))),
  376. "sample.labels", "times")
  377. # Store original mean and peak
  378. elec.means.pre.post[[patient]][[task.loop]][[elec.loop]][,paste0('original.mean_',lock.loop)] <-
  379. abs(.original.mean[samples.to.compare])
  380. elec.mean.maxes.pre.post[[patient]][[task.loop]][[elec.loop]][,paste0('original.max_',lock.loop)] <-
  381. max(abs(.original.mean[samples.to.compare]), na.rm = TRUE)
  382. elec.mean.maxes.pre.post[[patient]][[task.loop]][[elec.loop]][,paste0('original.peak.time_',lock.loop)] <- .original.peak.time
  383. rm(.original.mean)
  384. }; rm(lock.loop)
  385. } # if(.n.trials > 0)
  386. }; rm(elec.loop)
  387. }; rm(task.loop)
  388. ### Clean up
  389. elec.means.pre.post[[patient]] <-
  390. bind_rows(lapply(elec.means.pre.post[[patient]], function(x){bind_rows(x)}))
  391. elec.mean.maxes.pre.post[[patient]] <-
  392. lapply(elec.mean.maxes.pre.post[[patient]], bind_rows)
  393. ### Remove the "keep" data from the "adjust" data
  394. rm(data, keep.data.stimulus, keep.data.production)
  395. }; rm(patient)
  396. ###
  397. ### Save data
  398. ###
  399. ### Save all data
  400. save.these <- c(
  401. 'patient.trial.info',
  402. 'median.rt.samples',
  403. 'stretch.data',
  404. 'stretch.sample.labels',
  405. 'elec.mean.maxes.pre.post'
  406. )
  407. save.data.path <- paste0(path,'analysis/R/warp time series to standard RT/simple linear stretch to median RT/output - ',
  408. freq.band.loop,
  409. '/data/')
  410. dir.create(save.data.path, showWarnings = FALSE, recursive = TRUE)
  411. save(list = save.these,
  412. file = paste0(save.data.path,'elec data with RTs stretched to global median by task - bad trials and .025 to .95 RT outliers excluded.RData'))
  413. ### Save just median.rt.samples
  414. save.data.path <- paste0(path,'analysis/R/warp time series to standard RT/simple linear stretch to median RT/output/data/')
  415. dir.create(save.data.path, showWarnings = FALSE, recursive = TRUE)
  416. save(median.rt.samples,
  417. file = paste0(save.data.path,'median RT samples.RData'))
  418. ### Save just stretch sample labels
  419. save.data.path <- paste0(path,'analysis/R/warp time series to standard RT/simple linear stretch to median RT/output/data/')
  420. dir.create(save.data.path, showWarnings = FALSE, recursive = TRUE)
  421. save(stretch.sample.labels,
  422. file = paste0(save.data.path,'warped sample labels.RData'))
  423. } # freq.band.loop
  424. # Finish!
  425. message('Script completed successfully. ',Sys.time())

1 - simple linear stretch to median RT.R, under CC-BY-4.0 · at the source

Overview

  1. Department of Neurology, NYU Grossman School of Medicine, New York, NY 10016, USA
  2. Department of Neurosurgery, NYU Grossman School of Medicine, New York, NY 10016, USA
  3. Department of Biomedical Engineering, NYU Tandon School of Engineering, New York, NY 11201, USA
Institutions: New York University (United States)
Journal: Science advances, volume 12, issue 32, article eaec0518
Dates: received 5 September 2025; accepted 1 July 2026; published online 5 August 2026; in print August 2026
Type: Research article · Language: English
License: CC BY-NC
Identifiers: DOI 10.1126/sciadv.aec0518 · PMID 42555736 · PMCID PMC13440437 · OpenAlex W7172481444
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: intracranial EEG (iEEG / ECoG / SEEG) (modality), human (organism), systems (subfield)
Methods: Statistics, Spectral & time-frequency, Preprocessing, Machine learning, fMRI & imaging
MeSH: Language*, Linguistics*, Nerve Net*, Brain Mapping, Electrocorticography, Humans, Semantics (* major topic)
Topic: Neurobiology of Language and Bilingualism (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: NINDS NIH HHS (R01 NS109367, R01 NS115929); NIDCD NIH HHS (F32 DC019533, R01 DC018805)
Citations: not cited yet (Europe PMC); 152 references in the paper

Abstract

Humans are the only species with the ability to systematically combine words to convey an unbounded number of complex meanings. This process is guided by combinatorial processes whose underlying neural mechanisms remain obscured by inherent limitations of noninvasive brain measures and a near-total focus on comprehension paradigms. Here, we address these limitations with high-resolution neurosurgical recordings (electrocorticography) and a controlled sentence production experiment. We uncover distinct cortical networks encoding word-level and higher-order information. These networks exhibited a hybrid spatial organization: broadly distributed across traditional language areas but with focal concentrations of sensitivity to semantic and structural contrasts in canonical language regions. In contrast to previous comprehension-based findings, we find that these networks are largely nonoverlapping. Most notably, higher-order linguistic information showed an unexpected dissociation from local activity magnitude. This result establishes an operational dissociation between activity magnitude and information content, pointing toward a potentially distinct neural coding scheme for higher-order language, with important implications for the neurobiology of language.

Reproduced under the paper's license (CC BY-NC), 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.

Zenodo 20543385

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 5 files
Software Heritage: not checked
Found in: “Data, code, and materials availability:”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: tidyverse (22 files), caret (14 files), BayesFactor (2 files), lme4 (2 files), lmerTest (2 files), reticulate (2 files), EEGLAB (1 file), Parallel Computing Toolbox (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
41 files

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;
  • 40 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, code, and materials availability

All data, and code needed to evaluate and reproduce the results in the paper are present in the paper, the Supplementary Materials, and/or on Zenodo under the following DOI: https://doi.org/10.5281/zenodo.20543385. This study did not generate new materials.

Reproduced under the paper's license (CC BY-NC), 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, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 7 MeSH terms, 2 funders, 126 references.

Cite

This paper

Morgan, A. M., Devinsky, O., Doyle, W. K., Dugan, P., Friedman, D., & Flinker, A. (2026). Hybrid spatial organization and evidence for magnitude-independent neural coding of linguistic information during sentence production. Science advances, 12(32), eaec0518. https://doi.org/10.1126/sciadv.aec0518

BibTeX

@article{morgan2026hybrid,
author = {Morgan, Adam M and Devinsky, Orrin and Doyle, Werner K and Dugan, Patricia and Friedman, Daniel and Flinker, Adeen},
title = {{Hybrid spatial organization and evidence for magnitude-independent neural coding of linguistic information during sentence production}},
journal = {Science advances},
year = {2026},
month = aug,
volume = {12},
number = {32},
pages = {eaec0518},
publisher = {American Association for the Advancement of Science},
issn = {2375-2548},
doi = {10.1126/sciadv.aec0518},
url = {https://doi.org/10.1126/sciadv.aec0518},
pmid = {42555736},
pmcid = {PMC13440437}
}

RIS

TY - JOUR
AU - Morgan, Adam M
AU - Devinsky, Orrin
AU - Doyle, Werner K
AU - Dugan, Patricia
AU - Friedman, Daniel
AU - Flinker, Adeen
TI - Hybrid spatial organization and evidence for magnitude-independent neural coding of linguistic information during sentence production
T2 - Science advances
J2 - Sci Adv
PY - 2026
DA - 2026/08/05
VL - 12
IS - 32
SP - eaec0518
SN - 2375-2548
PB - American Association for the Advancement of Science
DO - 10.1126/sciadv.aec0518
UR - https://doi.org/10.1126/sciadv.aec0518
LA - en
ER -

CSL-JSON

{
"id": "10.1126/sciadv.aec0518",
"type": "article-journal",
"title": "Hybrid spatial organization and evidence for magnitude-independent neural coding of linguistic information during sentence production",
"container-title": "Science advances",
"author": [
{
"family": "Morgan",
"given": "Adam M"
},
{
"family": "Devinsky",
"given": "Orrin"
},
{
"family": "Doyle",
"given": "Werner K"
},
{
"family": "Dugan",
"given": "Patricia"
},
{
"family": "Friedman",
"given": "Daniel"
},
{
"family": "Flinker",
"given": "Adeen"
}
],
"container-title-short": "Sci Adv",
"volume": "12",
"issue": "32",
"page": "eaec0518",
"DOI": "10.1126/sciadv.aec0518",
"PMID": "42555736",
"PMCID": "PMC13440437",
"ISSN": "2375-2548",
"publisher": "American Association for the Advancement of Science",
"URL": "https://doi.org/10.1126/sciadv.aec0518",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
5
]
]
}
}

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-73947-8 [code]
Frontal cortex organization supporting audiovisual processing during naturalistic viewing.
Journal: Nature communications
In common: intracranial EEG (iEEG / ECoG / SEEG), 7 references, 2 authors
[2] doi:10.1162/nol.a.254
A Unified Neural Time Course for Words, Phrases, and Sentences: MEG Evidence from Parallel Presentation.
Journal: Neurobiology of language (Cambridge, Mass.)
In common: 12 references
[3] doi:10.1038/s41467-026-75745-8 [code]
A language network in the individualized functional connectomes of 1199 human brains doing arbitrary tasks.
Journal: Nature communications
In common: 11 references
[4] doi:10.1162/nol.a.264 [code]
The Temporal Dynamics of the Labeling Algorithm During Natural Language Comprehension: Neural Evidence for Phrase Grammatical Type Generation.
Journal: Neurobiology of language (Cambridge, Mass.)
In common: lmerTest, lme4, 9 references
[5] doi:10.1038/s41586-026-10691-5 [code]
Mapping the neuronal building blocks of human language with language models.
Journal: Nature
In common: 10 references
[6] doi:10.1038/s41467-026-75359-0 [code]
Neural mechanisms of time-forward predictions for naturalistic auditory tone sequences.
Journal: Nature communications
In common: 3 references, 2 authors
[7] doi:10.1038/s41467-026-76598-x
Preserved topography, lateralization, selectivity, and functional connectivity of the language network in older brains.
Journal: Nature communications
In common: 8 references
[8] doi:10.1162/imag.a.1246 [code]
A 3.5-minute-long reading-based fMRI localizer for the language network.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: lmerTest, lme4, tidyverse, 5 references
[9] doi:10.1111/cogs.70220 [code]
Shared Neural Computations for Syntactic and Morphological Structures: Evidence From Mandarin Chinese.
Journal: Cognitive science
In common: EEGLAB, 6 references
[10] doi:10.1162/imag.a.1201 [code]
All spectral frequencies of neural activity reveal semantic representation in the human anterior ventral temporal cortex.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: EEGLAB, Parallel Computing Toolbox, tidyverse, intracranial EEG (iEEG / ECoG / SEEG), 3 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.

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.