Most of the way through the code for merging ROIs together