analysis(matlab): add paper-style learning-curve plot to every variation

Add variation_plot.m + make_variation_plot.m, dropping plotcurve.m +
learning_curve.png into all 28 variation folders. Each figure plots mean +/-
SEM successful reaches per training day for the anodal/treatment group (red)
vs control (blue), in the style of the paper ("Lines indicate mean (and SEM)
across animals in the anodal (red) and control (blue) groups"). Per-group N is
read from the data and shown in the legend; training day is 1-indexed (our day
0 = paper Day 1). Headless via exportgraphics. prev_f_full reproduces the
paper's own figure (anodal N=12 vs control N=12).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Experiments DB Dev
2026-07-24 01:28:44 -04:00
parent 378ad6da05
commit a2a812acc8
58 changed files with 1681 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

@@ -0,0 +1,57 @@
% Variation learning-curve plot, in the style of the paper:
% "Lines indicate mean (and SEM) across animals in the anodal (red) and
% control (blue) groups."
% Plots mean +/- SEM successful reaches per training day for the treatment /
% anodal group (stim = 1, red) and the control group (stim = 0, blue), reading
% this folder's data.csv and saving learning_curve.png. The per-group N is read
% from the data (each variation pools different groups), so the legend shows the
% actual counts. Training day is 1-indexed (our day 0 = the paper's "Day 1").
% Run: matlab -batch "plotcurve"
% (Copy of analysis/matlab/variation_plot.m; see make_variation_plot.m.)
here = fileparts(mfilename('fullpath'));
if isempty(here); here = pwd; end
vname = regexprep(here, '.*[/\\]', '');
D = readtable(fullfile(here, 'data.csv'), 'TextType', 'string');
days = unique(D.day); % 0-indexed
xd = days + 1; % plot as 1-indexed training day (paper axis)
red = [0.85 0.10 0.10];
blue = [0.10 0.30 0.85];
[Ma, Sa, na] = localCurve(D, 1, days); % anodal / treatment (stim = 1)
[Mc, Sc, nc] = localCurve(D, 0, days); % control (stim = 0)
fig = figure('Visible', 'off', 'Color', 'w', 'Position', [100 100 560 460]);
hold on
e1 = errorbar(xd, Ma, Sa, '-o', 'Color', red, 'MarkerFaceColor', red, 'LineWidth', 2);
e2 = errorbar(xd, Mc, Sc, '-o', 'Color', blue, 'MarkerFaceColor', blue, 'LineWidth', 2);
hold off
legend([e1 e2], {sprintf('anodal, N = %d', na), sprintf('control, N = %d', nc)}, ...
'Location', 'northwest', 'Box', 'off');
xlabel('training day');
ylabel('# successes');
title(vname, 'Interpreter', 'none');
set(gca, 'XTick', xd, 'FontName', 'Arial', 'FontSize', 13, 'LineWidth', 1.5, 'Box', 'off');
outFile = fullfile(here, 'learning_curve.png');
exportgraphics(fig, outFile, 'Resolution', 150);
close(fig);
fprintf('%s: wrote learning_curve.png (anodal N=%d, control N=%d)\n', vname, na, nc);
% ------------------------------------------------------------------ helper
function [M, S, n] = localCurve(D, stimVal, days)
%LOCALCURVE Per-day mean and SEM of successes across the animals in a group.
subs = unique(D.subject(D.stim == stimVal));
n = numel(subs);
X = nan(numel(days), n);
for j = 1:n
for i = 1:numel(days)
r = D.subject == subs(j) & D.day == days(i);
if any(r); X(i, j) = mean(D.success(r)); end
end
end
M = mean(X, 2, 'omitnan');
S = std(X, [], 2, 'omitnan') ./ sqrt(sum(~isnan(X), 2));
end