spiketools.measures.conversions.convert_times_to_train¶
- spiketools.measures.conversions.convert_times_to_train(spikes, fs=1000, time_range=None)[source]¶
Convert spike times into a binary spike train.
- Parameters:
- spikes1d array
Spike times, in seconds.
- fsint, optional, default: 1000
The sampling rate to use for the computed spike train, in Hz.
- time_rangelist of [float, float], optional
Expected time range of the spikes, used to infer the length of the output spike train. If not provided, the length is set as the observed time range of ‘spikes’.
- Returns:
- spike_train1d array
Spike train.
Examples
Convert spike times into a corresponding binary spike train:
>>> spikes = np.array([0.002, 0.250, 0.500, 0.750, 1.000, 1.250, 1.500, 2.000]) >>> convert_times_to_train(spikes) array([0, 0, 1, ..., 0, 0, 1])