matlab(tdcs): assert reference group present; README scope note

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Experiments DB Dev
2026-07-20 08:08:27 -04:00
parent 01f59a5265
commit 13414d31fc
2 changed files with 12 additions and 0 deletions
+10
View File
@@ -97,3 +97,13 @@ for the small, unbalanced groups in this study. What should agree is the
condition classifies as A2-like/B2-like/ambiguous, and whether the learning condition classifies as A2-like/B2-like/ambiguous, and whether the learning
rates differ across groups. Treat the MATLAB numbers as a sensitivity check rates differ across groups. Treat the MATLAB numbers as a sensitivity check
on the Python's conclusions, not as a numerically-identical reproduction. on the Python's conclusions, not as a numerically-identical reproduction.
## Scope vs. the Python
The MATLAB port reproduces the Python's three core models (count, rate,
learning-rate), per-animal tests, unknown-group classification, and the H2
verdict (read off the main model's A2-vs-B2 term). The Python's two auxiliary
sensitivity sections — `report_anchor_only` (a two-anchor-only refit) and
`report_mixed` (a Bayesian MAP random-intercept model) — are intentionally
**not** ported: the anchor-only refit is closely tracked by the main-model H2
term, and MATLAB's native `fitglme` already *is* the random-intercept model.
+2
View File
@@ -66,6 +66,8 @@ groupCell = groupCell(dayMask);
% level). Only categories actually present after merge+window survive. % level). Only categories actually present after merge+window survive.
S.group = categorical(groupCell); S.group = categorical(groupCell);
allCats = categories(S.group); allCats = categories(S.group);
assert(ismember(cfg.ref, allCats), 'tdcs_scenario_data:refMissing', ...
'Reference group "%s" is absent from scenario "%s".', cfg.ref, char(scenario));
otherCats = allCats(~strcmp(allCats, cfg.ref)); otherCats = allCats(~strcmp(allCats, cfg.ref));
S.group = reordercats(S.group, [{cfg.ref}; otherCats]); S.group = reordercats(S.group, [{cfg.ref}; otherCats]);