classdef tExport < matlab.unittest.TestCase %TEXPORT Tests for tdcs_export_all (organized CSV export of all variations). methods (Test) function testExportTreeAndContents(testCase) outRoot = tempname; files = tdcs_export_all(outRoot); testCase.verifyGreaterThanOrEqual(numel(files), 22); % 1 + 9 + 3 + 9 % curated: 12 animals Tc = readtable(fullfile(outRoot, 'curated_all.csv'), 'TextType', 'string'); testCase.verifyEqual(numel(unique(Tc.subject)), 12); % scenario mergeB2_full: Box-B2 has 5 subjects Sb = readtable(fullfile(outRoot, 'scenarios', 'mergeB2_full.csv'), 'TextType', 'string'); nB2 = numel(unique(Sb.subject(Sb.group == "Electrode-Box-B2"))); testCase.verifyEqual(nB2, 5); % anchor file carries a binary tDCS factor with both levels A = readtable(fullfile(outRoot, 'anchors', 'mergeA2_B2vsA2.csv')); testCase.verifyEqual(sort(unique(A.tDCS))', [0 1]); % phases folder holds 3 merges x 3 phases = 9 files, each with dayp ph = dir(fullfile(outRoot, 'phases', '*.csv')); testCase.verifyEqual(numel(ph), 9); P = readtable(fullfile(outRoot, 'phases', 'mergeA2_phase_6-13.csv')); testCase.verifyTrue(ismember('dayp', P.Properties.VariableNames)); testCase.verifyGreaterThanOrEqual(min(P.dayp), 0); end end end