def _exclude_border(mask, exclude_border):
    """
    Remove peaks near the borders
    """
    for i, excluded in enumerate(exclude_border):
        if excluded == 0:
            continue
        mask[(slice(None),) * i + (slice(None, excluded),)] = False
        mask[(slice(None),) * i + (slice(-excluded, None),)] = False
    return mask
