OSCR

Neural similarity between choice options predicts group-level context effects.

Code ↔ Paper

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

3 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 18 matches
  1. [1] § Methods › Computational modeling ↔ code/behavioral_computational/computational_models.ipynb, lines 256 to 316 · score 0.74 · computational models, cross validation, predicted decoy, fmin, optimization, scipy · Report a mismatch
  2. [2] § Methods › Representational Similarity Analysis regression › Neural RDM regressions › Out-of-sample predictions ↔ code/mri/fig2_predictions.ipynb, lines 158 to 220 · score 0.70 · Lasso regression, cross validation, hyperparameter, inner, held, fold · Report a mismatch
  3. [3] § Results › The decoy effect is predicted by the similarity of neural representations ↔ code/behavioral_computational/computational_models.ipynb, lines 256 to 316 · score 0.66 · square error, cross validation, computational model, models prediction, fold, RMSE · Report a mismatch
  4. [4] § Methods › Explicit attribute representation analysis › Whole-brain attribute representation levels ↔ code/mri/fig3_attribute_representation_levels.ipynb, lines 177 to 222 · score 0.64 · posterior anterior coordinate, attribute representation, quadratic, parcel, fitted · Report a mismatch
  5. [5] § Methods › Representational Similarity Analysis regression › Pre-defined regions of interest ↔ code/mri/fig4_rep_geometry.ipynb, lines 112 to 166 · score 0.64 · vmPFC, vSTR, ACC, M1, PCC, V1 · Report a mismatch
  6. [6] § Methods › Behavioral tasks › Lottery evaluation task ↔ code/behavioral_computational/read_files.py, lines 335 to 379 · score 0.63 · remaining budget, behavioral sample, BDM, win, blocks · block oscr:b:JH3WXH0EEB3FZ-E · Report a mismatch
  7. [7] § Methods › Representational Similarity Analysis regression › Pre-defined regions of interest ↔ code/mri/fig2_fitting.ipynb, lines 26 to 30 · score 0.63 · vmPFC, vSTR, ACC, M1, PCC, V1 · Report a mismatch
  8. [8] § Results › The decoy effect is predicted by the similarity of neural representations ↔ code/mri/fig2_predictions.ipynb, lines 158 to 220 · score 0.62 · square error, Lasso regression, cross validation, fold, RMSE, trained · Report a mismatch
  9. [9] § Results › The decoy effect is predicted by the similarity of neural representations ↔ code/mri/fig3_attribute_representation_levels.ipynb, lines 177 to 222 · score 0.59 · quadratic fit, attribute RDM, attribute representation, anterior, posterior, parcel · Report a mismatch
  10. [10] § Methods › Representational Similarity Analysis regression › Neural RDM regressions › Data fitting ↔ code/mri/utils/stepwise_rdm.py, lines 14 to 48 · score 0.58 · forward stepwise regression, stepwise procedure, fitted, ROIs, RDMs, models · block oscr:b:2WT2JTQVWQNZX-X · Report a mismatch
  11. [11] § Methods › Computational modeling › Evidence accumulation (drift-diffusion) models ↔ code/behavioral_computational/ddms/ddms_model_eval.ipynb, lines 12 to 17 · score 0.56 · Mutual Inhibition, Selective Integration, competitor, fit, models, decoy · Report a mismatch
  12. [12] § Results › Mixture of explicit and latent attributes in neural representations predicts the decoy effect ↔ code/mri/fig3_attribute_representation_levels.ipynb, lines 35 to 61 · score 0.56 · lower triangles, attribute RDM, neural RDM, attribute representation, correlated, ROIs · Report a mismatch
  13. [13] § Results › The decoy effect is predicted by the similarity of neural representations ↔ code/behavioral_computational/computational_models.ipynb, lines 148 to 223 · score 0.54 · Recurrent Divisive Normalization, computational model, error, probability, prediction, decoy · Report a mismatch
  14. [14] § Methods › Computational modeling › Evidence accumulation (drift-diffusion) models ↔ code/behavioral_computational/ddms/ddms_model_eval.ipynb, lines 12 to 17 · score 0.53 · Mutual Inhibition, Selective Integration, models, decoy · Report a mismatch
  15. [15] § Results › The decoy effect is predicted by the similarity of neural representations ↔ code/mri/fig4_rep_geometry.ipynb, lines 361 to 431 · score 0.53 · biweight midcorrelation, effective dimensionality, networks, attribute representation, parcel, Figure 4 · Report a mismatch
  16. [16] § Results › The decoy effect is predicted by the similarity of neural representations ↔ code/mri/utils/stepwise_rdm.py, lines 14 to 48 · score 0.52 · forward stepwise regression, RDM regressions, FDR, fit, ROIs, model · block oscr:b:2WT2JTQVWQNZX-X · Report a mismatch
  17. [17] § Results › Low explicit attribute representation is tied to higher effective dimensionality ↔ code/mri/fig4_rep_geometry.ipynb, lines 112 to 166 · score 0.52 · vSTR, effective dimensionality, ACC, PCC, V1, MT · Report a mismatch
  18. [18] § Methods › Attributes-based models ↔ code/mri/utils/rdm_regression.py, lines 1 to 15 · score 0.51 · linear regression, neural RDM regression, fitted, predictions, decoy · block oscr:b:PA7FCWMV29Y2E-4 · 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

Jupyter notebook · 372 lines · 17 KB · CC-BY-4.0 · 3 matches

  1. # %% [markdown]
  2. # # Computational models of the decoy effect
  3. #
  4. # Fits and compares standard context-effect models: Adaptive Gain, Divisive Normalization, Range Normalization, to the empirical per-set decoy effects.
  5. # Each model predicts the trinary-vs-binary change in target choice share from the lottery attributes.
  6. # Leave-one-lottery-out cross-validated predictions are reported via MSE. Fitting results are reported as R^2.
  7. # %%
  8. import glob
  9. import os
  10. import tqdm
  11. import pandas as pd
  12. import numpy as np
  13. import matplotlib.pyplot as plt
  14. import matplotlib
  15. import scipy
  16. from scipy import optimize
  17. import read_files
  18. from copy import deepcopy
  19. from sklearn.metrics import mean_squared_error
  20. import warnings
  21. warnings.simplefilter(action='ignore', category=RuntimeWarning)
  22. # %%
  23. choice_stimuli = pd.read_csv('../../stimuli/stimuli_trinary.csv')
  24. trinary_stimuli = choice_stimuli
  25. binary_stimuli = pd.read_csv('../../stimuli/stimuli_binary.csv')
  26. # %%
  27. decoy_effects = pd.read_csv('../../results/decoy_table.csv')
  28. y = decoy_effects.decoy_effect_A.values
  29. # %% [markdown]
  30. # ### Fit computational models: Adaptive Gain
  31. # %% [markdown]
  32. # #### min-max scaling of amount and probabilities
  33. # %%
  34. binary_stimuli = trinary_stimuli.drop(['amountC', 'probC', 'trinary_id'], axis=1)
  35. binary_stimuli.loc[:, 'avg_amounts'] = np.mean(binary_stimuli.loc[:, ['amountA', 'amountB']], 1)
  36. binary_stimuli.loc[:, 'avg_probs'] = np.mean(binary_stimuli.loc[:, ['probA', 'probB']], 1)
  37. binary_stimuli = binary_stimuli.loc[binary_stimuli.binary_id < 28, :] # remove catch trials
  38. trinary_stimuli = trinary_stimuli.drop(['binary_id'], axis=1)
  39. trinary_stimuli.loc[:, 'avg_amounts'] = np.mean(trinary_stimuli.loc[:, ['amountA', 'amountB', 'amountC']], 1)
  40. trinary_stimuli.loc[:, 'avg_probs'] = np.mean(trinary_stimuli.loc[:, ['probA', 'probB', 'probC']], 1)
  41. trinary_stimuli = trinary_stimuli.loc[trinary_stimuli.trinary_id < 28] # remove catch trials
  42. # %%
  43. min_amount = 4
  44. max_amount = 79
  45. min_prob = 0
  46. max_prob = 100
  47. all_EVs = np.concatenate([trinary_stimuli.EVA.unique(), trinary_stimuli.EVB.unique(), trinary_stimuli.EVC.unique()])
  48. min_EV = np.min(all_EVs)
  49. max_EV = np.max(all_EVs)
  50. to_scale_cols = ['amountA', 'probA', 'amountB', 'probB', 'amountC', 'probC', 'EVA', 'EVB', 'EVC', 'avg_amounts', 'avg_probs']
  51. trinary_stimuli_norm = trinary_stimuli.copy()
  52. trinary_stimuli_norm.loc[:, 'amountA'] = (trinary_stimuli_norm.amountA - min_amount) / (max_amount - min_amount)
  53. trinary_stimuli_norm.loc[:, 'amountB'] = (trinary_stimuli_norm.amountB - min_amount) / (max_amount - min_amount)
  54. trinary_stimuli_norm.loc[:, 'amountC'] = (trinary_stimuli_norm.amountC - min_amount) / (max_amount - min_amount)
  55. trinary_stimuli_norm.loc[:, 'probA'] = (trinary_stimuli_norm.probA - min_prob) / (max_prob - min_prob)
  56. trinary_stimuli_norm.loc[:, 'probB'] = (trinary_stimuli_norm.probB - min_prob) / (max_prob - min_prob)
  57. trinary_stimuli_norm.loc[:, 'probC'] = (trinary_stimuli_norm.probC - min_prob) / (max_prob - min_prob)
  58. trinary_stimuli_norm.loc[:, 'EVA'] = (trinary_stimuli_norm.EVA - min_EV) / (max_EV - min_EV)
  59. trinary_stimuli_norm.loc[:, 'EVB'] = (trinary_stimuli_norm.EVB - min_EV) / (max_EV - min_EV)
  60. trinary_stimuli_norm.loc[:, 'EVC'] = (trinary_stimuli_norm.EVC - min_EV) / (max_EV - min_EV)
  61. trinary_stimuli_norm.loc[:, 'avg_amounts'] = trinary_stimuli_norm.loc[:, ['amountA', 'amountB', 'amountC']].mean(axis=1)
  62. trinary_stimuli_norm.loc[:, 'avg_probs'] = trinary_stimuli_norm.loc[:, ['probA', 'probB', 'probC']].mean(axis=1)
  63. binary_stimuli_norm = binary_stimuli.copy()
  64. binary_stimuli_norm.loc[:, 'amountA'] = (binary_stimuli_norm.amountA - min_amount) / (max_amount - min_amount)
  65. binary_stimuli_norm.loc[:, 'amountB'] = (binary_stimuli_norm.amountB - min_amount) / (max_amount - min_amount)
  66. binary_stimuli_norm.loc[:, 'probA'] = (binary_stimuli_norm.probA - min_prob) / (max_prob - min_prob)
  67. binary_stimuli_norm.loc[:, 'probB'] = (binary_stimuli_norm.probB - min_prob) / (max_prob - min_prob)
  68. binary_stimuli_norm.loc[:, 'EVA'] = (binary_stimuli_norm.EVA - min_EV) / (max_EV - min_EV)
  69. binary_stimuli_norm.loc[:, 'EVB'] = (binary_stimuli_norm.EVB - min_EV) / (max_EV - min_EV)
  70. binary_stimuli_norm.loc[:, 'avg_amounts'] = binary_stimuli_norm.loc[:, ['amountA', 'amountB']].mean(axis=1)
  71. binary_stimuli_norm.loc[:, 'avg_probs'] = binary_stimuli_norm.loc[:, ['probA', 'probB']].mean(axis=1)
  72. # %% [markdown]
  73. # #### read choice file per set, instead of per subject
  74. # %%
  75. raw_choices = pd.DataFrame()
  76. raw_files = glob.glob('../../data/behavioral_experiment/raw_choices_per_set/*.csv')
  77. for i in range(len(raw_files)):
  78. set_choices = pd.read_csv(raw_files[i])
  79. raw_choices = pd.concat([raw_choices, set_choices], axis=0)
  80. # remove catch trials
  81. raw_choices = raw_choices[raw_choices.binary_id<28]
  82. raw_choices = raw_choices[raw_choices.subject_id.str.contains('-')]
  83. # %%
  84. # add the lotteries' attributes to the choices
  85. binary_raw_choices = raw_choices[raw_choices.trinary_group==0]
  86. trinary_raw_choices = raw_choices[raw_choices.trinary_group==1]
  87. trinary_raw_choices_stimuli = trinary_raw_choices.merge(trinary_stimuli_norm, left_on='trinary_id', right_on='trinary_id', how='outer')
  88. binary_raw_choices_stimuli = binary_raw_choices.merge(binary_stimuli_norm, left_on='binary_id', right_on='binary_id', how='outer')
  89. # %%
  90. raw_choices_stimuli = pd.concat([binary_raw_choices_stimuli, trinary_raw_choices_stimuli], axis=0)
  91. # %%
  92. def trinary_neg_log_likelihood(p_all, choices):
  93. """
  94. Compute negative log-likelihood for trinary choice data.
  95. Parameters:
  96. - p_all: np.ndarray of shape (n_trials, 3), model predicted probabilities for [A, B, C]
  97. - choices: np.ndarray of shape (n_trials,), with values in {'A', 'B', 'C'}
  98. Returns:
  99. - neg_log_like: scalar, sum of negative log-likelihood over trials
  100. """
  101. # Map choices to indices
  102. choice_map = {'A': 0, 'B': 1, 'C': 2}
  103. choice_indices = np.vectorize(choice_map.get)(choices)
  104. # Extract the predicted probability assigned to the chosen option
  105. chosen_p = p_all[np.arange(len(choices)), choice_indices]
  106. # Avoid log(0)
  107. chosen_p = np.clip(chosen_p, 1e-5, 1 - 1e-5)
  108. # Compute NLL
  109. neg_log_like = -np.nansum(np.log(chosen_p))
  110. return neg_log_like
  111. # %%
  112. def softmax(x, tau=1):
  113. """
  114. Compute softmax probabilities for a given input vector x and temperature tau.
  115. Parameters:
  116. - x: np.ndarray, input vector of values
  117. - tau: float, temperature parameter
  118. Returns:
  119. - np.ndarray, softmax probabilities
  120. """
  121. exp_u = np.exp(tau*x)
  122. softmax_denominator = np.nansum(exp_u, axis=1, keepdims=True)
  123. p_all = exp_u / softmax_denominator
  124. return p_all
  125. # %%
  126. def run_model(params, df, model_type='AG', return_p=0):
  127. """
  128. Evaluate a context-effect model on a batch of choice trials or stimuli.
  129. Supports three families of models, each combining attribute-level
  130. normalization with a softmax decision rule and an amount/probability
  131. weighting ``w``:
  132. - 'AG' (Adaptive Gain): sigmoidal squashing of each attribute
  133. around the contextual mean with slope parameters.
  134. - 'DN' (Divisive Normalization): attribute divided by a
  135. weighted contextual sum plus a saturation constant.
  136. - 'RDN' (Recurrent Divisive Normalization): attribute divided by
  137. itself plus the contextual sum plus a saturation constant.
  138. Parameters:
  139. params: tuple of model parameters in the order documented above
  140. for each ``model_type``.
  141. df: DataFrame with columns ``amountA/B[/C]``, ``probA/B[/C]``,
  142. and the contextual means ``avg_amounts`` and ``avg_probs``.
  143. If ``target_choice`` or ``actual_choice`` is present the
  144. function returns the negative log-likelihood of the choices.
  145. model_type: 'AG', 'DN' or 'RDN'.
  146. return_p: if truthy, return the predicted ``P(A) / (P(A)+P(B))``
  147. instead of the negative log-likelihood (used to derive the
  148. model-predicted decoy effect from stimuli without choices).
  149. Returns:
  150. Either the predicted A-vs-B choice probabilities (when
  151. ``return_p`` is truthy) or the summed negative log-likelihood of
  152. the observed choices under the model.
  153. """
  154. # df could be subjects raw choices, or dataframe of stimuli (amounts, probs) without choices
  155. if 'amountC' in df.columns:
  156. amounts = df[['amountA', 'amountB', 'amountC']]
  157. probs = df[['probA', 'probB', 'probC']]
  158. else:
  159. amounts = df[['amountA', 'amountB']]
  160. probs = df[['probA', 'probB']]
  161. n_amounts = amounts.shape[1]
  162. avg_amounts_mat = np.vstack([df.avg_amounts.values]*n_amounts).transpose()
  163. avg_probs_mat = np.vstack([df.avg_probs.values]*n_amounts).transpose()
  164. if model_type=='RDN':
  165. # recurrent divisive normalization
  166. c_amount, c_prob, tau, w = params
  167. u_amounts = amounts / (amounts + avg_amounts_mat + c_amount)
  168. u_probs = probs / (probs + avg_probs_mat + c_prob)
  169. elif model_type=='DN':
  170. # divisive normalization
  171. c_amount, c_prob, tau, omega_amount, omega_prob, w = params
  172. u_amounts = amounts / (omega_amount*avg_amounts_mat + c_amount)
  173. u_probs = probs / (omega_prob*avg_probs_mat + c_prob)
  174. elif model_type=='AG':
  175. # adaptive gain
  176. c_amount, c_prob, tau, slope_amount, slope_prob, w = params
  177. u_amounts = 1 / (1 + np.exp(-1 * (amounts - avg_amounts_mat - c_amount) / slope_amount))
  178. u_probs = 1 / (1 + np.exp(-1 * (probs - avg_probs_mat - c_prob) / slope_prob))
  179. else:
  180. raise ValueError('model_type must be "AG" (adaptive gain), "RDN" or "DN" ([recurrent] devisive normalization)')
  181. u_all = w*u_amounts.values + (1-w)*u_probs.values
  182. p_all = softmax(u_all, tau=tau)
  183. p_A = p_all[:, 0]
  184. p_B = p_all[:, 1]
  185. p_C = p_all[:, 2] if n_amounts == 3 else np.zeros_like(p_A)
  186. p_A[p_A==0] = 1e-5
  187. p_B[p_B==0] = 1e-5
  188. p_C[p_C==0] = 1e-5
  189. if return_p:
  190. return p_A / (p_A + p_B)
  191. if 'target_choice' in df.columns:
  192. choose_A = df.target_choice.values
  193. neg_log_like = -1 * np.sum(choose_A * np.log(p_A) + (1-choose_A)*np.log(p_B))
  194. neg_log_like = trinary_neg_log_likelihood(p_all, df.actual_choice.values) if n_amounts == 3 else neg_log_like
  195. return neg_log_like
  196. # %%
  197. # c_amount, c_prob, tau, slope, w
  198. AG_init_params = np.array([0. , 0, 0.1 , 0.1, 0.1, 0.5])
  199. # c_amount, c_prob, tau, w
  200. RDN_init_params = np.array([0. , 0, 0.1 , 0.5 ])
  201. DN_init_params = AG_init_params
  202. # %% [markdown]
  203. # ### out of sample predictions (leave-one-set-out)
  204. # %%
  205. os.chdir('../mri')
  206. from utils import load_params
  207. behavior_results = load_params.load_behavior_results()
  208. set_objs = load_params.load_sets(behavior_results)
  209. folds = []
  210. for i, set_out in enumerate(set_objs):
  211. test_sets = []
  212. test_ind = []
  213. train_sets = []
  214. train_ind = []
  215. for j, set_obj in enumerate(set_objs):
  216. if set_obj.overlapping_with(set_out):
  217. test_sets.append(set_obj)
  218. test_ind.append(j)
  219. else:
  220. train_sets.append(set_obj)
  221. train_ind.append(j)
  222. if (train_ind, test_ind) not in folds:
  223. folds.append((train_ind, test_ind))
  224. # %%
  225. def cv_comp_model(folds, model_type='AG', init_params=AG_init_params):
  226. """
  227. Leave-one-set-out cross-validation of a computational choice model.
  228. For each fold the model parameters are fit to the pooled raw
  229. choices of the training sets (group-level fit), then used to
  230. predict the held-out sets' decoy effect as the difference between
  231. model-predicted target shares in the trinary and binary stimuli.
  232. Parameters:
  233. folds: iterable of (train_indices, test_indices) tuples over
  234. lottery-set indices (0-based).
  235. model_type: 'AG', 'DN' or 'RDN' (see :func:`run_model`).
  236. init_params: initial parameter vector for ``scipy.optimize.fmin``.
  237. Returns:
  238. Tuple ``(cv_rmse, cv_corr, train_rmse)`` of per-fold arrays
  239. with the out-of-sample RMSE, Spearman correlation between
  240. predicted and observed decoy effects, and the training
  241. RMSE for reference.
  242. """
  243. cv_rmse = np.zeros(len(folds))
  244. cv_corr = np.zeros(len(folds))
  245. train_rmse = np.zeros(len(folds))
  246. fold_i = 0
  247. for train_ind, test_ind in tqdm.tqdm(folds):
  248. # train test split
  249. y_train, y_test = y[train_ind], y[test_ind]
  250. train_set_inds = np.array(train_ind) + 1
  251. test_set_inds = np.array(test_ind) + 1
  252. train_raw_choices = raw_choices_stimuli[raw_choices_stimuli.trinary_id.isin(train_set_inds)]
  253. test_raw_choices = raw_choices_stimuli[raw_choices_stimuli.trinary_id.isin(test_set_inds)]
  254. # fit params to group level choices
  255. group_params = optimize.fmin(run_model, init_params, args=(train_raw_choices, model_type), maxiter=1e4, disp=False)
  256. loglike = -1 * run_model(group_params, test_raw_choices, model_type)
  257. # apply to test choices
  258. test_trinary_stimuli = trinary_stimuli_norm.loc[trinary_stimuli_norm.trinary_id.isin(test_set_inds)]
  259. test_binary_stimuli = binary_stimuli_norm.loc[binary_stimuli_norm.binary_id.isin(test_set_inds)]
  260. # calculate predicted decoy effects (average trinary minus average binary)
  261. trinary_ratio_pred = run_model(group_params, test_trinary_stimuli, model_type, return_p=1)
  262. binary_ratio_pred = run_model(group_params, test_binary_stimuli, model_type, return_p=1)
  263. decoy_pred = trinary_ratio_pred - binary_ratio_pred
  264. decoy_pred = np.nan_to_num(decoy_pred)
  265. # evaluate predictions
  266. cv_rmse[fold_i] = np.sqrt(mean_squared_error(y_test, decoy_pred))
  267. corr = scipy.stats.spearmanr(decoy_pred, y_test)[0]
  268. cv_corr[fold_i] = corr if ~np.isnan(corr) else 0
  269. # calcualte train metrics, for sanity
  270. train_trinary_stimuli = trinary_stimuli_norm.loc[trinary_stimuli_norm.trinary_id.isin(train_set_inds)]
  271. train_binary_stimuli = binary_stimuli_norm.loc[binary_stimuli_norm.binary_id.isin(train_set_inds)]
  272. train_trinary_ratio_pred = run_model(group_params, train_trinary_stimuli, model_type, return_p=1)
  273. train_binary_ratio_pred = run_model(group_params, train_binary_stimuli, model_type, return_p=1)
  274. train_decoy_pred = train_trinary_ratio_pred - train_binary_ratio_pred
  275. try:
  276. train_rmse[fold_i] = np.sqrt(mean_squared_error(y_train, train_decoy_pred))
  277. except ValueError:
  278. train_rmse[fold_i] = np.nan
  279. fold_i += 1
  280. return cv_rmse, cv_corr, train_rmse
  281. # %%
  282. AG_cv_rmse, AG_cv_corr, AG_train_rmse = cv_comp_model(folds, model_type='AG', init_params=AG_init_params)
  283. # %%
  284. RDN_cv_rmse, RDN_cv_corr, RDN_train_rmse = cv_comp_model(folds, model_type='RDN', init_params=RDN_init_params)
  285. # %%
  286. DN_cv_rmse, DN_cv_corr, DN_train_rmse = cv_comp_model(folds, model_type='DN', init_params=DN_init_params)
  287. # %%
  288. pd.DataFrame({ 'train_rmse': [np.nanmean(AG_train_rmse), np.mean(RDN_train_rmse), np.mean(DN_train_rmse)],
  289. 'rmse': [np.nanmean(AG_cv_rmse), np.mean(RDN_cv_rmse), np.mean(DN_cv_rmse)],
  290. 'r': [np.nanmean(AG_cv_corr), np.mean(RDN_cv_corr), np.mean(DN_cv_corr)]},
  291. index=['AG', 'RDN', 'DN'])
  292. # %% [markdown]
  293. # ### fitting
  294. # %%
  295. AG_group_params = optimize.fmin(run_model, AG_init_params, args=(raw_choices_stimuli, 'AG', 0),
  296. maxiter=1e4, disp=False)
  297. RDN_group_params = optimize.fmin( run_model, RDN_init_params, args=(raw_choices_stimuli, 'RDN'),
  298. maxiter=1e4, disp=False)
  299. DN_group_params = optimize.fmin( run_model, DN_init_params, args=(raw_choices_stimuli, 'DN'),
  300. maxiter=1e4, disp=False)
  301. # %%
  302. def get_fitted_decoy_effects(group_params, model_type='AG'):
  303. """
  304. Return the in-sample model-predicted decoy effects per lottery set.
  305. Applies the fitted ``group_params`` to the normalized trinary and
  306. binary stimuli, computes ``P(A)`` in each, and returns a DataFrame
  307. with one row per set containing ``P_a_trinary``, ``P_a_binary`` and
  308. the resulting predicted decoy effect column ``decoy_{model_type}``.
  309. """
  310. trinary_P_a = run_model(group_params, trinary_stimuli_norm, model_type=model_type, return_p=1)
  311. binary_P_a = run_model(group_params, binary_stimuli_norm, model_type=model_type,return_p=1)
  312. decoys = trinary_P_a - binary_P_a
  313. fitted_decoys = pd.DataFrame({'trinary_id': trinary_stimuli.trinary_id,
  314. 'P_a_trinary': trinary_P_a,
  315. 'P_a_binary': binary_P_a,
  316. f'decoy_{model_type}':decoys})
  317. return fitted_decoys
  318. # %%
  319. AG_fitted_decoys = get_fitted_decoy_effects(AG_group_params, model_type='AG')
  320. RDN_fitted_decoys = get_fitted_decoy_effects(RDN_group_params, model_type='RDN')
  321. DN_fitted_decoys = get_fitted_decoy_effects(DN_group_params, model_type='DN')
  322. # %%
  323. pd.DataFrame({ 'AG': AG_fitted_decoys.decoy_AG.values,
  324. 'RDN': RDN_fitted_decoys.decoy_RDN.values,
  325. 'DN': DN_fitted_decoys.decoy_DN.values,
  326. 'actual': decoy_effects.decoy_effect_A.values}).corr()

computational_models.ipynb at commit 7a034b0, under CC-BY-4.0 · at the source

Overview

Authors: Asaf Madar1, Tom Zemer1, Ido Tavor1,2, Dino J Levy1,3
  1. Sagol School of Neuroscience, Tel Aviv University, Tel Aviv, Israel
  2. Gray School of Medical Sciences, Gray Faculty of Medical & Health Sciences, Tel Aviv University, Tel Aviv, Israel
  3. Coller School of Management, Tel Aviv University, Tel Aviv, Israel
Institutions: Tel Aviv University (Israel)
Journal: Nature communications, volume 17, issue 1, article 7816
Dates: received 2 October 2025; accepted 3 June 2026; published online 21 June 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41467-026-74462-6 · PMID 42324265 · PMCID PMC13439569 · OpenAlex W7165487396
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: human (organism), cognitive (subfield)
Methods: Connectivity, Statistics, Smoothing, state filtering, decompositions, Machine learning, fMRI & imaging
Keywords: Decision, Human behaviour
MeSH: Brain*, Choice Behavior*, Brain Mapping, Decision Making, Female, Humans, Magnetic Resonance Imaging, Male (* major topic)
Topic: Neural and Behavioral Psychology Studies (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Israel Science Foundation (ISF) (1432/23)
Citations: not cited yet (Europe PMC); 72 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 18 matches between paragraphs and lines of code.

asafmm/neuro_decoy_effect

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 7a034b0a235946556b5a0113e7db85a95deabbd1, 25 May 2026
Languages: Python (9), Jupyter (8)
Size: 638 files, 17 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, environment (requirements.txt), 8 notebooks
Not found: CITATION.cff, tests, continuous integration, documentation
Tools: NumPy (17 files), pandas (16 files), Matplotlib (13 files), SciPy (8 files), scikit-learn (5 files), statsmodels (4 files), seaborn (3 files), NiBabel (2 files), Pingouin (2 files), Pillow (1 file), PyTorch (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
19 files

Code availability statement

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

Read it in the paper: doi.org/10.1038/s41467-026-74462-6.

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;
  • 17 scripts, each with its path and the digest of its content;
  • 18 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:

Read it in the paper: doi.org/10.1038/s41467-026-74462-6.

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, 2 keywords, 8 MeSH terms, 1 funder, 48 references.

Cite

This paper

Madar, A., Zemer, T., Tavor, I., & Levy, D. J. (2026). Neural similarity between choice options predicts group-level context effects. Nature communications, 17(1), 7816. https://doi.org/10.1038/s41467-026-74462-6

BibTeX

@article{madar2026neural,
author = {Madar, Asaf and Zemer, Tom and Tavor, Ido and Levy, Dino J},
title = {{Neural similarity between choice options predicts group-level context effects}},
journal = {Nature communications},
year = {2026},
month = jun,
volume = {17},
number = {1},
pages = {7816},
publisher = {Nature Portfolio},
issn = {2041-1723},
doi = {10.1038/s41467-026-74462-6},
url = {https://doi.org/10.1038/s41467-026-74462-6},
pmid = {42324265},
pmcid = {PMC13439569}
}

RIS

TY - JOUR
AU - Madar, Asaf
AU - Zemer, Tom
AU - Tavor, Ido
AU - Levy, Dino J
TI - Neural similarity between choice options predicts group-level context effects
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/06/21
VL - 17
IS - 1
SP - 7816
SN - 2041-1723
PB - Nature Portfolio
DO - 10.1038/s41467-026-74462-6
UR - https://doi.org/10.1038/s41467-026-74462-6
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41467-026-74462-6",
"type": "article-journal",
"title": "Neural similarity between choice options predicts group-level context effects",
"container-title": "Nature communications",
"author": [
{
"family": "Madar",
"given": "Asaf"
},
{
"family": "Zemer",
"given": "Tom"
},
{
"family": "Tavor",
"given": "Ido"
},
{
"family": "Levy",
"given": "Dino J"
}
],
"container-title-short": "Nat Commun",
"volume": "17",
"issue": "1",
"page": "7816",
"DOI": "10.1038/s41467-026-74462-6",
"PMID": "42324265",
"PMCID": "PMC13439569",
"ISSN": "2041-1723",
"publisher": "Nature Portfolio",
"URL": "https://doi.org/10.1038/s41467-026-74462-6",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
21
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1038/s41467-026-73153-6 [code]
Latent neural architecture organising shared aesthetic evaluations of visual artworks.
Journal: Nature communications
In common: Pingouin, Pillow, PyTorch, 6 other tools, cognitive, 7 references
[2] doi:10.1038/s41467-024-53148-x [code]
Multimodal gradients of basal forebrain connectivity across the neocortex.
Journal: Nature communications
In common: Pingouin, statsmodels, NiBabel, 6 other tools, 4 references
[3] doi:10.1038/s44220-026-00680-y [code]
The neuroimaging correlates of depression established across six large-scale population datasets.
Journal: Nature. Mental health
In common: Pillow, statsmodels, seaborn, 5 other tools, 6 references
[4] doi:10.1038/s41467-026-69068-x [code]
Sensory encoding and memory retrieval are coordinated with propagating waves in the human brain.
Journal: Nature communications
In common: Pillow, NiBabel, PyTorch, 6 other tools, cognitive, 4 references
[5] doi:10.21203/rs.3.rs-9326213/v1 [code]
Multi-task fMRI outperforms resting-state fMRI for revealing task-invariant organization of the human brain
Journal: Research Square (preprint)
In common: Pillow, NiBabel, PyTorch, 6 other tools, cognitive, 4 references
[6] doi:10.64898/2026.03.09.710558 [code]
Multi-task fMRI outperforms resting-state fMRI for revealing task-invariant organization of the human brain
Journal: bioRxiv (preprint)
In common: Pillow, NiBabel, PyTorch, 6 other tools, cognitive, 4 references
[7] doi:10.1162/imag_a_00184 [code]
Time-varying functional connectivity as Wishart processes.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: Pingouin, statsmodels, seaborn, 5 other tools, 5 references
[8] doi:10.1371/journal.pbio.3003277 [code]
Mapping cerebral blood perfusion and its links to multi-scale brain organization across the human lifespan.
Journal: PLoS biology
In common: statsmodels, NiBabel, seaborn, 5 other tools, 5 references
[9] doi:10.1038/s41467-025-66579-x [code]
The role of attention in multi attribute decision making.
Journal: Nature communications
In common: scikit-learn, SciPy, NumPy, cognitive, 2 references, author Dino J Levy
[10] doi:10.1162/imag_a_00081 [code]
Methods for decoding cortical gradients of functional connectivity.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: NiBabel, PyTorch, seaborn, 5 other tools, 6 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.1038/s41467-026-74462-6.svg)](https://openscicode.org/badge/doi/10.1038/s41467-026-74462-6)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1038/s41467-026-74462-6.svg
   :target: https://openscicode.org/badge/doi/10.1038/s41467-026-74462-6
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1038/s41467-026-74462-6"><img src="https://openscicode.org/badge/doi/10.1038/s41467-026-74462-6.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

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)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

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