Given an array with some specific points of the signal and a distance
    value, this function erases all the surplus points and returns an array
    with only one point (the first point) per distance samples values

    Parameters
    ----------
    points: array-like
      the events to filter.
    min_distance: int
      the distance value to exclude the unnecessary events.

    Returns
    -------
    fp: array-like
      the new events, after filtering just one per period.
    Example
    -------
    >>> clean_near_events([1,3,5,50,65,68,83,88],10)
    array([ 1, 50, 65, 83])

    See also: clean_near_peaks()

def clean_near_events(points, min_distance):
    """ Given an array with some specific points of the signal and a distance
    value, this function erases all the surplus points and returns an array
    with only one point (the first point) per distance samples values

    Parameters
    ----------
    points: array-like
      the events to filter.
    min_distance: int
      the distance value to exclude the unnecessary events.

    Returns
    -------
    fp: array-like
      the new events, after filtering just one per period.
    Example
    -------
    >>> clean_near_events([1,3,5,50,65,68,83,88],10)
    array([ 1, 50, 65, 83])

    See also: clean_near_peaks()
    """

    fp = []
    points = array(points)
    while len(points) > 0:
        fp += [points[0]]
        points = points[abs(points - points[0]) > min_distance]

    return array(fp)