'Convert time to indices.
Parameters
times : list-like | float | int
List of numbers or a number representing points in time.
use_rounding : boolean
If True, use rounding (instead of truncation) when converting
times to indices. This can help avoid non-unique indices.
Returns
index : ndarray
Indices corresponding to the times supplied.'

def time_as_index(self, times, use_rounding=False):

    from ..source_estimate import _BaseSourceEstimate
    if isinstance(self, _BaseSourceEstimate):
        sfreq = (1.0 / self.tstep)
    else:
        sfreq = self.info['sfreq']
    index = ((np.atleast_1d(times) - self.times[0]) * sfreq)
    if use_rounding:
        index = np.round(index)
    return index.astype(int)
