diff --git a/analysis/matlab/make_variation_plot.m b/analysis/matlab/make_variation_plot.m new file mode 100644 index 0000000..068c6c8 --- /dev/null +++ b/analysis/matlab/make_variation_plot.m @@ -0,0 +1,28 @@ +function make_variation_plot() +%MAKE_VARIATION_PLOT Add a paper-style learning-curve figure to each variation. +% MAKE_VARIATION_PLOT() copies variation_plot.m into every variations// +% folder with a data.csv (as plotcurve.m) and runs it, producing +% learning_curve.png (mean +/- SEM successes per training day, anodal red vs +% control blue). Re-runnable; picks up new folders. + +thisDir = fileparts(mfilename('fullpath')); +template = fullfile(thisDir, 'variation_plot.m'); +root = fullfile(thisDir, 'variations'); + +d = dir(root); +n = 0; +for i = 1:numel(d) + if ~d(i).isdir || ismember(d(i).name, {'.', '..'}); continue; end + folder = fullfile(root, d(i).name); + if ~exist(fullfile(folder, 'data.csv'), 'file'); continue; end + copyfile(template, fullfile(folder, 'plotcurve.m')); + localRun(fullfile(folder, 'plotcurve.m')); + n = n + 1; +end +fprintf('\nAdded plotcurve.m + learning_curve.png to %d variation folders.\n', n); + +end + +function localRun(scriptPath) +run(scriptPath); +end diff --git a/analysis/matlab/variation_plot.m b/analysis/matlab/variation_plot.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variation_plot.m @@ -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 diff --git a/analysis/matlab/variations/boxa_a2_d0_10/learning_curve.png b/analysis/matlab/variations/boxa_a2_d0_10/learning_curve.png new file mode 100644 index 0000000..3a10526 Binary files /dev/null and b/analysis/matlab/variations/boxa_a2_d0_10/learning_curve.png differ diff --git a/analysis/matlab/variations/boxa_a2_d0_10/plotcurve.m b/analysis/matlab/variations/boxa_a2_d0_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/boxa_a2_d0_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/boxa_a2_d0_5/learning_curve.png b/analysis/matlab/variations/boxa_a2_d0_5/learning_curve.png new file mode 100644 index 0000000..5ca4e38 Binary files /dev/null and b/analysis/matlab/variations/boxa_a2_d0_5/learning_curve.png differ diff --git a/analysis/matlab/variations/boxa_a2_d0_5/plotcurve.m b/analysis/matlab/variations/boxa_a2_d0_5/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/boxa_a2_d0_5/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/boxa_a2_d6_10/learning_curve.png b/analysis/matlab/variations/boxa_a2_d6_10/learning_curve.png new file mode 100644 index 0000000..48596de Binary files /dev/null and b/analysis/matlab/variations/boxa_a2_d6_10/learning_curve.png differ diff --git a/analysis/matlab/variations/boxa_a2_d6_10/plotcurve.m b/analysis/matlab/variations/boxa_a2_d6_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/boxa_a2_d6_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/boxa_b2_d0_10/learning_curve.png b/analysis/matlab/variations/boxa_b2_d0_10/learning_curve.png new file mode 100644 index 0000000..64415b4 Binary files /dev/null and b/analysis/matlab/variations/boxa_b2_d0_10/learning_curve.png differ diff --git a/analysis/matlab/variations/boxa_b2_d0_10/plotcurve.m b/analysis/matlab/variations/boxa_b2_d0_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/boxa_b2_d0_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/boxa_b2_d0_5/learning_curve.png b/analysis/matlab/variations/boxa_b2_d0_5/learning_curve.png new file mode 100644 index 0000000..945d772 Binary files /dev/null and b/analysis/matlab/variations/boxa_b2_d0_5/learning_curve.png differ diff --git a/analysis/matlab/variations/boxa_b2_d0_5/plotcurve.m b/analysis/matlab/variations/boxa_b2_d0_5/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/boxa_b2_d0_5/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/boxa_b2_d6_10/learning_curve.png b/analysis/matlab/variations/boxa_b2_d6_10/learning_curve.png new file mode 100644 index 0000000..4622719 Binary files /dev/null and b/analysis/matlab/variations/boxa_b2_d6_10/learning_curve.png differ diff --git a/analysis/matlab/variations/boxa_b2_d6_10/plotcurve.m b/analysis/matlab/variations/boxa_b2_d6_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/boxa_b2_d6_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/matched_current_d0_3/learning_curve.png b/analysis/matlab/variations/matched_current_d0_3/learning_curve.png new file mode 100644 index 0000000..ff1a27d Binary files /dev/null and b/analysis/matlab/variations/matched_current_d0_3/learning_curve.png differ diff --git a/analysis/matlab/variations/matched_current_d0_3/plotcurve.m b/analysis/matlab/variations/matched_current_d0_3/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/matched_current_d0_3/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_a2_d0_10/learning_curve.png b/analysis/matlab/variations/naive_a2_d0_10/learning_curve.png new file mode 100644 index 0000000..427a949 Binary files /dev/null and b/analysis/matlab/variations/naive_a2_d0_10/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_a2_d0_10/plotcurve.m b/analysis/matlab/variations/naive_a2_d0_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_a2_d0_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_a2_d0_13/learning_curve.png b/analysis/matlab/variations/naive_a2_d0_13/learning_curve.png new file mode 100644 index 0000000..6122b31 Binary files /dev/null and b/analysis/matlab/variations/naive_a2_d0_13/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_a2_d0_13/plotcurve.m b/analysis/matlab/variations/naive_a2_d0_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_a2_d0_13/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_a2_d0_5/learning_curve.png b/analysis/matlab/variations/naive_a2_d0_5/learning_curve.png new file mode 100644 index 0000000..78345a8 Binary files /dev/null and b/analysis/matlab/variations/naive_a2_d0_5/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_a2_d0_5/plotcurve.m b/analysis/matlab/variations/naive_a2_d0_5/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_a2_d0_5/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_a2_d6_10/learning_curve.png b/analysis/matlab/variations/naive_a2_d6_10/learning_curve.png new file mode 100644 index 0000000..029ba85 Binary files /dev/null and b/analysis/matlab/variations/naive_a2_d6_10/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_a2_d6_10/plotcurve.m b/analysis/matlab/variations/naive_a2_d6_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_a2_d6_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_a2_d6_13/learning_curve.png b/analysis/matlab/variations/naive_a2_d6_13/learning_curve.png new file mode 100644 index 0000000..eb6784c Binary files /dev/null and b/analysis/matlab/variations/naive_a2_d6_13/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_a2_d6_13/plotcurve.m b/analysis/matlab/variations/naive_a2_d6_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_a2_d6_13/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_boxa_d0_10/learning_curve.png b/analysis/matlab/variations/naive_boxa_d0_10/learning_curve.png new file mode 100644 index 0000000..58d5ff5 Binary files /dev/null and b/analysis/matlab/variations/naive_boxa_d0_10/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_boxa_d0_10/plotcurve.m b/analysis/matlab/variations/naive_boxa_d0_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_boxa_d0_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_boxa_d0_13/learning_curve.png b/analysis/matlab/variations/naive_boxa_d0_13/learning_curve.png new file mode 100644 index 0000000..026ae49 Binary files /dev/null and b/analysis/matlab/variations/naive_boxa_d0_13/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_boxa_d0_13/plotcurve.m b/analysis/matlab/variations/naive_boxa_d0_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_boxa_d0_13/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_boxa_d0_5/learning_curve.png b/analysis/matlab/variations/naive_boxa_d0_5/learning_curve.png new file mode 100644 index 0000000..c59672a Binary files /dev/null and b/analysis/matlab/variations/naive_boxa_d0_5/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_boxa_d0_5/plotcurve.m b/analysis/matlab/variations/naive_boxa_d0_5/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_boxa_d0_5/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_boxa_d6_10/learning_curve.png b/analysis/matlab/variations/naive_boxa_d6_10/learning_curve.png new file mode 100644 index 0000000..4e66928 Binary files /dev/null and b/analysis/matlab/variations/naive_boxa_d6_10/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_boxa_d6_10/plotcurve.m b/analysis/matlab/variations/naive_boxa_d6_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_boxa_d6_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/naive_boxa_d6_13/learning_curve.png b/analysis/matlab/variations/naive_boxa_d6_13/learning_curve.png new file mode 100644 index 0000000..01ba17f Binary files /dev/null and b/analysis/matlab/variations/naive_boxa_d6_13/learning_curve.png differ diff --git a/analysis/matlab/variations/naive_boxa_d6_13/plotcurve.m b/analysis/matlab/variations/naive_boxa_d6_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/naive_boxa_d6_13/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/prev_f_full/learning_curve.png b/analysis/matlab/variations/prev_f_full/learning_curve.png new file mode 100644 index 0000000..5b7419f Binary files /dev/null and b/analysis/matlab/variations/prev_f_full/learning_curve.png differ diff --git a/analysis/matlab/variations/prev_f_full/plotcurve.m b/analysis/matlab/variations/prev_f_full/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/prev_f_full/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/right_only_d0_10/learning_curve.png b/analysis/matlab/variations/right_only_d0_10/learning_curve.png new file mode 100644 index 0000000..7e11bfd Binary files /dev/null and b/analysis/matlab/variations/right_only_d0_10/learning_curve.png differ diff --git a/analysis/matlab/variations/right_only_d0_10/plotcurve.m b/analysis/matlab/variations/right_only_d0_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/right_only_d0_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/right_only_d0_13/learning_curve.png b/analysis/matlab/variations/right_only_d0_13/learning_curve.png new file mode 100644 index 0000000..fde70c7 Binary files /dev/null and b/analysis/matlab/variations/right_only_d0_13/learning_curve.png differ diff --git a/analysis/matlab/variations/right_only_d0_13/plotcurve.m b/analysis/matlab/variations/right_only_d0_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/right_only_d0_13/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/right_only_d0_5/learning_curve.png b/analysis/matlab/variations/right_only_d0_5/learning_curve.png new file mode 100644 index 0000000..01c8d4f Binary files /dev/null and b/analysis/matlab/variations/right_only_d0_5/learning_curve.png differ diff --git a/analysis/matlab/variations/right_only_d0_5/plotcurve.m b/analysis/matlab/variations/right_only_d0_5/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/right_only_d0_5/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/right_only_d6_10/learning_curve.png b/analysis/matlab/variations/right_only_d6_10/learning_curve.png new file mode 100644 index 0000000..beec2c1 Binary files /dev/null and b/analysis/matlab/variations/right_only_d6_10/learning_curve.png differ diff --git a/analysis/matlab/variations/right_only_d6_10/plotcurve.m b/analysis/matlab/variations/right_only_d6_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/right_only_d6_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/right_only_d6_13/learning_curve.png b/analysis/matlab/variations/right_only_d6_13/learning_curve.png new file mode 100644 index 0000000..d731fff Binary files /dev/null and b/analysis/matlab/variations/right_only_d6_13/learning_curve.png differ diff --git a/analysis/matlab/variations/right_only_d6_13/plotcurve.m b/analysis/matlab/variations/right_only_d6_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/right_only_d6_13/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/unmerge_d0_10/learning_curve.png b/analysis/matlab/variations/unmerge_d0_10/learning_curve.png new file mode 100644 index 0000000..0d415cc Binary files /dev/null and b/analysis/matlab/variations/unmerge_d0_10/learning_curve.png differ diff --git a/analysis/matlab/variations/unmerge_d0_10/plotcurve.m b/analysis/matlab/variations/unmerge_d0_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/unmerge_d0_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/unmerge_d0_13/learning_curve.png b/analysis/matlab/variations/unmerge_d0_13/learning_curve.png new file mode 100644 index 0000000..25f4432 Binary files /dev/null and b/analysis/matlab/variations/unmerge_d0_13/learning_curve.png differ diff --git a/analysis/matlab/variations/unmerge_d0_13/plotcurve.m b/analysis/matlab/variations/unmerge_d0_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/unmerge_d0_13/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/unmerge_d0_5/learning_curve.png b/analysis/matlab/variations/unmerge_d0_5/learning_curve.png new file mode 100644 index 0000000..6ba5896 Binary files /dev/null and b/analysis/matlab/variations/unmerge_d0_5/learning_curve.png differ diff --git a/analysis/matlab/variations/unmerge_d0_5/plotcurve.m b/analysis/matlab/variations/unmerge_d0_5/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/unmerge_d0_5/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/unmerge_d6_10/learning_curve.png b/analysis/matlab/variations/unmerge_d6_10/learning_curve.png new file mode 100644 index 0000000..c30f023 Binary files /dev/null and b/analysis/matlab/variations/unmerge_d6_10/learning_curve.png differ diff --git a/analysis/matlab/variations/unmerge_d6_10/plotcurve.m b/analysis/matlab/variations/unmerge_d6_10/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/unmerge_d6_10/plotcurve.m @@ -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 diff --git a/analysis/matlab/variations/unmerge_d6_13/learning_curve.png b/analysis/matlab/variations/unmerge_d6_13/learning_curve.png new file mode 100644 index 0000000..d5a8c3b Binary files /dev/null and b/analysis/matlab/variations/unmerge_d6_13/learning_curve.png differ diff --git a/analysis/matlab/variations/unmerge_d6_13/plotcurve.m b/analysis/matlab/variations/unmerge_d6_13/plotcurve.m new file mode 100644 index 0000000..bfc1386 --- /dev/null +++ b/analysis/matlab/variations/unmerge_d6_13/plotcurve.m @@ -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