RATS: Robust Automatic Threshold Selection