Rapid value learning reveals generalized and context-dependent codes in frontal cortex
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] § 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] § Results ↔ fig2_behaviour.m, lines 108–231 · score 0.60 · Probe Choice trials, Bonferroni corrected, 1–3, probability trials, accuracy, 7–10
- [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] § 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] § 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] § 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] § 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
- %% generate figure 6
- % input:
- % data/neural_data.mat
- % ~ "all_units" contains one structure element per recorded unit.
- % ~ each unit includes trial-by-time spike rasters aligned to cue onset, choice response and outcome.
- % ~ each raster spans 6s, with the alignment event occurring at time index 3000.
- % if using existing permutation test results: data/precomputed_perm_test/fig6/*.txt
- %
- % output:
- % figure 6
- %
- % required MATLAB toolboxes:
- % Statistics and Machine Learning Toolbox
- % Image Processing Toolbox
- %
- % required custom functions:
- % /analysis_functions: CPD, ols, compute_cluster_based_perm_test
- % /plot_functions: plotmse, figElements
- %
- % EG 2026
- %% set folders and load data
- analysis_dir = fileparts(mfilename('fullpath'));
- addpath(genpath(analysis_dir))
- data_dir = fullfile(analysis_dir, 'data');
- perm_dir = fullfile(data_dir, 'precomputed_perm_test', 'fig6');
- load(fullfile(data_dir, 'neural_data.mat'), 'all_units')
- n_units = numel(all_units);
- %% additional analysis parameters
- % set one option to true to recompute the corresponding permutation test.
- % run the permutations for t-statistics during Conditioning phase trials (fig. 6b)
- % or betas during Choice phase trials (fig. 6f-g) separately to limit memory use;
- % do not set both options to true in the same run.
- % NB: this may take a while!
- run_tstat_perm = false;
- run_betas_perm = false;
- n_perm = 1000;
- % time windows
- cue_avg_wndw = 3101:3500; % for averaging FR post-cue/sr
- sr_avg_wndw = 4101:4500;
- pre_cue_wndw = 2951:3500; % inc. pre-cue/sr window to plot over time
- pre_sr_wndw = 3951:4500;
- % presentation partitions
- presentation_parts = [1:4; 7:10];
- n_parts = size(presentation_parts, 1);
- presentation = repmat(1:10,10,1);
- presentation = presentation(:);
- cue_learners_pres_wndw = 4:10; % presentations to define cue value learners
- smaller_pres_wndws = reshape(1:10, 2, 5)';
- n_smaller_parts = size(smaller_pres_wndws, 1);
- % preallocate outputs
- tstat_value_cue_pres = nan(n_units, numel(pre_cue_wndw), n_parts);
- tstat_value_sr_pres = nan(n_units, numel(pre_sr_wndw), n_parts);
- beta_value_cue_pres = nan(n_units, n_parts);
- beta_value_sr_pres = nan(n_units, n_parts);
- cue_learner_beta = nan(n_units, 1);
- cue_learner_t = nan(n_units, 1);
- cue_learner_p = nan(n_units, 1);
- beta_value_cue_bins = nan(n_units, n_smaller_parts);
- beta_value_sr_bins = nan(n_units, n_smaller_parts);
- beta_choice_cue_ts = nan(n_units, 3, numel(pre_cue_wndw));
- beta_choice_outcome_ts = nan(n_units, 4, numel(pre_cue_wndw));
- if run_tstat_perm
- tstat_value_cue_perm = nan(n_units, numel(pre_cue_wndw), n_parts, n_perm, 'single');
- tstat_value_sr_perm = nan(n_units, numel(pre_sr_wndw), n_parts, n_perm, 'single');
- end
- % downsampling parameters for permutation test in fig. 6f-g
- beta_ds = 5; % downsampling factor; paper figure uses 5ms
- 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
- if run_betas_perm
- beta_choice_cue_perm = nan(n_units, numel(beta_ds_idx), n_perm, 'single');
- beta_out_rew_perm = nan(n_units, numel(beta_ds_idx), n_perm, 'single');
- beta_out_norew_perm = nan(n_units, numel(beta_ds_idx), n_perm, 'single');
- end
- %% run unit loop
- for u = 1:n_units
- disp(u)
- % get this unit's session
- curr_sess = all_units(u);
- % get this unit's rasters
- curr_unit_cue_on = curr_sess.raster_cue_on;
- curr_unit_choice = curr_sess.raster_choice;
- curr_unit_outcome = curr_sess.raster_outcome;
- % create masks to filter trials and conditions
- gt_mask = curr_sess.gt'; % was it a good trial? i.e. 0 or 6 on condition,
- task_phase = curr_sess.PhaseOfTask'; % task phase, learning (1) or choice phase (2)
- learning_phase = task_phase == 1;
- choice_phase = task_phase == 2;
- forced_trials = curr_sess.forced_trials';
- % create and centre regressors
- n_value_levels = 5;
- chosen_mag = curr_sess.chosen_pay'; % magnitude of chosen stimulus
- chosen_mag(chosen_mag==1) = nan;
- chosen_mag = discretize(chosen_mag, n_value_levels);
- chosen_mag = chosen_mag - (n_value_levels+1)/2;
- chosen_prob = curr_sess.chosen_prob'; % probability of chosen stimulus
- chosen_prob(chosen_prob==1) = nan;
- chosen_prob = discretize(chosen_prob, n_value_levels);
- chosen_prob = chosen_prob - (n_value_levels+1)/2;
- value = sum([chosen_mag chosen_prob], 2, 'omitnan'); % collapse across magnitude and probability trials
- mag_trial_inds = ~isnan(chosen_mag);
- prob_trial_inds = ~isnan(chosen_prob);
- rewarded = curr_sess.rewarded' -0.5;
- prob_rew = value; prob_rew(rewarded==-0.5) = 0;
- prob_norew = value; prob_norew(rewarded==0.5) = 0;
- chose_left = curr_sess.choseleft';
- % index trials required
- learning_inds = gt_mask & learning_phase & forced_trials;
- choice_inds = gt_mask & choice_phase & prob_trial_inds;
- % orthogonalise outcome regressors wrt reward delivery
- M = [ones(sum(choice_inds), 1), rewarded(choice_inds)];
- prob_rew_ortho = prob_rew(choice_inds) - M*(M\prob_rew(choice_inds));
- prob_norew_ortho = prob_norew(choice_inds) - M*(M\prob_norew(choice_inds));
- % create design matrix
- dm_learn = [ones(size(value)) value chose_left];
- dm_rpe = [rewarded(choice_inds) prob_rew_ortho prob_norew_ortho];
- % prepare FRs: index and smooth
- gauss_wndw = 250;
- fr_cue_on = smoothdata(curr_unit_cue_on, 2, 'gaussian', gauss_wndw);
- fr_choice = smoothdata(curr_unit_choice, 2, 'gaussian', gauss_wndw);
- fr_out = smoothdata(curr_unit_outcome, 2, 'gaussian', gauss_wndw);
- % reduce to valid learning trials
- learn_dm = dm_learn(learning_inds, :);
- learn_cue = fr_cue_on(learning_inds, :);
- learn_sr = fr_choice(learning_inds, :);
- % fig. 6a-c: early and late learning partitions
- for part = 1:n_parts
- part_mask = ismember(presentation, presentation_parts(part, :));
- % fig. 6b: value t-statistic over time
- [~, ~, t_cue] = ols(zscore(learn_cue(part_mask, pre_cue_wndw)), ...
- learn_dm(part_mask, :));
- [~, ~, t_sr] = ols(zscore(learn_sr(part_mask, pre_sr_wndw)), ...
- learn_dm(part_mask, :));
- tstat_value_cue_pres(u, :, part) = t_cue(2, :);
- tstat_value_sr_pres(u, :, part) = t_sr(2, :);
- % fig. 6c: value coefficient from averaged firing rate
- sr_fr_avg = mean(zscore(learn_sr(part_mask, sr_avg_wndw)), 2);
- b_sr = glmfit(learn_dm(part_mask, 2:end), sr_fr_avg);
- beta_value_sr_pres(u, part) = b_sr(2);
- % fig. 6a: example unit
- if u == 170
- example_fr(:, :, part) = [learn_cue(part_mask, pre_cue_wndw), ...
- learn_sr(part_mask, pre_sr_wndw)];
- example_dm(:, :, part) = learn_dm(part_mask, :);
- example_t(part, :) = [t_cue(2, :), t_sr(2, :)];
- end
- end
- % fig. 6c-g: define cue value learners
- learner_mask = ismember(presentation, cue_learners_pres_wndw);
- learner_fr = mean(zscore(learn_cue(learner_mask, cue_avg_wndw)), 2);
- [b_learner, ~, learner_stats] = glmfit(learn_dm(learner_mask, 2:end), learner_fr);
- cue_learner_beta(u) = b_learner(2);
- cue_learner_t(u) = learner_stats.t(2);
- cue_learner_p(u) = learner_stats.p(2);
- % fig. 6d-e: value coding across two-presentation bins
- for part = 1:n_smaller_parts
- part_mask = ismember(presentation, smaller_pres_wndws(part, :));
- cue_fr_avg = mean(zscore(learn_cue(part_mask, cue_avg_wndw)), 2);
- sr_fr_avg = mean(zscore(learn_sr(part_mask, sr_avg_wndw)), 2);
- b_cue = glmfit(learn_dm(part_mask, 2:end), cue_fr_avg);
- b_sr = glmfit(learn_dm(part_mask, 2:end), sr_fr_avg);
- beta_value_cue_bins(u, part) = b_cue(2);
- beta_value_sr_bins(u, part) = b_sr(2);
- end
- % fig. 6f-g: regression over time (Choice phase)
- choice_dm = dm_learn(choice_inds, :);
- beta_choice_cue_ts(u, :, :) = ols(zscore(fr_cue_on(choice_inds, pre_cue_wndw)), choice_dm);
- beta_choice_outcome_ts(u, :, :) = ols(zscore(fr_out(choice_inds, pre_cue_wndw)),[ones(sum(choice_inds), 1), dm_rpe]);
- % permutation tests
- % fig. 6b: permuted value t-statistics
- if run_tstat_perm
- for part = 1:n_parts
- part_mask = ismember(presentation, presentation_parts(part, :));
- part_dm = learn_dm(part_mask, :);
- part_cue = zscore(learn_cue(part_mask, pre_cue_wndw));
- part_sr = zscore(learn_sr(part_mask, pre_sr_wndw));
- for p = 1:n_perm
- shuf_i = randperm(size(part_dm, 1));
- [~, ~, t_cue_perm] = ols(part_cue(shuf_i, :), part_dm);
- [~, ~, t_sr_perm] = ols(part_sr(shuf_i, :), part_dm);
- tstat_value_cue_perm(u, :, part, p) = single(t_cue_perm(2, :));
- tstat_value_sr_perm(u, :, part, p) = single(t_sr_perm(2, :));
- end
- end
- end
- % % fig. 6f-g: permuted betas
- % if run_betas_perm
- % cue_fr_ds = zscore(fr_cue_on(choice_inds, pre_cue_wndw(beta_ds_idx)));
- % out_fr_ds = zscore(fr_out(choice_inds, pre_cue_wndw(beta_ds_idx)));
- % out_dm = [ones(sum(choice_inds), 1), dm_rpe];
- %
- % for p = 1:n_perm
- % shuf_i = randperm(sum(choice_inds));
- %
- % b_perm = ols(cue_fr_ds(shuf_i, :), choice_dm);
- % beta_choice_cue_perm(u, :, p) = single(b_perm(2, :));
- %
- % b_perm = ols(out_fr_ds(shuf_i, :), out_dm);
- % beta_out_rew_perm(u, :, p) = single(b_perm(3, :));
- % beta_out_norew_perm(u, :, p) = single(b_perm(4, :));
- % end
- % end
- end
- % extract unit info
- brain_region = [all_units.brain_region]';
- % prepare figure and plotting parameters
- epochs = {'Cue on', 'Forced choice', 'Secondary Reinforcer', 'Outcome'};
- event = {'Cue on', 'Forced choice', 'SR', 'Outcome'};
- regions = {'ACC', 'OFC'};
- attributes = {'Magnitude', 'Probability'};
- region_colours = [255, 215, 0; 0, 206, 209]./255;
- trial_colours = [135, 215, 250; 255, 115, 0]./255;
- value_colours = [0, 0, 128; 30, 144, 255; 255, 255, 0; 255, 140, 0;178, 34, 34]./255;
- cue_sr_colours = [0 153 0; 0 0 102]./255;
- phase_colours = [255 153 153; 102 0 0]./255;
- choice_out_colours = [0 153 0; 153 0 153]./255;
- %% figure 6a: example cue-value learner neuron
- f = figure('Color', 'w');
- tl = tiledlayout(f, 2, 4, 'Padding', 'loose', 'TileSpacing', 'tight');
- value_regr = unique(example_dm(:, 2, :));
- cue_idx = 1:numel(pre_cue_wndw);
- sr_idx = numel(pre_cue_wndw) + (1:numel(pre_sr_wndw));
- sig_cue = abs(example_t(:, cue_idx)) >= 3.1;
- sig_sr = abs(example_t(:, sr_idx)) >= 3.1;
- for part = 1:n_parts
- plot_data = {example_fr(:, cue_idx, part), example_fr(:, sr_idx, part)};
- sig_data = {sig_cue(part, :), sig_sr(part, :)};
- event_name = {'Cue on', 'SR on'};
- for epoch = 1:2
- ax = nexttile(tl, [1 2]);
- hold(ax, 'on');
- for v = 1:n_value_levels
- trial_mask = example_dm(:, 2, part) == value_regr(v);
- h(v) = plotmse(plot_data{epoch}(trial_mask, :), value_colours(v, :), [0 1]);
- h(v).LineWidth = 2;
- end
- figElements(h, [], 'Time (ms)', [], ...
- [1 550], [0 50], [50 550], {'0' '500'}, 0:25:50, {}, [], [], []);
- if epoch==1, ylabel('Firing rate (Hz)'); else, yticklabels([]); end
- xline(50, 'k');
- text(65, 42, event_name{epoch}, 'FontSize', 11);
- significant = sig_data{epoch};
- scatter(find(significant), 50.*ones(1, sum(significant)), 100, 'k.');
- set(ax, 'FontSize', 11);
- hold(ax, 'off');
- clear h
- end
- end
- %% figure 6b: correspondence between cue and SR value signals
- n_time = numel(pre_cue_wndw);
- cue_sr_corr = nan(2, n_time, numel(regions)); % late cue–early SR; early cue–late SR
- for r = 1:numel(regions)
- region_mask = brain_region == r;
- late_cue = squeeze(tstat_value_cue_pres(region_mask, :, 2));
- early_sr = squeeze(tstat_value_sr_pres(region_mask, :, 1));
- early_cue = squeeze(tstat_value_cue_pres(region_mask, :, 1));
- late_sr = squeeze(tstat_value_sr_pres(region_mask, :, 2));
- cue_sr_corr(1, :, r) = diag(corr(late_cue, early_sr, 'Rows', 'complete'))';
- cue_sr_corr(2, :, r) = diag(corr(early_cue, late_sr, 'Rows', 'complete'))';
- end
- % permutation tests
- if run_tstat_perm
- above_null_cue_sr = false(2, n_time, numel(regions));
- for r = 1:numel(regions)
- region_mask = brain_region == r;
- perm_data = nan(n_time, n_perm, 'single');
- for direction = 1:2
- for p = 1:n_perm
- if direction == 1
- cue_perm = squeeze(tstat_value_cue_perm(region_mask, :, 2, p));
- sr_perm = squeeze(tstat_value_sr_perm(region_mask, :, 1, p));
- else
- cue_perm = squeeze(tstat_value_cue_perm(region_mask, :, 1, p));
- sr_perm = squeeze(tstat_value_sr_perm(region_mask, :, 2, p));
- end
- perm_data(:, p) = single(diag(corr(cue_perm, sr_perm, ...
- 'Rows', 'complete')));
- end
- real_data = squeeze(cue_sr_corr(direction, :, r))';
- out = compute_cluster_based_perm_test(real_data, perm_data, 97.5, 2);
- above_null_cue_sr(direction, :, r) = reshape(out.survived_len_UB & out.survived_mass_UB, 1, []);
- end
- writematrix(above_null_cue_sr(:, :, r), fullfile(perm_dir, ...
- sprintf('fig6b_%s_cue_sr_corr.txt', lower(regions{r}))));
- end
- else
- for r = 1:numel(regions)
- above_null_cue_sr(:, :, r) = readmatrix(fullfile(perm_dir, ...
- sprintf('fig6b_%s_cue_sr_corr.txt', lower(regions{r}))));
- end
- end
- % plot
- f = figure('Color', 'w');
- tl = tiledlayout(f, 2, 1, 'Padding', 'loose', 'TileSpacing', 'tight');
- scatter_pos = [0.60 0.58];
- time_window = 1:n_time;
- for r = 1:numel(regions)
- ax = nexttile(tl);
- hold(ax, 'on');
- plot(ax, cue_sr_corr(1, :, r), 'Color', region_colours(r, :), 'LineWidth', 2);
- plot(ax, cue_sr_corr(2, :, r), '--', 'Color', [0.75 0.75 0.75], 'LineWidth', 2);
- significant = squeeze(above_null_cue_sr(1, :, r))==1;
- scatter(ax, time_window(significant), scatter_pos(r).*ones(1, sum(significant)), ...
- 100, '.', 'MarkerEdgeColor', region_colours(r, :));
- xline(ax, 50, 'k');
- yline(ax, 0, 'k');
- xlim(ax, [0 550]);
- ylim(ax, [-0.2 0.6]);
- xticks(ax, [0 50 550]);
- xticklabels(ax, {'-50' '0' '500'});
- yticks(ax, [0 0.6]);
- xlabel(ax, 'Time from cue/SR on (ms)');
- ylabel(ax, {'Value \itt \rmstatistic correlation';'at cue vs at SR'});
- title(ax, regions{r}, 'FontWeight', 'normal');
- box(ax, 'off');
- set(ax, 'FontSize', 11);
- end
- %% figure 6c: change in SR value coding in cue-value learners
- cue_value_learner = cue_learner_p < 0.05;
- negative_coder = cue_learner_beta < 0;
- % align coefficients to each neuron's cue-value coding direction
- beta_sr_aligned = beta_value_sr_pres;
- beta_sr_aligned(negative_coder, :) = -beta_sr_aligned(negative_coder, :);
- delta_sr = beta_sr_aligned(:, 2) - beta_sr_aligned(:, 1); % late − early
- n_learners = nan(1, numel(regions));
- mean_delta = nan(1, numel(regions));
- sem_delta = nan(1, numel(regions));
- p_delta = nan(1, numel(regions));
- for r = 1:numel(regions)
- values = delta_sr(cue_value_learner & brain_region == r);
- values = values(~isnan(values));
- n_learners(r) = sum(cue_value_learner & brain_region == r);
- mean_delta(r) = mean(values);
- sem_delta(r) = std(values) / sqrt(numel(values));
- [~, p_delta(r), ~, stats] = ttest(values);
- fprintf('Difference in late–early SR value coefficient in %s cue-value learners: n=%d, t=%.4g, df=%d, p=%.4g\n', ...
- regions{r}, n_learners(r), stats.tstat, stats.df, p_delta(r));
- end
- f = figure('Color', 'w');
- tl = tiledlayout(f, 2, 1, 'Padding', 'loose', 'TileSpacing', 'tight');
- ax = nexttile(tl, [2 1]);
- b = bar(ax, mean_delta, 'FaceColor', 'flat', 'EdgeColor', 'k');
- b.CData = region_colours;
- hold(ax, 'on');
- errorbar(ax, 1:numel(regions), mean_delta, sem_delta, 'k', 'LineStyle', 'none');
- yline(ax, 0, 'k');
- ylim(ax, [-0.1 0]);
- yticks(ax, [-0.1 0]);
- xticks(ax, 1:numel(regions));
- xticklabels(ax, regions);
- ylabel(ax, '\Delta value coefficient (Late–Early SR)');
- xlabel(ax, 'Cue value learners');
- box(ax, 'off');
- set(ax, 'FontSize', 11);
- %% figures 6d-e: emergence of value coding in cue-value learners
- cue_value_learner = cue_learner_p < 0.05;
- negative_coder = cue_learner_beta < 0;
- % align coefficients to each neuron's preferred cue-value direction
- beta_cue_aligned = beta_value_cue_bins;
- beta_sr_aligned = beta_value_sr_bins;
- beta_cue_aligned(negative_coder, :) = -beta_cue_aligned(negative_coder, :);
- beta_sr_aligned(negative_coder, :) = -beta_sr_aligned(negative_coder, :);
- n_bins = n_smaller_parts;
- mean_cue = nan(n_bins, numel(regions));
- mean_sr = nan(n_bins, numel(regions));
- sem_cue = nan(n_bins, numel(regions));
- sem_sr = nan(n_bins, numel(regions));
- p_sr = nan(n_bins, numel(regions));
- for r = 1:numel(regions)
- unit_mask = cue_value_learner & brain_region == r;
- cue_values = beta_cue_aligned(unit_mask, :);
- sr_values = beta_sr_aligned(unit_mask, :);
- mean_cue(:, r) = mean(cue_values, 1, 'omitnan')';
- mean_sr(:, r) = mean(sr_values, 1, 'omitnan')';
- sem_cue(:, r) = (std(cue_values, [], 1, 'omitnan') ./ sqrt(sum(~isnan(cue_values), 1)))';
- sem_sr(:, r) = (std(sr_values, [], 1, 'omitnan') ./ sqrt(sum(~isnan(sr_values), 1)))';
- for bin = 1:n_bins
- [~, p_sr(bin, r)] = ttest(sr_values(:, bin));
- end
- end
- bin_labels = {'1-2', '3-4', '5-6', '7-8', '9-10'};
- y_lims = [-0.1 0.2];
- f = figure('Color', 'w');
- tl = tiledlayout(f, 1, 2, 'Padding', 'loose', 'TileSpacing', 'tight');
- for r = 1:numel(regions)
- ax = nexttile(tl);
- hold(ax, 'on');
- % Early and late presentation windows
- patch(ax, [0.75 0.75 2.25 2.25], [y_lims fliplr(y_lims)], ...
- phase_colours(1, :), 'EdgeColor', 'none', 'FaceAlpha', 0.3);
- patch(ax, [3.75 3.75 5.25 5.25], [y_lims fliplr(y_lims)], ...
- phase_colours(2, :), 'EdgeColor', 'none', 'FaceAlpha', 0.4);
- h(1) = plot(ax, mean_cue(:, r), 'Color', cue_sr_colours(1, :), 'LineWidth', 2);
- errorbar(ax, 1:n_bins, mean_cue(:, r), sem_cue(:, r), ...
- 'Color', cue_sr_colours(1, :), 'LineStyle', 'none', 'LineWidth', 2);
- h(2) = plot(ax, mean_sr(:, r), 'Color', cue_sr_colours(2, :), 'LineWidth', 2);
- errorbar(ax, 1:n_bins, mean_sr(:, r), sem_sr(:, r), ...
- 'Color', cue_sr_colours(2, :), 'LineStyle', 'none', 'LineWidth', 2);
- % significance of SR coefficients against zero
- for bin = 1:n_bins
- labels = {'n.s.', '*', '**', '***'};
- level = 1 + (p_sr(bin,r)<0.05) + (p_sr(bin,r)<0.01) + (p_sr(bin,r)<0.001);
- if level > 1
- text(ax, bin, mean_sr(bin,r)+sem_sr(bin,r)+0.015, labels{level}, ...
- 'Color', cue_sr_colours(2, :), 'FontWeight', 'bold', ...
- 'HorizontalAlignment', 'center', 'FontSize', 12);
- end
- end
- text(ax, 1.5, -0.075, 'Early', 'HorizontalAlignment', 'center');
- text(ax, 4.5, -0.075, 'Late', 'HorizontalAlignment', 'center');
- xlim(ax, [0.5 5.5]);
- ylim(ax, y_lims);
- xticks(ax, 1:n_bins);
- xticklabels(ax, bin_labels);
- yticks(ax, -0.1:0.1:0.2);
- xlabel(ax, 'Presentations');
- ylabel(ax, 'Value regression coefficient');
- title(ax, regions{r}, 'FontWeight', 'normal');
- if r == 1
- legend(ax, h, {'at cue', 'at SR'}, 'Location', 'south', 'Box', 'off');
- end
- box(ax, 'off');
- set(ax, 'FontSize', 12);
- hold(ax, 'off');
- clear h
- end
- %% figures 6f-g: value coding during the choice phase
- cue_value_learner = cue_learner_p(:) < 0.05;
- brain_region = brain_region(:);
- beta_cue = squeeze(beta_choice_cue_ts(:, 2, :));
- beta_rew = squeeze(beta_choice_outcome_ts(:, 3, :));
- beta_norew = squeeze(beta_choice_outcome_ts(:, 4, :));
- % Align coefficients using each neuron's peak post-cue value coding
- align_idx = beta_ds_idx(beta_ds_idx > 50)';
- [~, peak_i] = max(abs(beta_cue(:, align_idx)), [], 2);
- peak_idx = align_idx(peak_i);
- unit_idx = (1:n_units)';
- peak_value = beta_cue(sub2ind(size(beta_cue), unit_idx, peak_idx));
- sign_flip = ones(n_units, 1);
- sign_flip(peak_value < 0) = -1;
- beta_cue_aligned = beta_cue .* sign_flip;
- beta_out_aligned = mean(cat(3, beta_rew .* sign_flip, ...
- beta_norew .* sign_flip), 3, 'omitnan');
- panel_tags = {'fig6f_acc', 'fig6g_ofc'};
- sig_cue_pos = false(numel(regions), numel(beta_ds_idx));
- sig_cue_neg = false(numel(regions), numel(beta_ds_idx));
- sig_out_pos = false(numel(regions), numel(beta_ds_idx));
- sig_out_neg = false(numel(regions), numel(beta_ds_idx));
- % permutation tests
- if run_betas_perm
- post_cue_ds = find(beta_ds_idx > 50)';
- for r = 1:numel(regions)
- unit_mask = cue_value_learner & brain_region == r;
- null_cue = nan(numel(beta_ds_idx), n_perm, 'single');
- null_out = nan(numel(beta_ds_idx), n_perm, 'single');
- for p = 1:n_perm
- cue_perm = squeeze(beta_choice_cue_perm(:, :, p));
- rew_perm = squeeze(beta_out_rew_perm(:, :, p));
- norew_perm = squeeze(beta_out_norew_perm(:, :, p));
- % Align each permutation using its own peak post-cue coding
- [~, peak_i] = max(abs(cue_perm(:, post_cue_ds)), [], 2);
- peak_idx = post_cue_ds(peak_i);
- unit_idx = (1:size(cue_perm, 1))';
- peak_value = cue_perm(sub2ind(size(cue_perm), unit_idx, peak_idx));
- perm_sign = ones(size(cue_perm, 1), 1, 'like', cue_perm);
- perm_sign(peak_value < 0) = -1;
- cue_perm = cue_perm .* perm_sign;
- out_perm = mean(cat(3, rew_perm .* perm_sign, ...
- norew_perm .* perm_sign), 3, 'omitnan');
- null_cue(:, p) = mean(cue_perm(unit_mask, :), 1, 'omitnan')';
- null_out(:, p) = mean(out_perm(unit_mask, :), 1, 'omitnan')';
- end
- real_cue = mean(beta_cue_aligned(unit_mask, beta_ds_idx), 1, 'omitnan')';
- real_out = mean(beta_out_aligned(unit_mask, beta_ds_idx), 1, 'omitnan')';
- out = compute_cluster_based_perm_test(real_cue, null_cue, 97.5, 2);
- sig_cue_pos(r, :) = reshape(out.survived_len_UB & out.survived_mass_UB, 1, []);
- sig_cue_neg(r, :) = reshape(out.survived_len_LB & out.survived_mass_LB, 1, []);
- out = compute_cluster_based_perm_test(real_out, null_out, 97.5, 2);
- sig_out_pos(r, :) = reshape(out.survived_len_UB & out.survived_mass_UB, 1, []);
- sig_out_neg(r, :) = reshape(out.survived_len_LB & out.survived_mass_LB, 1, []);
- writematrix([sig_cue_pos(r, :); sig_cue_neg(r, :)], ...
- fullfile(perm_dir, [panel_tags{r} '_choice_beta.txt']));
- writematrix([sig_out_pos(r, :); sig_out_neg(r, :)], ...
- fullfile(perm_dir, [panel_tags{r} '_outcome_beta.txt']));
- end
- else
- for r = 1:numel(regions)
- tmp = readmatrix(fullfile(perm_dir, [panel_tags{r} '_choice_beta.txt']));
- sig_cue_pos(r, :) = logical(tmp(1, :));
- sig_cue_neg(r, :) = logical(tmp(2, :));
- tmp = readmatrix(fullfile(perm_dir, [panel_tags{r} '_outcome_beta.txt']));
- sig_out_pos(r, :) = logical(tmp(1, :));
- sig_out_neg(r, :) = logical(tmp(2, :));
- end
- end
- % plot
- f = figure('Color', 'w');
- tl = tiledlayout(f, 1, 2, 'Padding', 'loose', 'TileSpacing', 'tight');
- for r = 1:numel(regions)
- ax = nexttile(tl);
- hold(ax, 'on');
- unit_mask = cue_value_learner & brain_region == r;
- h(1) = plotmse(beta_cue_aligned(unit_mask, :), ...
- choice_out_colours(1, :), [0 1]);
- h(2) = plotmse(beta_out_aligned(unit_mask, :), ...
- choice_out_colours(2, :), [0 1]);
- set(h, 'LineWidth', 2);
- figElements(h, [], 'Time from cue on/outcome (ms)', 'Value regression coefficient', ...
- [1 550], [-0.15 0.15], [50 300 550], {'0' '250' '500'}, -0.15:0.05:0.15, {}, [], [], []);
- scatter(beta_ds_idx(sig_cue_pos(r, :)), 0.142.*ones(1, sum(sig_cue_pos(r, :))), 100, '.', ...
- 'MarkerEdgeColor', choice_out_colours(1, :));
- scatter(beta_ds_idx(sig_cue_neg(r, :)), ...
- -0.142.*ones(1, sum(sig_cue_neg(r, :))), 100, '.', ...
- 'MarkerEdgeColor', choice_out_colours(1, :));
- scatter(beta_ds_idx(sig_out_pos(r, :)), ...
- 0.135.*ones(1, sum(sig_out_pos(r, :))), 100, '.', ...
- 'MarkerEdgeColor', choice_out_colours(2, :));
- scatter(beta_ds_idx(sig_out_neg(r, :)), ...
- -0.135.*ones(1, sum(sig_out_neg(r, :))), 100, '.', ...
- 'MarkerEdgeColor', choice_out_colours(2, :));
- yline(ax, 0, 'k');
- title(ax, regions{r}, 'FontWeight', 'normal');
- if r == 1
- legend(ax, h, {'at choice', 'at outcome'}, ...
- 'Location', 'southwest', 'Box', 'off');
- else
- ylabel(ax, []);
- yticklabels(ax, []);
- end
- set(ax, 'FontSize', 12);
- hold(ax, 'off');
- clear h
- end
fig6_rpe.m at commit 0341811, no license · at the source
Overview
- Department of Experimental Psychology, University of Oxford, Oxford, OX1 3SR, UK
- Institute of Neurology, Department of Clinical and Movement Neurosciences, University College London, London, WC1N 3BG, UK
- University of Oxford Centre for Integrative Neuroimaging, University of Oxford, FMRIB, John Radcliffe Hospital, Oxford, OX3 9DU, UK
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
0341811aac2cd86fc3bd27ee99c930d99977c218, 6 August 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
15 files
- analysis_functions/
BinomTest.m , MATLAB, 236 lines - analysis_functions/
CPD.m , MATLAB, 12 lines - analysis_functions/
chi2_test.m , MATLAB, 15 lines - analysis_functions/
compute_cluster_based_pe , MATLAB, 187 linesrm_test.m - analysis_functions/
compute_cluster_stats.m , MATLAB, 181 lines - analysis_functions/
compute_representation_s , MATLAB, 38 lines, 1 matchtructure.m - analysis_functions/
ols.m , MATLAB, 35 lines - fig2_behaviour.m, MATLAB, 232 lines, 1 match
- fig3_value.m, MATLAB, 1,112 lines, 1 match
- fig4_novelty.m, MATLAB, 750 lines, 1 match
- fig5_learning.m, MATLAB, 458 lines
- fig6_rpe.m, MATLAB, 685 lines, 3 matches
- plot_functions/
figElements.m , MATLAB, 68 lines - plot_functions/
plotmse.m , MATLAB, 131 lines - README.md, Text, 138 lines
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://
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://
BibTeX
@article{gutierrez2026ra
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/
url = {https://
}
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/
SN - 2693-5015
PB - Research Square
DO - 10.21203/
UR - https://
ER -
CSL-JSON
{
"id": "10.21203/
"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":
"DOI": "10.21203/
"ISSN": "2693-5015",
"publisher": "Research Square",
"URL": "https://
"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 neuroscienceIn 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: eLifeIn 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 neuroscienceIn 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: eLifeIn common: 5 references
- [5] doi:10.1038/s41467-026-71664-w [code]
- Dorsal prefrontal cortex drives perseverative behavior in mice.Journal: Nature communicationsIn 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 : CBIn 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 behaviourIn 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 neuroscienceIn common: 4 references
- [9] doi:10.1038/s41593-026-02345-6 [code]
- Human hippocampal ripples tune cortical responses based on predicted uncertainty.Journal: Nature neuroscienceIn 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: iScienceIn 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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 14 scripts, and 7 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:95dc1afde7527ca1…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
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.
