elephant.statistics.time_histogram¶
- elephant.statistics.time_histogram(spiketrains: List[SpikeTrain] | SpikeTrain, bin_size: Quantity, t_start: Quantity | None = None, t_stop: Quantity | None = None, output: str = 'counts', binary: bool = False) AnalogSignal[source]¶
Time Histogram of a list of
neo.core.SpikeTrainobjects.Visualization of this function is covered in Viziphant:
viziphant.statistics.plot_time_histogram().- Parameters:
- spiketrainslist of
neo.core.SpikeTrainorneo.core.SpikeTrain neo.SpikeTrain objects with a common time axis (same t_start and t_stop)
- bin_sizepq.Quantity
Width of the histogram’s time bins.
- t_startpq.Quantity, optional
Start time of the histogram. Only events in spiketrains falling between t_start and t_stop (both included) are considered in the histogram. If None, the maximum t_start of all
neo.core.SpikeTrainobjects is used as t_start. Default: None- t_stoppq.Quantity, optional
Stop time of the histogram. Only events in spiketrains falling between t_start and t_stop (both included) are considered in the histogram. If None, the minimum t_stop of all
neo.core.SpikeTrainobjects is used as t_stop. Default: None- output{‘counts’, ‘mean’, ‘rate’}, optional
Normalization of the histogram. Can be one of:
‘counts’: spike counts at each bin (as integer numbers).
‘mean’: mean spike counts per spike train.
‘rate’: mean spike rate per spike train. Like ‘mean’, but the counts are additionally normalized by the bin width.
Default: ‘counts’
- binarybool, optional
If True, indicates whether all
neo.core.SpikeTrainobjects should first be binned to a binary representation (using theelephant.conversion.BinnedSpikeTrainclass). The calculation of the histogram is based on this representation. Note that the output is not binary, but a histogram of the converted, binary representation. Default: False
- spiketrainslist of
- Returns:
- result
neo.core.AnalogSignal A
neo.core.AnalogSignalobject containing the histogram values. result[j] is the histogram computed between t_start + j * bin_size and t_start + (j + 1) * bin_size.
- result
- Raises:
- ValueError
If output is not ‘counts’, ‘mean’ or ‘rate’.
- Warns:
- UserWarning
If t_start is None and the objects in spiketrains have different t_start values. If t_stop is None and the objects in spiketrains have different t_stop values.
Examples
>>> import neo >>> import quantities as pq >>> from elephant import statistics >>> spiketrains = [ ... neo.SpikeTrain([0.3, 4.5, 6.7, 9.3], t_stop=10, units='s'), ... neo.SpikeTrain([0.7, 4.3, 8.2], t_stop=10, units='s') ... ] >>> hist = statistics.time_histogram(spiketrains, ... bin_size=1 * pq.s) >>> hist <AnalogSignal(array([[2], [0], [0], [0], [2], [0], [1], [0], [1], [1]]) * dimensionless, [0.0 s, 10.0 s], sampling rate: 1.0 1/s)>
>>> hist.magnitude.flatten() array([2, 0, 0, 0, 2, 0, 1, 0, 1, 1])