The docstring says that roi should be "a binary mask", but maybe we should add something like `roi = np.asarray(roi, dtype=bool)` to coerce rois into dtype=bool.