the resultant whirlwind of mini-seizures trapped within either cranial hemisphere , swirling in opposite polarities , caused total shutdown of the cerebral cortex , leaving only the brainstem functional , which continued to control such vital tasks as heart rate and rhythm , respiration , even gastrointestinal activities .