def time_slice(self, t_start, t_stop):
'''
Creates a new :class:`SpikeTrain` corresponding to the time slice of
the original :class:`SpikeTrain` between (and including) times
:attr:`t_start` and :attr:`t_stop`. Either parameter can also be None
to use infinite endpoints for the time interval.
'''
_t_start = t_start
_t_stop = t_stop
if t_start is None:
_t_start = -np.inf
if t_stop is None:
_t_stop = np.inf
indices = (self >= _t_start) & (self <= _t_stop)
new_st = self[indices]
new_st.t_start = max(_t_start, self.t_start)
new_st.t_stop = min(_t_stop, self.t_stop)
if self.waveforms is not None:
new_st.waveforms = self.waveforms[indices]
return new_st
评论列表
文章目录