An optimized adaptive spike detector for behavioural experiments