def fixation_detection(x, y, time, missing=0.0, maxdist=25, mindur=50):
    """Detects fixations, defined as consecutive samples with an inter-sample distance of less than a set amount of pixels (disregarding missing data)

	Parameters
	----------
	x : array
		Gaze x positions
	y :	array
		Gaze y positions
	time : array
		Timestamps
	missing	: float
		Value to be used for missing data (default = 0.0)
	maxdist : int
		Maximal inter sample distance in pixels (default = 25)
	mindur : int
		Minimal duration of a fixation in milliseconds; detected fixation cadidates will be disregarded if they are below this duration (default = 100)

	Returns
	-------
	Sfix : list of lists
		Each containing [starttime]
	Efix : list of lists
		Each containing [starttime, endtime, duration, endx, endy]

	"""
    Sfix = []
    Efix = []
    si = 0
    fixstart = False
    for i in range(1, len(x)):
        dist = ((x[si] - x[i]) ** 2 + (y[si] - y[i]) ** 2) ** 0.5
        if dist <= maxdist and not fixstart:
            si = 0 + i
            fixstart = True
            Sfix.append([time[i]])
        elif dist > maxdist and fixstart:
            fixstart = False
            if time[i - 1] - Sfix[-1][0] >= mindur:
                Efix.append([Sfix[-1][0], time[i - 1], time[i - 1] - Sfix[-
                    1][0], x[si], y[si]])
            else:
                Sfix.pop(-1)
            si = 0 + i
        elif not fixstart:
            si += 1
    return Sfix, Efix
