add methods to find maxima and minima in 3d using a mask