OSCR

Rapid value learning reveals generalized and context-dependent codes in frontal cortex

Code ↔ Paper

7 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 7 matches · 1 of them tie a paragraph to a whole file, not to given lines: a weak match, whose lines are not tinted
  1. [1] § Data analysis › Estimating temporal structure of choice novelty and chosen value codes (Fig. 4d) ↔ analysis_functions/compute_representation_structure.m, the whole file · a weak match · score 0.68 · indicate stronger, negative lags, cross correlations, temporal
  2. [2] § Results ↔ fig2_behaviour.m, lines 108–231 · score 0.60 · Probe Choice trials, Bonferroni corrected, 1–3, probability trials, accuracy, 7–10
  3. [3] § Data analysis › General linear models ↔ fig6_rpe.m, lines 137–178 · score 0.55 · reward delivery, firing rate, orthogonalised, Choice phase, probability, Figure 6
  4. [4] § Data analysis › Cross-correlation of parameter estimates from GLMs (Fig. 3b,d, Fig. 6b) ↔ fig6_rpe.m, lines 137–178 · score 0.55 · reward delivery, firing rate, Probability trials, matrix, regressors, pre
  5. [5] § Data analysis › Statistical inference on cross-correlation of parameter estimates (Fig. 3b, Fig. 6b) ↔ fig3_value.m, lines 730–854 · score 0.54 · correlation coefficients, OFC neurons, permuted, cluster, cross, Figure 3
  6. [6] § Data analysis › Neuronal selectivity (Fig. 3e, 4b, 6c-g) ↔ fig4_novelty.m, lines 333–387 · score 0.53 · selective neurons, chi squared, Binomial, GLM, 100 ms
  7. [7] § Data analysis › Reward prediction error-coding (Fig. 6c-g) ↔ fig6_rpe.m, lines 548–685 · score 0.52 · regression coefficient, flipped, Choice phase, learners, RPE, cluster

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 · 685 lines · 25 KB · no license · 3 matches

  1. %% generate figure 6
  2. % input:
  3. % data/neural_data.mat
  4. % ~ "all_units" contains one structure element per recorded unit.
  5. % ~ each unit includes trial-by-time spike rasters aligned to cue onset, choice response and outcome.
  6. % ~ each raster spans 6s, with the alignment event occurring at time index 3000.
  7. % if using existing permutation test results: data/precomputed_perm_test/fig6/*.txt
  8. %
  9. % output:
  10. % figure 6
  11. %
  12. % required MATLAB toolboxes:
  13. % Statistics and Machine Learning Toolbox
  14. % Image Processing Toolbox
  15. %
  16. % required custom functions:
  17. % /analysis_functions: CPD, ols, compute_cluster_based_perm_test
  18. % /plot_functions: plotmse, figElements
  19. %
  20. % EG 2026
  21. %% set folders and load data
  22. analysis_dir = fileparts(mfilename('fullpath'));
  23. addpath(genpath(analysis_dir))
  24. data_dir = fullfile(analysis_dir, 'data');
  25. perm_dir = fullfile(data_dir, 'precomputed_perm_test', 'fig6');
  26. load(fullfile(data_dir, 'neural_data.mat'), 'all_units')
  27. n_units = numel(all_units);
  28. %% additional analysis parameters
  29. % set one option to true to recompute the corresponding permutation test.
  30. % run the permutations for t-statistics during Conditioning phase trials (fig. 6b)
  31. % or betas during Choice phase trials (fig. 6f-g) separately to limit memory use;
  32. % do not set both options to true in the same run.
  33. % NB: this may take a while!
  34. run_tstat_perm = false;
  35. run_betas_perm = false;
  36. n_perm = 1000;
  37. % time windows
  38. cue_avg_wndw = 3101:3500; % for averaging FR post-cue/sr
  39. sr_avg_wndw = 4101:4500;
  40. pre_cue_wndw = 2951:3500; % inc. pre-cue/sr window to plot over time
  41. pre_sr_wndw = 3951:4500;
  42. % presentation partitions
  43. presentation_parts = [1:4; 7:10];
  44. n_parts = size(presentation_parts, 1);
  45. presentation = repmat(1:10,10,1);
  46. presentation = presentation(:);
  47. cue_learners_pres_wndw = 4:10; % presentations to define cue value learners
  48. smaller_pres_wndws = reshape(1:10, 2, 5)';
  49. n_smaller_parts = size(smaller_pres_wndws, 1);
  50. % preallocate outputs
  51. tstat_value_cue_pres = nan(n_units, numel(pre_cue_wndw), n_parts);
  52. tstat_value_sr_pres = nan(n_units, numel(pre_sr_wndw), n_parts);
  53. beta_value_cue_pres = nan(n_units, n_parts);
  54. beta_value_sr_pres = nan(n_units, n_parts);
  55. cue_learner_beta = nan(n_units, 1);
  56. cue_learner_t = nan(n_units, 1);
  57. cue_learner_p = nan(n_units, 1);
  58. beta_value_cue_bins = nan(n_units, n_smaller_parts);
  59. beta_value_sr_bins = nan(n_units, n_smaller_parts);
  60. beta_choice_cue_ts = nan(n_units, 3, numel(pre_cue_wndw));
  61. beta_choice_outcome_ts = nan(n_units, 4, numel(pre_cue_wndw));
  62. if run_tstat_perm
  63. tstat_value_cue_perm = nan(n_units, numel(pre_cue_wndw), n_parts, n_perm, 'single');
  64. tstat_value_sr_perm = nan(n_units, numel(pre_sr_wndw), n_parts, n_perm, 'single');
  65. end
  66. % downsampling parameters for permutation test in fig. 6f-g
  67. beta_ds = 5; % downsampling factor; paper figure uses 5ms
  68. beta_ds_idx = beta_ds:beta_ds:numel(pre_cue_wndw); % start at the 5th sample so that event onset at index 3000 is retained
  69. if run_betas_perm
  70. beta_choice_cue_perm = nan(n_units, numel(beta_ds_idx), n_perm, 'single');
  71. beta_out_rew_perm = nan(n_units, numel(beta_ds_idx), n_perm, 'single');
  72. beta_out_norew_perm = nan(n_units, numel(beta_ds_idx), n_perm, 'single');
  73. end
  74. %% run unit loop
  75. for u = 1:n_units
  76. disp(u)
  77. % get this unit's session
  78. curr_sess = all_units(u);
  79. % get this unit's rasters
  80. curr_unit_cue_on = curr_sess.raster_cue_on;
  81. curr_unit_choice = curr_sess.raster_choice;
  82. curr_unit_outcome = curr_sess.raster_outcome;
  83. % create masks to filter trials and conditions
  84. gt_mask = curr_sess.gt'; % was it a good trial? i.e. 0 or 6 on condition,
  85. task_phase = curr_sess.PhaseOfTask'; % task phase, learning (1) or choice phase (2)
  86. learning_phase = task_phase == 1;
  87. choice_phase = task_phase == 2;
  88. forced_trials = curr_sess.forced_trials';
  89. % create and centre regressors
  90. n_value_levels = 5;
  91. chosen_mag = curr_sess.chosen_pay'; % magnitude of chosen stimulus
  92. chosen_mag(chosen_mag==1) = nan;
  93. chosen_mag = discretize(chosen_mag, n_value_levels);
  94. chosen_mag = chosen_mag - (n_value_levels+1)/2;
  95. chosen_prob = curr_sess.chosen_prob'; % probability of chosen stimulus
  96. chosen_prob(chosen_prob==1) = nan;
  97. chosen_prob = discretize(chosen_prob, n_value_levels);
  98. chosen_prob = chosen_prob - (n_value_levels+1)/2;
  99. value = sum([chosen_mag chosen_prob], 2, 'omitnan'); % collapse across magnitude and probability trials
  100. mag_trial_inds = ~isnan(chosen_mag);
  101. prob_trial_inds = ~isnan(chosen_prob);
  102. rewarded = curr_sess.rewarded' -0.5;
  103. prob_rew = value; prob_rew(rewarded==-0.5) = 0;
  104. prob_norew = value; prob_norew(rewarded==0.5) = 0;
  105. chose_left = curr_sess.choseleft';
  106. % index trials required
  107. learning_inds = gt_mask & learning_phase & forced_trials;
  108. choice_inds = gt_mask & choice_phase & prob_trial_inds;
  109. % orthogonalise outcome regressors wrt reward delivery
  110. M = [ones(sum(choice_inds), 1), rewarded(choice_inds)];
  111. prob_rew_ortho = prob_rew(choice_inds) - M*(M\prob_rew(choice_inds));
  112. prob_norew_ortho = prob_norew(choice_inds) - M*(M\prob_norew(choice_inds));
  113. % create design matrix
  114. dm_learn = [ones(size(value)) value chose_left];
  115. dm_rpe = [rewarded(choice_inds) prob_rew_ortho prob_norew_ortho];
  116. % prepare FRs: index and smooth
  117. gauss_wndw = 250;
  118. fr_cue_on = smoothdata(curr_unit_cue_on, 2, 'gaussian', gauss_wndw);
  119. fr_choice = smoothdata(curr_unit_choice, 2, 'gaussian', gauss_wndw);
  120. fr_out = smoothdata(curr_unit_outcome, 2, 'gaussian', gauss_wndw);
  121. % reduce to valid learning trials
  122. learn_dm = dm_learn(learning_inds, :);
  123. learn_cue = fr_cue_on(learning_inds, :);
  124. learn_sr = fr_choice(learning_inds, :);
  125. % fig. 6a-c: early and late learning partitions
  126. for part = 1:n_parts
  127. part_mask = ismember(presentation, presentation_parts(part, :));
  128. % fig. 6b: value t-statistic over time
  129. [~, ~, t_cue] = ols(zscore(learn_cue(part_mask, pre_cue_wndw)), ...
  130. learn_dm(part_mask, :));
  131. [~, ~, t_sr] = ols(zscore(learn_sr(part_mask, pre_sr_wndw)), ...
  132. learn_dm(part_mask, :));
  133. tstat_value_cue_pres(u, :, part) = t_cue(2, :);
  134. tstat_value_sr_pres(u, :, part) = t_sr(2, :);
  135. % fig. 6c: value coefficient from averaged firing rate
  136. sr_fr_avg = mean(zscore(learn_sr(part_mask, sr_avg_wndw)), 2);
  137. b_sr = glmfit(learn_dm(part_mask, 2:end), sr_fr_avg);
  138. beta_value_sr_pres(u, part) = b_sr(2);
  139. % fig. 6a: example unit
  140. if u == 170
  141. example_fr(:, :, part) = [learn_cue(part_mask, pre_cue_wndw), ...
  142. learn_sr(part_mask, pre_sr_wndw)];
  143. example_dm(:, :, part) = learn_dm(part_mask, :);
  144. example_t(part, :) = [t_cue(2, :), t_sr(2, :)];
  145. end
  146. end
  147. % fig. 6c-g: define cue value learners
  148. learner_mask = ismember(presentation, cue_learners_pres_wndw);
  149. learner_fr = mean(zscore(learn_cue(learner_mask, cue_avg_wndw)), 2);
  150. [b_learner, ~, learner_stats] = glmfit(learn_dm(learner_mask, 2:end), learner_fr);
  151. cue_learner_beta(u) = b_learner(2);
  152. cue_learner_t(u) = learner_stats.t(2);
  153. cue_learner_p(u) = learner_stats.p(2);
  154. % fig. 6d-e: value coding across two-presentation bins
  155. for part = 1:n_smaller_parts
  156. part_mask = ismember(presentation, smaller_pres_wndws(part, :));
  157. cue_fr_avg = mean(zscore(learn_cue(part_mask, cue_avg_wndw)), 2);
  158. sr_fr_avg = mean(zscore(learn_sr(part_mask, sr_avg_wndw)), 2);
  159. b_cue = glmfit(learn_dm(part_mask, 2:end), cue_fr_avg);
  160. b_sr = glmfit(learn_dm(part_mask, 2:end), sr_fr_avg);
  161. beta_value_cue_bins(u, part) = b_cue(2);
  162. beta_value_sr_bins(u, part) = b_sr(2);
  163. end
  164. % fig. 6f-g: regression over time (Choice phase)
  165. choice_dm = dm_learn(choice_inds, :);
  166. beta_choice_cue_ts(u, :, :) = ols(zscore(fr_cue_on(choice_inds, pre_cue_wndw)), choice_dm);
  167. beta_choice_outcome_ts(u, :, :) = ols(zscore(fr_out(choice_inds, pre_cue_wndw)),[ones(sum(choice_inds), 1), dm_rpe]);
  168. % permutation tests
  169. % fig. 6b: permuted value t-statistics
  170. if run_tstat_perm
  171. for part = 1:n_parts
  172. part_mask = ismember(presentation, presentation_parts(part, :));
  173. part_dm = learn_dm(part_mask, :);
  174. part_cue = zscore(learn_cue(part_mask, pre_cue_wndw));
  175. part_sr = zscore(learn_sr(part_mask, pre_sr_wndw));
  176. for p = 1:n_perm
  177. shuf_i = randperm(size(part_dm, 1));
  178. [~, ~, t_cue_perm] = ols(part_cue(shuf_i, :), part_dm);
  179. [~, ~, t_sr_perm] = ols(part_sr(shuf_i, :), part_dm);
  180. tstat_value_cue_perm(u, :, part, p) = single(t_cue_perm(2, :));
  181. tstat_value_sr_perm(u, :, part, p) = single(t_sr_perm(2, :));
  182. end
  183. end
  184. end
  185. % % fig. 6f-g: permuted betas
  186. % if run_betas_perm
  187. % cue_fr_ds = zscore(fr_cue_on(choice_inds, pre_cue_wndw(beta_ds_idx)));
  188. % out_fr_ds = zscore(fr_out(choice_inds, pre_cue_wndw(beta_ds_idx)));
  189. % out_dm = [ones(sum(choice_inds), 1), dm_rpe];
  190. %
  191. % for p = 1:n_perm
  192. % shuf_i = randperm(sum(choice_inds));
  193. %
  194. % b_perm = ols(cue_fr_ds(shuf_i, :), choice_dm);
  195. % beta_choice_cue_perm(u, :, p) = single(b_perm(2, :));
  196. %
  197. % b_perm = ols(out_fr_ds(shuf_i, :), out_dm);
  198. % beta_out_rew_perm(u, :, p) = single(b_perm(3, :));
  199. % beta_out_norew_perm(u, :, p) = single(b_perm(4, :));
  200. % end
  201. % end
  202. end
  203. % extract unit info
  204. brain_region = [all_units.brain_region]';
  205. % prepare figure and plotting parameters
  206. epochs = {'Cue on', 'Forced choice', 'Secondary Reinforcer', 'Outcome'};
  207. event = {'Cue on', 'Forced choice', 'SR', 'Outcome'};
  208. regions = {'ACC', 'OFC'};
  209. attributes = {'Magnitude', 'Probability'};
  210. region_colours = [255, 215, 0; 0, 206, 209]./255;
  211. trial_colours = [135, 215, 250; 255, 115, 0]./255;
  212. value_colours = [0, 0, 128; 30, 144, 255; 255, 255, 0; 255, 140, 0;178, 34, 34]./255;
  213. cue_sr_colours = [0 153 0; 0 0 102]./255;
  214. phase_colours = [255 153 153; 102 0 0]./255;
  215. choice_out_colours = [0 153 0; 153 0 153]./255;
  216. %% figure 6a: example cue-value learner neuron
  217. f = figure('Color', 'w');
  218. tl = tiledlayout(f, 2, 4, 'Padding', 'loose', 'TileSpacing', 'tight');
  219. value_regr = unique(example_dm(:, 2, :));
  220. cue_idx = 1:numel(pre_cue_wndw);
  221. sr_idx = numel(pre_cue_wndw) + (1:numel(pre_sr_wndw));
  222. sig_cue = abs(example_t(:, cue_idx)) >= 3.1;
  223. sig_sr = abs(example_t(:, sr_idx)) >= 3.1;
  224. for part = 1:n_parts
  225. plot_data = {example_fr(:, cue_idx, part), example_fr(:, sr_idx, part)};
  226. sig_data = {sig_cue(part, :), sig_sr(part, :)};
  227. event_name = {'Cue on', 'SR on'};
  228. for epoch = 1:2
  229. ax = nexttile(tl, [1 2]);
  230. hold(ax, 'on');
  231. for v = 1:n_value_levels
  232. trial_mask = example_dm(:, 2, part) == value_regr(v);
  233. h(v) = plotmse(plot_data{epoch}(trial_mask, :), value_colours(v, :), [0 1]);
  234. h(v).LineWidth = 2;
  235. end
  236. figElements(h, [], 'Time (ms)', [], ...
  237. [1 550], [0 50], [50 550], {'0' '500'}, 0:25:50, {}, [], [], []);
  238. if epoch==1, ylabel('Firing rate (Hz)'); else, yticklabels([]); end
  239. xline(50, 'k');
  240. text(65, 42, event_name{epoch}, 'FontSize', 11);
  241. significant = sig_data{epoch};
  242. scatter(find(significant), 50.*ones(1, sum(significant)), 100, 'k.');
  243. set(ax, 'FontSize', 11);
  244. hold(ax, 'off');
  245. clear h
  246. end
  247. end
  248. %% figure 6b: correspondence between cue and SR value signals
  249. n_time = numel(pre_cue_wndw);
  250. cue_sr_corr = nan(2, n_time, numel(regions)); % late cue–early SR; early cue–late SR
  251. for r = 1:numel(regions)
  252. region_mask = brain_region == r;
  253. late_cue = squeeze(tstat_value_cue_pres(region_mask, :, 2));
  254. early_sr = squeeze(tstat_value_sr_pres(region_mask, :, 1));
  255. early_cue = squeeze(tstat_value_cue_pres(region_mask, :, 1));
  256. late_sr = squeeze(tstat_value_sr_pres(region_mask, :, 2));
  257. cue_sr_corr(1, :, r) = diag(corr(late_cue, early_sr, 'Rows', 'complete'))';
  258. cue_sr_corr(2, :, r) = diag(corr(early_cue, late_sr, 'Rows', 'complete'))';
  259. end
  260. % permutation tests
  261. if run_tstat_perm
  262. above_null_cue_sr = false(2, n_time, numel(regions));
  263. for r = 1:numel(regions)
  264. region_mask = brain_region == r;
  265. perm_data = nan(n_time, n_perm, 'single');
  266. for direction = 1:2
  267. for p = 1:n_perm
  268. if direction == 1
  269. cue_perm = squeeze(tstat_value_cue_perm(region_mask, :, 2, p));
  270. sr_perm = squeeze(tstat_value_sr_perm(region_mask, :, 1, p));
  271. else
  272. cue_perm = squeeze(tstat_value_cue_perm(region_mask, :, 1, p));
  273. sr_perm = squeeze(tstat_value_sr_perm(region_mask, :, 2, p));
  274. end
  275. perm_data(:, p) = single(diag(corr(cue_perm, sr_perm, ...
  276. 'Rows', 'complete')));
  277. end
  278. real_data = squeeze(cue_sr_corr(direction, :, r))';
  279. out = compute_cluster_based_perm_test(real_data, perm_data, 97.5, 2);
  280. above_null_cue_sr(direction, :, r) = reshape(out.survived_len_UB & out.survived_mass_UB, 1, []);
  281. end
  282. writematrix(above_null_cue_sr(:, :, r), fullfile(perm_dir, ...
  283. sprintf('fig6b_%s_cue_sr_corr.txt', lower(regions{r}))));
  284. end
  285. else
  286. for r = 1:numel(regions)
  287. above_null_cue_sr(:, :, r) = readmatrix(fullfile(perm_dir, ...
  288. sprintf('fig6b_%s_cue_sr_corr.txt', lower(regions{r}))));
  289. end
  290. end
  291. % plot
  292. f = figure('Color', 'w');
  293. tl = tiledlayout(f, 2, 1, 'Padding', 'loose', 'TileSpacing', 'tight');
  294. scatter_pos = [0.60 0.58];
  295. time_window = 1:n_time;
  296. for r = 1:numel(regions)
  297. ax = nexttile(tl);
  298. hold(ax, 'on');
  299. plot(ax, cue_sr_corr(1, :, r), 'Color', region_colours(r, :), 'LineWidth', 2);
  300. plot(ax, cue_sr_corr(2, :, r), '--', 'Color', [0.75 0.75 0.75], 'LineWidth', 2);
  301. significant = squeeze(above_null_cue_sr(1, :, r))==1;
  302. scatter(ax, time_window(significant), scatter_pos(r).*ones(1, sum(significant)), ...
  303. 100, '.', 'MarkerEdgeColor', region_colours(r, :));
  304. xline(ax, 50, 'k');
  305. yline(ax, 0, 'k');
  306. xlim(ax, [0 550]);
  307. ylim(ax, [-0.2 0.6]);
  308. xticks(ax, [0 50 550]);
  309. xticklabels(ax, {'-50' '0' '500'});
  310. yticks(ax, [0 0.6]);
  311. xlabel(ax, 'Time from cue/SR on (ms)');
  312. ylabel(ax, {'Value \itt \rmstatistic correlation';'at cue vs at SR'});
  313. title(ax, regions{r}, 'FontWeight', 'normal');
  314. box(ax, 'off');
  315. set(ax, 'FontSize', 11);
  316. end
  317. %% figure 6c: change in SR value coding in cue-value learners
  318. cue_value_learner = cue_learner_p < 0.05;
  319. negative_coder = cue_learner_beta < 0;
  320. % align coefficients to each neuron's cue-value coding direction
  321. beta_sr_aligned = beta_value_sr_pres;
  322. beta_sr_aligned(negative_coder, :) = -beta_sr_aligned(negative_coder, :);
  323. delta_sr = beta_sr_aligned(:, 2) - beta_sr_aligned(:, 1); % late − early
  324. n_learners = nan(1, numel(regions));
  325. mean_delta = nan(1, numel(regions));
  326. sem_delta = nan(1, numel(regions));
  327. p_delta = nan(1, numel(regions));
  328. for r = 1:numel(regions)
  329. values = delta_sr(cue_value_learner & brain_region == r);
  330. values = values(~isnan(values));
  331. n_learners(r) = sum(cue_value_learner & brain_region == r);
  332. mean_delta(r) = mean(values);
  333. sem_delta(r) = std(values) / sqrt(numel(values));
  334. [~, p_delta(r), ~, stats] = ttest(values);
  335. fprintf('Difference in late–early SR value coefficient in %s cue-value learners: n=%d, t=%.4g, df=%d, p=%.4g\n', ...
  336. regions{r}, n_learners(r), stats.tstat, stats.df, p_delta(r));
  337. end
  338. f = figure('Color', 'w');
  339. tl = tiledlayout(f, 2, 1, 'Padding', 'loose', 'TileSpacing', 'tight');
  340. ax = nexttile(tl, [2 1]);
  341. b = bar(ax, mean_delta, 'FaceColor', 'flat', 'EdgeColor', 'k');
  342. b.CData = region_colours;
  343. hold(ax, 'on');
  344. errorbar(ax, 1:numel(regions), mean_delta, sem_delta, 'k', 'LineStyle', 'none');
  345. yline(ax, 0, 'k');
  346. ylim(ax, [-0.1 0]);
  347. yticks(ax, [-0.1 0]);
  348. xticks(ax, 1:numel(regions));
  349. xticklabels(ax, regions);
  350. ylabel(ax, '\Delta value coefficient (Late–Early SR)');
  351. xlabel(ax, 'Cue value learners');
  352. box(ax, 'off');
  353. set(ax, 'FontSize', 11);
  354. %% figures 6d-e: emergence of value coding in cue-value learners
  355. cue_value_learner = cue_learner_p < 0.05;
  356. negative_coder = cue_learner_beta < 0;
  357. % align coefficients to each neuron's preferred cue-value direction
  358. beta_cue_aligned = beta_value_cue_bins;
  359. beta_sr_aligned = beta_value_sr_bins;
  360. beta_cue_aligned(negative_coder, :) = -beta_cue_aligned(negative_coder, :);
  361. beta_sr_aligned(negative_coder, :) = -beta_sr_aligned(negative_coder, :);
  362. n_bins = n_smaller_parts;
  363. mean_cue = nan(n_bins, numel(regions));
  364. mean_sr = nan(n_bins, numel(regions));
  365. sem_cue = nan(n_bins, numel(regions));
  366. sem_sr = nan(n_bins, numel(regions));
  367. p_sr = nan(n_bins, numel(regions));
  368. for r = 1:numel(regions)
  369. unit_mask = cue_value_learner & brain_region == r;
  370. cue_values = beta_cue_aligned(unit_mask, :);
  371. sr_values = beta_sr_aligned(unit_mask, :);
  372. mean_cue(:, r) = mean(cue_values, 1, 'omitnan')';
  373. mean_sr(:, r) = mean(sr_values, 1, 'omitnan')';
  374. sem_cue(:, r) = (std(cue_values, [], 1, 'omitnan') ./ sqrt(sum(~isnan(cue_values), 1)))';
  375. sem_sr(:, r) = (std(sr_values, [], 1, 'omitnan') ./ sqrt(sum(~isnan(sr_values), 1)))';
  376. for bin = 1:n_bins
  377. [~, p_sr(bin, r)] = ttest(sr_values(:, bin));
  378. end
  379. end
  380. bin_labels = {'1-2', '3-4', '5-6', '7-8', '9-10'};
  381. y_lims = [-0.1 0.2];
  382. f = figure('Color', 'w');
  383. tl = tiledlayout(f, 1, 2, 'Padding', 'loose', 'TileSpacing', 'tight');
  384. for r = 1:numel(regions)
  385. ax = nexttile(tl);
  386. hold(ax, 'on');
  387. % Early and late presentation windows
  388. patch(ax, [0.75 0.75 2.25 2.25], [y_lims fliplr(y_lims)], ...
  389. phase_colours(1, :), 'EdgeColor', 'none', 'FaceAlpha', 0.3);
  390. patch(ax, [3.75 3.75 5.25 5.25], [y_lims fliplr(y_lims)], ...
  391. phase_colours(2, :), 'EdgeColor', 'none', 'FaceAlpha', 0.4);
  392. h(1) = plot(ax, mean_cue(:, r), 'Color', cue_sr_colours(1, :), 'LineWidth', 2);
  393. errorbar(ax, 1:n_bins, mean_cue(:, r), sem_cue(:, r), ...
  394. 'Color', cue_sr_colours(1, :), 'LineStyle', 'none', 'LineWidth', 2);
  395. h(2) = plot(ax, mean_sr(:, r), 'Color', cue_sr_colours(2, :), 'LineWidth', 2);
  396. errorbar(ax, 1:n_bins, mean_sr(:, r), sem_sr(:, r), ...
  397. 'Color', cue_sr_colours(2, :), 'LineStyle', 'none', 'LineWidth', 2);
  398. % significance of SR coefficients against zero
  399. for bin = 1:n_bins
  400. labels = {'n.s.', '*', '**', '***'};
  401. level = 1 + (p_sr(bin,r)<0.05) + (p_sr(bin,r)<0.01) + (p_sr(bin,r)<0.001);
  402. if level > 1
  403. text(ax, bin, mean_sr(bin,r)+sem_sr(bin,r)+0.015, labels{level}, ...
  404. 'Color', cue_sr_colours(2, :), 'FontWeight', 'bold', ...
  405. 'HorizontalAlignment', 'center', 'FontSize', 12);
  406. end
  407. end
  408. text(ax, 1.5, -0.075, 'Early', 'HorizontalAlignment', 'center');
  409. text(ax, 4.5, -0.075, 'Late', 'HorizontalAlignment', 'center');
  410. xlim(ax, [0.5 5.5]);
  411. ylim(ax, y_lims);
  412. xticks(ax, 1:n_bins);
  413. xticklabels(ax, bin_labels);
  414. yticks(ax, -0.1:0.1:0.2);
  415. xlabel(ax, 'Presentations');
  416. ylabel(ax, 'Value regression coefficient');
  417. title(ax, regions{r}, 'FontWeight', 'normal');
  418. if r == 1
  419. legend(ax, h, {'at cue', 'at SR'}, 'Location', 'south', 'Box', 'off');
  420. end
  421. box(ax, 'off');
  422. set(ax, 'FontSize', 12);
  423. hold(ax, 'off');
  424. clear h
  425. end
  426. %% figures 6f-g: value coding during the choice phase
  427. cue_value_learner = cue_learner_p(:) < 0.05;
  428. brain_region = brain_region(:);
  429. beta_cue = squeeze(beta_choice_cue_ts(:, 2, :));
  430. beta_rew = squeeze(beta_choice_outcome_ts(:, 3, :));
  431. beta_norew = squeeze(beta_choice_outcome_ts(:, 4, :));
  432. % Align coefficients using each neuron's peak post-cue value coding
  433. align_idx = beta_ds_idx(beta_ds_idx > 50)';
  434. [~, peak_i] = max(abs(beta_cue(:, align_idx)), [], 2);
  435. peak_idx = align_idx(peak_i);
  436. unit_idx = (1:n_units)';
  437. peak_value = beta_cue(sub2ind(size(beta_cue), unit_idx, peak_idx));
  438. sign_flip = ones(n_units, 1);
  439. sign_flip(peak_value < 0) = -1;
  440. beta_cue_aligned = beta_cue .* sign_flip;
  441. beta_out_aligned = mean(cat(3, beta_rew .* sign_flip, ...
  442. beta_norew .* sign_flip), 3, 'omitnan');
  443. panel_tags = {'fig6f_acc', 'fig6g_ofc'};
  444. sig_cue_pos = false(numel(regions), numel(beta_ds_idx));
  445. sig_cue_neg = false(numel(regions), numel(beta_ds_idx));
  446. sig_out_pos = false(numel(regions), numel(beta_ds_idx));
  447. sig_out_neg = false(numel(regions), numel(beta_ds_idx));
  448. % permutation tests
  449. if run_betas_perm
  450. post_cue_ds = find(beta_ds_idx > 50)';
  451. for r = 1:numel(regions)
  452. unit_mask = cue_value_learner & brain_region == r;
  453. null_cue = nan(numel(beta_ds_idx), n_perm, 'single');
  454. null_out = nan(numel(beta_ds_idx), n_perm, 'single');
  455. for p = 1:n_perm
  456. cue_perm = squeeze(beta_choice_cue_perm(:, :, p));
  457. rew_perm = squeeze(beta_out_rew_perm(:, :, p));
  458. norew_perm = squeeze(beta_out_norew_perm(:, :, p));
  459. % Align each permutation using its own peak post-cue coding
  460. [~, peak_i] = max(abs(cue_perm(:, post_cue_ds)), [], 2);
  461. peak_idx = post_cue_ds(peak_i);
  462. unit_idx = (1:size(cue_perm, 1))';
  463. peak_value = cue_perm(sub2ind(size(cue_perm), unit_idx, peak_idx));
  464. perm_sign = ones(size(cue_perm, 1), 1, 'like', cue_perm);
  465. perm_sign(peak_value < 0) = -1;
  466. cue_perm = cue_perm .* perm_sign;
  467. out_perm = mean(cat(3, rew_perm .* perm_sign, ...
  468. norew_perm .* perm_sign), 3, 'omitnan');
  469. null_cue(:, p) = mean(cue_perm(unit_mask, :), 1, 'omitnan')';
  470. null_out(:, p) = mean(out_perm(unit_mask, :), 1, 'omitnan')';
  471. end
  472. real_cue = mean(beta_cue_aligned(unit_mask, beta_ds_idx), 1, 'omitnan')';
  473. real_out = mean(beta_out_aligned(unit_mask, beta_ds_idx), 1, 'omitnan')';
  474. out = compute_cluster_based_perm_test(real_cue, null_cue, 97.5, 2);
  475. sig_cue_pos(r, :) = reshape(out.survived_len_UB & out.survived_mass_UB, 1, []);
  476. sig_cue_neg(r, :) = reshape(out.survived_len_LB & out.survived_mass_LB, 1, []);
  477. out = compute_cluster_based_perm_test(real_out, null_out, 97.5, 2);
  478. sig_out_pos(r, :) = reshape(out.survived_len_UB & out.survived_mass_UB, 1, []);
  479. sig_out_neg(r, :) = reshape(out.survived_len_LB & out.survived_mass_LB, 1, []);
  480. writematrix([sig_cue_pos(r, :); sig_cue_neg(r, :)], ...
  481. fullfile(perm_dir, [panel_tags{r} '_choice_beta.txt']));
  482. writematrix([sig_out_pos(r, :); sig_out_neg(r, :)], ...
  483. fullfile(perm_dir, [panel_tags{r} '_outcome_beta.txt']));
  484. end
  485. else
  486. for r = 1:numel(regions)
  487. tmp = readmatrix(fullfile(perm_dir, [panel_tags{r} '_choice_beta.txt']));
  488. sig_cue_pos(r, :) = logical(tmp(1, :));
  489. sig_cue_neg(r, :) = logical(tmp(2, :));
  490. tmp = readmatrix(fullfile(perm_dir, [panel_tags{r} '_outcome_beta.txt']));
  491. sig_out_pos(r, :) = logical(tmp(1, :));
  492. sig_out_neg(r, :) = logical(tmp(2, :));
  493. end
  494. end
  495. % plot
  496. f = figure('Color', 'w');
  497. tl = tiledlayout(f, 1, 2, 'Padding', 'loose', 'TileSpacing', 'tight');
  498. for r = 1:numel(regions)
  499. ax = nexttile(tl);
  500. hold(ax, 'on');
  501. unit_mask = cue_value_learner & brain_region == r;
  502. h(1) = plotmse(beta_cue_aligned(unit_mask, :), ...
  503. choice_out_colours(1, :), [0 1]);
  504. h(2) = plotmse(beta_out_aligned(unit_mask, :), ...
  505. choice_out_colours(2, :), [0 1]);
  506. set(h, 'LineWidth', 2);
  507. figElements(h, [], 'Time from cue on/outcome (ms)', 'Value regression coefficient', ...
  508. [1 550], [-0.15 0.15], [50 300 550], {'0' '250' '500'}, -0.15:0.05:0.15, {}, [], [], []);
  509. scatter(beta_ds_idx(sig_cue_pos(r, :)), 0.142.*ones(1, sum(sig_cue_pos(r, :))), 100, '.', ...
  510. 'MarkerEdgeColor', choice_out_colours(1, :));
  511. scatter(beta_ds_idx(sig_cue_neg(r, :)), ...
  512. -0.142.*ones(1, sum(sig_cue_neg(r, :))), 100, '.', ...
  513. 'MarkerEdgeColor', choice_out_colours(1, :));
  514. scatter(beta_ds_idx(sig_out_pos(r, :)), ...
  515. 0.135.*ones(1, sum(sig_out_pos(r, :))), 100, '.', ...
  516. 'MarkerEdgeColor', choice_out_colours(2, :));
  517. scatter(beta_ds_idx(sig_out_neg(r, :)), ...
  518. -0.135.*ones(1, sum(sig_out_neg(r, :))), 100, '.', ...
  519. 'MarkerEdgeColor', choice_out_colours(2, :));
  520. yline(ax, 0, 'k');
  521. title(ax, regions{r}, 'FontWeight', 'normal');
  522. if r == 1
  523. legend(ax, h, {'at choice', 'at outcome'}, ...
  524. 'Location', 'southwest', 'Box', 'off');
  525. else
  526. ylabel(ax, []);
  527. yticklabels(ax, []);
  528. end
  529. set(ax, 'FontSize', 12);
  530. hold(ax, 'off');
  531. clear h
  532. end

fig6_rpe.m at commit 0341811, no license · at the source

Overview

Authors: Elena Gutierrez1, Timothy H. Muller1, James L. Butler1, W. M. Nishantha Malalasekera2, Laurence T. Hunt1,3, Sebastijan Veselic1, Steven W. Kennerley1,2
  1. Department of Experimental Psychology, University of Oxford, Oxford, OX1 3SR, UK
  2. Institute of Neurology, Department of Clinical and Movement Neurosciences, University College London, London, WC1N 3BG, UK
  3. University of Oxford Centre for Integrative Neuroimaging, University of Oxford, FMRIB, John Radcliffe Hospital, Oxford, OX3 9DU, UK
Institutions: University of Oxford (United Kingdom); UCL Queen Square Institute of Neurology (United Kingdom); University College London (United Kingdom); Wellcome Centre for Integrative Neuroimaging (United Kingdom); John Radcliffe Hospital (United Kingdom)
Dates: published 4 August 2026
Type: Preprint
License: CC BY
Identifiers: DOI 10.21203/rs.3.rs-10419673/v1 · OpenAlex W7172416244
Open access: green, a free copy (OpenAlex)
Status: code verified
Methods: Statistics, Machine learning, Preprocessing, fMRI & imaging, Single-unit activity, calcium imaging, Physiology & signal measures
Topic: Neural and Behavioral Psychology Studies (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Citations: not cited yet (OpenAlex); 71 references in the paper

Abstract

Studying how the brain represents value spans distinct methods and training histories, from neuroimaging in task-naïve humans to single-neuron recordings in extensively trained non-human primates. Similar findings across fields have encouraged the untested assumption that rapidly emerging and overtrained value representations are equivalent. Here we recorded single-neuron activity in anterior cingulate cortex (ACC) and orbitofrontal cortex (OFC) as macaques learned novel cue values and chose between novel and overtrained cues. Value responses emerged within 4-7 cue presentations, matching behavioural adaptation. Yet ACC and OFC used distinct codes. ACC encoded value in a common format that generalised across training history. OFC coding was more context-dependent, with distinct subpopulations recruited by choice experience. Choice novelty was also encoded independently of value before chosen value signals emerged. During learning, ACC responses shifted from overtrained secondary reinforcers to newly predictive cues. These findings establish the necessary (rapid acquisition) and sufficient (generalised format) conditions for comparing value representations across methods, species, and training histories.

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

elenagutierr/learning_paper

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 0341811aac2cd86fc3bd27ee99c930d99977c218, 6 August 2026
Languages: MATLAB (14)
Size: 52 files, 14 scripts
Software Heritage: not archived
Found in: “Data and materials availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
15 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;
  • 14 scripts, each with its path and the digest of its content;
  • 7 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data and materials availability

All data and code to reproduce figures will be available at https://github.com/elenagutierr/learning_paper upon publication.

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, journal, 7 authors, 68 references.

Cite

This paper

Gutierrez, E., Muller, T. H., Butler, J. L., Malalasekera, W. M. N., Hunt, L. T., Veselic, S., & Kennerley, S. W. (2026). Rapid value learning reveals generalized and context-dependent codes in frontal cortex. Research Square (preprint). https://doi.org/10.21203/rs.3.rs-10419673/v1

BibTeX

@article{gutierrez2026rapid,
author = {Gutierrez, Elena and Muller, Timothy H. and Butler, James L. and Malalasekera, W. M. Nishantha and Hunt, Laurence T. and Veselic, Sebastijan and Kennerley, Steven W.},
title = {{Rapid value learning reveals generalized and context-dependent codes in frontal cortex}},
journal = {Research Square (preprint)},
year = {2026},
month = aug,
publisher = {Research Square},
issn = {2693-5015},
doi = {10.21203/rs.3.rs-10419673/v1},
url = {https://doi.org/10.21203/rs.3.rs-10419673/v1}
}

RIS

TY - JOUR
AU - Gutierrez, Elena
AU - Muller, Timothy H.
AU - Butler, James L.
AU - Malalasekera, W. M. Nishantha
AU - Hunt, Laurence T.
AU - Veselic, Sebastijan
AU - Kennerley, Steven W.
TI - Rapid value learning reveals generalized and context-dependent codes in frontal cortex
T2 - Research Square (preprint)
J2 - Res Sq
PY - 2026
DA - 2026/08/04
SN - 2693-5015
PB - Research Square
DO - 10.21203/rs.3.rs-10419673/v1
UR - https://doi.org/10.21203/rs.3.rs-10419673/v1
ER -

CSL-JSON

{
"id": "10.21203/rs.3.rs-10419673/v1",
"type": "article",
"title": "Rapid value learning reveals generalized and context-dependent codes in frontal cortex",
"container-title": "Research Square (preprint)",
"author": [
{
"family": "Gutierrez",
"given": "Elena"
},
{
"family": "Muller",
"given": "Timothy H."
},
{
"family": "Butler",
"given": "James L."
},
{
"family": "Malalasekera",
"given": "W. M. Nishantha"
},
{
"family": "Hunt",
"given": "Laurence T."
},
{
"family": "Veselic",
"given": "Sebastijan"
},
{
"family": "Kennerley",
"given": "Steven W."
}
],
"container-title-short": "Res Sq",
"DOI": "10.21203/rs.3.rs-10419673/v1",
"ISSN": "2693-5015",
"publisher": "Research Square",
"URL": "https://doi.org/10.21203/rs.3.rs-10419673/v1",
"issued": {
"date-parts": [
[
2026,
8,
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.1038/s41593-026-02377-y [code]
Representations of the intrinsic value of information in mouse orbitofrontal cortex.
Journal: Nature neuroscience
In common: Image Processing Toolbox, Statistics and Machine Learning Toolbox, 5 references
[2] doi:10.7554/elife.105774 [code]
Anterior cingulate cortex monitors action state and action content in complex associative learning.
Journal: eLife
In common: 6 references
[3] doi:10.1111/ejn.70641
Distinct High-Gamma Signals in Primate Prefrontal Cortex Differentiate Cue Information, Preference Revision, and Expected Reward During Value-Based Decisions.
Journal: The European journal of neuroscience
In common: 5 references
[4] doi:10.7554/elife.106032 [code]
Neural signatures of model-based and model-free reinforcement learning across prefrontal cortex and striatum.
Journal: eLife
In common: 5 references
[5] doi:10.1038/s41467-026-71664-w [code]
Dorsal prefrontal cortex drives perseverative behavior in mice.
Journal: Nature communications
In common: Image Processing Toolbox, Signal Processing Toolbox, Statistics and Machine Learning Toolbox, 2 references
[6] doi:10.1016/j.cub.2026.05.068 [code]
An abstract relational map emerges in the human medial prefrontal cortex with consolidation.
Journal: Current biology : CB
In common: Image Processing Toolbox, Signal Processing Toolbox, Statistics and Machine Learning Toolbox, 2 references
[7] doi:10.1038/s41562-026-02473-w [code]
Brain activity, disruption and connectivity comparisons identify origins of human metacognition in other primates.
Journal: Nature human behaviour
In common: Image Processing Toolbox, Signal Processing Toolbox, Statistics and Machine Learning Toolbox, 2 references
[8] doi:10.1038/s41593-026-02342-9 [code]
Interpretable abstractions of artificial neural networks predict behavior and neural activity during human information gathering.
Journal: Nature neuroscience
In common: 4 references
[9] doi:10.1038/s41593-026-02345-6 [code]
Human hippocampal ripples tune cortical responses based on predicted uncertainty.
Journal: Nature neuroscience
In common: Image Processing Toolbox, Signal Processing Toolbox, Statistics and Machine Learning Toolbox, 1 reference
[10] doi:10.1016/j.isci.2026.117492 [code]
Neural subspace reorganization reflects value-based decision-making.
Journal: iScience
In common: 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.