A unified framework to study history dependence in the nervous system