"""Stimulus-only DirectNet control: both env/onset/dom streams; EEG always zero.

This diagnostic tests stimulus-only label shortcuts. No pretraining, no EEG
information, no audio waveform. The external runner is overridden in memory;
existing source files and existing experiment outputs remain untouched.
"""
import argparse,os,sys

def main():
 p=argparse.ArgumentParser();p.add_argument('--seed',type=int,choices=(0,1),default=0);p.add_argument('--phase',choices=('lodo','external'),default='lodo');a=p.parse_args()
 tag=f'_w10_stimonly_envonsetdom_s{a.seed}';exp='direct_clf__eaP_n5_t60'+tag
 opts=['model_blocks=3','batch_size=32','infer_bs=64','val_windows=512','steps_per_epoch=125']
 if a.phase=='lodo':
  os.environ['SAVE_FOLD_WEIGHTS']='1'
  sys.argv=['direct_classifier.py','--prep','eaP_n5_t60','--window-s','10','--targets','env,onset,dom','--train-seed',str(a.seed),'--min-epochs','10','--p-switch','0.5','--zero-eeg','--aug-set','clf_p_switch2=0.5','--set',*opts,'--tag',tag]
  path=os.path.join(os.path.dirname(__file__),'direct_classifier.py');src=open(path).read()
 else:
  sys.argv=['eval_external_clf.py','--seed',str(a.seed),'--window-s','10','--min-epochs','10','--p-switch','0.5','--prep','eaP_n5_t60','--ref',exp,'--tag','_w10stimonlyP','--set',*opts,'--aug-set','clf_p_switch2=0.5']
  path=os.path.join(os.path.dirname(__file__),'eval_external_clf.py');src=open(path).read()
  old='p_switch=a.p_switch, zero_eeg=False';assert src.count(old)==1
  src=src.replace(old,'p_switch=a.p_switch, zero_eeg=True')
  old='DC.logits(net, DC.wide(tr), _targets(tr))';assert src.count(old)==1
  src=src.replace(old,'DC.logits(net, DC.wide(tr, np.zeros_like(tr["eeg"])), _targets(tr))')
 exec(compile(src,path,'exec'),{'__name__':'__main__','__file__':path})
if __name__=='__main__':main()
