'Return a SourceEstimate object with data summarized over time bins.
Time bins of ``width`` seconds. This method is intended for
visualization only. No filter is applied to the data before binning,
making the method inappropriate as a tool for downsampling data.
Parameters
width : scalar
Width of the individual bins in seconds.
tstart : scalar | None
Time point where the first bin starts. The default is the first
time point of the stc.
tstop : scalar | None
Last possible time point contained in a bin (if the last bin would
be shorter than width it is dropped). The default is the last time
point of the stc.
func : callable
Function that is applied to summarize the data. Needs to accept a
numpy.array as first input and an ``axis`` keyword argument.
Returns
stc : instance of SourceEstimate
The binned SourceEstimate.'

def bin(self, width, tstart=None, tstop=None, func=np.mean):

    if (tstart is None):
        tstart = self.tmin
    if (tstop is None):
        tstop = self.times[(-1)]
    times = np.arange(tstart, (tstop + self.tstep), width)
    (nv, _) = self.shape
    nt = (len(times) - 1)
    data = np.empty((nv, nt), dtype=self.data.dtype)
    for i in range(nt):
        idx = ((self.times >= times[i]) & (self.times < times[(i + 1)]))
        data[:, i] = func(self.data[:, idx], axis=1)
    tmin = (times[0] + (width / 2.0))
    stc = _make_stc(data, vertices=self.vertices, tmin=tmin, tstep=width, subject=self.subject)
    return stc
