def thermalDistortion(x, y, stim_param):
    """Apply thermal distortion correction to positions in events list.

    No correction is necessary and none will be applied if the slopes are
    all 0 and the intercepts are all 1.

    Parameters
    ----------
    x: array like
        Array of detector X coordinates.

    y: array like
        Array of detector Y coordinates.

    stim_param: dictionary of lists
        The dictionary has keys i0, i1, x0, xslope, y0, yslope.

    Returns
    -------
    boolean
        True if a correction was actually applied in at least one of
        the time intervals.
    """
    x0 = stim_param['x0']
    xslope = stim_param['xslope']
    y0 = stim_param['y0']
    yslope = stim_param['yslope']
    actually_done = False
    if 'i0' in stim_param:
        i0 = stim_param['i0']
        i1 = stim_param['i1']
    else:
        i0 = [0]
        i1 = [len(x)]
    for n in range(len(i0)):
        i = i0[n]
        j = i1[n]
        if x0[n] != 0.0 or xslope[n] != 1.0 or y0[n] != 0.0 or yslope[n
            ] != 1.0:
            x[i:j] = x0[n] + x[i:j] * xslope[n]
            y[i:j] = y0[n] + y[i:j] * yslope[n]
            actually_done = True
    return actually_done
