Fix bug in peak detection raising error when threshold is too low