OSCR

Cross-domain encoding models reveal shared and domain-specific neural representations across language and mathematics.

Code ↔ Paper

6 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.

5 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.

The 6 matches
  1. [1] § MATERIALS AND METHODS › Functional connectivity analyses ↔ LM_FC_TestData.py, lines 316 to 369 · score 0.73 · right hemisphere, left hemisphere, MNE Connectivity, ROI, math · block oscr:b:0YE8T0GZD270A-E · Report a mismatch
  2. [2] § MATERIALS AND METHODS › Functional connectivity analyses ↔ LM_FC_TestPred.py, lines 384 to 438 · score 0.72 · right hemisphere, left hemisphere, MNE Connectivity, ROI · block oscr:b:PRNJ20VJYAXEW-E · Report a mismatch
  3. [3] § MATERIALS AND METHODS › Feature extraction ↔ LM_MakeFeatures_LLM.py, lines 60 to 121 · score 0.64 · GPT NeoX, LLM jp, RakutenAI2, Gemma2, layers, models · block oscr:b:AVXKZFSNHD1ES-Q · Report a mismatch
  4. [4] § RESULTS › Cross-domain prediction extends beyond simple visual or memory factors and is reproducible across different LLMs ↔ LM_MakeFeatures_LLM.py, lines 207 to 276 · score 0.62 · GPT NeoX, LLM jp, RakutenAI2, Gemma2, Llama3, encoding · block oscr:b:BPY07ZFPGMN4P-D · Report a mismatch
  5. [5] § MATERIALS AND METHODS › Preprocessing ↔ LM_VertexRidge_Train.py, lines 20 to 65 · score 0.62 · remove motor, temporal delay, regression, filtering, training, components · block oscr:b:ZZSPZAXX89TC3-2 · Report a mismatch
  6. [6] § MATERIALS AND METHODS › Vertex-wise encoding model fitting ↔ LM_VertexRidge_Train.py, lines 20 to 65 · score 0.60 · cross validation, temporal delays, regression, training, vertex, weight · block oscr:b:ZZSPZAXX89TC3-2 · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 787 lines · 32 KB · CC-BY-4.0 · 2 matches

  1. import numpy as np
  2. import os
  3. import csv
  4. import sys
  5. from scipy.signal import decimate
  6. import copy
  7. targ_layer = int(sys.argv[1])
  8. print("Target layer: ", targ_layer)
  9. model_name = "Llama3"
  10. from transformers import AutoTokenizer, AutoModelForCausalLM
  11. model = AutoModelForCausalLM.from_pretrained("elyza/Llama-3-ELYZA-JP-8B", output_hidden_states=True)
  12. tokenizer = AutoTokenizer.from_pretrained("elyza/Llama-3-ELYZA-JP-8B")
  13. #model_name = "GPT-Neox"
  14. #from transformers import GPTNeoXJapaneseTokenizer, GPTNeoXJapaneseModel
  15. #model = GPTNeoXJapaneseModel.from_pretrained("abeja/gpt-neox-japanese-2.7b", output_hidden_states=True)
  16. #tokenizer = GPTNeoXJapaneseTokenizer.from_pretrained("abeja/gpt-neox-japanese-2.7b")
  17. #model_name = "Gemma2"
  18. #from transformers import AutoTokenizer, AutoModelForCausalLM
  19. #token = "XXXYYYZZZ"
  20. #tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-jpn-it", token=token)
  21. #model = AutoModelForCausalLM.from_pretrained("google/gemma-2-2b-jpn-it", output_hidden_states=True, token=token)
  22. #model_name = "Qwen25"
  23. #from transformers import AutoTokenizer, AutoModelForCausalLM
  24. #model = AutoModelForCausalLM.from_pretrained("abeja/ABEJA-Qwen2.5-7b-Japanese-v0.1", output_hidden_states=True)
  25. #tokenizer = AutoTokenizer.from_pretrained("abeja/ABEJA-Qwen2.5-7b-Japanese-v0.1")
  26. #model_name = "RakutenAI2"
  27. #from transformers import AutoTokenizer, AutoModelForCausalLM
  28. #model = AutoModelForCausalLM.from_pretrained("Rakuten/RakutenAI-2.0-8x7B", output_hidden_states=True)
  29. #tokenizer = AutoTokenizer.from_pretrained("Rakuten/RakutenAI-2.0-8x7B")
  30. #model_name = "LLM-jp"
  31. #from transformers import AutoTokenizer, AutoModelForCausalLM
  32. #model = AutoModelForCausalLM.from_pretrained("llm-jp/llm-jp-3-13b", output_hidden_states=True)
  33. #tokenizer = AutoTokenizer.from_pretrained("llm-jp/llm-jp-3-13b")
  34. n_dim_pca_initial = 300
  35. n_dim_pca = 100
  36. curr_dir = os.getcwd()
  37. stim_dir = curr_dir + "/Stimuli"
  38. feature_dir = curr_dir + "/Features"
  39. np.random.seed(1234)
  40. def find_subsequence_last(seq, subseq):
  41. """Return the starting index of the last occurrence of subseq in seq. Return -1 if not found."""
  42. L, l = len(seq), len(subseq)
  43. for s in range(L - l, -1, -1):
  44. if seq[s:s+l] == subseq:
  45. return s
  46. return -1
  47. #Language
  48. print(" Loading Lang training data...")
  49. targ_out_lang = []
  50. for targ_run in range(4): #Use 5th run as test run, 1 to 4th runs are used for training
  51. print(targ_run)
  52. with open(os.path.join(stim_dir, "LangStim_Run0{:d}.csv".format(targ_run+1)), encoding="shift-jis") as f:
  53. reader = csv.reader(f)
  54. stim_all = [row for row in reader]
  55. EPS = 1e-12
  56. for targ_stim in range(len(stim_all)):
  57. print(' ', targ_stim)
  58. # Temporarily store embeddings within a sentence/trial
  59. targ_out_sent = []
  60. text_len = len(stim_all[targ_stim])
  61. for within_text_pos in range(text_len):
  62. # Build the incremental context (w1..wk) in the forward direction
  63. prefix_words = stim_all[targ_stim][0:(within_text_pos + 1)]
  64. input_text = ' '.join(prefix_words)
  65. # Word newly presented at this step
  66. target_word = stim_all[targ_stim][within_text_pos]
  67. # Tokenizer
  68. enc = tokenizer(input_text, return_tensors="pt")
  69. input_ids = enc["input_ids"].to(model.device)
  70. attention_mask = enc.get("attention_mask", None)
  71. if attention_mask is not None:
  72. attention_mask = attention_mask.to(model.device)
  73. # Output
  74. outputs = model(
  75. input_ids=input_ids,
  76. attention_mask=attention_mask,
  77. output_hidden_states=True,
  78. use_cache=False
  79. )
  80. hs = outputs.hidden_states
  81. # ---- Safely handle the first word (within_text_pos == 0) ----
  82. T = input_ids.shape[1] # sequence length
  83. if within_text_pos == 0:
  84. start, end = 1, T #BOS is shown in Llama3, Gemma2, RakutenAI2, LLM-jp
  85. #start, end = 0, T #No BOS is shown in GPT-Neox, Qwen25
  86. else:
  87. ids_full = input_ids[0].tolist()
  88. ids_word = tokenizer(" " + target_word, add_special_tokens=False)["input_ids"]
  89. start = find_subsequence_last(ids_full, ids_word)
  90. if start == -1:
  91. print("input_text:", input_text)
  92. print("target_word:", target_word)
  93. print("ids_full:", ids_full)
  94. print("ids_word:", ids_word)
  95. raise ValueError(f"target_word span not found: {target_word} in {input_text}")
  96. end = start + len(ids_word)
  97. # mean pooling
  98. span_vecs = hs[targ_layer][0, start:end, :]
  99. targ_out = span_vecs.mean(dim=0).detach().cpu().numpy()
  100. targ_out_lang.append(targ_out)
  101. #Math
  102. print(" Loading Math training data...")
  103. targ_out_math = []
  104. for targ_run in range(4): #Use 5th run as test run, 1 to 4th runs are used for training
  105. print(targ_run)
  106. with open(os.path.join(stim_dir, "MathStim_Run0{:d}.csv".format(targ_run+1))) as f:
  107. reader = csv.reader(f)
  108. stim_all = [row for row in reader]
  109. EPS = 1e-12
  110. for targ_stim in range(len(stim_all)):
  111. print(' ', targ_stim)
  112. # Temporarily store embeddings within a sentence/trial
  113. targ_out_sent = []
  114. text_len = len(stim_all[targ_stim])
  115. for within_text_pos in range(text_len):
  116. # Build the incremental context (w1..wk) in the forward direction
  117. prefix_words = stim_all[targ_stim][0:(within_text_pos + 1)]
  118. input_text = ' '.join(prefix_words)
  119. # Word newly presented at this step
  120. target_word = stim_all[targ_stim][within_text_pos]
  121. # Tokenizer
  122. enc = tokenizer(input_text, return_tensors="pt")
  123. input_ids = enc["input_ids"].to(model.device)
  124. attention_mask = enc.get("attention_mask", None)
  125. if attention_mask is not None:
  126. attention_mask = attention_mask.to(model.device)
  127. # Output
  128. outputs = model(
  129. input_ids=input_ids,
  130. attention_mask=attention_mask,
  131. output_hidden_states=True,
  132. use_cache=False
  133. )
  134. hs = outputs.hidden_states
  135. # ---- Safely handle the first word (within_text_pos == 0) ----
  136. T = input_ids.shape[1] # sequence length
  137. if within_text_pos == 0:
  138. start, end = 1, T #BOS is shown in Llama3, Gemma2, RakutenAI2, LLM-jp
  139. #start, end = 0, T #No BOS is shown in GPT-Neox, Qwen25
  140. else:
  141. ids_full = input_ids[0].tolist()
  142. ids_word = tokenizer(" " + target_word, add_special_tokens=False)["input_ids"]
  143. start = find_subsequence_last(ids_full, ids_word)
  144. if start == -1:
  145. print("input_text:", input_text)
  146. print("target_word:", target_word)
  147. print("ids_full:", ids_full)
  148. print("ids_word:", ids_word)
  149. raise ValueError(f"target_word span not found: {target_word} in {input_text}")
  150. end = start + len(ids_word)
  151. # mean pooling
  152. span_vecs = hs[targ_layer][0, start:end, :]
  153. targ_out = span_vecs.mean(dim=0).detach().cpu().numpy()
  154. targ_out_math.append(targ_out)
  155. #Concatenate lang and math features
  156. t_targ_out_trn = targ_out_lang + targ_out_math
  157. #Standardize
  158. mean = np.nanmean(t_targ_out_trn)
  159. std = np.nanstd(t_targ_out_trn)
  160. t_targ_st = (t_targ_out_trn - mean) / std
  161. t_targ_st = np.nan_to_num(t_targ_st)
  162. # Dimensionality reduction
  163. print("Performing PCA...")
  164. from sklearn.decomposition import PCA
  165. model_pca = PCA(n_components=n_dim_pca_initial)
  166. model_pca.fit(t_targ_st)
  167. t_stim_trn = t_targ_st @ model_pca.components_.T
  168. half_len = int(np.shape(t_stim_trn)[0]/2)
  169. lang_trn = t_stim_trn[0:half_len, :]
  170. math_trn = t_stim_trn[half_len:, :]
  171. print(" Total explained variance: {} %".format(np.round(np.sum(model_pca.explained_variance_ratio_)*100, 3)))
  172. # Use top 100 dimensions
  173. use_dimensions = list(range(100))
  174. t_stim_trn = t_targ_st @ model_pca.components_[use_dimensions].T
  175. half_len = int(np.shape(t_stim_trn)[0]/2)
  176. lang_trn = t_stim_trn[0:half_len, :]
  177. math_trn = t_stim_trn[half_len:, :]
  178. print(" Total explained variance after correction: {} %".format(np.round(np.sum(model_pca.explained_variance_ratio_[use_dimensions])*100, 3)))
  179. print("Processing test data based on PCA result ...")
  180. # Language test run (5th run)
  181. targ_run = 4
  182. targ_out_lang = []
  183. with open(os.path.join(stim_dir, "LangStim_Run0{:d}.csv".format(targ_run+1)), encoding="shift-jis") as f:
  184. reader = csv.reader(f)
  185. stim_all = [row for row in reader]
  186. EPS = 1e-12
  187. for targ_stim in range(len(stim_all)):
  188. print(' ', targ_stim)
  189. # Temporarily store embeddings within a sentence/trial
  190. targ_out_sent = []
  191. text_len = len(stim_all[targ_stim])
  192. for within_text_pos in range(text_len):
  193. # Build the incremental context (w1..wk) in the forward direction
  194. prefix_words = stim_all[targ_stim][0:(within_text_pos + 1)]
  195. input_text = ' '.join(prefix_words)
  196. # Word newly presented at this step
  197. target_word = stim_all[targ_stim][within_text_pos]
  198. # Tokenizer
  199. enc = tokenizer(input_text, return_tensors="pt")
  200. input_ids = enc["input_ids"].to(model.device)
  201. attention_mask = enc.get("attention_mask", None)
  202. if attention_mask is not None:
  203. attention_mask = attention_mask.to(model.device)
  204. # Output (requires hidden states to be returned)
  205. outputs = model(
  206. input_ids=input_ids,
  207. attention_mask=attention_mask,
  208. output_hidden_states=True,
  209. use_cache=False
  210. )
  211. hs = outputs.hidden_states
  212. # ---- Safely handle the first word (within_text_pos == 0) ----
  213. T = input_ids.shape[1] # sequence length
  214. if within_text_pos == 0:
  215. start, end = 1, T #BOS is shown in Llama3, Gemma2, RakutenAI2, LLM-jp
  216. #start, end = 0, T #No BOS is shown in GPT-Neox, Qwen25
  217. else:
  218. ids_full = input_ids[0].tolist()
  219. ids_word = tokenizer(" " + target_word, add_special_tokens=False)["input_ids"]
  220. start = find_subsequence_last(ids_full, ids_word)
  221. if start == -1:
  222. print("input_text:", input_text)
  223. print("target_word:", target_word)
  224. print("ids_full:", ids_full)
  225. print("ids_word:", ids_word)
  226. raise ValueError(f"target_word span not found: {target_word} in {input_text}")
  227. end = start + len(ids_word)
  228. # mean pooling
  229. span_vecs = hs[targ_layer][0, start:end, :]
  230. targ_out = span_vecs.mean(dim=0).detach().cpu().numpy()
  231. targ_out_lang.append(targ_out)
  232. # Math test run (5th run)
  233. targ_out_math = []
  234. with open(os.path.join(stim_dir, "MathStim_Run0{:d}.csv".format(targ_run+1))) as f:
  235. reader = csv.reader(f)
  236. stim_all = [row for row in reader]
  237. EPS = 1e-12
  238. for targ_stim in range(len(stim_all)):
  239. print(' ', targ_stim)
  240. # Temporarily store embeddings within a sentence/trial
  241. targ_out_sent = []
  242. text_len = len(stim_all[targ_stim])
  243. for within_text_pos in range(text_len):
  244. # Build the incremental context (w1..wk) in the forward direction
  245. prefix_words = stim_all[targ_stim][0:(within_text_pos + 1)]
  246. input_text = ' '.join(prefix_words)
  247. # Word newly presented at this step
  248. target_word = stim_all[targ_stim][within_text_pos]
  249. # Tokenizer
  250. enc = tokenizer(input_text, return_tensors="pt")
  251. input_ids = enc["input_ids"].to(model.device)
  252. attention_mask = enc.get("attention_mask", None)
  253. if attention_mask is not None:
  254. attention_mask = attention_mask.to(model.device)
  255. # Output (requires hidden states to be returned)
  256. outputs = model(
  257. input_ids=input_ids,
  258. attention_mask=attention_mask,
  259. output_hidden_states=True,
  260. use_cache=False
  261. )
  262. hs = outputs.hidden_states
  263. # ---- Safely handle the first word (within_text_pos == 0) ----
  264. T = input_ids.shape[1] # sequence length
  265. if within_text_pos == 0:
  266. start, end = 1, T #BOS is shown in Llama3, Gemma2, RakutenAI2, LLM-jp
  267. #start, end = 0, T #No BOS is shown in GPT-Neox, Qwen25
  268. else:
  269. ids_full = input_ids[0].tolist()
  270. ids_word = tokenizer(" " + target_word, add_special_tokens=False)["input_ids"]
  271. start = find_subsequence_last(ids_full, ids_word)
  272. if start == -1:
  273. print("input_text:", input_text)
  274. print("target_word:", target_word)
  275. print("ids_full:", ids_full)
  276. print("ids_word:", ids_word)
  277. raise ValueError(f"target_word span not found: {target_word} in {input_text}")
  278. end = start + len(ids_word)
  279. # mean pooling
  280. span_vecs = hs[targ_layer][0, start:end, :]
  281. targ_out = span_vecs.mean(dim=0).detach().cpu().numpy()
  282. targ_out_math.append(targ_out)
  283. #Apply PCA based on fitting with training data (no leakage from test to training data)
  284. t_targ_st = (targ_out_lang - mean) / std
  285. t_targ_st = np.nan_to_num(t_targ_st)
  286. lang_test = t_targ_st @ model_pca.components_[use_dimensions].T
  287. t_targ_st = (targ_out_math - mean) / std
  288. t_targ_st = np.nan_to_num(t_targ_st)
  289. math_test = t_targ_st @ model_pca.components_[use_dimensions].T
  290. with open(os.path.join(stim_dir, "LangJitter1.csv")) as f:
  291. reader = csv.reader(f)
  292. jitters_lang = [row for row in reader]
  293. with open(os.path.join(stim_dir, "MathJitter1.csv")) as f:
  294. reader = csv.reader(f)
  295. jitters_math = [row for row in reader]
  296. with open(os.path.join(stim_dir, "LangJitter2.csv")) as f:
  297. reader = csv.reader(f)
  298. jitters_lang_probe = [row for row in reader]
  299. with open(os.path.join(stim_dir, "MathJitter2.csv")) as f:
  300. reader = csv.reader(f)
  301. jitters_math_probe = [row for row in reader]
  302. print("Feature downsampling, Lang training runs ...")
  303. # Language, training run
  304. # Make features for 10 Hz (each 100ms)
  305. intro_dur = 60 #6s
  306. outro_dur = 60 #6s
  307. cue_dur = 5 #0.5s
  308. word_dur = 7 #0.7s for each (5 words in total)
  309. probe_dur = 20 #2s
  310. feedback_dur = 10 #1s of T/F feedback
  311. stim_lang_trn = []
  312. for targ_run in range(4):
  313. probe_id = 0 #Initialize
  314. #Intro
  315. stim = np.zeros([intro_dur, n_dim_pca])
  316. for trial_id in range(0,40):
  317. #Cue
  318. stim = np.concatenate([stim, np.zeros([cue_dur, n_dim_pca])], axis=0)
  319. #Stimuli
  320. stim = np.concatenate([stim, np.tile(lang_trn[200*targ_run + 5*trial_id, :], [word_dur, 1])], axis=0)
  321. stim = np.concatenate([stim, np.tile(lang_trn[200*targ_run + 5*trial_id+1, :], [word_dur, 1])], axis=0)
  322. stim = np.concatenate([stim, np.tile(lang_trn[200*targ_run + 5*trial_id+2, :], [word_dur, 1])], axis=0)
  323. stim = np.concatenate([stim, np.tile(lang_trn[200*targ_run + 5*trial_id+3, :], [word_dur, 1])], axis=0)
  324. stim = np.concatenate([stim, np.tile(lang_trn[200*targ_run + 5*trial_id+4, :], [word_dur, 1])], axis=0)
  325. #Jitter
  326. stim = np.concatenate([stim, np.zeros([10+10*int(jitters_lang[targ_run][trial_id]), n_dim_pca])], axis=0)
  327. #Probe
  328. if int(jitters_lang_probe[targ_run][trial_id]) > 0:
  329. #Probe
  330. stim = np.concatenate([stim, np.zeros([probe_dur, n_dim_pca])], axis=0)
  331. #Feedback
  332. stim = np.concatenate([stim, np.zeros([feedback_dur, n_dim_pca])], axis=0)
  333. #Probe jitter
  334. stim = np.concatenate([stim, np.zeros([10*int(jitters_lang_probe[targ_run][trial_id]), n_dim_pca])], axis=0)
  335. #Increment of probe index
  336. probe_id = probe_id + 1
  337. #Outro
  338. stim = np.concatenate([stim, np.zeros([outro_dur, n_dim_pca])], axis=0)
  339. #Exclude Intro
  340. stim = stim[60:,:]
  341. stim_lang_trn.append(stim)
  342. print("Feature downsampling, Math training runs ...")
  343. # Math training run
  344. stim_math_trn = []
  345. for targ_run in range(4):
  346. probe_id = 0 #Initialize
  347. #Intro
  348. stim = np.zeros([intro_dur, n_dim_pca])
  349. for trial_id in range(0,40):
  350. #Cue
  351. stim = np.concatenate([stim, np.zeros([cue_dur, n_dim_pca])], axis=0)
  352. #Stimuli
  353. stim = np.concatenate([stim, np.tile(math_trn[200*targ_run + 5*trial_id, :], [word_dur, 1])], axis=0)
  354. stim = np.concatenate([stim, np.tile(math_trn[200*targ_run + 5*trial_id+1, :], [word_dur, 1])], axis=0)
  355. stim = np.concatenate([stim, np.tile(math_trn[200*targ_run + 5*trial_id+2, :], [word_dur, 1])], axis=0)
  356. stim = np.concatenate([stim, np.tile(math_trn[200*targ_run + 5*trial_id+3, :], [word_dur, 1])], axis=0)
  357. stim = np.concatenate([stim, np.tile(math_trn[200*targ_run + 5*trial_id+4, :], [word_dur, 1])], axis=0)
  358. #Jitter
  359. stim = np.concatenate([stim, np.zeros([10+10*int(jitters_math[targ_run][trial_id]), n_dim_pca])], axis=0)
  360. #Probe
  361. if int(jitters_math_probe[targ_run][trial_id]) > 0:
  362. #Probe
  363. #stim = np.concatenate([stim, np.tile(math_probe_trn[8*targ_run + probe_id, :], [probe_dur, 1])], axis=0)
  364. stim = np.concatenate([stim, np.zeros([probe_dur, n_dim_pca])], axis=0)
  365. #Feedback
  366. stim = np.concatenate([stim, np.zeros([feedback_dur, n_dim_pca])], axis=0)
  367. #Probe jitter
  368. stim = np.concatenate([stim, np.zeros([10*int(jitters_math_probe[targ_run][trial_id]), n_dim_pca])], axis=0)
  369. #Increment of probe index
  370. probe_id = probe_id + 1
  371. #Outro
  372. stim = np.concatenate([stim, np.zeros([outro_dur, n_dim_pca])], axis=0)
  373. #Exclude Intro
  374. stim = stim[60:,:]
  375. stim_math_trn.append(stim)
  376. print("Feature downsampling, Lang test run ...")
  377. #Language, test run
  378. #Make features for 10 Hz (each 100ms)
  379. intro_dur = 60 #6s
  380. outro_dur = 60 #6s
  381. cue_dur = 5 #0.5s
  382. word_dur = 7 #0.7s for each (5 words in total)
  383. probe_dur = 20 #2s
  384. feedback_dur = 10 #1s of T/F feedback
  385. stim_lang_test = []
  386. targ_run = 4
  387. probe_id = 0 #Initialize
  388. #Intro
  389. stim = np.zeros([intro_dur, n_dim_pca])
  390. for trial_id in range(0,40):
  391. #Cue
  392. stim = np.concatenate([stim, np.zeros([cue_dur, n_dim_pca])], axis=0)
  393. #Stimuli
  394. stim = np.concatenate([stim, np.tile(lang_test[5*trial_id, :], [word_dur, 1])], axis=0)
  395. stim = np.concatenate([stim, np.tile(lang_test[5*trial_id+1, :], [word_dur, 1])], axis=0)
  396. stim = np.concatenate([stim, np.tile(lang_test[5*trial_id+2, :], [word_dur, 1])], axis=0)
  397. stim = np.concatenate([stim, np.tile(lang_test[5*trial_id+3, :], [word_dur, 1])], axis=0)
  398. stim = np.concatenate([stim, np.tile(lang_test[5*trial_id+4, :], [word_dur, 1])], axis=0)
  399. #Jitter
  400. stim = np.concatenate([stim, np.zeros([10+10*int(jitters_lang[targ_run][trial_id]), n_dim_pca])], axis=0) #test run id = 4
  401. #Probe
  402. if int(jitters_lang_probe[targ_run][trial_id]) > 0:
  403. #Probe
  404. #stim = np.concatenate([stim, np.tile(lang_probe_test[probe_id, :], [probe_dur, 1])], axis=0)
  405. stim = np.concatenate([stim, np.zeros([probe_dur, n_dim_pca])], axis=0)
  406. #Feedback
  407. stim = np.concatenate([stim, np.zeros([feedback_dur, n_dim_pca])], axis=0)
  408. #Probe jitter
  409. stim = np.concatenate([stim, np.zeros([10*int(jitters_lang_probe[targ_run][trial_id]), n_dim_pca])], axis=0)
  410. #Increment of probe index
  411. probe_id = probe_id + 1
  412. #Outro
  413. stim = np.concatenate([stim, np.zeros([outro_dur, n_dim_pca])], axis=0)
  414. #Exclude Intro
  415. stim = stim[60:,:]
  416. stim_lang_test = stim
  417. print("Feature downsampling, Math test run ...")
  418. #Math, test run
  419. stim_math_test = []
  420. targ_run = 4
  421. probe_id = 0 #Initialize
  422. #Intro
  423. stim = np.zeros([intro_dur, n_dim_pca])
  424. for trial_id in range(0,40):
  425. #Cue
  426. stim = np.concatenate([stim, np.zeros([cue_dur, n_dim_pca])], axis=0)
  427. #Stimuli
  428. stim = np.concatenate([stim, np.tile(math_test[5*trial_id, :], [word_dur, 1])], axis=0)
  429. stim = np.concatenate([stim, np.tile(math_test[5*trial_id+1, :], [word_dur, 1])], axis=0)
  430. stim = np.concatenate([stim, np.tile(math_test[5*trial_id+2, :], [word_dur, 1])], axis=0)
  431. stim = np.concatenate([stim, np.tile(math_test[5*trial_id+3, :], [word_dur, 1])], axis=0)
  432. stim = np.concatenate([stim, np.tile(math_test[5*trial_id+4, :], [word_dur, 1])], axis=0)
  433. #Jitter
  434. stim = np.concatenate([stim, np.zeros([10+10*int(jitters_math[targ_run][trial_id]), n_dim_pca])], axis=0) #test run id = 4
  435. #Probe
  436. if int(jitters_math_probe[targ_run][trial_id]) > 0:
  437. #Probe
  438. stim = np.concatenate([stim, np.zeros([probe_dur, n_dim_pca])], axis=0)
  439. #Feedback
  440. stim = np.concatenate([stim, np.zeros([feedback_dur, n_dim_pca])], axis=0)
  441. #Probe jitter
  442. stim = np.concatenate([stim, np.zeros([10*int(jitters_math_probe[targ_run][trial_id]), n_dim_pca])], axis=0)
  443. #Increment of probe index
  444. probe_id = probe_id + 1
  445. #Outro
  446. stim = np.concatenate([stim, np.zeros([outro_dur, n_dim_pca])], axis=0)
  447. #Exclude Intro
  448. stim = stim[60:,:]
  449. stim_math_test = stim
  450. #Down sampling to 1 Hz
  451. stim_lang_trn_tmp = np.zeros([np.shape(stim_lang_trn)[0], int(np.shape(stim_lang_trn)[1]/10), np.shape(stim_lang_trn)[2]])
  452. stim_math_trn_tmp = np.zeros([np.shape(stim_math_trn)[0], int(np.shape(stim_math_trn)[1]/10), np.shape(stim_math_trn)[2]])
  453. for ff in range(n_dim_pca):
  454. for rr in range(4):
  455. stim_lang_trn_tmp[rr][:, ff] = decimate(stim_lang_trn[rr][:, ff], 10, ftype='fir')
  456. stim_math_trn_tmp[rr][:, ff] = decimate(stim_math_trn[rr][:, ff], 10, ftype='fir')
  457. stim_lang_trn= copy.copy(stim_lang_trn_tmp)
  458. stim_math_trn = copy.copy(stim_math_trn_tmp)
  459. stim_lang_test_tmp = np.zeros([int(np.shape(stim_lang_test)[0]/10), np.shape(stim_lang_test)[1]])
  460. stim_math_test_tmp = np.zeros([int(np.shape(stim_math_test)[0]/10), np.shape(stim_math_test)[1]])
  461. for ff in range(n_dim_pca):
  462. stim_lang_test_tmp[:, ff] = decimate(stim_lang_test[:, ff], 10, ftype='fir')
  463. stim_math_test_tmp[:, ff] = decimate(stim_math_test[:, ff], 10, ftype='fir')
  464. stim_lang_test = copy.copy(stim_lang_test_tmp)
  465. stim_math_test = copy.copy(stim_math_test_tmp)
  466. np.save(os.path.join(feature_dir, f'Features_{model_name}_Layer{targ_layer:02d}_LangTrn'), stim_lang_trn)
  467. np.save(os.path.join(feature_dir, f'Features_{model_name}_Layer{targ_layer:02d}_LangTest'), stim_lang_test)
  468. np.save(os.path.join(feature_dir, f'Features_{model_name}_Layer{targ_layer:02d}_MathTrn'), stim_math_trn)
  469. np.save(os.path.join(feature_dir, f'Features_{model_name}_Layer{targ_layer:02d}_MathTest'), stim_math_test)
  470. print("Processing control data based on PCA result ...")
  471. #Control run
  472. targ_out_lang_ctrl = []
  473. with open(os.path.join(stim_dir, "LangStim_Ctrl.csv"), encoding="shift-jis") as f:
  474. reader = csv.reader(f)
  475. stim_all = [row for row in reader]
  476. for targ_stim in range(len(stim_all)):
  477. print(' ', targ_stim)
  478. # Temporarily store embeddings within a sentence/trial
  479. targ_out_sent = []
  480. text_len = len(stim_all[targ_stim])
  481. for within_text_pos in range(text_len):
  482. # Build the incremental context (w1..wk) in the forward direction
  483. prefix_words = stim_all[targ_stim][0:(within_text_pos + 1)]
  484. input_text = ' '.join(prefix_words) # Use a fixed concatenation rule
  485. # Word newly presented at this step
  486. target_word = stim_all[targ_stim][within_text_pos]
  487. # Tokenizer
  488. enc = tokenizer(input_text, return_tensors="pt")
  489. input_ids = enc["input_ids"].to(model.device)
  490. attention_mask = enc.get("attention_mask", None)
  491. if attention_mask is not None:
  492. attention_mask = attention_mask.to(model.device)
  493. # Output (requires hidden states to be returned)
  494. outputs = model(
  495. input_ids=input_ids,
  496. attention_mask=attention_mask,
  497. output_hidden_states=True,
  498. use_cache=False
  499. )
  500. hs = outputs.hidden_states
  501. # ---- Safely handle the first word (within_text_pos == 0) ----
  502. T = input_ids.shape[1] # sequence length
  503. if within_text_pos == 0:
  504. start, end = 1, T #BOS is shown in Llama3, Gemma2, RakutenAI2, LLM-jp
  505. #start, end = 0, T #No BOS is shown in GPT-Neox, Qwen25
  506. else:
  507. ids_full = input_ids[0].tolist()
  508. ids_word = tokenizer(" " + target_word, add_special_tokens=False)["input_ids"]
  509. start = find_subsequence_last(ids_full, ids_word)
  510. if start == -1:
  511. print("input_text:", input_text)
  512. print("target_word:", target_word)
  513. print("ids_full:", ids_full)
  514. print("ids_word:", ids_word)
  515. raise ValueError(f"target_word span not found: {target_word} in {input_text}")
  516. end = start + len(ids_word)
  517. # mean pooling
  518. span_vecs = hs[targ_layer][0, start:end, :]
  519. targ_out = span_vecs.mean(dim=0).detach().cpu().numpy()
  520. targ_out_lang_ctrl.append(targ_out)
  521. targ_out_math_ctrl = []
  522. with open(os.path.join(stim_dir, "MathStim_Ctrl.csv")) as f:
  523. reader = csv.reader(f)
  524. stim_all = [row for row in reader]
  525. for targ_stim in range(len(stim_all)):
  526. print(' ', targ_stim)
  527. # Temporarily store embeddings within a sentence/trial
  528. targ_out_sent = []
  529. text_len = len(stim_all[targ_stim])
  530. for within_text_pos in range(text_len):
  531. # Build the incremental context (w1..wk) in the forward direction
  532. prefix_words = stim_all[targ_stim][0:(within_text_pos + 1)]
  533. input_text = ' '.join(prefix_words)
  534. # Word newly presented at this step
  535. target_word = stim_all[targ_stim][within_text_pos]
  536. # Tokenizer
  537. enc = tokenizer(input_text, return_tensors="pt")
  538. input_ids = enc["input_ids"].to(model.device)
  539. attention_mask = enc.get("attention_mask", None)
  540. if attention_mask is not None:
  541. attention_mask = attention_mask.to(model.device)
  542. # Output (requires hidden states to be returned)
  543. outputs = model(
  544. input_ids=input_ids,
  545. attention_mask=attention_mask,
  546. output_hidden_states=True,
  547. use_cache=False
  548. )
  549. hs = outputs.hidden_states
  550. # ---- Safely handle the first word (within_text_pos == 0) ----
  551. T = input_ids.shape[1] # sequence length
  552. if within_text_pos == 0:
  553. start, end = 1, T #BOS is shown in Llama3, Gemma2, RakutenAI2, LLM-jp
  554. #start, end = 0, T #No BOS is shown in GPT-Neox, Qwen25
  555. else:
  556. ids_full = input_ids[0].tolist()
  557. ids_word = tokenizer(" " + target_word, add_special_tokens=False)["input_ids"]
  558. start = find_subsequence_last(ids_full, ids_word)
  559. if start == -1:
  560. print("input_text:", input_text)
  561. print("target_word:", target_word)
  562. print("ids_full:", ids_full)
  563. print("ids_word:", ids_word)
  564. raise ValueError(f"target_word span not found: {target_word} in {input_text}")
  565. end = start + len(ids_word)
  566. # mean pooling
  567. span_vecs = hs[targ_layer][0, start:end, :]
  568. targ_out = span_vecs.mean(dim=0).detach().cpu().numpy()
  569. targ_out_math_ctrl.append(targ_out)
  570. # Apply PCA based on fitting with training data (no leakage from test to training data)
  571. t_targ_st = (targ_out_lang_ctrl - mean) / std
  572. t_targ_st = np.nan_to_num(t_targ_st)
  573. lang_ctrl = t_targ_st @ model_pca.components_[use_dimensions].T
  574. t_targ_st = (targ_out_math_ctrl - mean) / std
  575. t_targ_st = np.nan_to_num(t_targ_st)
  576. math_ctrl = t_targ_st @ model_pca.components_[use_dimensions].T
  577. with open(os.path.join(stim_dir, "LangJitter1_Ctrl.csv")) as f:
  578. reader = csv.reader(f)
  579. jitters_lang_ctrl = [row for row in reader]
  580. with open(os.path.join(stim_dir, "MathJitter1_Ctrl.csv")) as f:
  581. reader = csv.reader(f)
  582. jitters_math_ctrl = [row for row in reader]
  583. with open(os.path.join(stim_dir, "LangJitter2_Ctrl.csv")) as f:
  584. reader = csv.reader(f)
  585. jitters_lang_ctrl_probe = [row for row in reader]
  586. with open(os.path.join(stim_dir, "MathJitter2_Ctrl.csv")) as f:
  587. reader = csv.reader(f)
  588. jitters_math_ctrl_probe = [row for row in reader]
  589. print("Feature downsampling, Control runs ...")
  590. #Language, control run
  591. #Make features for 10 Hz (each 100ms)
  592. intro_dur = 60 #6s
  593. outro_dur = 60 #6s
  594. cue_dur = 5 #0.5s
  595. word_dur = 7 #0.7s for each (5 words in total)
  596. probe_dur = 20 #2s
  597. feedback_dur = 10 #1s of T/F feedback
  598. stim_lang_ctrl = []
  599. probe_id = 0 #Initialize
  600. #Intro
  601. stim = np.zeros([intro_dur, n_dim_pca])
  602. for trial_id in range(0,40):
  603. #Cue
  604. stim = np.concatenate([stim, np.zeros([cue_dur, n_dim_pca])], axis=0)
  605. #Stimuli
  606. stim = np.concatenate([stim, np.tile(lang_ctrl[5*trial_id, :], [word_dur, 1])], axis=0)
  607. stim = np.concatenate([stim, np.tile(lang_ctrl[5*trial_id+1, :], [word_dur, 1])], axis=0)
  608. stim = np.concatenate([stim, np.tile(lang_ctrl[5*trial_id+2, :], [word_dur, 1])], axis=0)
  609. stim = np.concatenate([stim, np.tile(lang_ctrl[5*trial_id+3, :], [word_dur, 1])], axis=0)
  610. stim = np.concatenate([stim, np.tile(lang_ctrl[5*trial_id+4, :], [word_dur, 1])], axis=0)
  611. #Jitter
  612. stim = np.concatenate([stim, np.zeros([10+10*int(jitters_lang_ctrl[0][trial_id]), n_dim_pca])], axis=0) #test run id = 4
  613. #Probe
  614. if int(jitters_lang_ctrl_probe[0][trial_id]) > 0:
  615. #Probe
  616. #stim = np.concatenate([stim, np.tile(lang_probe_test[probe_id, :], [probe_dur, 1])], axis=0)
  617. stim = np.concatenate([stim, np.zeros([probe_dur, n_dim_pca])], axis=0)
  618. #Feedback
  619. stim = np.concatenate([stim, np.zeros([feedback_dur, n_dim_pca])], axis=0)
  620. #Probe jitter
  621. stim = np.concatenate([stim, np.zeros([10*int(jitters_lang_ctrl_probe[0][trial_id]), n_dim_pca])], axis=0)
  622. #Increment of probe index
  623. probe_id = probe_id + 1
  624. #Outro
  625. stim = np.concatenate([stim, np.zeros([outro_dur, n_dim_pca])], axis=0)
  626. #Exclude Intro
  627. stim = stim[60:,:]
  628. stim_lang_ctrl = stim
  629. #Math, test run
  630. stim_math_ctrl = []
  631. probe_id = 0 #Initialize
  632. #Intro
  633. stim = np.zeros([intro_dur, n_dim_pca])
  634. for trial_id in range(0,40):
  635. #Cue
  636. stim = np.concatenate([stim, np.zeros([cue_dur, n_dim_pca])], axis=0)
  637. #Stimuli
  638. stim = np.concatenate([stim, np.tile(math_ctrl[5*trial_id, :], [word_dur, 1])], axis=0)
  639. stim = np.concatenate([stim, np.tile(math_ctrl[5*trial_id+1, :], [word_dur, 1])], axis=0)
  640. stim = np.concatenate([stim, np.tile(math_ctrl[5*trial_id+2, :], [word_dur, 1])], axis=0)
  641. stim = np.concatenate([stim, np.tile(math_ctrl[5*trial_id+3, :], [word_dur, 1])], axis=0)
  642. stim = np.concatenate([stim, np.tile(math_ctrl[5*trial_id+4, :], [word_dur, 1])], axis=0)
  643. #Jitter
  644. stim = np.concatenate([stim, np.zeros([10+10*int(jitters_math_ctrl[0][trial_id]), n_dim_pca])], axis=0) #test run id = 4
  645. #Probe
  646. if int(jitters_math_ctrl_probe[0][trial_id]) > 0:
  647. #Probe
  648. #stim = np.concatenate([stim, np.tile(math_probe_test[probe_id, :], [probe_dur, 1])], axis=0)
  649. stim = np.concatenate([stim, np.zeros([probe_dur, n_dim_pca])], axis=0)
  650. #Feedback
  651. stim = np.concatenate([stim, np.zeros([feedback_dur, n_dim_pca])], axis=0)
  652. #Probe jitter
  653. stim = np.concatenate([stim, np.zeros([10*int(jitters_math_ctrl_probe[0][trial_id]), n_dim_pca])], axis=0)
  654. #Increment of probe index
  655. probe_id = probe_id + 1
  656. #Outro
  657. stim = np.concatenate([stim, np.zeros([outro_dur, n_dim_pca])], axis=0)
  658. #Exclude Intro
  659. stim = stim[60:,:]
  660. stim_math_ctrl = stim
  661. # Downsampling to 1 Hz
  662. stim_lang_ctrl_tmp = np.zeros([int(np.shape(stim_lang_ctrl)[0]/10), np.shape(stim_lang_ctrl)[1]])
  663. stim_math_ctrl_tmp = np.zeros([int(np.shape(stim_math_ctrl)[0]/10), np.shape(stim_math_ctrl)[1]])
  664. for ff in range(n_dim_pca):
  665. stim_lang_ctrl_tmp[:, ff] = decimate(stim_lang_ctrl[:, ff], 10, ftype='fir')
  666. stim_math_ctrl_tmp[:, ff] = decimate(stim_math_ctrl[:, ff], 10, ftype='fir')
  667. stim_lang_ctrl = copy.copy(stim_lang_ctrl_tmp)
  668. stim_math_ctrl = copy.copy(stim_math_ctrl_tmp)
  669. np.save(os.path.join(feature_dir, f'Features_{model_name}_Layer{targ_layer:02d}_LangCtrl'), stim_lang_ctrl)
  670. np.save(os.path.join(feature_dir, f'Features_{model_name}_Layer{targ_layer:02d}_MathCtrl'), stim_math_ctrl)

LM_MakeFeatures_LLM.py, under CC-BY-4.0 · at the source

Overview

  1. Graduate School of Information Science and Technology, The University of Tokyo, Tokyo, Japan
  2. Center for Information and Neural Networks, National Institute of Information and Communications Technology, Suita, Japan
  3. Graduate School of Medical and Dental Sciences, Institute of Science Tokyo, Tokyo, Japan
  4. Graduate School of Frontier Biosciences, The University of Osaka, Suita, Japan
  5. Graduate School of Medicine, The University of Osaka, Suita, Japan
Journal: Science advances, volume 12, issue 47, article eaej5555
Dates: received 11 June 2026; accepted 14 October 2026; published online 18 November 2026; in print November 2026
Type: Research article · Language: English
License: CC BY-NC
Identifiers: DOI 10.1126/sciadv.aej5555 · PMID 43050544 · PMCID PMC13781126 · OpenAlex W7163904149
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: human (organism)
Methods: Connectivity, Statistics, Smoothing, state filtering, decompositions, Machine learning, fMRI & imaging
MeSH: Language*, Mathematics*, Models, Neurological*, Adult, Brain Mapping, Comprehension, Female, Humans, Magnetic Resonance Imaging, Male, Young Adult (* major topic)
Topic: Neurobiology of Language and Bilingualism (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Japan Society for the Promotion of Science (JP18H05522, 24H00619, JP26H00539); Exploratory Research for Advanced Technology (JPMJER1801); Moonshot Research and Development Program (JPMJMS259G); Fusion Oriented REsearch for disruptive Science and Technology (JPMJFR231V)
Citations: not cited yet (Europe PMC); 100 references in the paper

Abstract

Whether language and mathematics rely on shared or distinct neural representations remains unresolved in cognitive neuroscience. Here, we combined latent features from a large language model with functional magnetic resonance imaging encoding models to test cross-domain generalization in 32 participants performing sentence comprehension and calculation tasks. Cross-domain prediction identified cortical regions showing partially shared representations, most consistently in the left area 55b, while control analyses suggested that these effects could not be fully explained by low-level visual or task-general factors. Domain-specificity contrasts revealed stronger language-related prediction in the left superior temporal sulcus and angular gyrus and math-related prediction in the left precentral sulcus and bilateral intraparietal sulci. Model-weight analyses revealed distinct weight profiles associated with shared and domain-specific prediction patterns. Cross-domain regions also exhibited task-dependent functional coupling with language- and math-related networks. Together, these findings suggest that language and mathematics involve partially shared neural representations alongside domain-specific cortical organization, helping reconcile previous contrasting views on their neural basis.

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

Zenodo 20361844

License: CC-BY-4.0
State: the link answers, verified on 21 November 2026
Evidence: files inventoried
Languages: Python (13)
Size: 19 files, 13 scripts
Software Heritage: not checked
Found in: “Data, code, and materials availability:”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (13 files), SciPy (10 files), Matplotlib (7 files), Nilearn (6 files), statsmodels (4 files), pandas (3 files), scikit-learn (3 files), seaborn (3 files), MNE-Connectivity (2 files), NiBabel (2 files), Pillow (1 file), PyTorch (1 file), Hugging Face Transformers (1 file)
Availability: 1 check, the latest on 21 November 2026: the link answers (HTTP 200)
  • 21 November 2026: the link answers (HTTP 200)
13 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;
  • 13 scripts, each with its path and the digest of its content;
  • 6 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 and/or the Supplementary Materials. This study did not generate new materials. The source data, stimuli, and analysis code used in the current study are available from Zenodo (https://zenodo.org/records/20361844).

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, 21 November 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 3 authors, 11 MeSH terms, 4 funders, 92 references.

Cite

This paper

Nakai, T., Kubo, R., & Nishimoto, S. (2026). Cross-domain encoding models reveal shared and domain-specific neural representations across language and mathematics. Science advances, 12(47), eaej5555. https://doi.org/10.1126/sciadv.aej5555

BibTeX

@article{nakai2026cross,
author = {Nakai, Tomoya and Kubo, Rieko and Nishimoto, Shinji},
title = {{Cross-domain encoding models reveal shared and domain-specific neural representations across language and mathematics}},
journal = {Science advances},
year = {2026},
month = nov,
volume = {12},
number = {47},
pages = {eaej5555},
publisher = {American Association for the Advancement of Science},
issn = {2375-2548},
doi = {10.1126/sciadv.aej5555},
url = {https://doi.org/10.1126/sciadv.aej5555},
pmid = {43050544},
pmcid = {PMC13781126}
}

RIS

TY - JOUR
AU - Nakai, Tomoya
AU - Kubo, Rieko
AU - Nishimoto, Shinji
TI - Cross-domain encoding models reveal shared and domain-specific neural representations across language and mathematics
T2 - Science advances
J2 - Sci Adv
PY - 2026
DA - 2026/11/18
VL - 12
IS - 47
SP - eaej5555
SN - 2375-2548
PB - American Association for the Advancement of Science
DO - 10.1126/sciadv.aej5555
UR - https://doi.org/10.1126/sciadv.aej5555
LA - en
ER -

CSL-JSON

{
"id": "10.1126/sciadv.aej5555",
"type": "article-journal",
"title": "Cross-domain encoding models reveal shared and domain-specific neural representations across language and mathematics",
"container-title": "Science advances",
"author": [
{
"family": "Nakai",
"given": "Tomoya"
},
{
"family": "Kubo",
"given": "Rieko"
},
{
"family": "Nishimoto",
"given": "Shinji"
}
],
"container-title-short": "Sci Adv",
"volume": "12",
"issue": "47",
"page": "eaej5555",
"DOI": "10.1126/sciadv.aej5555",
"PMID": "43050544",
"PMCID": "PMC13781126",
"ISSN": "2375-2548",
"publisher": "American Association for the Advancement of Science",
"URL": "https://doi.org/10.1126/sciadv.aej5555",
"language": "en",
"issued": {
"date-parts": [
[
2026,
11,
18
]
]
}
}

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.1016/j.isci.2026.117180 [code]
Developmental changes in similarity between neural representations of mental arithmetic and artificial neural networks.
Journal: iScience
In common: Hugging Face Transformers, Nilearn, statsmodels, 8 other tools, 17 references, author Tomoya Nakai
[2] doi:10.1038/s42003-025-08134-4 [code]
Cortical representational geometry of diverse tasks reveals subject-specific and subject-invariant cognitive structures.
Journal: Communications biology
In common: Nilearn, statsmodels, NiBabel, 6 other tools, 14 references, 2 authors
[3] doi:10.1038/s41467-024-49173-5 [code]
Shared functional specialization in transformer-based language models and the human brain.
Journal: Nature communications
In common: Hugging Face Transformers, Nilearn, statsmodels, 8 other tools, 10 references
[4] doi:10.1038/s41562-025-02231-4 [code]
Conversational content is organized across multiple timescales in the brain.
Journal: Nature human behaviour
In common: seaborn, scikit-learn, pandas, 3 other tools, 11 references, author Shinji Nishimoto
[5] doi:10.1038/s41597-025-05462-2 [code]
The "Podcast" ECoG dataset for modeling neural activity during natural language comprehension.
Journal: Scientific data
In common: Nilearn, statsmodels, NiBabel, 6 other tools, 10 references
[6] 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: Nilearn, Pillow, NiBabel, 6 other tools, 9 references
[7] doi:10.1371/journal.pbio.3003820 [code]
A cortical semantic map integrates fractions and integers in the human brain.
Journal: PLoS biology
In common: Nilearn, statsmodels, NiBabel, 6 other tools, 10 references
[8] doi:10.1038/s41467-025-66731-7 [code]
Text-to-music generation models capture musical semantic representations in the human brain.
Journal: Nature communications
In common: statsmodels, PyTorch, scikit-learn, 3 other tools, 4 references, 2 authors
[9] doi:10.1126/sciadv.adw1464 [code]
Mind captioning: Evolving descriptive text of mental content from human brain activity.
Journal: Science advances
In common: Hugging Face Transformers, Pillow, NiBabel, 7 other tools, 8 references
[10] doi:10.1016/j.dcn.2024.101470
Encoding models for developmental cognitive computational neuroscience: Promise, challenges, and potential.
Journal: Developmental cognitive neuroscience
In common: 11 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.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.1126/sciadv.aej5555.svg)](https://openscicode.org/badge/doi/10.1126/sciadv.aej5555)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1126/sciadv.aej5555.svg
   :target: https://openscicode.org/badge/doi/10.1126/sciadv.aej5555
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1126/sciadv.aej5555"><img src="https://openscicode.org/badge/doi/10.1126/sciadv.aej5555.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

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