merge threshold and ROI selection into one function