spiketools.utils.epoch.epoch_data_by_segment¶
- spiketools.utils.epoch.epoch_data_by_segment(timestamps, values, segments)[source]¶
Epoch data by segments.
- Parameters:
- timestamps1d array
Timestamps, in seconds.
- values1d or 2d array
Data values.
- segmentslist or 1d array of float
Time values that define the segments. Each segment time is defined as the interval between segment[n] and segment[n+1].
- Returns:
- segment_timestampslist of 1d array
The timestamps, in seconds, per segment.
- segment_valueslist of 1d array
The values, per segment.
Examples
Epoch data values into segments:
>>> timestamps = np.array([0.1, 0.4, 0.6, 0.7, 1]) >>> values = np.array([1, 3, 5, 7, 9]) >>> segments = [0, 0.35, 0.55, 0.8] >>> epoch_data_by_segment(timestamps, values, segments) ([array([0.1]), array([0.4]), array([0.6, 0.7])], [array([1]), array([3]), array([5, 7])])