OSCR

Computational parametric mapping of functional neuroimaging data.

Code ↔ Paper

11 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 11 matches · 5 of them tie a paragraph to a whole file, not to given lines: weak matches, whose lines are not tinted
  1. [1] § Real Data › Results ↔ SIMULATIONS/realdata_niv2012.m, lines 234–340 · score 0.82 · rMSE, NAcc, exceedance probabilities, risk sensitive TD, classical TD model, learning rate asymmetries
  2. [2] § Real Data › Results ↔ SIMULATIONS/realdata_niv2012.m, lines 234–340 · score 0.79 · NAcc, exceedance probabilities, risk sensitive TD, classic TD model, learning rate asymmetry, model comparison
  3. [3] § Computational Parametric Mapping › Hemodynamic response function ↔ toolbox/spm_prf_fx.m, the whole file · a weak match · score 0.64 · signal decay, balloon model, ratio, hemodynamic, transit, MRI
  4. [4] § Computational Parametric Mapping › Hemodynamic response function ↔ toolbox/spm_prf_gx.m, the whole file · a weak match · score 0.63 · field strength, hemodynamic model, intravascular, ratio, signal, pRF
  5. [5] § Simulation Results › Bayesian model selection ↔ SIMULATIONS/simulations_td.m, lines 229–247 · score 0.63 · exceedance probabilities, risk sensitive TD, classical TD model, model recovery, Bar, SNR
  6. [6] § Simulation Study ↔ SIMULATIONS/simulations_td/code/cpm_events_to_trials.m, the whole file · a weak match · score 0.61 · response cue, wealth update, stimulus onset, TD, Simulation
  7. [7] § Real Data › Results ↔ SIMULATIONS/simulations_td.m, lines 229–247 · score 0.58 · exceedance probabilities, risk sensitive TD, classic TD model, CPM
  8. [8] § Computational Parametric Mapping › Inputs ↔ toolbox/response_functions/spm_cpm_fcn_gaussian.m, lines 1–131 · score 0.57 · field model, fMRI, parameter space, cognitive, location, CPM
  9. [9] § Simulation Study ↔ SIMULATIONS/auxiliary_td.m, the whole file · a weak match · score 0.54 · stimulus onset, TD learning, CC, wealth, RPE, reward
  10. [10] § Real Data › Methods ↔ SIMULATIONS/auxiliary_td.m, the whole file · a weak match · score 0.54 · TD learning models, TD errors, event, onsets, CPM
  11. [11] § Real Data › Methods ↔ SIMULATIONS/realdata_niv2012.m, lines 399–426 · score 0.54 · motion parameters, quadratic, preprocessed, linear, regressing

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

MATLAB · 454 lines · 19 KB · GPL-3.0 · 3 matches

  1. function [] = realdata_niv()
  2. % Script to perform analysis of Niv et al. 2012.
  3. % ---------------------------------------------------------------------
  4. % Copyright (C) 2024 Simon R. Steinkamp
  5. % This program is free software: you can redistribute it and/or modify
  6. % it under the terms of the GNU General Public License as published by
  7. % the Free Software Foundation, either version 3 of the License, or
  8. % (at your option) any later version.
  9. %
  10. % This program is distributed in the hope that it will be useful,
  11. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. % GNU General Public License for more details.
  14. %
  15. % You should have received a copy of the GNU General Public License
  16. % along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. % ---------------------------------------------------------------------
  18. %% Adding necessary paths:
  19. rng(23, 'twister'); % Set random seed
  20. configs = simulation_configs();
  21. addpath(genpath('../toolbox'));
  22. addpath(configs.spm_path);
  23. addpath(genpath(configs.vba_path));
  24. addpath('simulations_td/code');
  25. spm fmri;
  26. close all;
  27. mkdir('realdata_niv2012');
  28. mkdir('realdata_niv2012/models');
  29. % data url for Wilson & Niv 2015
  30. if ~isfolder('realdata_niv2012/ROI_data')
  31. data_url = 'https://doi.org/10.1371/journal.pcbi.1004237.s003';
  32. save_dir = 'realdata_niv2012/data.zip';
  33. websave(save_dir, data_url);
  34. unzip(save_dir, 'realdata_niv2012');
  35. end
  36. % ==========================================================================
  37. % PREPARATION
  38. %% ==========================================================================
  39. logit_inv = @(x) 1 ./ (1 + exp(-x));
  40. % Loading some example data:
  41. naccLeft = load('realdata_niv2012/ROI_data/lNAC_AllEventsData.mat');
  42. naccRight = load('realdata_niv2012/ROI_data/rNAC_AllEventsData.mat');
  43. dt = naccLeft.dt;
  44. TE = 30 ./ 1000; % From paper
  45. TR = 2.0; %
  46. SPM = {};
  47. SPM.xY.RT = TR;
  48. % This is where the PRF will be saved, we just set it to be here.
  49. SPM.swd = 'realdata_niv2012/models';
  50. fixedparams = struct('gamma', 0.99, 'lambda', 1.0);
  51. % Setting options for inversion
  52. invert_options = struct('use_parfor', false, ...
  53. 'init', 'None', ...
  54. 'nograph', true, 'random_state', true);
  55. %%
  56. resolution = 41;
  57. subjects = [];
  58. % Select the participants that have data
  59. for ii = 1:length(naccLeft.Data)
  60. if ~isempty(naccLeft.Data{ii})
  61. subjects = [subjects, ii];
  62. end
  63. end
  64. model_names = {'td', 'rs'};
  65. run_estimation = {[1, 2, 3]};
  66. F = zeros(length(run_estimation), 2, length(subjects), length(model_names));
  67. fit_r = zeros(length(run_estimation), 2, length(subjects), length(model_names));
  68. fit_p = zeros(length(run_estimation), 2, length(subjects), length(model_names));
  69. fit_orig_r = zeros(size(fit_p));
  70. fit_orig_td = zeros(size(fit_p));
  71. fit_orig_rstd = zeros(size(fit_p));
  72. msez_rstd = zeros(size(fit_p));
  73. msez_td = zeros(size(fit_p));
  74. msez_fit = zeros(size(fit_p));
  75. learning_rates = zeros(length(run_estimation), 2, length(subjects), 3);
  76. PRFs = {};
  77. for data_idx = 1:2
  78. if data_idx == 1
  79. dataset = naccLeft;
  80. elseif data_idx == 2
  81. dataset = naccRight;
  82. end
  83. for sub_idx = 1:length(subjects)
  84. for re = 1:length(run_estimation)
  85. sub_data = dataset.Data{subjects(sub_idx)}; % Extract the data struct
  86. % There appear to be three runs of data, let's just use one first:
  87. % we have basically 1 voxel.
  88. [cleanData, stimOns, rewardOns, rewards, ...
  89. chosen, rstdsig, tdsig, n_trials] = prep_data(sub_data, ...
  90. run_estimation{re}, ...
  91. dt, TR);
  92. % For simplicity, we can re-use the CSC representation scripts I implemented for
  93. % the simulation study, but for this we need a "trial" structure first.
  94. trials = {};
  95. cc = 1;
  96. for nt = 1:n_trials
  97. if ~isnan(chosen(nt)) % We remove trials without a response
  98. trials(cc).onsets = [stimOns(nt), rewardOns(nt)];
  99. trials(cc).stimuli = {num2str(chosen(nt)), 'reward'};
  100. trials(cc).wealth = [0, rewards(nt)];
  101. cc = cc + 1;
  102. end
  103. end
  104. %%
  105. % Create a CSC representation from the trials struct. We use a very simple one
  106. % containing only the onset of the stimulus and the reward.
  107. csc_trials = cpm_trials_to_csc(trials, 4, [2, 3], [1], 3);
  108. % ==========================================================================
  109. %% The reinforcement learning algorithm
  110. % ==========================================================================
  111. % The BayesPRF requires an SPM struct, but only a few fields from there, which
  112. % we generate here:
  113. % Create a dummy VOI
  114. VOI = {};
  115. VOI.Y = cleanData;
  116. VOI.xY.y = cleanData;
  117. VOI.xY.XYZmm = zeros(3, 1);
  118. % Creating a data struct
  119. data = {};
  120. data.ons = cat(2, csc_trials.onsets);
  121. data.dur = zeros(size(data.ons)) + 2 .* dt;
  122. data.dt = zeros(size(data.ons)) + dt;
  123. data.trials = csc_trials;
  124. %% PRF
  125. for mi = 1:length(model_names)
  126. if strcmp(model_names{mi}, 'rs')
  127. name = ['sub-' num2str(sub_idx), '_data-', ...
  128. num2str(data_idx), '_run-', num2str(re), '_rs'];
  129. grid = struct('taupos', [-8.1259, 8.1259, resolution], ...
  130. 'tauneg', [-8.1259, 8.1259, resolution]);
  131. params = {{'taupos', 'tauneg'}};
  132. U_prf = cpm_precompute(@cpm_td_learning, ...
  133. grid, fixedparams, data, 'U_prf', true);
  134. U_prf = cpm_set_constraints(U_prf, 'taupos', [-4.0, 4.0]);
  135. U_prf = cpm_set_constraints(U_prf, 'tauneg', [-4.0, 4.0]);
  136. elseif strcmp(model_names{mi}, 'td')
  137. name = ['sub-' num2str(sub_idx), '_data-', ...
  138. num2str(data_idx) '_run-' num2str(re) '_td'];
  139. grid = struct('tau', [-8.1259, 8.1259, resolution]);
  140. params = {{'tau'}};
  141. U_prf = cpm_precompute(@cpm_td_learning, ...
  142. grid, fixedparams, data, 'U_prf', true);
  143. U_prf = cpm_set_constraints(U_prf, ...
  144. 'tau', ...
  145. [-4.0, 4.0]);
  146. end
  147. options = struct('model', 'spm_cpm_fcn_gaussian', ...
  148. 'name', name, ...
  149. 'params', params, ...
  150. 'TE', TE, ...
  151. 'B0', 3, ...
  152. 'voxel_wise', true, ...
  153. 'avg_sess', false);
  154. PRF = spm_prf_analyse('specify', SPM, VOI, U_prf, options);
  155. PRF.M.noprint = 1;
  156. PRFn = spm_prf_analyse('estimate', PRF, invert_options);
  157. save_wrapper(PRFn, fullfile(SPM.swd, ['PRF_' name '.mat']));
  158. F(re, data_idx, sub_idx, mi) = PRFn.F;
  159. PRFs{re, data_idx, sub_idx, mi} = PRFn;
  160. ypred = cpm_predict(PRFn, 1);
  161. [rtmp, ptmp] = corr(PRFn.Y.y, ypred);
  162. fit_r(re, data_idx, sub_idx, mi) = rtmp;
  163. fit_p(re, data_idx, sub_idx, mi) = ptmp;
  164. fit_orig_td(re, data_idx, sub_idx, mi) = corr(PRFn.Y.y, tdsig');
  165. fit_orig_rstd(re, data_idx, sub_idx, mi) = corr(PRFn.Y.y, rstdsig');
  166. fit_orig_r(re, data_idx, sub_idx, mi) = corr(rstdsig', ypred);
  167. msez_rstd(re, data_idx, sub_idx, mi) = mean((zscore(PRFn.Y.y) - ...
  168. zscore(rstdsig')).^2);
  169. msez_td(re, data_idx, sub_idx, mi) = mean((zscore(PRFn.Y.y) - ...
  170. zscore(tdsig')).^2);
  171. msez_fit(re, data_idx, sub_idx, mi) = mean((zscore(PRFn.Y.y) - ...
  172. zscore(ypred)).^2);
  173. if strcmp(model_names{mi}, 'td')
  174. true_params = cpm_get_true_parameters(PRFn, 1);
  175. learning_rates(re, data_idx, sub_idx, 1) = logit_inv(true_params.mu_tau);
  176. elseif strcmp(model_names{mi}, 'rs')
  177. true_params = cpm_get_true_parameters(PRFn, 1);
  178. learning_rates(re, data_idx, sub_idx, 2) = logit_inv(true_params.mu_tauneg);
  179. learning_rates(re, data_idx, sub_idx, 3) = logit_inv(true_params.mu_taupos);
  180. end
  181. end
  182. end
  183. end
  184. end
  185. %% Model comparisons
  186. ex_probs = zeros(4, 2, 2);
  187. for ridx = 1:length(run_estimation)
  188. for didx = 1:2
  189. [~, o] = VBA_groupBMC(squeeze(F(ridx, didx, :, :))', struct('DisplayWin', 0));
  190. ex_probs(ridx, didx, :) = o.ep;
  191. end
  192. end
  193. %%
  194. taus = zeros(length(run_estimation), 2, length(subjects));
  195. for ridx = 1:length(run_estimation)
  196. for didx = 1:2
  197. for sidx = 1:length(subjects)
  198. taus(ridx, didx, sidx) = (squeeze(learning_rates(ridx, didx, sidx, 2)) ./ ...
  199. sum(squeeze(learning_rates(ridx, didx, sidx, 2:3))));
  200. end
  201. end
  202. end
  203. %%
  204. fig1 = figure('Position', [0, 0, 2000, 800]);
  205. subplot(2, 3, 1);
  206. bar([squeeze(ex_probs(1, :, :))]'); % , squeeze(ex_probs_sig(1,: ,:))]);
  207. legend({'left NAcc', 'right NAcc'}); % , 'left NAcc (only sig.)', 'right NAcc (only sig.)'})
  208. xticklabels({'classic TD', 'risk-sensitive TD'});
  209. ylabel('exceedance probability');
  210. title('Model comparison');
  211. subplot(2, 3, 2);
  212. scatter(squeeze(fit_r(1, 1, :, 1)), squeeze(fit_orig_td(1, 1, :, 1)), [], 'blue');
  213. xlabel('r CPM');
  214. ylabel('r regressors');
  215. hold on;
  216. scatter(squeeze(fit_r(1, 2, :, 1)), squeeze(fit_orig_td(1, 2, :, 1)), [], 'red');
  217. title('Classic TD model');
  218. h1 = lsline();
  219. h1(1).Color = 'blue';
  220. h1(2).Color = 'red';
  221. legend({'left NAcc', 'right NAcc'});
  222. subplot(2, 3, 3);
  223. scatter(squeeze(fit_r(1, 2, :, 1)), squeeze(fit_orig_rstd(1, 2, :, 1)), [], 'blue');
  224. xlabel('r CPM');
  225. ylabel('r regressors');
  226. hold on;
  227. scatter(squeeze(fit_r(1, 2, :, 2)), squeeze(fit_orig_rstd(1, 2, :, 2)), [], 'red');
  228. title('risk-sensitive TD model');
  229. h1 = lsline();
  230. h1(1).Color = 'blue';
  231. h1(2).Color = 'red';
  232. legend({'left NAcc', 'right NAcc'});
  233. subplot(2, 3, 4);
  234. scatter(ones(length(subjects), 1)', squeeze(taus(1, 1, :)));
  235. hold on;
  236. scatter(ones(length(subjects), 1)' + 1, squeeze(taus(1, 2, :)));
  237. for ii = 1:length(subjects)
  238. plot([1, 2], [taus(1, 1, ii), taus(1, 2, ii)], ...
  239. 'Color', [0.2, 0.2, 0.2, 0.2], 'LineWidth', 0.1);
  240. end
  241. xlim([0.5, 2.5]);
  242. xticks([1, 2]);
  243. xticklabels({'left NAcc', 'right NAcc'});
  244. ylabel('\tau = (\alpha^+) / (\alpha^+ + \alpha^-)');
  245. title('Learning rate asymmetries (risk-sensitive TD)');
  246. subplot(2, 3, 5);
  247. mse_diff = sqrt(msez_rstd) - sqrt(msez_td);
  248. scatter(ones(length(subjects), 1)', squeeze(mse_diff(1, 1, :, 1)));
  249. hold on;
  250. scatter(ones(length(subjects), 1)' + 1, squeeze(mse_diff(1, 2, :, 1)));
  251. boxplot([squeeze(mse_diff(1, 1, :, 1)), squeeze(mse_diff(1, 2, :, 1))]);
  252. yline(0);
  253. xticklabels({'left NAcc', 'right NAcc'});
  254. ylabel('rMSE_{RSTD} - rMSE_{TD}');
  255. title('MSE original models');
  256. subplot(2, 3, 6);
  257. mse_diff = sqrt(msez_fit(:, :, :, 2)) - sqrt(msez_fit(:, :, :, 1));
  258. scatter(ones(length(subjects), 1)', squeeze(mse_diff(1, 1, :, 1)));
  259. hold on;
  260. scatter(ones(length(subjects), 1)' + 1, squeeze(mse_diff(1, 2, :, 1)));
  261. boxplot([squeeze(mse_diff(1, 1, :, 1)), squeeze(mse_diff(1, 2, :, 1))]);
  262. xticklabels({'left NAcc', 'right NAcc'});
  263. ylabel('rMSE_{RSTD} - rMSE_{TD}');
  264. title('MSE CPM');
  265. yline(0);
  266. sgtitle('Application to Niv et al. (2012)');
  267. % Writing out results:
  268. % row 1, col 2:
  269. fileID = fopen(fullfile('realdata_niv2012', 'results.txt'), 'w');
  270. [c12_1, p12_1] = corr(squeeze(fit_r(1, 1, :, 1)), squeeze(fit_orig_td(1, 1, :, 1)));
  271. fprintf(fileID, 'Correlation classic TD (left): c12_1 = %.4f, p12_1 = %.10f\n', c12_1, p12_1);
  272. [c12_2, p12_2] = corr(squeeze(fit_r(1, 2, :, 1)), squeeze(fit_orig_td(1, 2, :, 1)));
  273. fprintf(fileID, 'Correlation classic TD (right): c12_2 = %.4f, p12_2 = %.10f\n', c12_2, p12_2);
  274. [c13_1, p13_1] = corr(squeeze(fit_r(1, 1, :, 2)), squeeze(fit_orig_rstd(1, 1, :, 1)));
  275. fprintf(fileID, 'Correlation RSTD (left): c13_1 = %.4f, p13_1 = %.10f\n', c13_1, p13_1);
  276. [c13_2, p13_2] = corr(squeeze(fit_r(1, 2, :, 2)), squeeze(fit_orig_rstd(1, 2, :, 1)));
  277. fprintf(fileID, 'Correlation RSTD (right): c13_2 = %.4f, p13_2 = %.10f\n', c13_2, p13_2);
  278. [~, p21, ~, stats_21] = ttest(squeeze(taus(1, 1, :)), squeeze(taus(1, 2, :)));
  279. fprintf(fileID, 'Ttest - tau: p21 = %.10f, tstat = %.4f, df = %.4f\n', p21, stats_21.tstat, stats_21.df);
  280. bf_right_clrstd = ex_probs(1, 2,2) / ex_probs(1, 2, 1);
  281. bf_left_clrstd = ex_probs(1, 1,2) / ex_probs(1, 1, 1);
  282. fprintf(fileID, 'BF_cl_rstd left = %.10f, BF_cl_rstd right = %.10f\n', bf_left_clrstd, bf_right_clrstd);
  283. fprintf(fileID, 'Prob NAcc-left-CL = %.10f, Prob NAcc-left-RSTD = %.10f\n', ex_probs(1, 1, 1), ex_probs(1, 1, 2));
  284. fprintf(fileID, 'Prob NAcc-right-CL = %.10f, Prob NAcc-right-RSTD = %.10f\n', ex_probs(1, 2, 1), ex_probs(1, 2, 2));
  285. fclose(fileID);
  286. cpm_savefig(fig1, fullfile('realdata_niv2012', 'fig1_niv.png'));
  287. %%
  288. % Example PRFs
  289. fig2 = figure('Position', [0, 0, 2000, 400]);
  290. ax(1) = subplot(1, 3, 1);
  291. plot_single_voxel(PRFs{1, 1, 13, 2}, 1, {'taupos', 'tauneg'}, {[], []}, {'taupos', 'tauneg'}, 1000, 'prior', true);
  292. real_params = cpm_get_true_parameters(PRFs{1, 1, 13, 2}.M.pE{1}, PRFs{1, 1, 13, 2}.M, PRFs{1, 1, 13, 2}.U);
  293. scatter(real_params.mu_tauneg, real_params.mu_taupos, ...
  294. 'filled', 'MarkerEdgeColor', [0.5 0.5 0.5], ...
  295. 'MarkerFaceColor', [1 1 1], 'LineWidth', 1.0);
  296. tp = -pi:0.01:pi;
  297. y_post =real_params.mu_taupos + 2 * real_params.width_taupos .* cos(tp);
  298. x_post = real_params.mu_tauneg + 2 * real_params.width_tauneg .* sin(tp);
  299. plot(x_post, y_post);
  300. xlabel('\tau^-');
  301. ylabel('\tau^+');
  302. xlim(PRFs{1, 1, 13, 2}.U(1).grid.taupos(1:2));
  303. ylim(PRFs{1, 1, 13, 2}.U(1).grid.tauneg(1:2));
  304. title("prior density")
  305. ax(2) = subplot(1, 3, 2);
  306. plot_single_voxel(PRFs{1, 1, 13, 2}, 1, {'taupos', 'tauneg'}, {[], []}, {'taupos', 'tauneg'}, 400, 'posterior', true);
  307. real_params = cpm_get_true_parameters(PRFs{1, 1, 13, 2}, 1);
  308. scatter(real_params.mu_tauneg, real_params.mu_taupos, ...
  309. 'filled', 'MarkerEdgeColor', [0.5 0.5 0.5], ...
  310. 'MarkerFaceColor', [1 1 1], 'LineWidth', 1.0);
  311. tp = -pi:0.01:pi;
  312. y_post =real_params.mu_taupos + 2 * real_params.width_taupos .* cos(tp);
  313. x_post = real_params.mu_tauneg + 2 * real_params.width_tauneg .* sin(tp);
  314. plot(x_post, y_post);
  315. xlabel('\tau^-');
  316. ylabel('\tau^+');
  317. xlim(PRFs{1, 1, 13, 2}.U(1).grid.taupos(1:2));
  318. ylim(PRFs{1, 1, 13, 2}.U(1).grid.tauneg(1:2));
  319. title("posterior predictive density")
  320. ax(3) = subplot(1, 3, 3);
  321. plot_single_voxel(PRFs{1, 1, 13, 2}, 1, {'taupos', 'tauneg'}, {[], []}, {'taupos', 'tauneg'}, 1000, 'response', true);
  322. real_params = cpm_get_true_parameters(PRFs{1, 1, 13, 2}, 1);
  323. scatter(real_params.mu_tauneg, real_params.mu_taupos, ...
  324. 'filled', 'MarkerEdgeColor', [0.5 0.5 0.5], ...
  325. 'MarkerFaceColor', [1 1 1], 'LineWidth', 1.0);
  326. tp = -pi:0.01:pi;
  327. y_post =real_params.mu_taupos + 2 * real_params.width_taupos .* cos(tp);
  328. x_post = real_params.mu_tauneg + 2 * real_params.width_tauneg .* sin(tp);
  329. plot(x_post, y_post);
  330. xlabel('\tau^-');
  331. ylabel('\tau^+');
  332. xlim(PRFs{1, 1, 13, 2}.U(1).grid.taupos(1:2));
  333. ylim(PRFs{1, 1, 13, 2}.U(1).grid.tauneg(1:2));
  334. title('population field')
  335. sgtitle("Estimated PRFs of best fitting participant (13), left NAcc")
  336. cpm_savefig(fig2, fullfile('realdata_niv2012', 'fig2_niv.png'));
  337. %%
  338. end
  339. function [cleanData, stimOns, rewardOns, rewards, ...
  340. chosen, rstdsig, tdsig, n_trials] = prep_data(sub_data, runs, dt, TR)
  341. cleanData = [];
  342. stimOns = [];
  343. rewardOns = [];
  344. rewards = [];
  345. chosen = [];
  346. rstdsig = [];
  347. tdsig = [];
  348. n_trials = 0;
  349. for run_idx = runs
  350. [n_times, n_voxels] = size(sub_data.TimeCourse{run_idx});
  351. nt = length(cleanData);
  352. % Very simple preprocessing: regressing out the motion parameter and a linear,
  353. % quadratic and an intercept term.
  354. regs = sub_data.Motion{run_idx};
  355. diff_motion = [zeros(1, size(regs, 2)); diff(regs)];
  356. intercept = ones(n_times, n_voxels);
  357. regs = [regs, [1:n_times]', [1:n_times]'.^2, diff_motion]; % , cs_onset', us_onset'];
  358. regs = [regs, intercept];
  359. [~, ~, cleanMRI, ~] = regress(sub_data.TimeCourse{run_idx}, regs);
  360. cleanData = [cleanData; cleanMRI];
  361. %% Create trial structrue
  362. % Onsets are already provided in micro time, we want them in seconds:
  363. stimOns = [stimOns, sub_data.CSonset{run_idx} .* dt + nt * TR]; % Converting to seconds
  364. rewardOns = [rewardOns, sub_data.USonset{run_idx} .* dt + nt * TR];
  365. rewards = [rewards, sub_data.Rewards{run_idx}];
  366. chosen = [chosen, sub_data.Chosen{run_idx}];
  367. n_trials = n_trials + length(sub_data.Trials{run_idx});
  368. stick = zeros(1, n_times);
  369. stick(ceil((sub_data.TDtimes{run_idx} * dt) ./ TR)) = sub_data.RSTDerr{run_idx};
  370. canonical_hrf = spm_hrf(TR);
  371. orig_td_signal = conv(stick, canonical_hrf);
  372. orig_td_signal = orig_td_signal(1:n_times);
  373. rstdsig = [rstdsig, orig_td_signal];
  374. stick = zeros(1, n_times);
  375. stick(ceil((sub_data.TDtimes{run_idx} * dt) ./ TR)) = sub_data.TDerr{run_idx};
  376. canonical_hrf = spm_hrf(TR);
  377. orig_td_signal = conv(stick, canonical_hrf);
  378. orig_td_signal = orig_td_signal(1:n_times);
  379. tdsig = [tdsig, orig_td_signal];
  380. end
  381. end
  382. function save_wrapper(PRF, out)
  383. save(out, 'PRF');
  384. end

realdata_niv2012.m at commit 3b06373, under GPL-3.0 · at the source

Overview

Authors: Simon R Steinkamp1, Iyadh Chaker2, Felix Hubert3, David Meder1, Oliver J Hulme1,4,5
ORCID iDs: Oliver J Hulme
  1. Danish Research Centre for Magnetic Resonance, Department of Radiology and Nuclear Medicine, Copenhagen University Hospital Amager and Hvidovre, Copenhagen, Denmark
  2. Department of Physics, University of Trento, Trento, Italy
  3. Department of Basic Neuroscience, University of Geneva, Geneva, Switzerland
  4. London Mathematical Laboratory, London, United Kingdom
  5. Department of Psychology, University of Copenhagen, Copenhagen, Denmark
Institutions: Amager Hospital (Denmark); Copenhagen University Hospital (Denmark); University of Trento (Italy); University of Geneva (Switzerland); University of Copenhagen (Denmark); London Mathematical Laboratory (United Kingdom)
Journal: Imaging neuroscience (Cambridge, Mass.), volume 4, article IMAG.a.1130
Dates: received 19 December 2024; accepted 18 January 2026; published online 4 March 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1162/imag.a.1130 · PMID 41799677 · PMCID PMC12961307 · OpenAlex W7125591433
Open access: diamond, a free copy (OpenAlex)
Status: code verified
Categories: fMRI (modality)
Keywords: functional neuroimaging, variational Bayes, computational modeling, population receptive field, cognitive modeling, topographic mapping
Topic: Functional Brain Connectivity Studies (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Lundbeckfonden (R402-2022-1411); Danmarks Frie Forskningsfond (1052-00054B); Novo Nordisk Fonden (NNF20OC0064869)
Citations: not cited yet (Europe PMC); 25 references in the paper

Abstract

Elucidating the neural basis of cognition requires theoretical models of cognition to constrain the modeling of neural data. A prevalent strategy in functional neuroimaging is to regress the latent variables of cognitive models onto neural data. Though widely used, this approach restricts the mapping of computational variables to single parameter values. We introduce computational parametric mapping (CPM), which builds on and generalizes the Bayesian population receptive field framework. CPM offers three main advances for cognitive computational modeling. First, it allows the fitting of cognitive models directly to neuroimaging data. Second, it allows for voxelwise or regionwise mapping of parameters of cognitive computational models onto the brain, thus making the topographic mapping methods prevalent in the sensory sciences available to the cognitive computational neuroscientist. Finally, it is efficient enough to make voxelwise mapping over large regions of interest feasible. Here, we illustrate how CPM can be used to fit reinforcement-learning algorithms to synthetic and real data.

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

Repository

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

ergEx/BayespRF_CPM

License: GPL-3.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 3b063739ab8422cb39ae70dcb93f91d956782ecc, 18 December 2024
Languages: MATLAB (58)
Size: 71 files, 58 scripts
Software Heritage: not archived
Found in: “Data and Code Availability”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
60 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;
  • 58 scripts, each with its path and the digest of its content;
  • 11 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

Datasets cited

Data and Code Availability

All code for this study is available on Github https://github.com/ergEx/BayespRF_CPM. The code for the simulations can be found in the SIMULATIONS folder. Data for Niv et al. (2012) / Wilson and Niv (2015) are available at https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1004237. The data for the retinotopic simulation were taken from the SAMSRF ((Schwarzkopf, 2016) example data, available at https://zenodo.org/records/163582, and use the apsBars.mat file in the pRF folder. Raw and preprocessed data for the topographic maps are available on request from O.J.H. The data are not publicly available at this point in time due to data protection reasons.

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, 30 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 5 authors, 6 keywords, 3 funders, 25 references.

Cite

This paper

Steinkamp, S. R., Chaker, I., Hubert, F., Meder, D., & Hulme, O. J. (2026). Computational parametric mapping of functional neuroimaging data. Imaging neuroscience (Cambridge, Mass.), 4, IMAG.a.1130. https://doi.org/10.1162/imag.a.1130

BibTeX

@article{steinkamp2026computational,
author = {Steinkamp, Simon R and Chaker, Iyadh and Hubert, Felix and Meder, David and Hulme, Oliver J},
title = {{Computational parametric mapping of functional neuroimaging data}},
journal = {Imaging neuroscience (Cambridge, Mass.)},
year = {2026},
month = mar,
volume = {4},
pages = {IMAG.a.1130},
publisher = {MIT Press},
issn = {2837-6056},
doi = {10.1162/imag.a.1130},
url = {https://doi.org/10.1162/imag.a.1130},
pmid = {41799677},
pmcid = {PMC12961307}
}

RIS

TY - JOUR
AU - Steinkamp, Simon R
AU - Chaker, Iyadh
AU - Hubert, Felix
AU - Meder, David
AU - Hulme, Oliver J
TI - Computational parametric mapping of functional neuroimaging data
T2 - Imaging neuroscience (Cambridge, Mass.)
J2 - Imaging Neurosci (Camb)
PY - 2026
DA - 2026/03/04
VL - 4
SP - IMAG.a.1130
SN - 2837-6056
PB - MIT Press
DO - 10.1162/imag.a.1130
UR - https://doi.org/10.1162/imag.a.1130
LA - en
ER -

CSL-JSON

{
"id": "10.1162/imag.a.1130",
"type": "article-journal",
"title": "Computational parametric mapping of functional neuroimaging data",
"container-title": "Imaging neuroscience (Cambridge, Mass.)",
"author": [
{
"family": "Steinkamp",
"given": "Simon R"
},
{
"family": "Chaker",
"given": "Iyadh"
},
{
"family": "Hubert",
"given": "Felix"
},
{
"family": "Meder",
"given": "David"
},
{
"family": "Hulme",
"given": "Oliver J"
}
],
"container-title-short": "Imaging Neurosci (Camb)",
"volume": "4",
"page": "IMAG.a.1130",
"DOI": "10.1162/imag.a.1130",
"PMID": "41799677",
"PMCID": "PMC12961307",
"ISSN": "2837-6056",
"publisher": "MIT Press",
"URL": "https://doi.org/10.1162/imag.a.1130",
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
4
]
]
}
}

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.1162/imag.a.1142 [code]
Encoding neural representations of time-continuous stimulus-response transformations in the human brain with advanced deep neural networks.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: SPM, Statistics and Machine Learning Toolbox, fMRI, 3 references
[2] doi:10.1007/s12021-025-09759-w [code]
Limitations of Variational Laplace-Based Dynamic Causal Modelling for Multistable Cortical Circuits.
Journal: Neuroinformatics
In common: SPM, Statistics and Machine Learning Toolbox, 3 references
[3] doi:10.1162/imag.a.1210 [code]
Modeling 2D spatio-tactile population receptive fields of the fingertip in human primary somatosensory cortex.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: SPM, Image Processing Toolbox, Statistics and Machine Learning Toolbox, fMRI, 1 reference
[4] doi:10.1038/s41593-026-02219-x [code]
A neural signature of adaptive mentalization.
Journal: Nature neuroscience
In common: SPM, Image Processing Toolbox, Statistics and Machine Learning Toolbox, fMRI, 1 reference
[5] doi:10.1371/journal.pbio.3003922 [code]
Competing value signals impair reward-learning via dopaminergic mechanisms and increase exploration.
Journal: PLoS biology
In common: 4 references
[6] doi:10.1038/s41586-026-10910-z [code]
Psychedelics align brain activity with context.
Journal: Nature
In common: SPM, Image Processing Toolbox, Statistics and Machine Learning Toolbox, fMRI, 1 reference
[7] doi:10.1162/imag.a.1234 [code]
Multiscale parcellation of dynamic causal models of the brain.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: SPM, Statistics and Machine Learning Toolbox, 2 references
[8] doi:10.1162/imag.a.1250 [code]
Dynamics-informed priors (DIP) for neural mass modelling.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: SPM, Statistics and Machine Learning Toolbox, 2 references
[9] doi:10.1016/j.celrep.2026.117454 [code]
Model-based and model-free valuation signals in the human brain vary markedly in relation to individual differences in behavioral control.
Journal: Cell reports
In common: SPM, Statistics and Machine Learning Toolbox, 2 references
[10] doi:10.1162/netn.a.544 [code]
Brain network reconfiguration during reward prediction error processing.
Journal: Network neuroscience (Cambridge, Mass.)
In common: fMRI, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

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

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

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