def scale_to_voltage(dataarray, feature_range=(-80, -20)):
    """
    Scale data array to voltage-like range. Good for spindles detection.
    """
    data_scale = (feature_range[1] - feature_range[0]) / (
        dataarray.max(dim="time") - dataarray.min(dim="time")
    )
    data_min = feature_range[0] - dataarray.min(dim="time") * data_scale

    return data_scale * dataarray + data_min