mask.ndim is not supposed to exist for a niimg.