OSCR

Frontal brain injury alters human risky choices in self and other contexts.

Code ↔ Paper

2 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 2 matches
  1. [1] § STAR★Methods › Quantification and statistical analysis › Computational modeling ↔ Analysis_Code/OSF_model_comparison.py, lines 186–228 · score 0.60 · log likelihood, optimization, bounds, BFGS, error, AIC
  2. [2] § Results › Model selection and validation ↔ Analysis_Code/OSF_bootstrap_and_sensitivity.py, lines 225–252 · score 0.51 · CI widths, bootstrap CIs, Median

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 · 334 lines · 10 KB · no license · 1 match

  1. #!/usr/bin/env python3
  2. """
  3. Nested Prospect Theory model comparison (AIC/BIC) using a single CSV trial file.
  4. Assumes the input data (All_Trials_Data_Final.csv) is already perfectly filtered
  5. to contain only the final 40 subjects (20 patients, 20 controls).
  6. Input CSV format (no header), 7 columns:
  7. 0: subject_id
  8. 1: is_patient (0=Control, 1=Patient)
  9. 2: is_other (0=Self, 1=Other)
  10. 3: gain
  11. 4: loss (negative)
  12. 5: p_gain
  13. 6: choice (1=accept, 0=reject)
  14. Models:
  15. - M1 (5 params): alpha, beta, lambda_param, gamma, theta
  16. - M2 (4 params): alpha, lambda_param, gamma, theta; beta = alpha
  17. - M3 (3 params): alpha, gamma, theta; beta = alpha, lambda_param = 1
  18. - M4 (2 params): alpha, theta; beta = alpha, lambda_param = 1, gamma = 1
  19. """
  20. import argparse
  21. from pathlib import Path
  22. import numpy as np
  23. import pandas as pd
  24. from scipy.optimize import minimize
  25. from scipy.special import expit
  26. from tqdm import tqdm
  27. EPS = 1e-10
  28. MODEL_ORDER = ["M1", "M2", "M3", "M4"]
  29. FULL_BOUNDS = {
  30. "alpha": (0.01, 2.0),
  31. "beta": (0.01, 2.0),
  32. "lambda_param": (0.01, 5.0),
  33. "gamma": (0.01, 2.0),
  34. "theta": (0.01, 20.0),
  35. }
  36. def _expand_m1(x):
  37. return np.array([x[0], x[1], x[2], x[3], x[4]], dtype=float)
  38. def _expand_m2(x):
  39. alpha, lambda_param, gamma, theta = x
  40. return np.array([alpha, alpha, lambda_param, gamma, theta], dtype=float)
  41. def _expand_m3(x):
  42. alpha, gamma, theta = x
  43. return np.array([alpha, alpha, 1.0, gamma, theta], dtype=float)
  44. def _expand_m4(x):
  45. alpha, theta = x
  46. return np.array([alpha, alpha, 1.0, 1.0, theta], dtype=float)
  47. MODEL_SPECS = {
  48. "M1": {"free_params": ["alpha", "beta", "lambda_param", "gamma", "theta"], "expand": _expand_m1},
  49. "M2": {"free_params": ["alpha", "lambda_param", "gamma", "theta"], "expand": _expand_m2},
  50. "M3": {"free_params": ["alpha", "gamma", "theta"], "expand": _expand_m3},
  51. "M4": {"free_params": ["alpha", "theta"], "expand": _expand_m4},
  52. }
  53. def parse_args():
  54. parser = argparse.ArgumentParser(description="Nested PT model comparison (AIC/BIC).")
  55. parser.add_argument(
  56. "--input-csv",
  57. type=str,
  58. default="All_Trials_Data_Final.csv",
  59. help="Path to all-trials CSV (default: All_Trials_Data_Final.csv).",
  60. )
  61. parser.add_argument(
  62. "--output-csv",
  63. type=str,
  64. default="model_comparison_results.csv",
  65. help="Output CSV filename.",
  66. )
  67. parser.add_argument(
  68. "--n-starts",
  69. type=int,
  70. default=15,
  71. help="Number of random starts per model fit (minimum enforced: 15).",
  72. )
  73. parser.add_argument(
  74. "--seed",
  75. type=int,
  76. default=42,
  77. help="Random seed for reproducibility.",
  78. )
  79. return parser.parse_args()
  80. def _format_subject_id(value):
  81. try:
  82. x = float(value)
  83. if np.isfinite(x) and np.isclose(x, np.round(x)):
  84. return str(int(np.round(x)))
  85. return f"{x:.6f}".rstrip("0").rstrip(".")
  86. except Exception:
  87. return str(value).strip()
  88. def load_datasets_from_csv(csv_path):
  89. df = pd.read_csv(csv_path, header=None)
  90. if df.shape[1] != 7:
  91. raise ValueError(f"{csv_path} must have exactly 7 columns; found {df.shape[1]}.")
  92. df.columns = [
  93. "subject_id",
  94. "is_patient",
  95. "is_other",
  96. "gain",
  97. "loss",
  98. "p_gain",
  99. "choice",
  100. ]
  101. for col in df.columns:
  102. df[col] = pd.to_numeric(df[col], errors="coerce")
  103. before = len(df)
  104. df = df.dropna().copy()
  105. dropped = before - len(df)
  106. df["group"] = df["is_patient"].map({0: "Control", 1: "Patient"})
  107. df["condition"] = df["is_other"].map({0: "Self", 1: "Other"})
  108. df["subject_id"] = df["subject_id"].apply(_format_subject_id)
  109. datasets = []
  110. grouped = df.groupby(["subject_id", "group", "condition"], sort=True)
  111. for (subject_id, group, condition), g in grouped:
  112. design_matrix = g[["gain", "loss", "p_gain"]].to_numpy(dtype=float)
  113. choices = g["choice"].to_numpy(dtype=int)
  114. if len(choices) == 0:
  115. continue
  116. datasets.append(
  117. {
  118. "subject_id": subject_id,
  119. "group": group,
  120. "condition": condition,
  121. "design_matrix": design_matrix,
  122. "choices": choices,
  123. }
  124. )
  125. datasets.sort(key=lambda d: (d["group"], d["condition"], d["subject_id"]))
  126. return datasets, len(df), dropped
  127. def prelec_weight(p, gamma):
  128. p = np.clip(p, EPS, 1.0 - EPS)
  129. return np.exp(-((-np.log(p)) ** gamma))
  130. def compute_p_accept(full_params, design_matrix):
  131. alpha, beta, lambda_param, gamma, theta = full_params
  132. gain = np.clip(design_matrix[:, 0], EPS, None)
  133. loss = design_matrix[:, 1]
  134. p_gain = design_matrix[:, 2]
  135. p_loss = 1.0 - p_gain
  136. u_gain = gain ** alpha
  137. u_loss = -lambda_param * (np.abs(loss) ** beta)
  138. v = prelec_weight(p_gain, gamma) * u_gain + prelec_weight(p_loss, gamma) * u_loss
  139. p_accept = expit(theta * v)
  140. return np.clip(p_accept, EPS, 1.0 - EPS)
  141. def neg_log_likelihood(free_params, model_name, design_matrix, choices):
  142. full_params = MODEL_SPECS[model_name]["expand"](free_params)
  143. p_accept = compute_p_accept(full_params, design_matrix)
  144. ll = np.sum(choices * np.log(p_accept) + (1.0 - choices) * np.log(1.0 - p_accept))
  145. return -float(ll)
  146. def fit_model_for_subject(choices, design_matrix, model_name, n_starts, rng):
  147. free_names = MODEL_SPECS[model_name]["free_params"]
  148. bounds = [FULL_BOUNDS[name] for name in free_names]
  149. best_fun = np.inf
  150. best_x = None
  151. for _ in range(max(15, n_starts)):
  152. x0 = np.array([rng.uniform(lo, hi) for lo, hi in bounds], dtype=float)
  153. res = minimize(
  154. neg_log_likelihood,
  155. x0=x0,
  156. args=(model_name, design_matrix, choices),
  157. method="L-BFGS-B",
  158. bounds=bounds,
  159. )
  160. # Keep the numerically best fit even if optimizer flags a warning.
  161. if np.isfinite(res.fun) and res.fun < best_fun:
  162. best_fun = float(res.fun)
  163. best_x = np.array(res.x, dtype=float)
  164. if best_x is None:
  165. raise RuntimeError(f"Optimization failed for model {model_name}.")
  166. full_params = MODEL_SPECS[model_name]["expand"](best_x)
  167. k = len(free_names)
  168. n_trials = int(len(choices))
  169. ll = -best_fun
  170. aic = 2 * k - 2 * ll
  171. bic = k * np.log(max(n_trials, 1)) - 2 * ll
  172. return {
  173. "k": k,
  174. "LL": ll,
  175. "AIC": aic,
  176. "BIC": bic,
  177. "alpha": full_params[0],
  178. "beta": full_params[1],
  179. "lambda_param": full_params[2],
  180. "gamma": full_params[3],
  181. "theta": full_params[4],
  182. }
  183. def print_summary(results_df):
  184. print("\nMean AIC/BIC by model")
  185. print("-" * 46)
  186. print(f"{'Model':<8}{'Mean AIC':>18}{'Mean BIC':>18}")
  187. print("-" * 46)
  188. summary = (
  189. results_df.groupby("model")[["AIC", "BIC"]]
  190. .mean()
  191. .reindex(MODEL_ORDER)
  192. )
  193. for model in MODEL_ORDER:
  194. row = summary.loc[model]
  195. print(f"{model:<8}{row['AIC']:>18.3f}{row['BIC']:>18.3f}")
  196. print("-" * 46)
  197. grouping = ["subject_id", "group", "condition"]
  198. best_aic_rows = results_df.loc[results_df.groupby(grouping)["AIC"].idxmin()]
  199. best_bic_rows = results_df.loc[results_df.groupby(grouping)["BIC"].idxmin()]
  200. best_aic_counts = best_aic_rows["model"].value_counts().reindex(MODEL_ORDER, fill_value=0)
  201. best_bic_counts = best_bic_rows["model"].value_counts().reindex(MODEL_ORDER, fill_value=0)
  202. print("\nBest-model counts (lowest AIC)")
  203. for model in MODEL_ORDER:
  204. print(f"{model}: {int(best_aic_counts[model])}")
  205. print("\nBest-model counts (lowest BIC)")
  206. for model in MODEL_ORDER:
  207. print(f"{model}: {int(best_bic_counts[model])}")
  208. def main():
  209. args = parse_args()
  210. rng = np.random.default_rng(args.seed)
  211. datasets, n_trials, dropped_rows = load_datasets_from_csv(args.input_csv)
  212. if not datasets:
  213. raise RuntimeError("No valid subject-condition datasets were loaded from CSV.")
  214. print(f"\nLoaded {len(datasets)} subject-condition datasets from {n_trials} valid trials.")
  215. if dropped_rows > 0:
  216. print(f"Dropped {dropped_rows} rows with missing/non-numeric values.")
  217. results = []
  218. total_fits = len(datasets) * len(MODEL_ORDER)
  219. with tqdm(total=total_fits, desc="Fitting models") as pbar:
  220. for ds in datasets:
  221. design_matrix = ds["design_matrix"]
  222. choices = ds["choices"]
  223. for model_name in MODEL_ORDER:
  224. fit = fit_model_for_subject(
  225. choices=choices,
  226. design_matrix=design_matrix,
  227. model_name=model_name,
  228. n_starts=args.n_starts,
  229. rng=rng,
  230. )
  231. results.append({
  232. "subject_id": ds["subject_id"],
  233. "group": ds["group"],
  234. "condition": ds["condition"],
  235. "model": model_name,
  236. "k": fit["k"],
  237. "LL": fit["LL"],
  238. "AIC": fit["AIC"],
  239. "BIC": fit["BIC"],
  240. "alpha": fit["alpha"],
  241. "beta": fit["beta"],
  242. "lambda_param": fit["lambda_param"],
  243. "gamma": fit["gamma"],
  244. "theta": fit["theta"],
  245. })
  246. pbar.update(1)
  247. results_df = pd.DataFrame(results)[
  248. [
  249. "subject_id",
  250. "group",
  251. "condition",
  252. "model",
  253. "k",
  254. "LL",
  255. "AIC",
  256. "BIC",
  257. "alpha",
  258. "beta",
  259. "lambda_param",
  260. "gamma",
  261. "theta",
  262. ]
  263. ]
  264. results_df.to_csv(args.output_csv, index=False)
  265. print(f"\nSaved results to: {Path(args.output_csv).resolve()}")
  266. print_summary(results_df)
  267. if __name__ == "__main__":
  268. main()

OSF_model_comparison.py, no license · at the source

Overview

Authors: Farzad Rostami1,2, Sarvenaz Soltani3,4, Jordan Grafman5,6, Raheleh Heyrani7, Aryan Yazdanpanah8, Amin Jahanbakhshi9,10, Abdol-Hossein Vahabie11, Seyed Vahid Shariat12, AmirHussein Abdolalizadeh13, Fatemeh Sadat Mirfazeli3,4,12
13 affiliations
  1. Institut des Sciences Cognitives Marc Jeannerod –UMR5229, CNRS & Université Claude Bernard Lyon1, 67 Boulevard Pinel, Bron 69675, France
  2. School of Cognitive Sciences, Institute for Research in Fundamental Sciences (IPM), Tehran, Iran
  3. National Brain Centre, Iran University of Medical Sciences, Tehran, Iran
  4. Faculty of Advanced Technologies in Medicine, Iran University of Medical Sciences, Tehran, Iran
  5. Shirley Ryan Ability Lab, Departments of Physical Medicine and Rehabilitation, Neurology, Cognitive Neurology, and Alzheimer’s Center, Chicago, IL, USA
  6. Department of Psychiatry, Feinberg School of Medicine and Psychology, Weinberg College of Arts and Sciences, Northwestern University, Chicago, IL, USA
  7. Department of Applied Educational Science, Umeå University, Umeå, Sweden
  8. Department of Psychological and Brain Sciences, Dartmouth College, Hanover, NH, USA
  9. Department of Neurosurgery, Skull Base Research Center, Rasool-Akram Hospital, Iran University of Medical Sciences, Tehran, Iran
  10. Stem Cell and Regenerative Medicine Research Center, Iran University of Medical Sciences, Tehran, Iran
  11. Cognitive Systems Laboratory, Control and Intelligent Processing Center of Excellence (CIPCE), School of Electrical and Computer Engineering, College of Engineering, University of Tehran, Tehran, Iran
  12. Mental Health Research Center, Psychosocial Health Research Institute, Department of Psychiatry, School of Medicine, Iran University of Medical Sciences, Tehran, Iran
  13. Department of Psychology, Carl Von Ossietzky University, Oldenburg, Germany
Journal: iScience, volume 29, issue 7, article 116427
Dates: received 15 November 2025; accepted 1 June 2026; published online 18 June 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1016/j.isci.2026.116427 · PMID 42375538 · PMCID PMC13312174 · OpenAlex W7165156847
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism)
Methods: Spectral & time-frequency, Statistics
Keywords: health sciences, medicine, neuroscience
Topic: Traumatic Brain Injury Research (Epidemiology, Medicine), according to OpenAlex
Funding: Iran University of Medical Sciences
Citations: not cited yet (Europe PMC); 32 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 2 matches between paragraphs and lines of code.

OSF cx73n

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: Python (4)
Size: 85 files, 4 scripts
Software Heritage: not checked
Found in: the text, “Software”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (4 files), pandas (4 files), SciPy (4 files), Matplotlib (1 file), Pingouin (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
4 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;
  • 4 scripts, each with its path and the digest of its content;
  • 2 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.

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

  • it says that the data are available on request
  • it says that the code is available on request

Read it in the paper: doi.org/10.1016/j.isci.2026.116427.

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, 10 authors, 3 keywords, 1 funder, 31 references.

Cite

This paper

Rostami, F., Soltani, S., Grafman, J., Heyrani, R., Yazdanpanah, A., Jahanbakhshi, A., Vahabie, A.-H., Shariat, S. V., Abdolalizadeh, A., & Mirfazeli, F. S. (2026). Frontal brain injury alters human risky choices in self and other contexts. iScience, 29(7), 116427. https://doi.org/10.1016/j.isci.2026.116427

BibTeX

@article{rostami2026frontal,
author = {Rostami, Farzad and Soltani, Sarvenaz and Grafman, Jordan and Heyrani, Raheleh and Yazdanpanah, Aryan and Jahanbakhshi, Amin and Vahabie, Abdol-Hossein and Shariat, Seyed Vahid and Abdolalizadeh, AmirHussein and Mirfazeli, Fatemeh Sadat},
title = {{Frontal brain injury alters human risky choices in self and other contexts}},
journal = {iScience},
year = {2026},
month = jun,
volume = {29},
number = {7},
pages = {116427},
publisher = {Elsevier},
issn = {2589-0042},
doi = {10.1016/j.isci.2026.116427},
url = {https://doi.org/10.1016/j.isci.2026.116427},
pmid = {42375538},
pmcid = {PMC13312174}
}

RIS

TY - JOUR
AU - Rostami, Farzad
AU - Soltani, Sarvenaz
AU - Grafman, Jordan
AU - Heyrani, Raheleh
AU - Yazdanpanah, Aryan
AU - Jahanbakhshi, Amin
AU - Vahabie, Abdol-Hossein
AU - Shariat, Seyed Vahid
AU - Abdolalizadeh, AmirHussein
AU - Mirfazeli, Fatemeh Sadat
TI - Frontal brain injury alters human risky choices in self and other contexts
T2 - iScience
J2 - iScience
PY - 2026
DA - 2026/06/18
VL - 29
IS - 7
SP - 116427
SN - 2589-0042
PB - Elsevier
DO - 10.1016/j.isci.2026.116427
UR - https://doi.org/10.1016/j.isci.2026.116427
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.isci.2026.116427",
"type": "article-journal",
"title": "Frontal brain injury alters human risky choices in self and other contexts",
"container-title": "iScience",
"author": [
{
"family": "Rostami",
"given": "Farzad"
},
{
"family": "Soltani",
"given": "Sarvenaz"
},
{
"family": "Grafman",
"given": "Jordan"
},
{
"family": "Heyrani",
"given": "Raheleh"
},
{
"family": "Yazdanpanah",
"given": "Aryan"
},
{
"family": "Jahanbakhshi",
"given": "Amin"
},
{
"family": "Vahabie",
"given": "Abdol-Hossein"
},
{
"family": "Shariat",
"given": "Seyed Vahid"
},
{
"family": "Abdolalizadeh",
"given": "AmirHussein"
},
{
"family": "Mirfazeli",
"given": "Fatemeh Sadat"
}
],
"container-title-short": "iScience",
"volume": "29",
"issue": "7",
"page": "116427",
"DOI": "10.1016/j.isci.2026.116427",
"PMID": "42375538",
"PMCID": "PMC13312174",
"ISSN": "2589-0042",
"publisher": "Elsevier",
"URL": "https://doi.org/10.1016/j.isci.2026.116427",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
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.3389/fnhum.2026.1813515 [code]
Neural correlates of risky monetary decision-making impacting others.
Journal: Frontiers in human neuroscience
In common: 3 references
[2] doi:10.1371/journal.pone.0358044 [code]
An exploratory fNIRS study on directional asymmetry in segmental discrimination: Lateral-rhotic (/la-ra/) and labial-dorsal (/ba-ga/) contrasts tested in 5- and 9-month-old Japanese infants.
Journal: PloS one
In common: Pingouin, pandas, SciPy, 2 other tools
[3] doi:10.1371/journal.pcbi.1013752 [code]
Calmodulin controls spatial and temporal specificity of calcium-induced calcium release.
Journal: PLoS computational biology
In common: Pingouin, pandas, SciPy, 2 other tools
[4] doi:10.7554/elife.108408 [code]
Frequency and laminar profile of feature-specific visual activity revealed by interleaved EEG-fMRI.
Journal: eLife
In common: Pingouin, pandas, SciPy, 2 other tools
[5] doi:10.7554/elife.108673 [code]
Adaptive behavior is guided by integrated representations of controlled and non-controlled information.
Journal: eLife
In common: Pingouin, pandas, SciPy, 2 other tools
[6] doi:10.1371/journal.pcbi.1014571 [code]
SynAPSeg: A novel dataset and image analysis framework for deep learning-based synapse detection and quantification.
Journal: PLoS computational biology
In common: Pingouin, pandas, SciPy, 2 other tools
[7] doi:10.1093/braincomms/fcag270 [code]
Neural correlates of emotion processing and regulation dissociate frontal and temporal lobe epilepsy.
Journal: Brain communications
In common: Pingouin, pandas, SciPy, 2 other tools
[8] doi:10.1007/s10548-026-01238-y [code]
Topographic Reorganization of EEG Complexity During Visual Mental Imagery: Insights from Lempel-Ziv Complexity in High-Density EEG.
Journal: Brain topography
In common: Pingouin, pandas, SciPy, 2 other tools
[9] doi:10.1038/s41467-026-75705-2 [code]
Redundant prefrontal hemispheres adapt storage strategy to working memory demands.
Journal: Nature communications
In common: Pingouin, pandas, SciPy, 2 other tools
[10] doi:10.1038/s41467-026-74743-0 [code]
Meta-analytic evidence for distinct neural correlates of conditioned versus verbally induced placebo analgesia.
Journal: Nature communications
In common: Pingouin, pandas, SciPy, 2 other tools

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.