function cfg = tdcs_config()
%TDCS_CONFIG Curated group map and merge maps for the tDCS reaching study.
%   CFG = TDCS_CONFIG() returns a struct with:
%     .groups     containers.Map, subject name (char) -> curated group name
%                 (char), for the 12 curated animals only. All other
%                 animals present in the raw export are not in this map
%                 and must be dropped by callers.
%     .ref        reference group used to code the GLME group factor,
%                 'Electrode-Box-B2'.
%     .mergeA2    containers.Map collapsing the two UNKNOWN conditions
%                 toward the weaker anchor: Electrode-Box-A ->
%                 Electrode-Box-A2, Right-Electrode -> Electrode-Box-B2.
%     .mergeB2    containers.Map collapsing both UNKNOWN conditions onto
%                 the stronger anchor: Electrode-Box-A -> Electrode-Box-B2,
%                 Right-Electrode -> Electrode-Box-B2.
%     .anchorLow  'Electrode-Box-A2', the weaker of the two known anchors.
%     .anchorHigh 'Electrode-Box-B2', the stronger known anchor (== ref).
%     .unknowns   cell array of the two ungrouped conditions that get
%                 classified against the two anchors: {'Electrode-Box-A',
%                 'Right-Electrode'}.
%
%   See docs/superpowers/plans/2026-07-20-matlab-tdcs-analysis.md (Global
%   Constraints) for the source of these values.

% Curated 12-animal group map (by animal name).
subjectGroup = {
    'Vu-vuong',      'Naive'
    'Khoai-lang-2',  'Naive'
    'Khoai-tay-2',   'Naive'
    'OM-2',          'Naive'
    'Khoai-tay-1',   'Electrode-Box-A'
    'Banh-mi-2',     'Electrode-Box-A2'
    'Egg-tart-2',    'Electrode-Box-A2'
    'Root-beer-2',   'Electrode-Box-A2'
    'Banh-mi-1',     'Electrode-Box-B2'
    'Egg-tart-1',    'Electrode-Box-B2'
    'Root-beer-1',   'Electrode-Box-B2'
    'Khoai-lang-1',  'Right-Electrode'
    };

cfg = struct();
cfg.groups = containers.Map(subjectGroup(:, 1), subjectGroup(:, 2));

cfg.ref = 'Electrode-Box-B2';
cfg.anchorLow = 'Electrode-Box-A2';
cfg.anchorHigh = 'Electrode-Box-B2';
cfg.unknowns = {'Electrode-Box-A', 'Right-Electrode'};

cfg.mergeA2 = containers.Map( ...
    {'Electrode-Box-A', 'Right-Electrode'}, ...
    {'Electrode-Box-A2', 'Electrode-Box-B2'});

cfg.mergeB2 = containers.Map( ...
    {'Electrode-Box-A', 'Right-Electrode'}, ...
    {'Electrode-Box-B2', 'Electrode-Box-B2'});

% mergeNaive: pool Naive into the Box-A2 (control) side and Right-Electrode
% into the Box-B2 (tDCS) side. Control = Box-A2 + Naive (n=7), tDCS = Box-B2 +
% Right-Electrode (n=4); Electrode-Box-A is left unchanged.
cfg.mergeNaive = containers.Map( ...
    {'Naive', 'Right-Electrode'}, ...
    {'Electrode-Box-A2', 'Electrode-Box-B2'});

end
