analysis(matlab): add per-variation power simulation (powersim.m + power_result.txt)

Add variation_power.m (self-contained Monte-Carlo power for the paper's
stim x day interaction, using each folder's own data as ground truth; scores
per-animal cluster-honest power + LME power across N=[3..24] and effect
multipliers 1/0.5) and make_variation_power.m, which drops powersim.m into
every variations/<name>/ folder and runs it, writing power_result.txt beside
the existing data.csv/analyze.m/result.txt. Named powersim (not power) to
avoid shadowing the MATLAB builtin. All 28 folders processed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Experiments DB Dev
2026-07-23 13:57:25 -04:00
parent e1af1af7f4
commit bb5e2d88c0
58 changed files with 4234 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
function make_variation_power()
%MAKE_VARIATION_POWER Add a power-simulation script + result to every variation.
% MAKE_VARIATION_POWER() copies variation_power.m into each
% variations/<name>/ folder that contains a data.csv (as powersim.m) and runs
% it, producing power_result.txt beside the existing data.csv / analyze.m /
% result.txt. Re-runnable; also picks up any folders added later.
thisDir = fileparts(mfilename('fullpath'));
template = fullfile(thisDir, 'variation_power.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, 'powersim.m'));
fprintf('\n### %s ###\n', d(i).name);
localRun(fullfile(folder, 'powersim.m'));
n = n + 1;
end
fprintf('\nAdded powersim.m + power_result.txt to %d variation folders.\n', n);
end
function localRun(scriptPath)
run(scriptPath);
end