Estimating a dynamic state to relate neural spiking activity to behavioral signals during cognitive tasks