function make_variation_logpower()
%MAKE_VARIATION_LOGPOWER Add the log-day model + Cohen's f + power to each variation.
%   MAKE_VARIATION_LOGPOWER() copies variation_logpower.m into every
%   variations/<name>/ folder with a data.csv (as logpowersim.m) and runs it,
%   producing logpower_result.txt. Re-runnable; picks up new folders.

thisDir = fileparts(mfilename('fullpath'));
template = fullfile(thisDir, 'variation_logpower.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, 'logpowersim.m'));
    fprintf('\n### %s ###\n', d(i).name);
    localRun(fullfile(folder, 'logpowersim.m'));
    n = n + 1;
end
fprintf('\nAdded logpowersim.m + logpower_result.txt to %d variation folders.\n', n);

end

function localRun(scriptPath)
run(scriptPath);
end
