A non-transitory computer-readable medium storing instructions that, when executed, cause one or more processors to:
- obtain a head conductivity model;
- compute a Foramen-Magnum Current-Occupancy Index (FM-COI) and enforce electrical and sleep-architecture safety limits;
- classify sleep stage using a convolutional neural network (CNN);
- compute a skin-path-corrected intracranial impedance (SPC-Z);
- estimate GCI/RGCI from SPC-Z and regional sensitivities;
- identify GC windows from the classified sleep stage and SPC-Z;
- and schedule delivery of transcranial electrical stimulation during the GC windows while maintaining the safety limits.