elephant.statistics.fanofactor

elephant.statistics.fanofactor(spiketrains: List[SpikeTrain] | List[Quantity] | List[ndarray] | Trials, warn_tolerance: Quantity = array(0.1) * ms) float | List[float] | List[List[float]][source]

Evaluates the empirical Fano factor F of the spike counts of a list of neo.core.SpikeTrain objects or elephant.trials object.

Given the vector v containing the observed spike counts (one per spike train) in the time window [t0, t1], F is defined as:

\[F := \frac{var(v)}{mean(v)}\]

The Fano factor is typically computed for spike trains representing the activity of the same neuron over different trials. The higher F, the larger the cross-trial non-stationarity. In theory for a time-stationary Poisson process, F=1.

Parameters:
spiketrainslist or elephant.trials

List of neo.core.SpikeTrain or pq.Quantity or np.ndarray or list of spike times for which to compute the Fano factor of spike counts, or an elephant.trials object. If a elephant.trials object is used, spike trains are pooled across trials before computing the Fano factor.

warn_tolerancepq.Quantity, optional

In case of a list of input neo.core.SpikeTrain, if their durations vary by more than warn_tolerance in their absolute values, throw a warning (see Notes). Default: 0.1 ms

Returns:
outputfloat or list of float

The Fano factor of the spike counts of the input spike trains. If a list was provided as input, output is a single number. In case an elephant.trials object was provided as input, output is a list of Fano factors, one for each spike train across the trials. output is np.nan if an empty list is specified, or if all spike trains are empty. An elephant.trials object without spike trains will return an empty list.

Raises:
TypeError

If the input spiketrains are neo.core.SpikeTrain objects, but warn_tolerance is not a quantity.

Notes

The check for the equal duration of the input spike trains is performed only if the input is of type neo.core.SpikeTrain: if you pass e.g. a numpy array, please make sure that they all have the same duration manually.

Examples

>>> import neo
>>> from elephant import statistics
>>> spiketrains = [
...     neo.SpikeTrain([0.3, 4.5, 6.7, 9.3], t_stop=10, units='s'),
...     neo.SpikeTrain([1.4, 3.3, 8.2], t_stop=10, units='s')
... ]
>>> statistics.fanofactor(spiketrains)
0.07142857142857142