Detection of Internal and External Events in Spiking Neural Networks