OSCR

Shared memories of event details in the human brain are altered by misinformation and test expectations.

Code ↔ Paper

The paper beside its authors' code: matches between them have not been computed for this paper yet.

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

Python · 340 lines · 11 KB · CC-BY-4.0

  1. #!/usr/bin/env python3
  2. """Calculate ROI-based inter-subject pattern similarity (ISPS) for one subject pair.
  3. Subject-pair, single-ROI mode. Four input tables are required: subject A
  4. behavior + neural pattern, subject B behavior + neural pattern. Computes
  5. ISPS for one ROI between the two subjects.
  6. WSLD: similarity to the partner's vector for the same stimulus.
  7. BSLD: mean similarity to the partner's *other slides within
  8. the same event*.
  9. """
  10. from __future__ import annotations
  11. import argparse
  12. import csv
  13. import math
  14. import os
  15. from collections import defaultdict
  16. from typing import Dict, Iterable, List, Sequence, Tuple
  17. PAIR_OUTPUT_COLUMNS = [
  18. "paired_id",
  19. "subject_id",
  20. "pair_subject_id",
  21. "stim_events",
  22. "stim_slides",
  23. "stim_type",
  24. "memory_type",
  25. "smltp",
  26. "stim_version",
  27. "isps",
  28. ]
  29. PAIR_BEHAVIOR_COLUMNS = {
  30. "subject_id",
  31. "stim_events",
  32. "stim_slides",
  33. "stim_type",
  34. "stim_version",
  35. }
  36. PAIR_NEURAL_ID_COLUMNS = {"subject_id", "stim_events", "stim_slides"}
  37. def parse_args() -> argparse.Namespace:
  38. parser = argparse.ArgumentParser(
  39. description="Compute single-ROI inter-subject pattern similarity for a subject pair."
  40. )
  41. parser.add_argument("--output", help="Output CSV/TSV path.")
  42. parser.add_argument("--output-dir", help="Output directory for pair/ROI mode.")
  43. parser.add_argument("--subject-a-behavior", help="Subject A behavior TSV/CSV.")
  44. parser.add_argument("--subject-a-neural", help="Subject A single-ROI neural TSV/CSV.")
  45. parser.add_argument("--subject-b-behavior", help="Subject B behavior TSV/CSV.")
  46. parser.add_argument("--subject-b-neural", help="Subject B single-ROI neural TSV/CSV.")
  47. parser.add_argument("--roi-name", help="ROI name used in the pair/ROI output filename.")
  48. return parser.parse_args()
  49. def delimiter_for_path(path: str) -> str:
  50. return "\t" if path.endswith((".tsv", ".tsv.gz")) else ","
  51. def read_table(path: str) -> List[Dict[str, str]]:
  52. delimiter = delimiter_for_path(path)
  53. with open(path, newline="") as f:
  54. rows = list(csv.DictReader(f, delimiter=delimiter))
  55. if not rows:
  56. raise ValueError(f"Input table has no rows: {path}")
  57. return rows
  58. def require_columns(rows: List[Dict[str, str]], required: set[str], label: str) -> None:
  59. missing = required - set(rows[0])
  60. if missing:
  61. raise ValueError(f"{label} is missing required columns: {sorted(missing)}")
  62. def clean_str(value: object) -> str:
  63. return str(value).strip()
  64. def pearson(x: Sequence[float], y: Sequence[float]) -> float:
  65. pairs = [
  66. (float(a), float(b))
  67. for a, b in zip(x, y)
  68. if not (math.isnan(float(a)) or math.isnan(float(b)))
  69. ]
  70. if len(pairs) < 2:
  71. return math.nan
  72. xs = [a for a, _ in pairs]
  73. ys = [b for _, b in pairs]
  74. mean_x = sum(xs) / len(xs)
  75. mean_y = sum(ys) / len(ys)
  76. dx = [a - mean_x for a in xs]
  77. dy = [b - mean_y for b in ys]
  78. ss_x = sum(a * a for a in dx)
  79. ss_y = sum(b * b for b in dy)
  80. if ss_x <= 0 or ss_y <= 0:
  81. return math.nan
  82. return sum(a * b for a, b in zip(dx, dy)) / math.sqrt(ss_x * ss_y)
  83. def fisher_z(r: float) -> float:
  84. """Return Fisher's z transform for a Pearson correlation."""
  85. if r is None or math.isnan(float(r)):
  86. return math.nan
  87. clipped = max(min(float(r), 0.999999), -0.999999)
  88. return math.atanh(clipped)
  89. def average(values: Iterable[float]) -> float:
  90. vals = [v for v in values if not math.isnan(v)]
  91. if not vals:
  92. return math.nan
  93. return sum(vals) / len(vals)
  94. def subject_pair_label(subject_a: str, subject_b: str) -> str:
  95. return "_".join(sorted([clean_str(subject_a), clean_str(subject_b)]))
  96. def pair_version_label(version_a: str, version_b: str) -> str:
  97. return "same" if clean_str(version_a) == clean_str(version_b) else "diff"
  98. def sort_key_event_slide(row: Dict[str, object]) -> Tuple[int, int, str, str]:
  99. try:
  100. event = int(clean_str(row["stim_events"]))
  101. except ValueError:
  102. event = 0
  103. try:
  104. slide = int(clean_str(row["stim_slides"]))
  105. except ValueError:
  106. slide = 0
  107. return event, slide, clean_str(row["subject_id"]), clean_str(row["stim_slides"])
  108. def merge_subject_behavior_neural(
  109. behavior_path: str,
  110. neural_path: str,
  111. ) -> List[Dict[str, object]]:
  112. behavior_rows = read_table(behavior_path)
  113. neural_rows = read_table(neural_path)
  114. require_columns(behavior_rows, PAIR_BEHAVIOR_COLUMNS, behavior_path)
  115. require_columns(neural_rows, PAIR_NEURAL_ID_COLUMNS, neural_path)
  116. voxel_cols = [col for col in neural_rows[0] if col not in PAIR_NEURAL_ID_COLUMNS]
  117. if not voxel_cols:
  118. raise ValueError(f"{neural_path} must include one or more voxel columns.")
  119. neural_by_key: Dict[Tuple[str, str, str], Dict[str, str]] = {}
  120. for row in neural_rows:
  121. key = (
  122. clean_str(row["subject_id"]),
  123. clean_str(row["stim_events"]),
  124. clean_str(row["stim_slides"]),
  125. )
  126. neural_by_key[key] = row
  127. merged: List[Dict[str, object]] = []
  128. event_versions: Dict[Tuple[str, str], str] = {}
  129. for row in behavior_rows:
  130. key = (
  131. clean_str(row["subject_id"]),
  132. clean_str(row["stim_events"]),
  133. clean_str(row["stim_slides"]),
  134. )
  135. if key not in neural_by_key:
  136. raise ValueError(
  137. "No neural row for behavior key "
  138. f"subject={key[0]} event={key[1]} slide={key[2]}"
  139. )
  140. event_key = (key[0], key[1])
  141. version = clean_str(row["stim_version"])
  142. previous_version = event_versions.setdefault(event_key, version)
  143. if previous_version != version:
  144. raise ValueError(
  145. "stim_version must be constant within each subject/event: "
  146. f"subject={key[0]} event={key[1]}"
  147. )
  148. neural_row = neural_by_key[key]
  149. merged.append(
  150. {
  151. "subject_id": key[0],
  152. "stim_events": key[1],
  153. "stim_slides": key[2],
  154. "stim_type": clean_str(row["stim_type"]),
  155. "memory_type": clean_str(row.get("memory_type", "")),
  156. "stim_version": version,
  157. "vector": [float(neural_row[col]) for col in voxel_cols],
  158. }
  159. )
  160. return sorted(merged, key=sort_key_event_slide)
  161. def compute_pair_roi_isps_rows(
  162. subject_a_rows: List[Dict[str, object]],
  163. subject_b_rows: List[Dict[str, object]],
  164. ) -> List[Dict[str, object]]:
  165. if not subject_a_rows or not subject_b_rows:
  166. return []
  167. subject_a = clean_str(subject_a_rows[0]["subject_id"])
  168. subject_b = clean_str(subject_b_rows[0]["subject_id"])
  169. subject_pair = subject_pair_label(subject_a, subject_b)
  170. rows_by_subject = {
  171. subject_a: subject_a_rows,
  172. subject_b: subject_b_rows,
  173. }
  174. rows_by_subject_event_slide: Dict[Tuple[str, str, str], Dict[str, object]] = {}
  175. rows_by_subject_event: Dict[Tuple[str, str], List[Dict[str, object]]] = defaultdict(list)
  176. for subject_rows in rows_by_subject.values():
  177. for row in subject_rows:
  178. key = (
  179. clean_str(row["subject_id"]),
  180. clean_str(row["stim_events"]),
  181. clean_str(row["stim_slides"]),
  182. )
  183. rows_by_subject_event_slide[key] = row
  184. rows_by_subject_event[(key[0], key[1])].append(row)
  185. output_rows: List[Dict[str, object]] = []
  186. for subject_id, pair_subject_id in ((subject_a, subject_b), (subject_b, subject_a)):
  187. for target in rows_by_subject[subject_id]:
  188. event = clean_str(target["stim_events"])
  189. slide = clean_str(target["stim_slides"])
  190. pair_same_key = (pair_subject_id, event, slide)
  191. if pair_same_key not in rows_by_subject_event_slide:
  192. continue
  193. pair_same = rows_by_subject_event_slide[pair_same_key]
  194. pair_event_rows = [
  195. row
  196. for row in rows_by_subject_event[(pair_subject_id, event)]
  197. if clean_str(row["stim_slides"]) != slide
  198. ]
  199. if not pair_event_rows:
  200. continue
  201. wsld = fisher_z(pearson(target["vector"], pair_same["vector"]))
  202. bsld = average(
  203. fisher_z(pearson(target["vector"], pair_row["vector"]))
  204. for pair_row in pair_event_rows
  205. )
  206. stim_version = pair_version_label(target["stim_version"], pair_same["stim_version"])
  207. common = {
  208. "paired_id": subject_pair,
  209. "subject_id": subject_id,
  210. "pair_subject_id": pair_subject_id,
  211. "stim_events": event,
  212. "stim_slides": slide,
  213. "stim_type": clean_str(target["stim_type"]),
  214. "memory_type": clean_str(target.get("memory_type", "")),
  215. "stim_version": stim_version,
  216. }
  217. output_rows.append({**common, "smltp": "wsld", "isps": wsld})
  218. output_rows.append({**common, "smltp": "bsld", "isps": bsld})
  219. return sorted(
  220. output_rows,
  221. key=lambda row: (
  222. int(row["stim_events"]),
  223. int(row["stim_slides"]),
  224. row["subject_id"],
  225. row["smltp"],
  226. ),
  227. )
  228. def write_pair_rows(path: str, rows: Iterable[Dict[str, object]]) -> None:
  229. output_dir = os.path.dirname(path)
  230. if output_dir:
  231. os.makedirs(output_dir, exist_ok=True)
  232. delimiter = delimiter_for_path(path)
  233. with open(path, "w", newline="") as f:
  234. writer = csv.DictWriter(f, fieldnames=PAIR_OUTPUT_COLUMNS, delimiter=delimiter)
  235. writer.writeheader()
  236. for row in rows:
  237. clean_row = dict(row)
  238. isps = clean_row["isps"]
  239. clean_row["isps"] = (
  240. "" if isps is None or math.isnan(float(isps)) else f"{float(isps):.8f}"
  241. )
  242. writer.writerow(clean_row)
  243. def run_pair_roi_mode(args: argparse.Namespace) -> str:
  244. required_args = {
  245. "--subject-a-behavior": args.subject_a_behavior,
  246. "--subject-a-neural": args.subject_a_neural,
  247. "--subject-b-behavior": args.subject_b_behavior,
  248. "--subject-b-neural": args.subject_b_neural,
  249. "--roi-name": args.roi_name,
  250. }
  251. missing_args = [name for name, value in required_args.items() if not value]
  252. if missing_args:
  253. raise SystemExit("Pair/ROI mode is missing: " + ", ".join(missing_args))
  254. subject_a_rows = merge_subject_behavior_neural(
  255. args.subject_a_behavior,
  256. args.subject_a_neural,
  257. )
  258. subject_b_rows = merge_subject_behavior_neural(
  259. args.subject_b_behavior,
  260. args.subject_b_neural,
  261. )
  262. rows = compute_pair_roi_isps_rows(subject_a_rows, subject_b_rows)
  263. subject_pair = subject_pair_label(
  264. subject_a_rows[0]["subject_id"],
  265. subject_b_rows[0]["subject_id"],
  266. )
  267. output_path = args.output
  268. if not output_path:
  269. output_dir = args.output_dir or "."
  270. output_path = os.path.join(
  271. output_dir,
  272. f"{subject_pair}_{args.roi_name}_isps.tsv",
  273. )
  274. write_pair_rows(output_path, rows)
  275. return output_path
  276. def main() -> None:
  277. args = parse_args()
  278. run_pair_roi_mode(args)
  279. if __name__ == "__main__":
  280. main()

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

Overview

Authors: Xuhao Shao1,2,3, Chuansheng Chen4, Elizabeth F. Loftus4, Bi Zhu1,2,3
  1. State Key Laboratory of Cognitive Neuroscience and Learning, Beijing Normal University, Beijing, China
  2. Institute of Developmental Psychology, Beijing Normal University, Beijing, China
  3. IDG/McGovern Institute for Brain Research, Beijing Normal University, Beijing, China
  4. Department of Psychology, University of California, Irvine, California, United States of America
Journal: PLoS biology, volume 24, issue 7, article e3003886
Dates: received 30 December 2025; accepted 17 June 2026; published online 6 July 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1371/journal.pbio.3003886 · PMID 42406796 · PMCID PMC13336189 · OpenAlex W7167508305
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: fMRI (modality), human (organism), cognitive (subfield)
Methods: Connectivity, Statistics, Preprocessing, fMRI & imaging
MeSH: Brain*, Communication*, Memory*, Mental Recall*, Adult, Brain Mapping, Female, Humans, Magnetic Resonance Imaging, Male, Young Adult (* major topic)
Journal subjects: Biology and Life Sciences, Neuroscience, Cognitive Science, Cognition, Memory, Memory Recall, Learning and Memory, False Memories, Anatomy, Brain, Prefrontal Cortex, Medicine and Health Sciences, Cognitive Psychology, Perception, Sensory Perception, Vision, Psychology, Social Sciences, Brain Mapping, Functional Magnetic Resonance Imaging, Diagnostic Medicine, Diagnostic Radiology, Magnetic Resonance Imaging, Research and Analysis Methods, Imaging Techniques, Radiology and Imaging, Neuroimaging, Physical Sciences, Mathematics, Discrete Mathematics, Combinatorics, Permutation, Hippocampus
Topic: Memory Processes and Influences (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Brain Science and Brain-like Intelligence Technology - National Science and Technology Major Project (2021ZD0200500); National Natural Science Foundation of China (32330039, 31971000); Fundamental Research Funds for the Central Universities (2243300006); China Postdoctoral Science Foundation (2024M750210)
Citations: not cited yet (Europe PMC); 84 references in the paper

Abstract

Shared memories of event details are crucial to eyewitness testimony. When different people encode or recall the same event, similar scene-specific neural activity patterns emerge across individual brains. However, it remains unclear whether these patterns are specific to event details and how test expectancy (i.e., expecting free recall or general memory tests) and misinformation affect them. In this study, 100 participants were randomly assigned to view one of two versions of each event. Both versions featured identical scenarios, but with different details. About half of the participants were informed about the upcoming free recall before viewing events, while the others were told to expect a general memory test. Functional magnetic resonance imaging was used to record their brain activity during four stages: viewing original events, initial free recall, reading misinformation, and final free recall of original events. The neuroimaging data were analyzed based on the similarity of neural patterns across participants. Test expectancy increased the similarity of detail-specific neural activity patterns between individuals when they viewed original events in brain regions relevant for visual attention. Misinformation increased the likelihood of people forming shared false memories of event details. People who formed shared false memories exhibited similar detail-specific patterns of activity in the dorsomedial prefrontal cortex when reading misinformation. People who formed shared true memories exhibited similar detail-specific patterns of activity in the inferior parietal lobe when viewing original events, as well as in the ventrolateral prefrontal cortex and middle temporal gyrus when recalling them after exposure to misinformation. Our findings revealed that different brain regions of the default mode network play distinct roles in the encoding and recall of event details shared by individuals.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above.

Zenodo 20656852

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: R (2), Python (1)
Size: 3 files, 3 scripts
Software Heritage: not checked
Found in: “Data Availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: data.table (2 files), lme4 (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
3 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;
  • 3 scripts, each with its path and the digest of its content;
  • no match between paragraphs and code yet;
  • 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

All relevant data is available within the manuscript and Supporting information files. Analysis code is available on Zenodo at: https://doi.org/10.5281/zenodo.20656852.

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

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

Cite

This paper

Shao, X., Chen, C., Loftus, E. F., & Zhu, B. (2026). Shared memories of event details in the human brain are altered by misinformation and test expectations. PLoS biology, 24(7), e3003886. https://doi.org/10.1371/journal.pbio.3003886

BibTeX

@article{shao2026shared,
author = {Shao, Xuhao and Chen, Chuansheng and Loftus, Elizabeth F. and Zhu, Bi},
title = {{Shared memories of event details in the human brain are altered by misinformation and test expectations}},
journal = {PLoS biology},
year = {2026},
month = jul,
volume = {24},
number = {7},
pages = {e3003886},
publisher = {PLOS},
issn = {1544-9173},
doi = {10.1371/journal.pbio.3003886},
url = {https://doi.org/10.1371/journal.pbio.3003886},
pmid = {42406796},
pmcid = {PMC13336189}
}

RIS

TY - JOUR
AU - Shao, Xuhao
AU - Chen, Chuansheng
AU - Loftus, Elizabeth F.
AU - Zhu, Bi
TI - Shared memories of event details in the human brain are altered by misinformation and test expectations
T2 - PLoS biology
J2 - PLoS Biol
PY - 2026
DA - 2026/07/06
VL - 24
IS - 7
SP - e3003886
SN - 1544-9173
PB - PLOS
DO - 10.1371/journal.pbio.3003886
UR - https://doi.org/10.1371/journal.pbio.3003886
LA - en
ER -

CSL-JSON

{
"id": "10.1371/journal.pbio.3003886",
"type": "article-journal",
"title": "Shared memories of event details in the human brain are altered by misinformation and test expectations",
"container-title": "PLoS biology",
"author": [
{
"family": "Shao",
"given": "Xuhao"
},
{
"family": "Chen",
"given": "Chuansheng"
},
{
"family": "Loftus",
"given": "Elizabeth F."
},
{
"family": "Zhu",
"given": "Bi"
}
],
"container-title-short": "PLoS Biol",
"volume": "24",
"issue": "7",
"page": "e3003886",
"DOI": "10.1371/journal.pbio.3003886",
"PMID": "42406796",
"PMCID": "PMC13336189",
"ISSN": "1544-9173",
"publisher": "PLOS",
"URL": "https://doi.org/10.1371/journal.pbio.3003886",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
6
]
]
}
}

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/s44271-026-00481-0 [code]
Natural language processing captures memory content associated with shared neural patterns at encoding and retrieval.
Journal: Communications psychology
In common: lme4, cognitive, 7 references
[2] doi:10.1016/j.neuroimage.2026.122171 [code]
A conserved node degree-based backbone and flexible hub organization of brain connectome during naturalistic movie watching.
Journal: NeuroImage
In common: fMRI, 5 references
[3] doi:10.1073/pnas.2530482123 [code]
The detection of episodic memory in others biases social choice.
Journal: Proceedings of the National Academy of Sciences of the United States of America
In common: lme4, cognitive, 3 references
[4] doi:10.1038/s41467-026-71428-6 [code]
Binding items to contexts through conjunctive neural representations with the method of loci.
Journal: Nature communications
In common: lme4, 3 references
[5] doi:10.1038/s41467-026-73914-3 [code]
Cortical reinstatement of causally related events sparks narrative insights by updating neural representation patterns.
Journal: Nature communications
In common: lme4, cognitive, 2 references
[6] doi:10.1371/journal.pbio.3003666 [code]
Emotion regulation success involves systematic gradient-based reconfigurations of large-scale activation patterns in the human brain.
Journal: PLoS biology
In common: lme4, data.table, fMRI, cognitive, 1 reference
[7] doi:10.1038/s41467-026-76452-0 [code]
Music evokes shared neural representations of imagined narratives across sensory modalities.
Journal: Nature communications
In common: cognitive, 3 references
[8] doi:10.1038/s41597-026-07676-4 [code]
A neuroimaging dataset combining movie-watching, eye-tracking, sensorimotor mapping, and cognitive tasks.
Journal: Scientific data
In common: 3 references
[9] doi:10.1038/s41598-026-58866-4 [code]
A neurocognitive interactive activation model of semantic priming in lexical decisions.
Journal: Scientific reports
In common: lme4, fMRI, cognitive, 1 reference
[10] doi:10.1162/imag.a.1349 [code]
Rapid cortical mapping with cross-participant encoding models.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: fMRI, cognitive, 2 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.