elephant.spike_train_dissimilarity.victor_purpura_distance¶

elephant.spike_train_dissimilarity.
victor_purpura_distance
(spiketrains, cost_factor=array(1.) * Hz, kernel=None, sort=True, algorithm='fast')[source]¶ Calculates the VictorPurpura’s (VP) distance. It is often denoted as .
It is defined as the minimal cost of transforming spike train a into spike train b by using the following operations:
 Inserting or deleting a spike (cost 1.0).
 Shifting a spike from to (cost ).
A detailed description can be found in Victor, J. D., & Purpura, K. P. (1996). Nature and precision of temporal coding in visual cortex: a metricspace analysis. Journal of Neurophysiology.
Given the average number of spikes in a spike train and spike trains the runtime complexity of this function is and memory will be needed.
Parameters:  spiketrainslist of neo.SpikeTrain
Spike trains to calculate pairwise distance.
 cost_factorpq.Quantity, optional
A cost factor for spike shifts as inverse time scalar. Extreme values meaning no cost for any shift of spikes, or :math: q=np.inf meaning infinite cost for any spike shift and hence exclusion of spike shifts, are explicitly allowed. If kernel is not None, will be ignored. Default: 1.0 * pq.Hz
 kernelelephant.kernels.Kernel or None, optional
Kernel to use in the calculation of the distance. If kernel is None, an unnormalized triangular kernel with standard deviation of :math:’2.0/(q * sqrt(6.0))’ corresponding to a half width of will be used. Usage of the default value calculates the VictorPurpura distance correctly with a triangular kernel of the suitable width. The choice of another kernel is enabled, but this leaves the framework of VictorPurpura distances. Default: None
 sortbool, optional
Spike trains with sorted spike times will be needed for the calculation. You can set sort to False if you know that your spike trains are already sorted to decrease calculation time. Default: True
 algorithmstr, optional
Allowed values are ‘fast’ or ‘intuitive’, each selecting an algorithm with which to calculate the pairwise VictorPurpura distance. Typically ‘fast’ should be used, because while giving always the same result as ‘intuitive’, within the temporary structure of Python and addon modules as numpy it is faster. Default: ‘fast’
Returns:  np.ndarray
2D Matrix containing the VP distance of all pairs of spike trains.
Examples
>>> import quantities as pq >>> from elephant.spike_train_dissimilarity import victor_purpura_distance >>> q = 1.0 / (10.0 * pq.ms) >>> st_a = SpikeTrain([10, 20, 30], units='ms', t_stop= 1000.0) >>> st_b = SpikeTrain([12, 24, 30], units='ms', t_stop= 1000.0) >>> vp_f = victor_purpura_distance([st_a, st_b], q)[0, 1] >>> vp_i = victor_purpura_distance([st_a, st_b], q, ... algorithm='intuitive')[0, 1]